integration-impl/src/main/java/se/idsec/signservice/integration/process/impl/DefaultSignResponseProcessor.java
protected void validateResponseTime(final XMLGregorianCalendar responseTime, final XMLGregorianCalendar requestTime,
      final String requestID) throws SignServiceIntegrationException {

    if (responseTime == null) {
      final String msg = String.format("SignResponse does not contain required ResponseTime [request-id='%s']", requestID);
      log.error("{}: {}", CorrelationID.id(), msg);
      throw new SignServiceProtocolException(msg);
    }
    final long responseTimeMillis = responseTime.toGregorianCalendar().getTimeInMillis();
    final long now = System.currentTimeMillis();

    // Has the response expired?
    //
    if ((now - responseTimeMillis - this.processingConfiguration.getAllowedClockSkew()) > this.processingConfiguration
      .getMaximumAllowedResponseAge()) {
      final String msg = String.format("SignResponse is too old. response-time:%d - current-time:%d - max-allowed-age:%d - " +
          "allowed-clock-skew:%d [request-id='%s']",
        responseTimeMillis, now, this.processingConfiguration.getMaximumAllowedResponseAge(),
        this.processingConfiguration.getAllowedClockSkew(), requestID);
      log.error("{}: {}", CorrelationID.id(), msg);
      throw new SignResponseProcessingException(new ErrorCode.Code("expired-response"), msg);
    }

    // Also check the "not yet valid" case...
    //
    if ((responseTimeMillis - this.processingConfiguration.getAllowedClockSkew()) > now) {
      final String msg = String.format("SignResponse is not yet valid according to ResponseTime. response-time:%d - current-time:%d - " +
          "allowed-clock-skew:%d [request-id='%s']",
        responseTimeMillis, now, this.processingConfiguration.getAllowedClockSkew(), requestID);
      log.error("{}: {}", CorrelationID.id(), msg);
      throw new SignResponseProcessingException(new ErrorCode.Code("invalid-response"), msg);
    }

    // We also want to ensure that the server processing time hasn't exceeded or max limit ...
    // We don't have to care about clock skew since we were the ones that set the request time.
    //
    final long requestTimeMillis = requestTime.toGregorianCalendar().getTimeInMillis();
    if ((now - requestTimeMillis) > this.processingConfiguration.getMaximumAllowedProcessingTime()) {
      final String msg = String.format(
        "Server processing time exceeded allowed limit. request-time:%d - current-time:%d - limit:%d [request-id='%s']",
        requestTimeMillis, now, this.processingConfiguration.getMaximumAllowedProcessingTime(), requestID);
      log.error("{}: {}", CorrelationID.id(), msg);
      throw new SignResponseProcessingException(new ErrorCode.Code("server-processing-time-exceeded-limit"), msg);
    }
  }
/**
   * Validates the the response time from the SignResponse is valid. The method also ensures that the server processing
   * time hasn't exceeded or max limit.
   * 
   * @param responseTime
   *          the response time
   * @param requestTime
   *          the time when the request was sent
   * @param requestID
   *          the requestID (for logging)
   * @throws SignServiceIntegrationException
   *           for expired responses
   */
Validates the the response time from the SignResponse is valid. The method also ensures that the server processing
time hasn't exceeded or max limit.

