[java-opensaml COMMIT] /trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/profile/impl/AbstractEncryptAc...
noreply at shibboleth.net
noreply at shibboleth.net
Tue May 13 21:25:52 EDT 2014
Author: scantor
Date: Tue May 13 21:25:52 2014
New Revision: 3868
URL: http://svn.shibboleth.net/view/java-opensaml?rev=3868&view=rev
Log:
Add pluggable option for key placement.
Modified:
trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/profile/impl/AbstractEncryptAction.java
Modified: trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/profile/impl/AbstractEncryptAction.java
URL: http://svn.shibboleth.net/view/java-opensaml/trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/profile/impl/AbstractEncryptAction.java?rev=3868&r1=3867&r2=3868&view=diff
==============================================================================
--- trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/profile/impl/AbstractEncryptAction.java (original)
+++ trunk/opensaml-saml-impl/src/main/java/org/opensaml/saml/saml2/profile/impl/AbstractEncryptAction.java Tue May 13 21:25:52 2014
@@ -22,6 +22,7 @@
import net.shibboleth.utilities.java.support.component.ComponentSupport;
import net.shibboleth.utilities.java.support.logic.Constraint;
+import net.shibboleth.utilities.java.support.logic.FunctionSupport;
import org.opensaml.messaging.context.navigate.ChildContextLookup;
import org.opensaml.profile.action.AbstractConditionalProfileAction;
@@ -59,6 +60,9 @@
/** Strategy used to locate the encryption recipient. */
@Nullable private Function<ProfileRequestContext,String> recipientLookupStrategy;
+ /** Strategy used to determine encrypted key placement. */
+ @Nonnull private Function<ProfileRequestContext,Encrypter.KeyPlacement> keyPlacementLookupStrategy;
+
/** The encryption object. */
@Nullable private Encrypter encrypter;
@@ -66,6 +70,7 @@
public AbstractEncryptAction() {
encryptionCtxLookupStrategy = Functions.compose(new ChildContextLookup<>(EncryptionContext.class),
new OutboundMessageContextLookup());
+ keyPlacementLookupStrategy = FunctionSupport.<ProfileRequestContext,KeyPlacement>constant(KeyPlacement.INLINE);
}
/**
@@ -94,6 +99,17 @@
}
/**
+ * Set the strategy used to determine the encrypted key placement strategy.
+ *
+ * @param strategy lookup strategy
+ */
+ public void setKeyPlacementLookupStrategy(@Nonnull final Function<ProfileRequestContext,KeyPlacement> strategy) {
+ ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+
+ keyPlacementLookupStrategy = Constraint.isNotNull(strategy, "Key placement lookup strategy cannot be null");
+ }
+
+ /**
* Get the encrypter.
*
* @return the encrypter
@@ -119,7 +135,7 @@
final KeyEncryptionParameters keyParams = new KeyEncryptionParameters(params, recipient);
encrypter = new Encrypter(dataParams, keyParams);
- encrypter.setKeyPlacement(KeyPlacement.INLINE);
+ encrypter.setKeyPlacement(keyPlacementLookupStrategy.apply(profileRequestContext));
return super.doPreExecute(profileRequestContext);
}
More information about the commits
mailing list