Class BasicSignatureSigningParametersResolver

    • Field Detail

      • log

        private final org.slf4j.Logger log
        Class logger.
      • algorithmRegistry

        private AlgorithmRegistry algorithmRegistry
        The AlgorithmRegistry used when processing algorithm URIs.
    • Constructor Detail

      • BasicSignatureSigningParametersResolver

        public BasicSignatureSigningParametersResolver()
        Constructor.
    • Method Detail

      • logResult

        protected void logResult​(@Nonnull
                                 SignatureSigningParameters params)
        Log the resolved parameters.
        Parameters:
        params - the resolved param
      • validate

        protected boolean validate​(@Nonnull
                                   SignatureSigningParameters params)
        Validate that the SignatureSigningParameters instance has all the required properties populated.
        Parameters:
        params - the parameters instance to evaluate
        Returns:
        true if parameters instance passes validation, false otherwise
      • getIncludeExcludePredicate

        @Nonnull
        protected Predicate<String> getIncludeExcludePredicate​(@Nonnull
                                                               CriteriaSet criteria)
        Get a predicate which implements the effective configured include/exclude policy.
        Parameters:
        criteria - the input criteria being evaluated
        Returns:
        include/exclude predicate instance
      • resolveAndPopulateCredentialAndSignatureAlgorithm

        protected void resolveAndPopulateCredentialAndSignatureAlgorithm​(@Nonnull
                                                                         SignatureSigningParameters params,
                                                                         @Nonnull
                                                                         CriteriaSet criteria,
                                                                         Predicate<String> includeExcludePredicate)
        Resolve and populate the signing credential and signature method algorithm URI on the supplied parameters instance.
        Parameters:
        params - the parameters instance being populated
        criteria - the input criteria being evaluated
        includeExcludePredicate - the include/exclude predicate with which to evaluate the candidate signing method algorithm URIs
      • findCompatibleAlgorithmAndCredential

        protected void findCompatibleAlgorithmAndCredential​(List<String> algorithms,
                                                            List<Credential> credentials,
                                                            @Nonnull
                                                            SignatureSigningParameters params)
        Loop through the algorithms and find the first compatible credential. Add the compatible algorithm and credential to the signing parameters.
        Parameters:
        algorithms - the algorithms to find compatible from
        credentials - the credentials to find compatibility with
        params - the parameters to add a compatible algorithm and credential too.
      • getAlgorithmRuntimeSupportedPredicate

        @Nonnull
        protected Predicate<String> getAlgorithmRuntimeSupportedPredicate()
        Get a predicate which evaluates whether a cryptographic algorithm is supported by the runtime environment.
        Returns:
        the predicate
      • credentialSupportsSigningAlgorithm

        protected boolean credentialSupportsSigningAlgorithm​(@Nonnull
                                                             Credential credential,
                                                             @Nonnull @NotEmpty
                                                             String algorithm)
        Evaluate whether the specified credential is supported for use with the specified signing algorithm.

        First, the key type is checked against the algorithm family, then the algorithm and key length are checked. If the key is an EC type, the curve is also checked against the algorithm. If the key is a MAC type, check the key length matches the MAC signing algorithm used.

        Parameters:
        credential - the credential to evaluate
        algorithm - the algorithm URI to evaluate
        Returns:
        true if credential may be used with the supplied algorithm URI, false otherwise
      • getEffectiveSigningCredentials

        @Nonnull
        protected List<Credential> getEffectiveSigningCredentials​(@Nonnull
                                                                  CriteriaSet criteria)
        Get the effective list of signing credentials to consider.
        Parameters:
        criteria - the input criteria being evaluated
        Returns:
        the list of credentials
      • getEffectiveSignatureAlgorithms

        @Nonnull
        protected List<String> getEffectiveSignatureAlgorithms​(@Nonnull
                                                               CriteriaSet criteria,
                                                               @Nonnull
                                                               Predicate<String> includeExcludePredicate)
        Get the effective list of signature algorithm URIs to consider, including application of include/exclude policy.
        Parameters:
        criteria - the input criteria being evaluated
        includeExcludePredicate - the include/exclude predicate to use
        Returns:
        the list of effective algorithm URIs