@param responseTime
the response time
@param requestTime
the time when the request was sent
@param requestID
the requestID (for logging)
@throws SignServiceIntegrationException
for expired responses
Validates the the response time from the SignResponse is valid . The method also ensures that the server processing time hasn ' t exceeded or max limit . @param responseTime the response time @param requestTime the time when the request was sent @param requestID the requestID ( for logging ) @throws SignServiceIntegrationException for expired responses
protected void validateResponseTime(final XMLGregorianCalendar responseTime, final XMLGregorianCalendar requestTime,
      final String requestID) throws SignServiceIntegrationException {
    if (responseTime == null) {
      final String msg = String.format("SignResponse does not contain required ResponseTime [request-id='%s']", requestID);
      log.error("{}: {}", CorrelationID.id(), msg);
      throw new SignServiceProtocolException(msg);
    }
    final long responseTimeMillis = responseTime.toGregorianCalendar().getTimeInMillis();
    final long now = System.currentTimeMillis();
    if ((now - responseTimeMillis - this.processingConfiguration.getAllowedClockSkew()) > this.processingConfiguration
      .getMaximumAllowedResponseAge()) {
      final String msg = String.format("SignResponse is too old. response-time:%d - current-time:%d - max-allowed-age:%d - " +
          "allowed-clock-skew:%d [request-id='%s']",
        responseTimeMillis, now, this.processingConfiguration.getMaximumAllowedResponseAge(),
        this.processingConfiguration.getAllowedClockSkew(), requestID);
      log.error("{}: {}", CorrelationID.id(), msg);
      throw new SignResponseProcessingException(new ErrorCode.Code("expired-response"), msg);
    }
     Also check the "not yet valid" case...
    if ((responseTimeMillis - this.processingConfiguration.getAllowedClockSkew()) > now) {
      final String msg = String.format("SignResponse is not yet valid according to ResponseTime. response-time:%d - current-time:%d - " +
          "allowed-clock-skew:%d [request-id='%s']",
        responseTimeMillis, now, this.processingConfiguration.getAllowedClockSkew(), requestID);
      log.error("{}: {}", CorrelationID.id(), msg);
      throw new SignResponseProcessingException(new ErrorCode.Code("invalid-response"), msg);
    }
     We also want to ensure that the server processing time hasn't exceeded or max limit ...
     We don't have to care about clock skew since we were the ones that set the request time.
    final long requestTimeMillis = requestTime.toGregorianCalendar().getTimeInMillis();
    if ((now - requestTimeMillis) > this.processingConfiguration.getMaximumAllowedProcessingTime()) {
      final String msg = String.format(
        "Server processing time exceeded allowed limit. request-time:%d - current-time:%d - limit:%d [request-id='%s']",
        requestTimeMillis, now, this.processingConfiguration.getMaximumAllowedProcessingTime(), requestID);
      log.error("{}: {}", CorrelationID.id(), msg);
      throw new SignResponseProcessingException(new ErrorCode.Code("server-processing-time-exceeded-limit"), msg);
    }
  }
protected void validateResponseTime ( final XMLGregorianCalendar responseTime , final XMLGregorianCalendar requestTime , final String requestID ) throws SignServiceIntegrationException { if ( responseTime == null ) { final String msg = String . format ( "SignResponse does not contain required ResponseTime [request-id='%s']" , requestID ) ; log . error ( "{}: {}" , CorrelationID . id ( ) , msg ) ; throw new SignServiceProtocolException ( msg ) ; } final long responseTimeMillis = responseTime . toGregorianCalendar ( ) . getTimeInMillis ( ) ; final long now = System . currentTimeMillis ( ) ; if ( ( now - responseTimeMillis - this . processingConfiguration . getAllowedClockSkew ( ) ) > this . processingConfiguration . getMaximumAllowedResponseAge ( ) ) { final String msg = String . format ( "SignResponse is too old. response-time:%d - current-time:%d - max-allowed-age:%d - " + "allowed-clock-skew:%d [request-id='%s']" , responseTimeMillis , now , this . processingConfiguration . getMaximumAllowedResponseAge ( ) , this . processingConfiguration . getAllowedClockSkew ( ) , requestID ) ; log . error ( "{}: {}" , CorrelationID . id ( ) , msg ) ; throw new SignResponseProcessingException ( new ErrorCode . Code ( "expired-response" ) , msg ) ; } if ( ( responseTimeMillis - this . processingConfiguration . getAllowedClockSkew ( ) ) > now ) { final String msg = String . format ( "SignResponse is not yet valid according to ResponseTime. response-time:%d - current-time:%d - " + "allowed-clock-skew:%d [request-id='%s']" , responseTimeMillis , now , this . processingConfiguration . getAllowedClockSkew ( ) , requestID ) ; log . error ( "{}: {}" , CorrelationID . id ( ) , msg ) ; throw new SignResponseProcessingException ( new ErrorCode . Code ( "invalid-response" ) , msg ) ; } final long requestTimeMillis = requestTime . toGregorianCalendar ( ) . getTimeInMillis ( ) ; if ( ( now - requestTimeMillis ) > this . processingConfiguration . getMaximumAllowedProcessingTime ( ) ) { final String msg = String . format ( "Server processing time exceeded allowed limit. request-time:%d - current-time:%d - limit:%d [request-id='%s']" , requestTimeMillis , now , this . processingConfiguration . getMaximumAllowedProcessingTime ( ) , requestID ) ; log . error ( "{}: {}" , CorrelationID . id ( ) , msg ) ; throw new SignResponseProcessingException ( new ErrorCode . Code ( "server-processing-time-exceeded-limit" ) , msg ) ; } }
Validates the the response time from the SignResponse is valid.
Validates the the response time from the SignResponse is valid .
// Has the response expired? // // Also check the "not yet valid" case... // // We also want to ensure that the server processing time hasn't exceeded or max limit ... // We don't have to care about clock skew since we were the ones that set the request time. //