Class KeyDescriptorTransformerFunction
java.lang.Object
se.swedenconnect.security.credential.opensaml.KeyDescriptorTransformerFunction
- All Implemented Interfaces:
Function<PkiCredential,KeyDescriptor>
public class KeyDescriptorTransformerFunction
extends Object
implements Function<PkiCredential,KeyDescriptor>
Function that transform a
PkiCredential into an OpenSAML KeyDescriptor.- Author:
- Martin Lindström
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final BiFunction<PkiCredential, UsageType, List<EncryptionMethod>> The default function for gettingmd:EncryptionMethodobjects to be added to themd:KeyDescriptor.static final Function<PkiCredential, String> The default function for calculating theds:keyName.static final Function<PkiCredential, UsageType> The default function for getting the usage type (useattribute). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionapply(PkiCredential credential) Given the suppliedPkiCredential, the method creates an OpenSAMLKeyDescriptorfor inclusion in anEntityDescriptor.function()Creates aKeyDescriptorTransformerFunction.withEncryptionMethodsFunction(BiFunction<PkiCredential, UsageType, List<EncryptionMethod>> encryptionMethodsFunction) Customizes this function with a function that returns a list ofmd:EncryptionMethodelements for inclusion in themd:KeyDescriptor.withKeyNameFunction(Function<PkiCredential, String> keyNameFunction) Customizes this function with a function that calculates theds:KeyName.withUsageTypeFunction(Function<PkiCredential, UsageType> usageTypeFunction) Customizes this function with a function that gets theuseattribute.
-
Field Details
-
defaultKeyNameFunction
The default function for calculating theds:keyName. It uses thePkiCredential.getName(). -
defaultUsageTypeFunction
The default function for getting the usage type (useattribute). It checks if the metadata propertyPkiCredential.Metadata.USAGE_PROPERTYis assigned, and set to eitherPkiCredential.Metadata.USAGE_SIGNINGorPkiCredential.Metadata.USAGE_ENCRYPTION. -
defaultEncryptionMethodsFunction
public static final BiFunction<PkiCredential,UsageType, defaultEncryptionMethodsFunctionList<EncryptionMethod>> The default function for gettingmd:EncryptionMethodobjects to be added to themd:KeyDescriptor. If the usage for the credential is encryption (or unspecified), and the metadata propertyOpenSamlMetadataProperties.ENCRYPTION_METHODShas been assigned, these values are used to createmd:EncryptionMethodelements.
-
-
Constructor Details
-
KeyDescriptorTransformerFunction
public KeyDescriptorTransformerFunction()Constructor.
-
-
Method Details
-
function
Creates aKeyDescriptorTransformerFunction.- Returns:
- a
KeyDescriptorTransformerFunction
-
apply
Given the suppliedPkiCredential, the method creates an OpenSAMLKeyDescriptorfor inclusion in anEntityDescriptor.Unless changed with the withXXX method, the method will process the following parameters:
-
The credential name - The name, as given by
PkiCredential.getName()will be used as value for theds:KeyNameelement. SeedefaultKeyNameFunction. -
The usage - If the metadata property
PkiCredential.Metadata.USAGE_PROPERTYis assigned, and set to eitherPkiCredential.Metadata.USAGE_SIGNINGorPkiCredential.Metadata.USAGE_ENCRYPTION, theuseattribute of themd:KeyDescriptorelement will be set accordingly. SeedefaultUsageTypeFunction. -
Encryption methods - If the usage for the credential is encryption (or unspecified), and the metadata property
OpenSamlMetadataProperties.ENCRYPTION_METHODShas been assigned, these values are used to create, and add,md:EncryptionMethodelements to the resultingmd:KeyDescriptor. SeedefaultEncryptionMethodsFunction.
- Specified by:
applyin interfaceFunction<PkiCredential,KeyDescriptor> - Parameters:
credential- the credential- Returns:
- a
KeyDescriptor
-
The credential name - The name, as given by
-
withKeyNameFunction
@Nonnull public KeyDescriptorTransformerFunction withKeyNameFunction(@Nonnull Function<PkiCredential, String> keyNameFunction) Customizes this function with a function that calculates theds:KeyName.The default is
defaultKeyNameFunction.- Parameters:
keyNameFunction- the function- Returns:
- this instance
-
withUsageTypeFunction
@Nonnull public KeyDescriptorTransformerFunction withUsageTypeFunction(@Nonnull Function<PkiCredential, UsageType> usageTypeFunction) Customizes this function with a function that gets theuseattribute.The default is
defaultUsageTypeFunction.- Parameters:
usageTypeFunction- the function- Returns:
- this instance
-
withEncryptionMethodsFunction
@Nonnull public KeyDescriptorTransformerFunction withEncryptionMethodsFunction(@Nonnull BiFunction<PkiCredential, UsageType, List<EncryptionMethod>> encryptionMethodsFunction) Customizes this function with a function that returns a list ofmd:EncryptionMethodelements for inclusion in themd:KeyDescriptor.- Parameters:
encryptionMethodsFunction- the function- Returns:
- this instance
-