[java-opensaml COMMIT] in /trunk/opensaml-xmlsec-impl/src/main/java/org/opensaml/xmlsec/impl: AbstractSecurityParamet...
noreply at shibboleth.net
noreply at shibboleth.net
Fri Mar 21 21:59:59 EDT 2014
Author: putmanb
Date: Fri Mar 21 21:59:58 2014
New Revision: 3725
URL: http://svn.shibboleth.net/view/java-opensaml?rev=3725&view=rev
Log:
Factor out some KeyInfoGenerator lookup code for reuse.
Modified:
trunk/opensaml-xmlsec-impl/src/main/java/org/opensaml/xmlsec/impl/AbstractSecurityParametersResolver.java
trunk/opensaml-xmlsec-impl/src/main/java/org/opensaml/xmlsec/impl/BasicSignatureSigningParametersResolver.java
Modified: trunk/opensaml-xmlsec-impl/src/main/java/org/opensaml/xmlsec/impl/AbstractSecurityParametersResolver.java
URL: http://svn.shibboleth.net/view/java-opensaml/trunk/opensaml-xmlsec-impl/src/main/java/org/opensaml/xmlsec/impl/AbstractSecurityParametersResolver.java?rev=3725&r1=3724&r2=3725&view=diff
==============================================================================
--- trunk/opensaml-xmlsec-impl/src/main/java/org/opensaml/xmlsec/impl/AbstractSecurityParametersResolver.java (original)
+++ trunk/opensaml-xmlsec-impl/src/main/java/org/opensaml/xmlsec/impl/AbstractSecurityParametersResolver.java Fri Mar 21 21:59:58 2014
@@ -30,9 +30,13 @@
import net.shibboleth.utilities.java.support.resolver.CriteriaSet;
import net.shibboleth.utilities.java.support.resolver.Resolver;
+import org.opensaml.security.credential.Credential;
import org.opensaml.xmlsec.WhitelistBlacklistConfiguration;
import org.opensaml.xmlsec.WhitelistBlacklistConfiguration.Precedence;
import org.opensaml.xmlsec.WhitelistBlacklistParameters;
+import org.opensaml.xmlsec.keyinfo.KeyInfoGenerator;
+import org.opensaml.xmlsec.keyinfo.KeyInfoGeneratorFactory;
+import org.opensaml.xmlsec.keyinfo.NamedKeyInfoGeneratorManager;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
@@ -46,6 +50,38 @@
*/
public abstract class AbstractSecurityParametersResolver<ProductType>
implements Resolver<ProductType, CriteriaSet>{
+
+ /**
+ * Resolve a {@link KeyInfoGenerator} instance based on a {@link NamedKeyInfoGeneratorManager},
+ * {@link Credential} and optional KeyInfo generation profile name.
+ *
+ * @param credential the credential for which a KeyInfo generator is needed
+ * @param manager the named KeyInfo generator manager instance
+ * @param keyInfoProfileName KeyInfo generation profile name
+ *
+ * @return the resolved KeyInfo generator instance, or null
+ */
+ @Nullable protected KeyInfoGenerator lookupKeyInfoGenerator(@Nonnull final Credential credential,
+ @Nullable final NamedKeyInfoGeneratorManager manager, @Nullable String keyInfoProfileName) {
+ Constraint.isNotNull(credential, "Credential may not be null");
+
+ if (manager == null) {
+ return null;
+ }
+
+ KeyInfoGeneratorFactory factory = null;
+ if (keyInfoProfileName != null) {
+ factory = manager.getFactory(keyInfoProfileName, credential);
+ } else {
+ factory = manager.getDefaultManager().getFactory(credential);
+ }
+
+ if (factory != null) {
+ return factory.newInstance();
+ }
+
+ return null;
+ }
/**
* Resolve and populate the effective whitelist or blacklist on the supplied instance of
Modified: trunk/opensaml-xmlsec-impl/src/main/java/org/opensaml/xmlsec/impl/BasicSignatureSigningParametersResolver.java
URL: http://svn.shibboleth.net/view/java-opensaml/trunk/opensaml-xmlsec-impl/src/main/java/org/opensaml/xmlsec/impl/BasicSignatureSigningParametersResolver.java?rev=3725&r1=3724&r2=3725&view=diff
==============================================================================
--- trunk/opensaml-xmlsec-impl/src/main/java/org/opensaml/xmlsec/impl/BasicSignatureSigningParametersResolver.java (original)
+++ trunk/opensaml-xmlsec-impl/src/main/java/org/opensaml/xmlsec/impl/BasicSignatureSigningParametersResolver.java Fri Mar 21 21:59:58 2014
@@ -39,8 +39,6 @@
import org.opensaml.xmlsec.criterion.SignatureSigningConfiguratonCriterion;
import org.opensaml.xmlsec.crypto.AlgorithmSupport;
import org.opensaml.xmlsec.keyinfo.KeyInfoGenerator;
-import org.opensaml.xmlsec.keyinfo.KeyInfoGeneratorFactory;
-import org.opensaml.xmlsec.keyinfo.NamedKeyInfoGeneratorManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -265,18 +263,9 @@
for (SignatureSigningConfiguration config : criteria.get(SignatureSigningConfiguratonCriterion.class)
.getConfigurations()) {
- NamedKeyInfoGeneratorManager manager = config.getKeyInfoGeneratorManager();
- if (manager != null) {
- KeyInfoGeneratorFactory factory = null;
- if (name != null) {
- factory = manager.getFactory(name, signingCredential);
- } else {
- factory = manager.getDefaultManager().getFactory(signingCredential);
- }
-
- if (factory != null) {
- return factory.newInstance();
- }
[... 7 lines stripped ...]
More information about the commits
mailing list