xml/src/main/java/se/idsec/signservice/integration/document/xml/XmlSignedDocumentProcessor.java
@Override
  protected void performAdditionalAdesValidation(final XadesQualifyingProperties adesObject, final X509Certificate signingCertificate,
      final SignTaskData signTaskData, final SignRequestWrapper signRequest, final SignResponseWrapper signResponse,
      final SignResponseProcessingParameters parameters) throws DocumentProcessingException {

    try {
      final Long signingTime = adesObject.getSigningTime();
      if (signingTime == null) {
        final String msg = String.format("No SigningTime available in XAdES object for sign task '%s' [request-id='%s']",
          signTaskData.getSignTaskId(), signRequest.getRequestID());
        log.warn("{}: {}", CorrelationID.id(), msg);
        if (this.getProcessingConfiguration().isStrictProcessing()) {
          throw new DocumentProcessingException(new ErrorCode.Code("invalid-ades-object"), msg);
        }
        else {
          return;
        }
      }
      // SigningTime must be before the response time ...
      //
      final long responseTime = signResponse.getSignResponseExtension().getResponseTime().toGregorianCalendar().getTimeInMillis();
      if (signingTime > responseTime) {
        final String msg = String.format(
          "Invalid SigningTime (%d) in XAdES object for sign task '%s' - it is after response time (%d) [request-id='%s']",
          signingTime, signTaskData.getSignTaskId(), responseTime, signRequest.getRequestID());
        log.error("{}: {}", CorrelationID.id(), msg);
        throw new DocumentProcessingException(new ErrorCode.Code("invalid-ades-object"), msg);
      }
      
      // SigningTime must not be before request time ...
      //
      final long requestTime = signRequest.getSignRequestExtension().getRequestTime().toGregorianCalendar().getTimeInMillis();
      if (requestTime < (signingTime - this.getProcessingConfiguration().getAllowedClockSkew())) {
        final String msg = String.format(
          "Invalid SigningTime (%d) in XAdES object for sign task '%s' - it is before request time (%d) [request-id='%s']",
          signingTime, signTaskData.getSignTaskId(), requestTime, signRequest.getRequestID());
        log.error("{}: {}", CorrelationID.id(), msg);
        throw new DocumentProcessingException(new ErrorCode.Code("invalid-ades-object"), msg);
      }
      
      log.debug("{}: Successfully validated SigningTime in XAdES object for sign task '%s' [request-id='%s']",
        CorrelationID.id(), signTaskData.getSignTaskId(), signRequest.getRequestID());
    }
    catch (SignServiceProtocolException e) {
      throw new DocumentProcessingException(new ErrorCode.Code("invalid-ades-object"), e.getMessage(), e);
    }
  }
/**
   * Validates that the {@code xades:SigningTime} is valid.
   */
Validates that the  xades:SigningTime is valid.
Validates that the xades : SigningTime is valid .
@Override
  protected void performAdditionalAdesValidation(final XadesQualifyingProperties adesObject, final X509Certificate signingCertificate,
      final SignTaskData signTaskData, final SignRequestWrapper signRequest, final SignResponseWrapper signResponse,
      final SignResponseProcessingParameters parameters) throws DocumentProcessingException {
    try {
      final Long signingTime = adesObject.getSigningTime();
      if (signingTime == null) {
        final String msg = String.format("No SigningTime available in XAdES object for sign task '%s' [request-id='%s']",
          signTaskData.getSignTaskId(), signRequest.getRequestID());
        log.warn("{}: {}", CorrelationID.id(), msg);
        if (this.getProcessingConfiguration().isStrictProcessing()) {
          throw new DocumentProcessingException(new ErrorCode.Code("invalid-ades-object"), msg);
        }
        else {
          return;
        }
      }
      final long responseTime = signResponse.getSignResponseExtension().getResponseTime().toGregorianCalendar().getTimeInMillis();
      if (signingTime > responseTime) {
        final String msg = String.format(
          "Invalid SigningTime (%d) in XAdES object for sign task '%s' - it is after response time (%d) [request-id='%s']",
          signingTime, signTaskData.getSignTaskId(), responseTime, signRequest.getRequestID());
        log.error("{}: {}", CorrelationID.id(), msg);
        throw new DocumentProcessingException(new ErrorCode.Code("invalid-ades-object"), msg);
      }
       SigningTime must not be before request time ...
      final long requestTime = signRequest.getSignRequestExtension().getRequestTime().toGregorianCalendar().getTimeInMillis();
      if (requestTime < (signingTime - this.getProcessingConfiguration().getAllowedClockSkew())) {
        final String msg = String.format(
          "Invalid SigningTime (%d) in XAdES object for sign task '%s' - it is before request time (%d) [request-id='%s']",
          signingTime, signTaskData.getSignTaskId(), requestTime, signRequest.getRequestID());
        log.error("{}: {}", CorrelationID.id(), msg);
        throw new DocumentProcessingException(new ErrorCode.Code("invalid-ades-object"), msg);
      }
      log.debug("{}: Successfully validated SigningTime in XAdES object for sign task '%s' [request-id='%s']",
        CorrelationID.id(), signTaskData.getSignTaskId(), signRequest.getRequestID());
    }
    catch (SignServiceProtocolException e) {
      throw new DocumentProcessingException(new ErrorCode.Code("invalid-ades-object"), e.getMessage(), e);
    }
  }
