public void validateTokenRequest(String uid,String signature,String timestamp,String stringToSign) throws DataAccessException, UnauthorizedException {
  if (!Utilities.isTimestampValid(timestamp)) {
    throw new UnauthorizedException("Invalid timestamp: " + timestamp);
  }
  log.info(String.format("Timestamp [ %s ] is valid",timestamp));
  DeviceInfo device=deviceAuthenticator.getDeviceInfo(uid);
  if (device == null) {
    throw new UnauthorizedException("Couldn't find device: " + uid);
  }
  if (!validateSignature(stringToSign,device.getKey(),signature)) {
    log.info("String to sign: " + stringToSign);
    throw new UnauthorizedException("Invalid signature: " + signature);
  }
  log.info("Signature matched!!!");
}

public void validateTokenRequest ( String uid , String signature , String timestamp , String stringToSign ) throws DataAccessException , UnauthorizedException { if ( ! Utilities . isTimestampValid ( timestamp ) ) { throw new UnauthorizedException ( "Invalid timestamp: " + timestamp ) ; } log . info ( String . format ( "Timestamp [ %s ] is valid" , timestamp ) ) ; DeviceInfo device = deviceAuthenticator . getDeviceInfo ( uid ) ; if ( device == null ) { throw new UnauthorizedException ( "Couldn't find device: " + uid ) ; } if ( ! validateSignature ( stringToSign , device . getKey ( ) , signature ) ) { log . info ( "String to sign: " + stringToSign ) ; throw new UnauthorizedException ( "Invalid signature: " + signature ) ; } log . info ( "Signature matched!!!" ) ; }
verify if the token request is valid . uid is authenticated . the timestamp is checked to see it falls within the valid timestamp window . the signature is computed and matched against the given signature . useful in anonymous and identity modes
