pdf/src/main/java/se/idsec/signservice/integration/document/pdf/signpage/DefaultPdfSignaturePagePreparator.java
private void validateInput(final byte[] pdfDocument,
      final PdfSignaturePagePreferences signaturePagePreferences,
      final IntegrationServiceConfiguration policyConfiguration)
      throws InputValidationException {

    if (pdfDocument == null) {
      throw new InputValidationException("pdfDocument", "Missing pdfDocument");
    }
    if (signaturePagePreferences == null) {
      throw new InputValidationException("signaturePagePreferences", "Missing signaturePagePreferences");
    }
    if (policyConfiguration == null) {
      throw new InputValidationException("policy", "Can not find policy");
    }
    this.pdfSignaturePagePreferencesValidator.validateObject(signaturePagePreferences, "signaturePagePreferences", policyConfiguration);

    // Update the preferences with settings from the config (if needed) ...
    // Note: No checks need to be applied since the validator would have failed if there is something missing.
    //
    if (signaturePagePreferences.getSignaturePageReference() == null && signaturePagePreferences.getSignaturePage() == null) {
      signaturePagePreferences.setSignaturePage(policyConfiguration.getPdfSignaturePages().get(0));
      log.debug("Using default PdfSignaturePage ({}) for policy '{}'",
        signaturePagePreferences.getSignaturePage().getId(), policyConfiguration.getPolicy());
    }
    if (signaturePagePreferences.getSignaturePageReference() != null) {
      signaturePagePreferences.setSignaturePage(policyConfiguration.getPdfSignaturePages()
        .stream()
        .filter(p -> signaturePagePreferences.getSignaturePageReference().equals(p.getId()))
        .findFirst()
        .orElse(null));
    }
  }
/**
   * Validates the input supplied to
   * {@link #preparePdfSignaturePage(byte[], PdfSignaturePagePreferences, IntegrationServiceConfiguration)}.
   * 
   * @param pdfDocument
   *          the PDF document
   * @param signaturePagePreferences
   *          the signature page preferences
   * @param policyConfiguration
   *          the policy configuration
   * @throws InputValidationException
   *           for validation errors
   */


@param pdfDocument
the PDF document
@param signaturePagePreferences
the signature page preferences
@param policyConfiguration
the policy configuration
@throws InputValidationException
for validation errors
@param pdfDocument the PDF document @param signaturePagePreferences the signature page preferences @param policyConfiguration the policy configuration @throws InputValidationException for validation errors
private void validateInput(final byte[] pdfDocument,
      final PdfSignaturePagePreferences signaturePagePreferences,
      final IntegrationServiceConfiguration policyConfiguration)
      throws InputValidationException {
    if (pdfDocument == null) {
      throw new InputValidationException("pdfDocument", "Missing pdfDocument");
    }
    if (signaturePagePreferences == null) {
      throw new InputValidationException("signaturePagePreferences", "Missing signaturePagePreferences");
    }
    if (policyConfiguration == null) {
      throw new InputValidationException("policy", "Can not find policy");
    }
    this.pdfSignaturePagePreferencesValidator.validateObject(signaturePagePreferences, "signaturePagePreferences", policyConfiguration);
    if (signaturePagePreferences.getSignaturePageReference() == null && signaturePagePreferences.getSignaturePage() == null) {
      signaturePagePreferences.setSignaturePage(policyConfiguration.getPdfSignaturePages().get(0));
      log.debug("Using default PdfSignaturePage ({}) for policy '{}'",
        signaturePagePreferences.getSignaturePage().getId(), policyConfiguration.getPolicy());
    }
    if (signaturePagePreferences.getSignaturePageReference() != null) {
      signaturePagePreferences.setSignaturePage(policyConfiguration.getPdfSignaturePages()
        .stream()
        .filter(p -> signaturePagePreferences.getSignaturePageReference().equals(p.getId()))
        .findFirst()
        .orElse(null));
    }
  }
private void validateInput ( final byte [ ] pdfDocument , final PdfSignaturePagePreferences signaturePagePreferences , final IntegrationServiceConfiguration policyConfiguration ) throws InputValidationException { if ( pdfDocument == null ) { throw new InputValidationException ( "pdfDocument" , "Missing pdfDocument" ) ; } if ( signaturePagePreferences == null ) { throw new InputValidationException ( "signaturePagePreferences" , "Missing signaturePagePreferences" ) ; } if ( policyConfiguration == null ) { throw new InputValidationException ( "policy" , "Can not find policy" ) ; } this . pdfSignaturePagePreferencesValidator . validateObject ( signaturePagePreferences , "signaturePagePreferences" , policyConfiguration ) ; if ( signaturePagePreferences . getSignaturePageReference ( ) == null && signaturePagePreferences . getSignaturePage ( ) == null ) { signaturePagePreferences . setSignaturePage ( policyConfiguration . getPdfSignaturePages ( ) . get ( 0 ) ) ; log . debug ( "Using default PdfSignaturePage ({}) for policy '{}'" , signaturePagePreferences . getSignaturePage ( ) . getId ( ) , policyConfiguration . getPolicy ( ) ) ; } if ( signaturePagePreferences . getSignaturePageReference ( ) != null ) { signaturePagePreferences . setSignaturePage ( policyConfiguration . getPdfSignaturePages ( ) . stream ( ) . filter ( p -> signaturePagePreferences . getSignaturePageReference ( ) . equals ( p . getId ( ) ) ) . findFirst ( ) . orElse ( null ) ) ; } }
Validates the input supplied to
 {@link #preparePdfSignaturePage(byte[], PdfSignaturePagePreferences, IntegrationServiceConfiguration)}.
Validates the input supplied to { @link #preparePdfSignaturePage ( byte [] PdfSignaturePagePreferences IntegrationServiceConfiguration ) } .
// Update the preferences with settings from the config (if needed) ... // Note: No checks need to be applied since the validator would have failed if there is something missing. //