@ Override protected void performAdditionalAdesValidation ( final XadesQualifyingProperties adesObject , final X509Certificate signingCertificate , final SignTaskData signTaskData , final SignRequestWrapper signRequest , final SignResponseWrapper signResponse , final SignResponseProcessingParameters parameters ) throws DocumentProcessingException { try { final Long signingTime = adesObject . getSigningTime ( ) ; if ( signingTime == null ) { final String msg = String . format ( "No SigningTime available in XAdES object for sign task '%s' [request-id='%s']" , signTaskData . getSignTaskId ( ) , signRequest . getRequestID ( ) ) ; log . warn ( "{}: {}" , CorrelationID . id ( ) , msg ) ; if ( this . getProcessingConfiguration ( ) . isStrictProcessing ( ) ) { throw new DocumentProcessingException ( new ErrorCode . Code ( "invalid-ades-object" ) , msg ) ; } else { return ; } } final long responseTime = signResponse . getSignResponseExtension ( ) . getResponseTime ( ) . toGregorianCalendar ( ) . getTimeInMillis ( ) ; if ( signingTime > responseTime ) { final String msg = String . format ( "Invalid SigningTime (%d) in XAdES object for sign task '%s' - it is after response time (%d) [request-id='%s']" , signingTime , signTaskData . getSignTaskId ( ) , responseTime , signRequest . getRequestID ( ) ) ; log . error ( "{}: {}" , CorrelationID . id ( ) , msg ) ; throw new DocumentProcessingException ( new ErrorCode . Code ( "invalid-ades-object" ) , msg ) ; } final long requestTime = signRequest . getSignRequestExtension ( ) . getRequestTime ( ) . toGregorianCalendar ( ) . getTimeInMillis ( ) ; if ( requestTime < ( signingTime - this . getProcessingConfiguration ( ) . getAllowedClockSkew ( ) ) ) { final String msg = String . format ( "Invalid SigningTime (%d) in XAdES object for sign task '%s' - it is before request time (%d) [request-id='%s']" , signingTime , signTaskData . getSignTaskId ( ) , requestTime , signRequest . getRequestID ( ) ) ; log . error ( "{}: {}" , CorrelationID . id ( ) , msg ) ; throw new DocumentProcessingException ( new ErrorCode . Code ( "invalid-ades-object" ) , msg ) ; } log . debug ( "{}: Successfully validated SigningTime in XAdES object for sign task '%s' [request-id='%s']" , CorrelationID . id ( ) , signTaskData . getSignTaskId ( ) , signRequest . getRequestID ( ) ) ; } catch ( SignServiceProtocolException e ) { throw new DocumentProcessingException ( new ErrorCode . Code ( "invalid-ades-object" ) , e . getMessage ( ) , e ) ; } }
Validates that the {@code xades:SigningTime} is valid.
Validates that the { @code xades : SigningTime } is valid .
// SigningTime must be before the response time ... // // SigningTime must not be before request time ... //