Class SAMLMetadataEncryptionParametersResolver
- java.lang.Object
-
- org.opensaml.xmlsec.impl.AbstractSecurityParametersResolver<EncryptionParameters>
-
- org.opensaml.xmlsec.impl.BasicEncryptionParametersResolver
-
- org.opensaml.saml.security.impl.SAMLMetadataEncryptionParametersResolver
-
- All Implemented Interfaces:
Resolver<EncryptionParameters,CriteriaSet>,EncryptionParametersResolver
public class SAMLMetadataEncryptionParametersResolver extends BasicEncryptionParametersResolver
A specialization ofBasicEncryptionParametersResolverwhich resolves credentials and algorithm preferences against SAML metadata via aMetadataCredentialResolver.In addition to the
Criterioninputs documented inBasicEncryptionParametersResolver, the inputs and associated modes of operation documented forMetadataCredentialResolverare also supported and required.The
CriteriaSetinstance passed to the configured metadata credential resolver will be a copy of the input criteria set, with the addition of aUsageCriterioncontaining the valueUsageType.ENCRYPTION, which will replace any existing usage criterion instance.
-
-
Field Summary
Fields Modifier and Type Field Description private MetadataCredentialResolvercredentialResolverMetadata credential resolver.private SAMLMetadataKeyAgreementEncryptionConfiguration.KeyWrapdefaultKeyAgreementUseKeyWrapDefault for usage of key wrapping with key agreement if not otherwise configured.private org.slf4j.LoggerlogLogger.private booleanmergeMetadataRSAOAEPParametersWithConfigFlag indicating whether the resolver should attempt to merge RSAOAEPParameters values resolved from metadata with additional parameters from supplied instances ofEncryptionConfiguration.
-
Constructor Summary
Constructors Constructor Description SAMLMetadataEncryptionParametersResolver(MetadataCredentialResolver resolver)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleancheckAndProcessKeyAgreement(EncryptionParameters params, CriteriaSet criteria, Predicate<String> includeExcludePredicate, Credential credential)Check for a credential type that implies a key agreement operation, and process if so indicated.private List<String>concatLists(List<String>... lists)Concatenate multiple lists into one list.protected booleancredentialSupportsEncryptionMethod(Credential credential, EncryptionMethod encryptionMethod)Evaluate whether the specified credential is supported for use with the specifiedEncryptionMethod.protected booleanevaluateEncryptionMethodChildren(EncryptionMethod encryptionMethod, CriteriaSet criteria, Predicate<String> includeExcludePredicate)Evaluate the child elements of an EncryptionMethod for acceptability based on for example include/exclude policy and algorithm runtime support.protected booleanevaluateRSAOAEPChildren(EncryptionMethod encryptionMethod, CriteriaSet criteria, Predicate<String> includeExcludePredicate)Evaluate the child elements of an RSA OAEP EncryptionMethod for acceptability based on for example include/exclude policy and algorithm runtime support.SAMLMetadataKeyAgreementEncryptionConfiguration.KeyWrapgetDefaultKeyAgreemenUseKeyWrap()Get the default for usage of key wrapping with key agreement if not otherwise configured.protected SAMLMetadataKeyAgreementEncryptionConfigurationgetEffectiveKeyAgreementConfiguration(CriteriaSet criteria, Credential credential)Get the effectiveSAMLMetadataKeyAgreementEncryptionConfigurationto use with the specified credential.protected MetadataCredentialResolvergetMetadataCredentialResolver()Get the metadata credential resolver instance to use to resolve encryption credentials.booleanisMergeMetadataRSAOAEPParametersWithConfig()Determine whether the resolver should attempt to merge RSAOAEPParameters values resolved from metadata with additional parameters from supplied instances ofEncryptionConfiguration.protected voidpopulateRSAOAEPParamsFromEncryptionMethod(RSAOAEPParameters params, EncryptionMethod encryptionMethod, Predicate<String> includeExcludePredicate)ExtractDigestMethod,MGFandOAEPparamsdata present on the supplied instance ofEncryptionMethodand populate it on the supplied instance of ofRSAOAEPParameters.protected voidresolveAndPopulateCredentialsAndAlgorithms(EncryptionParameters params, CriteriaSet criteria, Predicate<String> includeExcludePredicate)protected voidresolveAndPopulateRSAOAEPParams(EncryptionParameters params, CriteriaSet criteria, Predicate<String> includeExcludePredicate, EncryptionMethod encryptionMethod)Resolve and populate an instance ofRSAOAEPParameters, if appropriate for the selected key transport encryption algorithm.protected Pair<String,EncryptionMethod>resolveDataEncryptionAlgorithm(CriteriaSet criteria, Predicate<String> includeExcludePredicate, SAMLMDCredentialContext metadataCredContext)Determine the data encryption algorithm URI to use, also returning the associatedEncryptionMethodfrom metadata if relevant.protected Pair<String,EncryptionMethod>resolveKeyTransportAlgorithm(Credential keyTransportCredential, CriteriaSet criteria, Predicate<String> includeExcludePredicate, String dataEncryptionAlgorithm, SAMLMDCredentialContext metadataCredContext)Determine the key transport algorithm URI to use with the specified credential, also returning the associatedEncryptionMethodfrom metadata if relevant.voidsetDefaultKeyAgreementUseKeyWrap(SAMLMetadataKeyAgreementEncryptionConfiguration.KeyWrap keyWrap)Set the default for usage of key wrapping with key agreement if not otherwise configured.voidsetMergeMetadataRSAOAEPParametersWithConfig(boolean flag)Set whether the resolver should attempt to merge RSAOAEPParameters values resolved from metadata with additional parameters from supplied instances ofEncryptionConfiguration.-
Methods inherited from class org.opensaml.xmlsec.impl.BasicEncryptionParametersResolver
checkAndProcessKeyAgreement, credentialSupportsAlgorithm, generateDataEncryptionCredential, getAlgorithmRegistry, getAlgorithmRuntimeSupportedPredicate, getEffectiveDataEncryptionAlgorithms, getEffectiveDataEncryptionCredentials, getEffectiveKeyTransportAlgorithms, getEffectiveKeyTransportCredentials, getIncludeExcludePredicate, getWhitelistBlacklistPredicate, isAutoGenerateDataEncryptionCredential, isDataEncryptionAlgorithm, isKeyTransportAlgorithm, logResult, populateRSAOAEPParams, processDataEncryptionCredentialAutoGeneration, resolve, resolveAndPopulateRSAOAEPParams, resolveDataEncryptionAlgorithm, resolveDataEncryptionAlgorithm, resolveDataKeyInfoGenerator, resolveKeyTransportAlgorithm, resolveKeyTransportAlgorithm, resolveKeyTransportAlgorithmPredicate, resolveKeyTransportKeyInfoGenerator, resolveSingle, setAlgorithmRegistry, setAutoGenerateDataEncryptionCredential, validate
-
Methods inherited from class org.opensaml.xmlsec.impl.AbstractSecurityParametersResolver
lookupKeyInfoGenerator, resolveAndPopulateIncludesExcludes, resolveEffectiveExcludes, resolveEffectiveIncludes, resolveIncludeExcludePrecedence, resolveIncludeExcludePredicate
-
-
-
-
Field Detail
-
log
@Nonnull private org.slf4j.Logger log
Logger.
-
credentialResolver
@Nonnull private MetadataCredentialResolver credentialResolver
Metadata credential resolver.
-
mergeMetadataRSAOAEPParametersWithConfig
private boolean mergeMetadataRSAOAEPParametersWithConfig
Flag indicating whether the resolver should attempt to merge RSAOAEPParameters values resolved from metadata with additional parameters from supplied instances ofEncryptionConfiguration.
-
defaultKeyAgreementUseKeyWrap
@Nonnull private SAMLMetadataKeyAgreementEncryptionConfiguration.KeyWrap defaultKeyAgreementUseKeyWrap
Default for usage of key wrapping with key agreement if not otherwise configured.
-
-
Constructor Detail
-
SAMLMetadataEncryptionParametersResolver
public SAMLMetadataEncryptionParametersResolver(@Nonnull @ParameterName(name="resolver") MetadataCredentialResolver resolver)
Constructor.- Parameters:
resolver- the metadata credential resolver instance to use to resolve encryption credentials
-
-
Method Detail
-
isMergeMetadataRSAOAEPParametersWithConfig
public boolean isMergeMetadataRSAOAEPParametersWithConfig()
Determine whether the resolver should attempt to merge RSAOAEPParameters values resolved from metadata with additional parameters from supplied instances ofEncryptionConfiguration.Defaults to:
false- Returns:
- true if should merge metadata parameters with configuration, false otherwise
-
setMergeMetadataRSAOAEPParametersWithConfig
public void setMergeMetadataRSAOAEPParametersWithConfig(boolean flag)
Set whether the resolver should attempt to merge RSAOAEPParameters values resolved from metadata with additional parameters from supplied instances ofEncryptionConfiguration.Defaults to:
false- Parameters:
flag- true if should merge metadata parameters with configuration, false otherwise
-
getDefaultKeyAgreemenUseKeyWrap
@Nonnull public SAMLMetadataKeyAgreementEncryptionConfiguration.KeyWrap getDefaultKeyAgreemenUseKeyWrap()
Get the default for usage of key wrapping with key agreement if not otherwise configured.The default is:
SAMLMetadataKeyAgreementEncryptionConfiguration.KeyWrap.Default.- Returns:
- the default value
-
setDefaultKeyAgreementUseKeyWrap
public void setDefaultKeyAgreementUseKeyWrap(@Nullable SAMLMetadataKeyAgreementEncryptionConfiguration.KeyWrap keyWrap)Set the default for usage of key wrapping with key agreement if not otherwise configured.The default is:
SAMLMetadataKeyAgreementEncryptionConfiguration.KeyWrap.Default.- Parameters:
keyWrap- the value to set; null impliesSAMLMetadataKeyAgreementEncryptionConfiguration.KeyWrap.Default
-
getMetadataCredentialResolver
@Nonnull protected MetadataCredentialResolver getMetadataCredentialResolver()
Get the metadata credential resolver instance to use to resolve encryption credentials.- Returns:
- the configured metadata credential resolver instance
-
resolveAndPopulateCredentialsAndAlgorithms
protected void resolveAndPopulateCredentialsAndAlgorithms(@Nonnull EncryptionParameters params, @Nonnull CriteriaSet criteria, @Nonnull Predicate<String> includeExcludePredicate)- Overrides:
resolveAndPopulateCredentialsAndAlgorithmsin classBasicEncryptionParametersResolver
-
checkAndProcessKeyAgreement
protected boolean checkAndProcessKeyAgreement(@Nonnull EncryptionParameters params, @Nonnull CriteriaSet criteria, @Nonnull Predicate<String> includeExcludePredicate, @Nonnull Credential credential)Check for a credential type that implies a key agreement operation, and process if so indicated.- Parameters:
params- the params instance being populatedcriteria- the input criteria being evaluatedincludeExcludePredicate- the include/exclude predicatecredential- the credential being evaluated- Returns:
- true if all required parameters were supplied, key agreement was successfully performed,
and the
EncryptionParametersinstance's credential and algorithms properties are fully populated, otherwise false
-
getEffectiveKeyAgreementConfiguration
@Nullable protected SAMLMetadataKeyAgreementEncryptionConfiguration getEffectiveKeyAgreementConfiguration(@Nonnull CriteriaSet criteria, @Nonnull Credential credential)
Get the effectiveSAMLMetadataKeyAgreementEncryptionConfigurationto use with the specified credential.- Overrides:
getEffectiveKeyAgreementConfigurationin classBasicEncryptionParametersResolver- Parameters:
criteria- the criteriacredential- the credential to evaluate- Returns:
- the key agreement configuration for the credential, or null if could not be resolved
-
concatLists
@SafeVarargs private List<String> concatLists(@Nonnull List<String>... lists)
Concatenate multiple lists into one list.- Parameters:
lists- the lists to process- Returns:
- the concatenation of the supplied lists
-
resolveAndPopulateRSAOAEPParams
protected void resolveAndPopulateRSAOAEPParams(@Nonnull EncryptionParameters params, @Nonnull CriteriaSet criteria, @Nonnull Predicate<String> includeExcludePredicate, @Nullable EncryptionMethod encryptionMethod)Resolve and populate an instance ofRSAOAEPParameters, if appropriate for the selected key transport encryption algorithm.This method itself resolves the parameters data from the metadata
EncryptionMethod. If this results in a non-complete RSAOAEPParameters instance and ifisMergeMetadataRSAOAEPParametersWithConfig()evaluates true, then the resolver will delegate to the local config resolution process via the superclass to attempt to resolve and merge any null parameter values. (seeBasicEncryptionParametersResolver.resolveAndPopulateRSAOAEPParams(EncryptionParameters, CriteriaSet, Predicate)).- Parameters:
params- the current encryption parameters instance being resolvedcriteria- the criteria instance being evaluatedincludeExcludePredicate- the include/exclude predicate with which to evaluate the candidate data encryption and key transport algorithm URIsencryptionMethod- the method encryption method that was resolved along with the key transport encryption algorithm URI, if any. May be null.
-
populateRSAOAEPParamsFromEncryptionMethod
protected void populateRSAOAEPParamsFromEncryptionMethod(@Nonnull RSAOAEPParameters params, @Nonnull EncryptionMethod encryptionMethod, @Nonnull Predicate<String> includeExcludePredicate)ExtractDigestMethod,MGFandOAEPparamsdata present on the supplied instance ofEncryptionMethodand populate it on the supplied instance of ofRSAOAEPParameters.Include/exclude evaluation is applied to the digest method and MGF algorithm URIs.
- Parameters:
params- the existing RSAOAEPParameters instance being populatedencryptionMethod- the method encryption method that was resolved along with the key transport encryption algorithm URI, if any. May be null.includeExcludePredicate- the include/exclude predicate with which to evaluate the candidate data encryption and key transport algorithm URIs
-
resolveKeyTransportAlgorithm
@Nonnull protected Pair<String,EncryptionMethod> resolveKeyTransportAlgorithm(@Nonnull Credential keyTransportCredential, @Nonnull CriteriaSet criteria, @Nonnull Predicate<String> includeExcludePredicate, @Nullable String dataEncryptionAlgorithm, @Nullable SAMLMDCredentialContext metadataCredContext)
Determine the key transport algorithm URI to use with the specified credential, also returning the associatedEncryptionMethodfrom metadata if relevant.Any algorithms specified in metadata via the passed
SAMLMDCredentialContextare considered first, followed by locally configured algorithms.- Parameters:
keyTransportCredential- the key transport credential to evaluatecriteria- the criteria instance being evaluatedincludeExcludePredicate- the include/exclude predicate with which to evaluate the candidate data encryption and key transport algorithm URIsdataEncryptionAlgorithm- the optional data encryption algorithm URI to considermetadataCredContext- the credential context extracted from metadata- Returns:
- the selected algorithm URI and the associated encryption method from metadata, if any.
-
resolveDataEncryptionAlgorithm
@Nonnull protected Pair<String,EncryptionMethod> resolveDataEncryptionAlgorithm(@Nonnull CriteriaSet criteria, @Nonnull Predicate<String> includeExcludePredicate, @Nullable SAMLMDCredentialContext metadataCredContext)
Determine the data encryption algorithm URI to use, also returning the associatedEncryptionMethodfrom metadata if relevant.Any algorithms specified in metadata via the passed
SAMLMDCredentialContextare considered first, followed by locally configured algorithms.- Parameters:
criteria- the criteria instance being evaluatedincludeExcludePredicate- the include/exclude predicate with which to evaluate the candidate data encryption and key transport algorithm URIsmetadataCredContext- the credential context extracted from metadata- Returns:
- the selected algorithm URI and the associated encryption method from metadata, if any
-
evaluateEncryptionMethodChildren
protected boolean evaluateEncryptionMethodChildren(@Nonnull EncryptionMethod encryptionMethod, @Nonnull CriteriaSet criteria, @Nonnull Predicate<String> includeExcludePredicate)Evaluate the child elements of an EncryptionMethod for acceptability based on for example include/exclude policy and algorithm runtime support.- Parameters:
encryptionMethod- the EncryptionMethod being evaluatedcriteria- the criteria instance being evaluatedincludeExcludePredicate- the include/exclude predicate with which to evaluate the candidate data encryption and key transport algorithm URIs- Returns:
- true if the EncryptionMethod children are acceptable
-
evaluateRSAOAEPChildren
protected boolean evaluateRSAOAEPChildren(@Nonnull EncryptionMethod encryptionMethod, @Nonnull CriteriaSet criteria, @Nonnull Predicate<String> includeExcludePredicate)Evaluate the child elements of an RSA OAEP EncryptionMethod for acceptability based on for example include/exclude policy and algorithm runtime support.- Parameters:
encryptionMethod- the EncryptionMethod being evaluatedcriteria- the criteria instance being evaluatedincludeExcludePredicate- the include/exclude predicate with which to evaluate the candidate data encryption and key transport algorithm URIs- Returns:
- true if the EncryptionMethod children are acceptable
-
credentialSupportsEncryptionMethod
protected boolean credentialSupportsEncryptionMethod(@Nonnull Credential credential, @Nonnull @NotEmpty EncryptionMethod encryptionMethod)Evaluate whether the specified credential is supported for use with the specifiedEncryptionMethod.- Parameters:
credential- the credential to evaluateencryptionMethod- the encryption method to evaluate- Returns:
- true if credential may be used with the supplied encryption method, false otherwise
-
-