You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by co...@apache.org on 2011/02/14 12:49:42 UTC
svn commit: r1070452 [1/2] - in /santuario/xml-security-java/trunk/src:
main/java/org/apache/xml/security/ main/java/org/apache/xml/security/keys/
main/java/org/apache/xml/security/keys/keyresolver/
main/java/org/apache/xml/security/keys/keyresolver/im...
Author: coheigea
Date: Mon Feb 14 11:49:42 2011
New Revision: 1070452
URL: http://svn.apache.org/viewvc?rev=1070452&view=rev
Log:
Some changes to KeyResolver stuff
- Removed code to insert frequently hit stuff at position 0 of static lists
- Changed KeyResolvers to not create new instances on a hit by default.
Modified:
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/Init.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/KeyInfo.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/keyresolver/KeyResolver.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/keyresolver/KeyResolverSpi.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/DSAKeyValueResolver.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/EncryptedKeyResolver.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/RSAKeyValueResolver.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/RetrievalMethodResolver.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/X509CertificateResolver.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/X509IssuerSerialResolver.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/X509SKIResolver.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/X509SubjectNameResolver.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/resolver/ResourceResolver.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/resolver/implementations/ResolverAnonymous.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/resolver/implementations/ResolverDirectHTTP.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/resolver/implementations/ResolverFragment.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/resolver/implementations/ResolverLocalFilesystem.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/resolver/implementations/ResolverXPointer.java
santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/utils/OldApiTest.java
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/Init.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/Init.java?rev=1070452&r1=1070451&r2=1070452&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/Init.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/Init.java Mon Feb 14 11:49:42 2011
@@ -315,7 +315,6 @@ public class Init {
if (tag.equals("KeyResolver")){
XX_configure_reg_keyResolver_start =System.currentTimeMillis();
- KeyResolver.init();
Element[] resolverElem = XMLUtils.selectNodes(el.getFirstChild(), CONF_NS,"Resolver");
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/KeyInfo.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/KeyInfo.java?rev=1070452&r1=1070451&r2=1070452&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/KeyInfo.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/KeyInfo.java Mon Feb 14 11:49:42 2011
@@ -751,7 +751,6 @@ public class KeyInfo extends SignatureEl
);
if (pk != null) {
- KeyResolver.hit(it);
return pk;
}
}
@@ -860,7 +859,6 @@ public class KeyInfo extends SignatureEl
KeyResolverSpi keyResolver = (KeyResolverSpi) it.next();
X509Certificate cert = applyCurrentResolver(uri, storageLength, keyResolver);
if (cert != null) {
- KeyResolver.hit(it);
return cert;
}
}
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/keyresolver/KeyResolver.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/keyresolver/KeyResolver.java?rev=1070452&r1=1070451&r2=1070452&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/keyresolver/KeyResolver.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/keyresolver/KeyResolver.java Mon Feb 14 11:49:42 2011
@@ -1,4 +1,3 @@
-
/*
* Copyright 1999-2010 The Apache Software Foundation.
*
@@ -29,330 +28,307 @@ import org.apache.xml.security.keys.stor
import org.w3c.dom.Element;
import org.w3c.dom.Node;
-
/**
* KeyResolver is factory class for subclass of KeyResolverSpi that
* represent child element of KeyInfo.
- *
- * @author $Author$
- * @version %I%, %G%
*/
public class KeyResolver {
- /** {@link org.apache.commons.logging} logging facility */
- static org.apache.commons.logging.Log log =
- org.apache.commons.logging.LogFactory.getLog(KeyResolver.class.getName());
-
- /** Field _alreadyInitialized */
- static boolean _alreadyInitialized = false;
-
- /** Field _resolverVector */
- static List _resolverVector = null;
-
- /** Field _resolverSpi */
- protected KeyResolverSpi _resolverSpi = null;
-
- /** Field _storage */
- protected StorageResolver _storage = null;
-
- /**
- * Constructor ResourceResolver
- *
- * @param className
- * @throws ClassNotFoundException
- * @throws IllegalAccessException
- * @throws InstantiationException
- */
- private KeyResolver(String className)
- throws ClassNotFoundException, IllegalAccessException,
- InstantiationException {
- this._resolverSpi =
- (KeyResolverSpi) Class.forName(className).newInstance();
- this._resolverSpi.setGlobalResolver(true);
- }
-
- /**
- * Method length
- *
- * @return the length of resolvers registered
- */
- public static int length() {
- return KeyResolver._resolverVector.size();
- }
-
- /**
- * This method is called when a KeyResolver is successful
- * with the hope that this information can improve performance.
- * @param hintI
- */
- public static void hit(Iterator hintI) {
- // Move the successful KeyResolver to the beginning of the list
- ResolverIterator hint = (ResolverIterator) hintI;
- int i = hint.i;
- if (i!=1 && hint.res ==_resolverVector) {
- List resolverVector=(List)((ArrayList)_resolverVector).clone();
- Object ob=resolverVector.remove(i-1);
- resolverVector.add(0,ob);
- _resolverVector=resolverVector;
- } else {
- //System.out.println("KeyResolver hitting");
- }
- }
-
- /**
- * Method getX509Certificate
- *
- * @param element
- * @param BaseURI
- * @param storage
- * @return The certificate represented by the element.
- *
- * @throws KeyResolverException
- */
- public static final X509Certificate getX509Certificate(
- Element element, String BaseURI, StorageResolver storage)
- throws KeyResolverException {
-
- // use the old vector to not be hit by updates
- List resolverVector = KeyResolver._resolverVector;
- for (int i = 0; i < resolverVector.size(); i++) {
- KeyResolver resolver=
- (KeyResolver) resolverVector.get(i);
-
- if (resolver==null) {
- Object exArgs[] = {
- (((element != null)
- && (element.getNodeType() == Node.ELEMENT_NODE))
- ? element.getTagName()
- : "null") };
-
- throw new KeyResolverException("utils.resolver.noClass", exArgs);
- }
- if (log.isDebugEnabled())
+ /** {@link org.apache.commons.logging} logging facility */
+ private static org.apache.commons.logging.Log log =
+ org.apache.commons.logging.LogFactory.getLog(KeyResolver.class.getName());
+
+ /** Field resolverVector */
+ private static List<KeyResolver> resolverVector = new ArrayList<KeyResolver>();
+
+ /** Field resolverSpi */
+ protected KeyResolverSpi resolverSpi = null;
+
+ /**
+ * Constructor ResourceResolver
+ *
+ * @param className
+ * @throws ClassNotFoundException
+ * @throws IllegalAccessException
+ * @throws InstantiationException
+ */
+ private KeyResolver(String className, boolean globalResolver)
+ throws ClassNotFoundException, IllegalAccessException, InstantiationException {
+ this.resolverSpi =
+ (KeyResolverSpi) Class.forName(className).newInstance();
+ this.resolverSpi.setGlobalResolver(globalResolver);
+ }
+
+ /**
+ * Method length
+ *
+ * @return the length of resolvers registered
+ */
+ public synchronized static int length() {
+ return KeyResolver.resolverVector.size();
+ }
+
+ /**
+ * Method getX509Certificate
+ *
+ * @param element
+ * @param BaseURI
+ * @param storage
+ * @return The certificate represented by the element.
+ *
+ * @throws KeyResolverException
+ */
+ public synchronized static final X509Certificate getX509Certificate(
+ Element element, String BaseURI, StorageResolver storage
+ ) throws KeyResolverException {
+ for (KeyResolver resolver : resolverVector) {
+ if (resolver == null) {
+ Object exArgs[] = {
+ (((element != null)
+ && (element.getNodeType() == Node.ELEMENT_NODE))
+ ? element.getTagName() : "null")
+ };
+
+ throw new KeyResolverException("utils.resolver.noClass", exArgs);
+ }
+ if (log.isDebugEnabled()) {
log.debug("check resolvability by class " + resolver.getClass());
+ }
+
+ X509Certificate cert = resolver.resolveX509Certificate(element, BaseURI, storage);
+ if (cert != null) {
+ return cert;
+ }
+ }
+
+ Object exArgs[] = {
+ (((element != null) && (element.getNodeType() == Node.ELEMENT_NODE))
+ ? element.getTagName() : "null")
+ };
+
+ throw new KeyResolverException("utils.resolver.noClass", exArgs);
+ }
+
+ /**
+ * Method getPublicKey
+ *
+ * @param element
+ * @param BaseURI
+ * @param storage
+ * @return the public key contained in the element
+ *
+ * @throws KeyResolverException
+ */
+ public synchronized static final PublicKey getPublicKey(
+ Element element, String BaseURI, StorageResolver storage
+ ) throws KeyResolverException {
+ for (int i = 0; i < resolverVector.size(); i++) {
+ KeyResolver resolver = resolverVector.get(i);
+ if (resolver == null) {
+ Object exArgs[] = {
+ (((element != null)
+ && (element.getNodeType() == Node.ELEMENT_NODE))
+ ? element.getTagName() : "null")
+ };
- X509Certificate cert=resolver.resolveX509Certificate(element, BaseURI, storage);
- if (cert!=null) {
- return cert;
- }
- }
-
- Object exArgs[] = {
- (((element != null) && (element.getNodeType() == Node.ELEMENT_NODE))
- ? element.getTagName()
- : "null") };
-
- throw new KeyResolverException("utils.resolver.noClass", exArgs);
- }
-
- /**
- * Method getPublicKey
- *
- * @param element
- * @param BaseURI
- * @param storage
- * @return the public key contained in the element
- *
- * @throws KeyResolverException
- */
- public static final PublicKey getPublicKey(
- Element element, String BaseURI, StorageResolver storage)
- throws KeyResolverException {
-
- // use the old vector to not be hit by updates
- List resolverVector = KeyResolver._resolverVector;
- for (int i = 0; i < resolverVector.size(); i++) {
- KeyResolver resolver=
- (KeyResolver) resolverVector.get(i);
-
- if (resolver==null) {
- Object exArgs[] = {
- (((element != null)
- && (element.getNodeType() == Node.ELEMENT_NODE))
- ? element.getTagName()
- : "null") };
-
- throw new KeyResolverException("utils.resolver.noClass", exArgs);
- }
- if (log.isDebugEnabled())
+ throw new KeyResolverException("utils.resolver.noClass", exArgs);
+ }
+ if (log.isDebugEnabled()) {
log.debug("check resolvability by class " + resolver.getClass());
+ }
+
+ PublicKey cert = resolver.resolvePublicKey(element, BaseURI, storage);
+ if (cert != null) {
+ return cert;
+ }
+ }
- PublicKey cert=resolver.resolvePublicKey(element, BaseURI, storage);
- if (cert!=null) {
- if (i!=0 && resolverVector==_resolverVector) {
- //update resolver.
- resolverVector=(List)((ArrayList)_resolverVector).clone();
- Object ob=resolverVector.remove(i);
- resolverVector.add(0,ob);
- _resolverVector=resolverVector;
- }
- return cert;
- }
- }
-
- Object exArgs[] = {
- (((element != null) && (element.getNodeType() == Node.ELEMENT_NODE))
- ? element.getTagName()
- : "null") };
-
- throw new KeyResolverException("utils.resolver.noClass", exArgs);
- }
-
- /**
- * The init() function is called by org.apache.xml.security.Init.init()
- */
- public static void init() {
-
- if (!KeyResolver._alreadyInitialized) {
- KeyResolver._resolverVector = new ArrayList(10);
- _alreadyInitialized = true;
- }
- }
-
- /**
- * This method is used for registering {@link KeyResolverSpi}s which are
- * available to <I>all</I> {@link org.apache.xml.security.keys.KeyInfo} objects. This means that
- * personalized {@link KeyResolverSpi}s should only be registered directly
- * to the {@link org.apache.xml.security.keys.KeyInfo} using
- * {@link org.apache.xml.security.keys.KeyInfo#registerInternalKeyResolver}.
- *
- * @param className
- * @throws InstantiationException
- * @throws IllegalAccessException
- * @throws ClassNotFoundException
- */
- public static void register(String className) throws ClassNotFoundException, IllegalAccessException, InstantiationException {
- KeyResolver._resolverVector.add(new KeyResolver(className));
- }
-
- /**
- * This method is used for registering {@link KeyResolverSpi}s which are
- * available to <I>all</I> {@link org.apache.xml.security.keys.KeyInfo} objects. This means that
- * personalized {@link KeyResolverSpi}s should only be registered directly
- * to the {@link org.apache.xml.security.keys.KeyInfo} using {@link org.apache.xml.security.keys.KeyInfo#registerInternalKeyResolver}.
- *
- * @param className
- */
- public static void registerAtStart(String className) {
- // For backwards compatibility, use a RuntimeException instead of adding a throws clause
- KeyResolver resolver = null;
- Exception ex = null;
-
- try {
- resolver = new KeyResolver(className);
- } catch (ClassNotFoundException e) {
- ex = e;
- } catch (IllegalAccessException e) {
- ex = e;
- } catch (InstantiationException e) {
- ex = e;
- }
-
- if (ex != null) {
- throw (IllegalArgumentException) new
- IllegalArgumentException("Invalid KeyResolver class name").initCause(ex);
- }
-
- KeyResolver._resolverVector.add(0, resolver);
- }
-
- /**
- * Method resolvePublicKey
- *
- * @param element
- * @param BaseURI
- * @param storage
- * @return resolved public key from the registered from the elements
- *
- * @throws KeyResolverException
- */
- public PublicKey resolvePublicKey(
- Element element, String BaseURI, StorageResolver storage)
- throws KeyResolverException {
- return this._resolverSpi.engineLookupAndResolvePublicKey(element, BaseURI, storage);
- }
-
- /**
- * Method resolveX509Certificate
- *
- * @param element
- * @param BaseURI
- * @param storage
- * @return resolved X509certificate key from the registered from the elements
- *
- * @throws KeyResolverException
- */
- public X509Certificate resolveX509Certificate(
- Element element, String BaseURI, StorageResolver storage)
- throws KeyResolverException {
- return this._resolverSpi.engineLookupResolveX509Certificate(element, BaseURI,
- storage);
- }
-
- /**
- * @param element
- * @param BaseURI
- * @param storage
- * @return resolved SecretKey key from the registered from the elements
- * @throws KeyResolverException
- */
- public SecretKey resolveSecretKey(
- Element element, String BaseURI, StorageResolver storage)
- throws KeyResolverException {
- return this._resolverSpi.engineLookupAndResolveSecretKey(element, BaseURI,
- storage);
- }
-
- /**
- * Method setProperty
- *
- * @param key
- * @param value
- */
- public void setProperty(String key, String value) {
- this._resolverSpi.engineSetProperty(key, value);
- }
-
- /**
- * Method getProperty
- *
- * @param key
- * @return the property setted for this resolver
- */
- public String getProperty(String key) {
- return this._resolverSpi.engineGetProperty(key);
- }
-
-
- /**
- * Method understandsProperty
- *
- * @param propertyToTest
- * @return true if the resolver understands property propertyToTest
- */
- public boolean understandsProperty(String propertyToTest) {
- return this._resolverSpi.understandsProperty(propertyToTest);
- }
-
-
- /**
- * Method resolverClassName
- *
- * @return the name of the resolver.
- */
- public String resolverClassName() {
- return this._resolverSpi.getClass().getName();
- }
-
- /**
- * Iterate over the KeyResolverSpi instances
- */
- static class ResolverIterator implements Iterator {
- List res;
- Iterator it;
+ Object exArgs[] = {
+ (((element != null) && (element.getNodeType() == Node.ELEMENT_NODE))
+ ? element.getTagName() : "null")
+ };
+
+ throw new KeyResolverException("utils.resolver.noClass", exArgs);
+ }
+
+ /**
+ * This method is used for registering {@link KeyResolverSpi}s which are
+ * available to <I>all</I> {@link org.apache.xml.security.keys.KeyInfo} objects. This means that
+ * personalized {@link KeyResolverSpi}s should only be registered directly
+ * to the {@link org.apache.xml.security.keys.KeyInfo} using
+ * {@link org.apache.xml.security.keys.KeyInfo#registerInternalKeyResolver}.
+ * The KeyResolverSpi instance is not registered as a global resolver
+ *
+ * @param className
+ * @throws InstantiationException
+ * @throws IllegalAccessException
+ * @throws ClassNotFoundException
+ */
+ public static void register(String className)
+ throws ClassNotFoundException, IllegalAccessException, InstantiationException {
+ register(className, false);
+ }
+
+ /**
+ * This method is used for registering {@link KeyResolverSpi}s which are
+ * available to <I>all</I> {@link org.apache.xml.security.keys.KeyInfo} objects. This means that
+ * personalized {@link KeyResolverSpi}s should only be registered directly
+ * to the {@link org.apache.xml.security.keys.KeyInfo} using
+ * {@link org.apache.xml.security.keys.KeyInfo#registerInternalKeyResolver}.
+ *
+ * @param className
+ * @param globalResolver Whether the KeyResolverSpi is a global resolver or not
+ * @throws InstantiationException
+ * @throws IllegalAccessException
+ * @throws ClassNotFoundException
+ */
+ public synchronized static void register(String className, boolean globalResolver)
+ throws ClassNotFoundException, IllegalAccessException, InstantiationException {
+ KeyResolver.resolverVector.add(new KeyResolver(className, globalResolver));
+ }
+
+ /**
+ * This method is used for registering {@link KeyResolverSpi}s which are
+ * available to <I>all</I> {@link org.apache.xml.security.keys.KeyInfo} objects. This means that
+ * personalized {@link KeyResolverSpi}s should only be registered directly
+ * to the {@link org.apache.xml.security.keys.KeyInfo} using
+ * {@link org.apache.xml.security.keys.KeyInfo#registerInternalKeyResolver}.
+ * The KeyResolverSpi instance is not registered as a global resolver
+ *
+ * @param className
+ */
+ public static void registerAtStart(String className) {
+ registerAtStart(className, false);
+ }
+
+ /**
+ * This method is used for registering {@link KeyResolverSpi}s which are
+ * available to <I>all</I> {@link org.apache.xml.security.keys.KeyInfo} objects. This means that
+ * personalized {@link KeyResolverSpi}s should only be registered directly
+ * to the {@link org.apache.xml.security.keys.KeyInfo} using
+ * {@link org.apache.xml.security.keys.KeyInfo#registerInternalKeyResolver}.
+ *
+ * @param className
+ * @param globalResolver Whether the KeyResolverSpi is a global resolver or not
+ */
+ public synchronized static void registerAtStart(String className, boolean globalResolver) {
+ // For backwards compatibility, use a RuntimeException instead of adding a throws clause
+ KeyResolver resolver = null;
+ Exception ex = null;
+
+ try {
+ resolver = new KeyResolver(className, globalResolver);
+ } catch (ClassNotFoundException e) {
+ ex = e;
+ } catch (IllegalAccessException e) {
+ ex = e;
+ } catch (InstantiationException e) {
+ ex = e;
+ }
+
+ if (ex != null) {
+ throw (IllegalArgumentException) new
+ IllegalArgumentException("Invalid KeyResolver class name").initCause(ex);
+ }
+
+ KeyResolver.resolverVector.add(0, resolver);
+ }
+
+ /**
+ * Method resolvePublicKey
+ *
+ * @param element
+ * @param BaseURI
+ * @param storage
+ * @return resolved public key from the registered from the elements
+ *
+ * @throws KeyResolverException
+ */
+ public PublicKey resolvePublicKey(
+ Element element, String BaseURI, StorageResolver storage
+ ) throws KeyResolverException {
+ return this.resolverSpi.engineLookupAndResolvePublicKey(element, BaseURI, storage);
+ }
+
+ /**
+ * Method resolveX509Certificate
+ *
+ * @param element
+ * @param BaseURI
+ * @param storage
+ * @return resolved X509certificate key from the registered from the elements
+ *
+ * @throws KeyResolverException
+ */
+ public X509Certificate resolveX509Certificate(
+ Element element, String BaseURI, StorageResolver storage
+ ) throws KeyResolverException {
+ return this.resolverSpi.engineLookupResolveX509Certificate(element, BaseURI, storage);
+ }
+
+ /**
+ * @param element
+ * @param BaseURI
+ * @param storage
+ * @return resolved SecretKey key from the registered from the elements
+ * @throws KeyResolverException
+ */
+ public SecretKey resolveSecretKey(
+ Element element, String BaseURI, StorageResolver storage
+ ) throws KeyResolverException {
+ return this.resolverSpi.engineLookupAndResolveSecretKey(element, BaseURI, storage);
+ }
+
+ /**
+ * Method setProperty
+ *
+ * @param key
+ * @param value
+ */
+ public void setProperty(String key, String value) {
+ this.resolverSpi.engineSetProperty(key, value);
+ }
+
+ /**
+ * Method getProperty
+ *
+ * @param key
+ * @return the property set for this resolver
+ */
+ public String getProperty(String key) {
+ return this.resolverSpi.engineGetProperty(key);
+ }
+
+
+ /**
+ * Method understandsProperty
+ *
+ * @param propertyToTest
+ * @return true if the resolver understands property propertyToTest
+ */
+ public boolean understandsProperty(String propertyToTest) {
+ return this.resolverSpi.understandsProperty(propertyToTest);
+ }
+
+
+ /**
+ * Method resolverClassName
+ *
+ * @return the name of the resolver.
+ */
+ public String resolverClassName() {
+ return this.resolverSpi.getClass().getName();
+ }
+
+ /**
+ * Iterate over the KeyResolverSpi instances
+ */
+ static class ResolverIterator implements Iterator<KeyResolverSpi> {
+ List<KeyResolver> res;
+ Iterator<KeyResolver> it;
int i;
- public ResolverIterator(List list) {
+ public ResolverIterator(List<KeyResolver> list) {
res = list;
it = res.iterator();
}
@@ -361,23 +337,22 @@ public class KeyResolver {
return it.hasNext();
}
- public Object next() {
+ public KeyResolverSpi next() {
i++;
- KeyResolver resolver = (KeyResolver) it.next();
+ KeyResolver resolver = it.next();
if (resolver == null) {
throw new RuntimeException("utils.resolver.noClass");
}
- return resolver._resolverSpi;
+ return resolver.resolverSpi;
}
public void remove() {
- throw new UnsupportedOperationException(
- "Can't remove resolvers using the iterator");
+ throw new UnsupportedOperationException("Can't remove resolvers using the iterator");
}
- };
-
- public static Iterator iterator() {
- return new ResolverIterator(_resolverVector);
- }
+ };
+
+ public synchronized static Iterator<KeyResolverSpi> iterator() {
+ return new ResolverIterator(resolverVector);
+ }
}
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/keyresolver/KeyResolverSpi.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/keyresolver/KeyResolverSpi.java?rev=1070452&r1=1070451&r2=1070452&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/keyresolver/KeyResolverSpi.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/keyresolver/KeyResolverSpi.java Mon Feb 14 11:49:42 2011
@@ -27,9 +27,9 @@ import org.apache.xml.security.keys.stor
import org.w3c.dom.Element;
/**
- * This class is an abstract class for a child KeyInfo Elemnet.
+ * This class is an abstract class for a child KeyInfo Element.
*
- * If you want the your KeyResolver, at firstly you must extand this class, and register
+ * If you want the your KeyResolver, at firstly you must extend this class, and register
* as following in config.xml
* <PRE>
* <KeyResolver URI="http://www.w3.org/2000/09/xmldsig#KeyValue"
@@ -97,9 +97,9 @@ public abstract class KeyResolverSpi {
try {
tmp = (KeyResolverSpi) getClass().newInstance();
} catch (InstantiationException e) {
- throw new KeyResolverException("",e);
+ throw new KeyResolverException("", e);
} catch (IllegalAccessException e) {
- throw new KeyResolverException("",e);
+ throw new KeyResolverException("", e);
}
}
return tmp;
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/DSAKeyValueResolver.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/DSAKeyValueResolver.java?rev=1070452&r1=1070451&r2=1070452&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/DSAKeyValueResolver.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/DSAKeyValueResolver.java Mon Feb 14 11:49:42 2011
@@ -16,8 +16,6 @@
*/
package org.apache.xml.security.keys.keyresolver.implementations;
-
-
import java.security.PublicKey;
import java.security.cert.X509Certificate;
@@ -30,66 +28,62 @@ import org.apache.xml.security.utils.Con
import org.apache.xml.security.utils.XMLUtils;
import org.w3c.dom.Element;
-
-/**
- *
- * @author $Author$
- */
public class DSAKeyValueResolver extends KeyResolverSpi {
-
- /**
- * Method engineResolvePublicKey
- *
- * @param element
- * @param BaseURI
- * @param storage
- * @return null if no {@link PublicKey} could be obtained
- */
- public PublicKey engineLookupAndResolvePublicKey(
- Element element, String BaseURI, StorageResolver storage) {
- if (element == null) {
- return null;
- }
- Element dsaKeyElement=null;
- boolean isKeyValue = XMLUtils.elementIsInSignatureSpace(element,
- Constants._TAG_KEYVALUE);
- if (isKeyValue) {
- dsaKeyElement =
- XMLUtils.selectDsNode(element.getFirstChild(),Constants._TAG_DSAKEYVALUE,0);
- } else if (XMLUtils.elementIsInSignatureSpace(element,
- Constants._TAG_DSAKEYVALUE)) {
- // this trick is needed to allow the RetrievalMethodResolver to eat a
- // ds:DSAKeyValue directly (without KeyValue)
- dsaKeyElement = element;
- }
-
- if (dsaKeyElement == null) {
- return null;
- }
-
- try {
- DSAKeyValue dsaKeyValue = new DSAKeyValue(dsaKeyElement,
- BaseURI);
- PublicKey pk = dsaKeyValue.getPublicKey();
-
- return pk;
- } catch (XMLSecurityException ex) {
- //do nothing
- }
-
- return null;
- }
-
-
- /** @inheritDoc */
- public X509Certificate engineLookupResolveX509Certificate(
- Element element, String BaseURI, StorageResolver storage) {
- return null;
- }
-
- /** @inheritDoc */
- public javax.crypto.SecretKey engineLookupAndResolveSecretKey(
- Element element, String BaseURI, StorageResolver storage){
- return null;
- }
+
+ /**
+ * Method engineResolvePublicKey
+ *
+ * @param element
+ * @param BaseURI
+ * @param storage
+ * @return null if no {@link PublicKey} could be obtained
+ */
+ public PublicKey engineLookupAndResolvePublicKey(
+ Element element, String BaseURI, StorageResolver storage
+ ) {
+ if (element == null) {
+ return null;
+ }
+ Element dsaKeyElement = null;
+ boolean isKeyValue =
+ XMLUtils.elementIsInSignatureSpace(element, Constants._TAG_KEYVALUE);
+ if (isKeyValue) {
+ dsaKeyElement =
+ XMLUtils.selectDsNode(element.getFirstChild(), Constants._TAG_DSAKEYVALUE, 0);
+ } else if (XMLUtils.elementIsInSignatureSpace(element, Constants._TAG_DSAKEYVALUE)) {
+ // this trick is needed to allow the RetrievalMethodResolver to eat a
+ // ds:DSAKeyValue directly (without KeyValue)
+ dsaKeyElement = element;
+ }
+
+ if (dsaKeyElement == null) {
+ return null;
+ }
+
+ try {
+ DSAKeyValue dsaKeyValue = new DSAKeyValue(dsaKeyElement, BaseURI);
+ PublicKey pk = dsaKeyValue.getPublicKey();
+
+ return pk;
+ } catch (XMLSecurityException ex) {
+ //do nothing
+ }
+
+ return null;
+ }
+
+
+ /** @inheritDoc */
+ public X509Certificate engineLookupResolveX509Certificate(
+ Element element, String BaseURI, StorageResolver storage
+ ) {
+ return null;
+ }
+
+ /** @inheritDoc */
+ public javax.crypto.SecretKey engineLookupAndResolveSecretKey(
+ Element element, String BaseURI, StorageResolver storage
+ ) {
+ return null;
+ }
}
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/EncryptedKeyResolver.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/EncryptedKeyResolver.java?rev=1070452&r1=1070451&r2=1070452&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/EncryptedKeyResolver.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/EncryptedKeyResolver.java Mon Feb 14 11:49:42 2011
@@ -43,16 +43,14 @@ import org.w3c.dom.Element;
*
* @author Berin Lautenbach
*/
-
public class EncryptedKeyResolver extends KeyResolverSpi {
/** {@link org.apache.commons.logging} logging facility */
- static org.apache.commons.logging.Log log =
- org.apache.commons.logging.LogFactory.getLog(
- RSAKeyValueResolver.class.getName());
+ private static org.apache.commons.logging.Log log =
+ org.apache.commons.logging.LogFactory.getLog(RSAKeyValueResolver.class.getName());
- Key _kek;
- String _algorithm;
+ private Key kek;
+ private String algorithm;
/**
* Constructor for use when a KEK needs to be derived from a KeyInfo
@@ -60,8 +58,8 @@ public class EncryptedKeyResolver extend
* @param algorithm
*/
public EncryptedKeyResolver(String algorithm) {
- _kek = null;
- _algorithm=algorithm;
+ kek = null;
+ this.algorithm = algorithm;
}
/**
@@ -70,25 +68,28 @@ public class EncryptedKeyResolver extend
* @param kek
*/
public EncryptedKeyResolver(String algorithm, Key kek) {
- _algorithm = algorithm;
- _kek = kek;
+ this.algorithm = algorithm;
+ this.kek = kek;
}
-
+
/** @inheritDoc */
public PublicKey engineLookupAndResolvePublicKey(
- Element element, String BaseURI, StorageResolver storage) {
+ Element element, String BaseURI, StorageResolver storage
+ ) {
return null;
}
/** @inheritDoc */
public X509Certificate engineLookupResolveX509Certificate(
- Element element, String BaseURI, StorageResolver storage) {
+ Element element, String BaseURI, StorageResolver storage
+ ) {
return null;
}
/** @inheritDoc */
public javax.crypto.SecretKey engineLookupAndResolveSecretKey(
- Element element, String BaseURI, StorageResolver storage) {
+ Element element, String BaseURI, StorageResolver storage
+ ) {
if (log.isDebugEnabled()) {
log.debug("EncryptedKeyResolver - Can I resolve " + element.getTagName());
}
@@ -98,18 +99,20 @@ public class EncryptedKeyResolver extend
}
SecretKey key = null;
- boolean isEncryptedKey = XMLUtils.elementIsInEncryptionSpace(element,
- EncryptionConstants._TAG_ENCRYPTEDKEY);
+ boolean isEncryptedKey =
+ XMLUtils.elementIsInEncryptionSpace(element, EncryptionConstants._TAG_ENCRYPTEDKEY);
if (isEncryptedKey) {
- log.debug("Passed an Encrypted Key");
+ if (log.isDebugEnabled()) {
+ log.debug("Passed an Encrypted Key");
+ }
try {
XMLCipher cipher = XMLCipher.getInstance();
- cipher.init(XMLCipher.UNWRAP_MODE, _kek);
+ cipher.init(XMLCipher.UNWRAP_MODE, kek);
EncryptedKey ek = cipher.loadEncryptedKey(element);
- key = (SecretKey) cipher.decryptKey(ek, _algorithm);
+ key = (SecretKey) cipher.decryptKey(ek, algorithm);
} catch (XMLEncryptionException e) {}
}
-
+
return key;
- }
+ }
}
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/RSAKeyValueResolver.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/RSAKeyValueResolver.java?rev=1070452&r1=1070451&r2=1070452&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/RSAKeyValueResolver.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/RSAKeyValueResolver.java Mon Feb 14 11:49:42 2011
@@ -1,4 +1,3 @@
-
/*
* Copyright 1999-2004 The Apache Software Foundation.
*
@@ -17,8 +16,6 @@
*/
package org.apache.xml.security.keys.keyresolver.implementations;
-
-
import java.security.PublicKey;
import java.security.cert.X509Certificate;
@@ -31,69 +28,64 @@ import org.apache.xml.security.utils.Con
import org.apache.xml.security.utils.XMLUtils;
import org.w3c.dom.Element;
-
-/**
- *
- * @author $Author$
- */
public class RSAKeyValueResolver extends KeyResolverSpi {
- /** {@link org.apache.commons.logging} logging facility */
- static org.apache.commons.logging.Log log =
- org.apache.commons.logging.LogFactory.getLog(
- RSAKeyValueResolver.class.getName());
-
- /** Field _rsaKeyElement */
-
-
- /** @inheritDoc */
- public PublicKey engineLookupAndResolvePublicKey(
- Element element, String BaseURI, StorageResolver storage) {
- if (log.isDebugEnabled())
- log.debug("Can I resolve " + element.getTagName());
- if (element == null) {
- return null;
- }
-
- boolean isKeyValue = XMLUtils.elementIsInSignatureSpace(element,
- Constants._TAG_KEYVALUE);
- Element rsaKeyElement=null;
- if (isKeyValue) {
- rsaKeyElement = XMLUtils.selectDsNode(element.getFirstChild(),
- Constants._TAG_RSAKEYVALUE, 0);
- } else if (XMLUtils.elementIsInSignatureSpace(element,
- Constants._TAG_RSAKEYVALUE)) {
- // this trick is needed to allow the RetrievalMethodResolver to eat a
- // ds:RSAKeyValue directly (without KeyValue)
- rsaKeyElement = element;
- }
-
-
- if (rsaKeyElement == null) {
- return null;
- }
-
- try {
- RSAKeyValue rsaKeyValue = new RSAKeyValue(rsaKeyElement,
- BaseURI);
-
- return rsaKeyValue.getPublicKey();
- } catch (XMLSecurityException ex) {
- log.debug("XMLSecurityException", ex);
- }
-
- return null;
- }
-
- /** @inheritDoc */
- public X509Certificate engineLookupResolveX509Certificate(
- Element element, String BaseURI, StorageResolver storage) {
- return null;
- }
-
- /** @inheritDoc */
- public javax.crypto.SecretKey engineLookupAndResolveSecretKey(
- Element element, String BaseURI, StorageResolver storage) {
- return null;
- }
+ /** {@link org.apache.commons.logging} logging facility */
+ private static org.apache.commons.logging.Log log =
+ org.apache.commons.logging.LogFactory.getLog(RSAKeyValueResolver.class.getName());
+
+
+ /** @inheritDoc */
+ public PublicKey engineLookupAndResolvePublicKey(
+ Element element, String BaseURI, StorageResolver storage
+ ) {
+ if (log.isDebugEnabled()) {
+ log.debug("Can I resolve " + element.getTagName());
+ }
+ if (element == null) {
+ return null;
+ }
+
+ boolean isKeyValue = XMLUtils.elementIsInSignatureSpace(element, Constants._TAG_KEYVALUE);
+ Element rsaKeyElement = null;
+ if (isKeyValue) {
+ rsaKeyElement =
+ XMLUtils.selectDsNode(element.getFirstChild(), Constants._TAG_RSAKEYVALUE, 0);
+ } else if (XMLUtils.elementIsInSignatureSpace(element, Constants._TAG_RSAKEYVALUE)) {
+ // this trick is needed to allow the RetrievalMethodResolver to eat a
+ // ds:RSAKeyValue directly (without KeyValue)
+ rsaKeyElement = element;
+ }
+
+
+ if (rsaKeyElement == null) {
+ return null;
+ }
+
+ try {
+ RSAKeyValue rsaKeyValue = new RSAKeyValue(rsaKeyElement, BaseURI);
+
+ return rsaKeyValue.getPublicKey();
+ } catch (XMLSecurityException ex) {
+ if (log.isDebugEnabled()) {
+ log.debug("XMLSecurityException", ex);
+ }
+ }
+
+ return null;
+ }
+
+ /** @inheritDoc */
+ public X509Certificate engineLookupResolveX509Certificate(
+ Element element, String BaseURI, StorageResolver storage
+ ) {
+ return null;
+ }
+
+ /** @inheritDoc */
+ public javax.crypto.SecretKey engineLookupAndResolveSecretKey(
+ Element element, String BaseURI, StorageResolver storage
+ ) {
+ return null;
+ }
}
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/RetrievalMethodResolver.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/RetrievalMethodResolver.java?rev=1070452&r1=1070451&r2=1070452&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/RetrievalMethodResolver.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/RetrievalMethodResolver.java Mon Feb 14 11:49:42 2011
@@ -65,9 +65,8 @@ import org.xml.sax.SAXException;
public class RetrievalMethodResolver extends KeyResolverSpi {
/** {@link org.apache.commons.logging} logging facility */
- static org.apache.commons.logging.Log log =
- org.apache.commons.logging.LogFactory.getLog(
- RetrievalMethodResolver.class.getName());
+ private static org.apache.commons.logging.Log log =
+ org.apache.commons.logging.LogFactory.getLog(RetrievalMethodResolver.class.getName());
/**
* Method engineResolvePublicKey
@@ -77,10 +76,9 @@ public class RetrievalMethodResolver ext
* @param storage
*/
public PublicKey engineLookupAndResolvePublicKey(
- Element element, String BaseURI, StorageResolver storage)
- {
- if (!XMLUtils.elementIsInSignatureSpace(element,
- Constants._TAG_RETRIEVALMETHOD)) {
+ Element element, String BaseURI, StorageResolver storage
+ ) {
+ if (!XMLUtils.elementIsInSignatureSpace(element, Constants._TAG_RETRIEVALMETHOD)) {
return null;
}
@@ -100,39 +98,29 @@ public class RetrievalMethodResolver ext
Element e = obtainReferenceElement(resource);
return resolveKey(e, BaseURI, storage);
} catch (XMLSecurityException ex) {
- log.debug("XMLSecurityException", ex);
+ if (log.isDebugEnabled()) {
+ log.debug("XMLSecurityException", ex);
+ }
} catch (CertificateException ex) {
- log.debug("CertificateException", ex);
+ if (log.isDebugEnabled()) {
+ log.debug("CertificateException", ex);
+ }
} catch (IOException ex) {
- log.debug("IOException", ex);
+ if (log.isDebugEnabled()) {
+ log.debug("IOException", ex);
+ }
} catch (ParserConfigurationException e) {
- log.debug("ParserConfigurationException", e);
+ if (log.isDebugEnabled()) {
+ log.debug("ParserConfigurationException", e);
+ }
} catch (SAXException e) {
- log.debug("SAXException", e);
+ if (log.isDebugEnabled()) {
+ log.debug("SAXException", e);
+ }
}
return null;
}
- static private Element obtainReferenceElement(XMLSignatureInput resource)
- throws CanonicalizationException, ParserConfigurationException,
- IOException, SAXException, KeyResolverException {
- Element e;
- if (resource.isElement()){
- e = (Element) resource.getSubNode();
- } else if (resource.isNodeSet()) {
- // Retrieved resource is a nodeSet
- e = getDocumentElement(resource.getNodeSet());
- } else {
- // Retrieved resource is an inputStream
- byte inputBytes[] = resource.getBytes();
- e = getDocFromBytes(inputBytes);
- // otherwise, we parse the resource, create an Element and delegate
- if (log.isDebugEnabled())
- log.debug("we have to parse " + inputBytes.length + " bytes");
- }
- return e;
- }
-
/**
* Method engineResolveX509Certificate
* @inheritDoc
@@ -142,8 +130,7 @@ public class RetrievalMethodResolver ext
*/
public X509Certificate engineLookupResolveX509Certificate(
Element element, String BaseURI, StorageResolver storage) {
- if (!XMLUtils.elementIsInSignatureSpace(element,
- Constants._TAG_RETRIEVALMETHOD)) {
+ if (!XMLUtils.elementIsInSignatureSpace(element, Constants._TAG_RETRIEVALMETHOD)) {
return null;
}
@@ -158,15 +145,25 @@ public class RetrievalMethodResolver ext
Element e = obtainReferenceElement(resource);
return resolveCertificate(e, BaseURI, storage);
} catch (XMLSecurityException ex) {
- log.debug("XMLSecurityException", ex);
+ if (log.isDebugEnabled()) {
+ log.debug("XMLSecurityException", ex);
+ }
} catch (CertificateException ex) {
- log.debug("CertificateException", ex);
+ if (log.isDebugEnabled()) {
+ log.debug("CertificateException", ex);
+ }
} catch (IOException ex) {
- log.debug("IOException", ex);
+ if (log.isDebugEnabled()) {
+ log.debug("IOException", ex);
+ }
} catch (ParserConfigurationException e) {
- log.debug("ParserConfigurationException", e);
+ if (log.isDebugEnabled()) {
+ log.debug("ParserConfigurationException", e);
+ }
} catch (SAXException e) {
- log.debug("SAXException", e);
+ if (log.isDebugEnabled()) {
+ log.debug("SAXException", e);
+ }
}
return null;
}
@@ -179,8 +176,9 @@ public class RetrievalMethodResolver ext
* @return
* @throws KeyResolverException
*/
- static private X509Certificate resolveCertificate(Element e,
- String BaseURI, StorageResolver storage) throws KeyResolverException {
+ private static X509Certificate resolveCertificate(
+ Element e, String BaseURI, StorageResolver storage
+ ) throws KeyResolverException {
if (log.isDebugEnabled()) {
log.debug("Now we have a {" + e.getNamespaceURI() + "}"
+ e.getLocalName() + " Element");
@@ -200,8 +198,9 @@ public class RetrievalMethodResolver ext
* @return
* @throws KeyResolverException
*/
- static private PublicKey resolveKey(Element e, String BaseURI,
- StorageResolver storage) throws KeyResolverException {
+ private static PublicKey resolveKey(
+ Element e, String BaseURI, StorageResolver storage
+ ) throws KeyResolverException {
if (log.isDebugEnabled()) {
log.debug("Now we have a {" + e.getNamespaceURI() + "}"
+ e.getLocalName() + " Element");
@@ -212,9 +211,30 @@ public class RetrievalMethodResolver ext
}
return null;
}
+
+ private static Element obtainReferenceElement(XMLSignatureInput resource)
+ throws CanonicalizationException, ParserConfigurationException,
+ IOException, SAXException, KeyResolverException {
+ Element e;
+ if (resource.isElement()){
+ e = (Element) resource.getSubNode();
+ } else if (resource.isNodeSet()) {
+ // Retrieved resource is a nodeSet
+ e = getDocumentElement(resource.getNodeSet());
+ } else {
+ // Retrieved resource is an inputStream
+ byte inputBytes[] = resource.getBytes();
+ e = getDocFromBytes(inputBytes);
+ // otherwise, we parse the resource, create an Element and delegate
+ if (log.isDebugEnabled()) {
+ log.debug("we have to parse " + inputBytes.length + " bytes");
+ }
+ }
+ return e;
+ }
- static private X509Certificate getRawCertificate(XMLSignatureInput resource)
- throws CanonicalizationException, IOException, CertificateException {
+ private static X509Certificate getRawCertificate(XMLSignatureInput resource)
+ throws CanonicalizationException, IOException, CertificateException {
byte inputBytes[] = resource.getBytes();
// if the resource stores a raw certificate, we have to handle it
CertificateFactory certFact =
@@ -229,8 +249,9 @@ public class RetrievalMethodResolver ext
* @return
* @throws XMLSecurityException
*/
- static private XMLSignatureInput resolveInput(RetrievalMethod rm,
- String BaseURI) throws XMLSecurityException {
+ private static XMLSignatureInput resolveInput(
+ RetrievalMethod rm, String BaseURI
+ ) throws XMLSecurityException {
Attr uri = rm.getURIAttr();
// Apply the transforms
Transforms transforms = rm.getTransforms();
@@ -238,7 +259,9 @@ public class RetrievalMethodResolver ext
if (resRes != null) {
XMLSignatureInput resource = resRes.resolve(uri, BaseURI);
if (transforms != null) {
- log.debug("We have Transforms");
+ if (log.isDebugEnabled()) {
+ log.debug("We have Transforms");
+ }
resource = transforms.performTransforms(resource);
}
return resource;
@@ -253,7 +276,7 @@ public class RetrievalMethodResolver ext
* @return the Document Element after parsing bytes
* @throws KeyResolverException if something goes wrong
*/
- static Element getDocFromBytes(byte[] bytes) throws KeyResolverException {
+ private static Element getDocFromBytes(byte[] bytes) throws KeyResolverException {
try {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
@@ -277,12 +300,12 @@ public class RetrievalMethodResolver ext
* @param storage
*/
public javax.crypto.SecretKey engineLookupAndResolveSecretKey(
- Element element, String BaseURI, StorageResolver storage)
- {
+ Element element, String BaseURI, StorageResolver storage
+ ) {
return null;
}
- static Element getDocumentElement(Set set) {
+ private static Element getDocumentElement(Set set) {
Iterator it = set.iterator();
Element e = null;
while (it.hasNext()) {
@@ -292,7 +315,7 @@ public class RetrievalMethodResolver ext
break;
}
}
- List parents = new ArrayList(10);
+ List<Node> parents = new ArrayList<Node>();
// Obtain all the parents of the elemnt
while (e != null) {
@@ -304,7 +327,7 @@ public class RetrievalMethodResolver ext
e = (Element) n;
}
// Visit them in reverse order.
- ListIterator it2 = parents.listIterator(parents.size()-1);
+ ListIterator<Node> it2 = parents.listIterator(parents.size()-1);
Element ele = null;
while (it2.hasPrevious()) {
ele = (Element) it2.previous();
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/X509CertificateResolver.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/X509CertificateResolver.java?rev=1070452&r1=1070451&r2=1070452&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/X509CertificateResolver.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/X509CertificateResolver.java Mon Feb 14 11:49:42 2011
@@ -1,4 +1,3 @@
-
/*
* Copyright 1999-2004 The Apache Software Foundation.
*
@@ -17,12 +16,9 @@
*/
package org.apache.xml.security.keys.keyresolver.implementations;
-
-
import java.security.PublicKey;
import java.security.cert.X509Certificate;
-
import org.apache.xml.security.exceptions.XMLSecurityException;
import org.apache.xml.security.keys.content.x509.XMLX509Certificate;
import org.apache.xml.security.keys.keyresolver.KeyResolverException;
@@ -32,7 +28,6 @@ import org.apache.xml.security.utils.Con
import org.apache.xml.security.utils.XMLUtils;
import org.w3c.dom.Element;
-
/**
* Resolves Certificates which are directly contained inside a
* <CODE>ds:X509Certificate</CODE> Element.
@@ -41,87 +36,84 @@ import org.w3c.dom.Element;
*/
public class X509CertificateResolver extends KeyResolverSpi {
- /** {@link org.apache.commons.logging} logging facility */
- static org.apache.commons.logging.Log log =
+ /** {@link org.apache.commons.logging} logging facility */
+ private static org.apache.commons.logging.Log log =
org.apache.commons.logging.LogFactory.getLog(X509CertificateResolver.class.getName());
+ /**
+ * Method engineResolvePublicKey
+ * @inheritDoc
+ * @param element
+ * @param BaseURI
+ * @param storage
+ *
+ * @throws KeyResolverException
+ */
+ public PublicKey engineLookupAndResolvePublicKey(
+ Element element, String BaseURI, StorageResolver storage
+ ) throws KeyResolverException {
+
+ X509Certificate cert =
+ this.engineLookupResolveX509Certificate(element, BaseURI, storage);
+
+ if (cert != null) {
+ return cert.getPublicKey();
+ }
+
+ return null;
+ }
+
+ /**
+ * Method engineResolveX509Certificate
+ * @inheritDoc
+ * @param element
+ * @param BaseURI
+ * @param storage
+ *
+ * @throws KeyResolverException
+ */
+ public X509Certificate engineLookupResolveX509Certificate(
+ Element element, String BaseURI, StorageResolver storage
+ ) throws KeyResolverException {
+
+ try {
+ Element[] els =
+ XMLUtils.selectDsNodes(element.getFirstChild(), Constants._TAG_X509CERTIFICATE);
+ if ((els == null) || (els.length == 0)) {
+ Element el =
+ XMLUtils.selectDsNode(element.getFirstChild(), Constants._TAG_X509DATA, 0);
+ if (el != null) {
+ return engineLookupResolveX509Certificate(el, BaseURI, storage);
+ }
+ return null;
+ }
-
- /**
- * Method engineResolvePublicKey
- * @inheritDoc
- * @param element
- * @param BaseURI
- * @param storage
- *
- * @throws KeyResolverException
- */
- public PublicKey engineLookupAndResolvePublicKey(
- Element element, String BaseURI, StorageResolver storage)
- throws KeyResolverException {
-
- X509Certificate cert = this.engineLookupResolveX509Certificate(element,
- BaseURI, storage);
-
- if (cert != null) {
- return cert.getPublicKey();
- }
-
- return null;
- }
-
- /**
- * Method engineResolveX509Certificate
- * @inheritDoc
- * @param element
- * @param BaseURI
- * @param storage
- *
- * @throws KeyResolverException
- */
- public X509Certificate engineLookupResolveX509Certificate(
- Element element, String BaseURI, StorageResolver storage)
- throws KeyResolverException {
-
- try {
- Element[] els=XMLUtils.selectDsNodes(element.getFirstChild(),
- Constants._TAG_X509CERTIFICATE);
- if ((els == null) || (els.length == 0)) {
- Element el=XMLUtils.selectDsNode(element.getFirstChild(),
- Constants._TAG_X509DATA,0);
- if (el!=null) {
- return engineLookupResolveX509Certificate(el, BaseURI, storage);
- }
- return null;
- }
-
- // populate Object array
- for (int i = 0; i < els.length; i++) {
- XMLX509Certificate xmlCert=new XMLX509Certificate(els[i], BaseURI);
- X509Certificate cert = xmlCert.getX509Certificate();
- if (cert!=null) {
- return cert;
+ // populate Object array
+ for (int i = 0; i < els.length; i++) {
+ XMLX509Certificate xmlCert = new XMLX509Certificate(els[i], BaseURI);
+ X509Certificate cert = xmlCert.getX509Certificate();
+ if (cert != null) {
+ return cert;
+ }
}
- }
- return null;
- } catch (XMLSecurityException ex) {
- log.debug("XMLSecurityException", ex);
-
- throw new KeyResolverException("generic.EmptyMessage", ex);
- }
- }
-
- /**
- * Method engineResolveSecretKey
- * @inheritDoc
- * @param element
- * @param BaseURI
- * @param storage
- *
- */
- public javax.crypto.SecretKey engineLookupAndResolveSecretKey(
- Element element, String BaseURI, StorageResolver storage)
- {
- return null;
- }
+ return null;
+ } catch (XMLSecurityException ex) {
+ log.debug("XMLSecurityException", ex);
+
+ throw new KeyResolverException("generic.EmptyMessage", ex);
+ }
+ }
+
+ /**
+ * Method engineResolveSecretKey
+ * @inheritDoc
+ * @param element
+ * @param BaseURI
+ * @param storage
+ */
+ public javax.crypto.SecretKey engineLookupAndResolveSecretKey(
+ Element element, String BaseURI, StorageResolver storage
+ ) {
+ return null;
+ }
}
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/X509IssuerSerialResolver.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/X509IssuerSerialResolver.java?rev=1070452&r1=1070451&r2=1070452&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/X509IssuerSerialResolver.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/X509IssuerSerialResolver.java Mon Feb 14 11:49:42 2011
@@ -1,4 +1,3 @@
-
/*
* Copyright 1999-2010 The Apache Software Foundation.
*
@@ -17,9 +16,8 @@
*/
package org.apache.xml.security.keys.keyresolver.implementations;
-
-
import java.security.PublicKey;
+import java.security.cert.Certificate;
import java.security.cert.X509Certificate;
import java.util.Iterator;
@@ -33,115 +31,121 @@ import org.apache.xml.security.signature
import org.apache.xml.security.utils.Constants;
import org.w3c.dom.Element;
-
-/**
- *
- * @author $Author$
- */
public class X509IssuerSerialResolver extends KeyResolverSpi {
- /** {@link org.apache.commons.logging} logging facility */
- static org.apache.commons.logging.Log log =
- org.apache.commons.logging.LogFactory.getLog(
- X509IssuerSerialResolver.class.getName());
-
-
- /** @inheritDoc */
- public PublicKey engineLookupAndResolvePublicKey(
- Element element, String BaseURI, StorageResolver storage)
- throws KeyResolverException {
-
- X509Certificate cert = this.engineLookupResolveX509Certificate(element,
- BaseURI, storage);
-
- if (cert != null) {
- return cert.getPublicKey();
- }
-
- return null;
- }
-
- /** @inheritDoc */
- public X509Certificate engineLookupResolveX509Certificate(
- Element element, String BaseURI, StorageResolver storage)
- throws KeyResolverException {
- if (log.isDebugEnabled())
- log.debug("Can I resolve " + element.getTagName() + "?");
-
- X509Data x509data = null;
- try {
- x509data = new X509Data(element, BaseURI);
- } catch (XMLSignatureException ex) {
- log.debug("I can't");
- return null;
- } catch (XMLSecurityException ex) {
- log.debug("I can't");
- return null;
- }
-
- if (x509data == null) {
- log.debug("I can't");
- return null;
- }
-
- if (!x509data.containsIssuerSerial()) {
- return null;
- }
- try {
- if (storage == null) {
- Object exArgs[] = { Constants._TAG_X509ISSUERSERIAL };
- KeyResolverException ex =
- new KeyResolverException("KeyResolver.needStorageResolver",
- exArgs);
-
- log.info("", ex);
- throw ex;
- }
-
- int noOfISS = x509data.lengthIssuerSerial();
-
- Iterator storageIterator = storage.getIterator();
- while (storageIterator.hasNext()) {
- X509Certificate cert = (X509Certificate)storageIterator.next();
- XMLX509IssuerSerial certSerial = new XMLX509IssuerSerial(element.getOwnerDocument(), cert);
+ /** {@link org.apache.commons.logging} logging facility */
+ private static org.apache.commons.logging.Log log =
+ org.apache.commons.logging.LogFactory.getLog(X509IssuerSerialResolver.class.getName());
+
+
+ /** @inheritDoc */
+ public PublicKey engineLookupAndResolvePublicKey(
+ Element element, String BaseURI, StorageResolver storage
+ ) throws KeyResolverException {
+
+ X509Certificate cert =
+ this.engineLookupResolveX509Certificate(element, BaseURI, storage);
+
+ if (cert != null) {
+ return cert.getPublicKey();
+ }
+
+ return null;
+ }
+
+ /** @inheritDoc */
+ public X509Certificate engineLookupResolveX509Certificate(
+ Element element, String BaseURI, StorageResolver storage
+ ) throws KeyResolverException {
+ if (log.isDebugEnabled()) {
+ log.debug("Can I resolve " + element.getTagName() + "?");
+ }
+
+ X509Data x509data = null;
+ try {
+ x509data = new X509Data(element, BaseURI);
+ } catch (XMLSignatureException ex) {
+ if (log.isDebugEnabled()) {
+ log.debug("I can't");
+ }
+ return null;
+ } catch (XMLSecurityException ex) {
+ if (log.isDebugEnabled()) {
+ log.debug("I can't");
+ }
+ return null;
+ }
+
+ if (x509data == null) {
+ if (log.isDebugEnabled()) {
+ log.debug("I can't");
+ }
+ return null;
+ }
+
+ if (!x509data.containsIssuerSerial()) {
+ return null;
+ }
+ try {
+ if (storage == null) {
+ Object exArgs[] = { Constants._TAG_X509ISSUERSERIAL };
+ KeyResolverException ex =
+ new KeyResolverException("KeyResolver.needStorageResolver", exArgs);
+
+ if (log.isDebugEnabled()) {
+ log.debug("", ex);
+ }
+ throw ex;
+ }
+
+ int noOfISS = x509data.lengthIssuerSerial();
+
+ Iterator<Certificate> storageIterator = storage.getIterator();
+ while (storageIterator.hasNext()) {
+ X509Certificate cert = (X509Certificate)storageIterator.next();
+ XMLX509IssuerSerial certSerial = new XMLX509IssuerSerial(element.getOwnerDocument(), cert);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Found Certificate Issuer: " + certSerial.getIssuerName());
+ log.debug("Found Certificate Serial: " + certSerial.getSerialNumber().toString());
+ }
+
+ for (int i = 0; i < noOfISS; i++) {
+ XMLX509IssuerSerial xmliss = x509data.itemIssuerSerial(i);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Found Element Issuer: "
+ + xmliss.getIssuerName());
+ log.debug("Found Element Serial: "
+ + xmliss.getSerialNumber().toString());
+ }
+
+ if (certSerial.equals(xmliss)) {
+ if (log.isDebugEnabled()) {
+ log.debug("match !!! ");
+ }
+ return cert;
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("no match...");
+ }
+ }
+ }
+ return null;
+ } catch (XMLSecurityException ex) {
if (log.isDebugEnabled()) {
- log.debug("Found Certificate Issuer: "
- + certSerial.getIssuerName());
- log.debug("Found Certificate Serial: "
- + certSerial.getSerialNumber().toString());
- }
-
- for (int i=0; i<noOfISS; i++) {
- XMLX509IssuerSerial xmliss = x509data.itemIssuerSerial(i);
-
- if (log.isDebugEnabled()) {
- log.debug("Found Element Issuer: "
- + xmliss.getIssuerName());
- log.debug("Found Element Serial: "
- + xmliss.getSerialNumber().toString());
- }
-
- if (certSerial.equals(xmliss)) {
- log.debug("match !!! ");
-
- return cert;
- }
- log.debug("no match...");
- }
- }
-
- return null;
- } catch (XMLSecurityException ex) {
- log.debug("XMLSecurityException", ex);
-
- throw new KeyResolverException("generic.EmptyMessage", ex);
- }
- }
-
- /** @inheritDoc */
- public javax.crypto.SecretKey engineLookupAndResolveSecretKey(
- Element element, String BaseURI, StorageResolver storage) {
- return null;
- }
+ log.debug("XMLSecurityException", ex);
+ }
+
+ throw new KeyResolverException("generic.EmptyMessage", ex);
+ }
+ }
+
+ /** @inheritDoc */
+ public javax.crypto.SecretKey engineLookupAndResolveSecretKey(
+ Element element, String BaseURI, StorageResolver storage
+ ) {
+ return null;
+ }
}
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/X509SKIResolver.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/X509SKIResolver.java?rev=1070452&r1=1070451&r2=1070452&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/X509SKIResolver.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/X509SKIResolver.java Mon Feb 14 11:49:42 2011
@@ -1,4 +1,3 @@
-
/*
* Copyright 1999-2010 The Apache Software Foundation.
*
@@ -17,9 +16,8 @@
*/
package org.apache.xml.security.keys.keyresolver.implementations;
-
-
import java.security.PublicKey;
+import java.security.cert.Certificate;
import java.security.cert.X509Certificate;
import java.util.Iterator;
@@ -33,125 +31,124 @@ import org.apache.xml.security.utils.Con
import org.apache.xml.security.utils.XMLUtils;
import org.w3c.dom.Element;
-
-/**
- *
- *
- * @author $Author$
- */
public class X509SKIResolver extends KeyResolverSpi {
- /** {@link org.apache.commons.logging} logging facility */
- static org.apache.commons.logging.Log log =
+ /** {@link org.apache.commons.logging} logging facility */
+ private static org.apache.commons.logging.Log log =
org.apache.commons.logging.LogFactory.getLog(X509SKIResolver.class.getName());
-
- /**
- * Method engineResolvePublicKey
- *
- * @param element
- * @param BaseURI
- * @param storage
- * @return null if no {@link PublicKey} could be obtained
- * @throws KeyResolverException
- */
- public PublicKey engineLookupAndResolvePublicKey(
- Element element, String BaseURI, StorageResolver storage)
- throws KeyResolverException {
-
- X509Certificate cert = this.engineLookupResolveX509Certificate(element,
- BaseURI, storage);
-
- if (cert != null) {
- return cert.getPublicKey();
- }
-
- return null;
- }
-
- /**
- * Method engineResolveX509Certificate
- * @inheritDoc
- * @param element
- * @param BaseURI
- * @param storage
- *
- * @throws KeyResolverException
- */
- public X509Certificate engineLookupResolveX509Certificate(
- Element element, String BaseURI, StorageResolver storage)
- throws KeyResolverException {
- if (log.isDebugEnabled()) {
- log.debug("Can I resolve " + element.getTagName() + "?");
- }
- if (!XMLUtils.elementIsInSignatureSpace(element,
- Constants._TAG_X509DATA)) {
- log.debug("I can't");
- return null;
- }
- /** Field _x509childObject[] */
- XMLX509SKI x509childObject[] = null;
-
- Element x509childNodes[] = null;
- x509childNodes = XMLUtils.selectDsNodes(element.getFirstChild(),
- Constants._TAG_X509SKI);
-
- if (!((x509childNodes != null)
- && (x509childNodes.length > 0))) {
- log.debug("I can't");
- return null;
- }
- try {
- if (storage == null) {
- Object exArgs[] = { Constants._TAG_X509SKI };
- KeyResolverException ex =
- new KeyResolverException("KeyResolver.needStorageResolver",
- exArgs);
-
- log.info("", ex);
-
- throw ex;
- }
-
- x509childObject = new XMLX509SKI[x509childNodes.length];
-
- for (int i = 0; i < x509childNodes.length; i++) {
- x509childObject[i] =
- new XMLX509SKI(x509childNodes[i], BaseURI);
- }
-
- Iterator storageIterator = storage.getIterator();
- while (storageIterator.hasNext()) {
- X509Certificate cert = (X509Certificate)storageIterator.next();
- XMLX509SKI certSKI = new XMLX509SKI(element.getOwnerDocument(), cert);
-
- for (int i = 0; i < x509childObject.length; i++) {
- if (certSKI.equals(x509childObject[i])) {
- log.debug("Return PublicKey from "
- + cert.getSubjectDN().getName());
- return cert;
- }
+ /**
+ * Method engineResolvePublicKey
+ *
+ * @param element
+ * @param BaseURI
+ * @param storage
+ * @return null if no {@link PublicKey} could be obtained
+ * @throws KeyResolverException
+ */
+ public PublicKey engineLookupAndResolvePublicKey(
+ Element element, String BaseURI, StorageResolver storage
+ ) throws KeyResolverException {
+
+ X509Certificate cert =
+ this.engineLookupResolveX509Certificate(element, BaseURI, storage);
+
+ if (cert != null) {
+ return cert.getPublicKey();
+ }
+
+ return null;
+ }
+
+ /**
+ * Method engineResolveX509Certificate
+ * @inheritDoc
+ * @param element
+ * @param BaseURI
+ * @param storage
+ *
+ * @throws KeyResolverException
+ */
+ public X509Certificate engineLookupResolveX509Certificate(
+ Element element, String BaseURI, StorageResolver storage
+ ) throws KeyResolverException {
+ if (log.isDebugEnabled()) {
+ log.debug("Can I resolve " + element.getTagName() + "?");
+ }
+ if (!XMLUtils.elementIsInSignatureSpace(element, Constants._TAG_X509DATA)) {
+ if (log.isDebugEnabled()) {
+ log.debug("I can't");
+ }
+ return null;
+ }
+ /** Field _x509childObject[] */
+ XMLX509SKI x509childObject[] = null;
+
+ Element x509childNodes[] = null;
+ x509childNodes = XMLUtils.selectDsNodes(element.getFirstChild(), Constants._TAG_X509SKI);
+
+ if (!((x509childNodes != null)
+ && (x509childNodes.length > 0))) {
+ if (log.isDebugEnabled()) {
+ log.debug("I can't");
+ }
+ return null;
+ }
+ try {
+ if (storage == null) {
+ Object exArgs[] = { Constants._TAG_X509SKI };
+ KeyResolverException ex =
+ new KeyResolverException("KeyResolver.needStorageResolver", exArgs);
+
+ if (log.isDebugEnabled()) {
+ log.debug("", ex);
+ }
+
+ throw ex;
+ }
+
+ x509childObject = new XMLX509SKI[x509childNodes.length];
+
+ for (int i = 0; i < x509childNodes.length; i++) {
+ x509childObject[i] =
+ new XMLX509SKI(x509childNodes[i], BaseURI);
+ }
+
+ Iterator<Certificate> storageIterator = storage.getIterator();
+ while (storageIterator.hasNext()) {
+ X509Certificate cert = (X509Certificate)storageIterator.next();
+ XMLX509SKI certSKI = new XMLX509SKI(element.getOwnerDocument(), cert);
+
+ for (int i = 0; i < x509childObject.length; i++) {
+ if (certSKI.equals(x509childObject[i])) {
+ if (log.isDebugEnabled()) {
+ log.debug("Return PublicKey from "
+ + cert.getSubjectDN().getName());
+ }
+
+ return cert;
+ }
+ }
}
- }
- } catch (XMLSecurityException ex) {
- throw new KeyResolverException("empty", ex);
- }
-
- return null;
- }
-
- /**
- * Method engineResolveSecretKey
- * @inheritDoc
- * @param element
- * @param BaseURI
- * @param storage
- *
- */
- public javax.crypto.SecretKey engineLookupAndResolveSecretKey(
- Element element, String BaseURI, StorageResolver storage)
- {
- return null;
- }
+ } catch (XMLSecurityException ex) {
+ throw new KeyResolverException("empty", ex);
+ }
+
+ return null;
+ }
+
+ /**
+ * Method engineResolveSecretKey
+ * @inheritDoc
+ * @param element
+ * @param BaseURI
+ * @param storage
+ *
+ */
+ public javax.crypto.SecretKey engineLookupAndResolveSecretKey(
+ Element element, String BaseURI, StorageResolver storage
+ ) {
+ return null;
+ }
}
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/X509SubjectNameResolver.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/X509SubjectNameResolver.java?rev=1070452&r1=1070451&r2=1070452&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/X509SubjectNameResolver.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/keyresolver/implementations/X509SubjectNameResolver.java Mon Feb 14 11:49:42 2011
@@ -16,9 +16,8 @@
*/
package org.apache.xml.security.keys.keyresolver.implementations;
-
-
import java.security.PublicKey;
+import java.security.cert.Certificate;
import java.security.cert.X509Certificate;
import java.util.Iterator;
@@ -32,134 +31,140 @@ import org.apache.xml.security.utils.Con
import org.apache.xml.security.utils.XMLUtils;
import org.w3c.dom.Element;
-
-/**
- *
- * @author $Author$
- */
public class X509SubjectNameResolver extends KeyResolverSpi {
- /** {@link org.apache.commons.logging} logging facility */
- static org.apache.commons.logging.Log log =
- org.apache.commons.logging.LogFactory.getLog(
- X509SubjectNameResolver.class.getName());
-
-
- /**
- * Method engineResolvePublicKey
- *
- * @param element
- * @param BaseURI
- * @param storage
- * @return null if no {@link PublicKey} could be obtained
- * @throws KeyResolverException
- */
- public PublicKey engineLookupAndResolvePublicKey(
- Element element, String BaseURI, StorageResolver storage)
- throws KeyResolverException {
-
- X509Certificate cert = this.engineLookupResolveX509Certificate(element,
- BaseURI, storage);
-
- if (cert != null) {
- return cert.getPublicKey();
- }
-
- return null;
- }
-
- /**
- * Method engineResolveX509Certificate
- * @inheritDoc
- * @param element
- * @param BaseURI
- * @param storage
- *
- * @throws KeyResolverException
- */
- public X509Certificate engineLookupResolveX509Certificate(
- Element element, String BaseURI, StorageResolver storage)
- throws KeyResolverException {
- if (log.isDebugEnabled())
- log.debug("Can I resolve " + element.getTagName() + "?");
- Element[] x509childNodes = null;
- XMLX509SubjectName x509childObject[] = null;
-
- if (!XMLUtils.elementIsInSignatureSpace(element,
- Constants._TAG_X509DATA) ) {
- log.debug("I can't");
- return null;
- }
- x509childNodes = XMLUtils.selectDsNodes(element.getFirstChild(),
- Constants._TAG_X509SUBJECTNAME);
+ /** {@link org.apache.commons.logging} logging facility */
+ private static org.apache.commons.logging.Log log =
+ org.apache.commons.logging.LogFactory.getLog(X509SubjectNameResolver.class.getName());
+
+
+ /**
+ * Method engineResolvePublicKey
+ *
+ * @param element
+ * @param BaseURI
+ * @param storage
+ * @return null if no {@link PublicKey} could be obtained
+ * @throws KeyResolverException
+ */
+ public PublicKey engineLookupAndResolvePublicKey(
+ Element element, String BaseURI, StorageResolver storage
+ ) throws KeyResolverException {
+
+ X509Certificate cert =
+ this.engineLookupResolveX509Certificate(element, BaseURI, storage);
+
+ if (cert != null) {
+ return cert.getPublicKey();
+ }
+
+ return null;
+ }
+
+ /**
+ * Method engineResolveX509Certificate
+ * @inheritDoc
+ * @param element
+ * @param BaseURI
+ * @param storage
+ *
+ * @throws KeyResolverException
+ */
+ public X509Certificate engineLookupResolveX509Certificate(
+ Element element, String BaseURI, StorageResolver storage
+ ) throws KeyResolverException {
+ if (log.isDebugEnabled()) {
+ log.debug("Can I resolve " + element.getTagName() + "?");
+ }
+ Element[] x509childNodes = null;
+ XMLX509SubjectName x509childObject[] = null;
+
+ if (!XMLUtils.elementIsInSignatureSpace(element,
+ Constants._TAG_X509DATA) ) {
+ log.debug("I can't");
+ return null;
+ }
+ x509childNodes =
+ XMLUtils.selectDsNodes(element.getFirstChild(), Constants._TAG_X509SUBJECTNAME);
if (!((x509childNodes != null)
- && (x509childNodes.length > 0))) {
- log.debug("I can't");
- return null;
+ && (x509childNodes.length > 0))) {
+ if (log.isDebugEnabled()) {
+ log.debug("I can't");
+ }
+ return null;
+ }
+
+ try {
+ if (storage == null) {
+ Object exArgs[] = { Constants._TAG_X509SUBJECTNAME };
+ KeyResolverException ex =
+ new KeyResolverException("KeyResolver.needStorageResolver", exArgs);
+
+ if (log.isDebugEnabled()) {
+ log.debug("", ex);
+ }
+
+ throw ex;
}
-
- try {
- if (storage == null) {
- Object exArgs[] = { Constants._TAG_X509SUBJECTNAME };
- KeyResolverException ex =
- new KeyResolverException("KeyResolver.needStorageResolver",
- exArgs);
-
- log.info("", ex);
-
- throw ex;
- }
-
- x509childObject =
- new XMLX509SubjectName[x509childNodes.length];
-
- for (int i = 0; i < x509childNodes.length; i++) {
- x509childObject[i] =
- new XMLX509SubjectName(x509childNodes[i],
- BaseURI);
- }
-
- Iterator storageIterator = storage.getIterator();
- while (storageIterator.hasNext()) {
- X509Certificate cert = (X509Certificate)storageIterator.next();
- XMLX509SubjectName certSN =
- new XMLX509SubjectName(element.getOwnerDocument(), cert);
-
- log.debug("Found Certificate SN: " + certSN.getSubjectName());
-
- for (int i = 0; i < x509childObject.length; i++) {
- log.debug("Found Element SN: "
- + x509childObject[i].getSubjectName());
-
- if (certSN.equals(x509childObject[i])) {
- log.debug("match !!! ");
-
- return cert;
- }
- log.debug("no match...");
+
+ x509childObject = new XMLX509SubjectName[x509childNodes.length];
+
+ for (int i = 0; i < x509childNodes.length; i++) {
+ x509childObject[i] =
+ new XMLX509SubjectName(x509childNodes[i], BaseURI);
+ }
+
+ Iterator<Certificate> storageIterator = storage.getIterator();
+ while (storageIterator.hasNext()) {
+ X509Certificate cert = (X509Certificate)storageIterator.next();
+ XMLX509SubjectName certSN =
+ new XMLX509SubjectName(element.getOwnerDocument(), cert);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Found Certificate SN: " + certSN.getSubjectName());
+ }
+
+ for (int i = 0; i < x509childObject.length; i++) {
+ if (log.isDebugEnabled()) {
+ log.debug("Found Element SN: "
+ + x509childObject[i].getSubjectName());
+ }
+
+ if (certSN.equals(x509childObject[i])) {
+ if (log.isDebugEnabled()) {
+ log.debug("match !!! ");
+ }
+
+ return cert;
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("no match...");
+ }
+ }
+ }
+
+ return null;
+ } catch (XMLSecurityException ex) {
+ if (log.isDebugEnabled()) {
+ log.debug("XMLSecurityException", ex);
}
- }
- return null;
- } catch (XMLSecurityException ex) {
- log.debug("XMLSecurityException", ex);
-
- throw new KeyResolverException("generic.EmptyMessage", ex);
- }
- }
-
- /**
- * Method engineResolveSecretKey
- * @inheritDoc
- * @param element
- * @param BaseURI
- * @param storage
- *
- */
- public javax.crypto.SecretKey engineLookupAndResolveSecretKey(
- Element element, String BaseURI, StorageResolver storage)
- {
- return null;
- }
+ throw new KeyResolverException("generic.EmptyMessage", ex);
+ }
+ }
+
+ /**
+ * Method engineResolveSecretKey
+ * @inheritDoc
+ * @param element
+ * @param BaseURI
+ * @param storage
+ *
+ */
+ public javax.crypto.SecretKey engineLookupAndResolveSecretKey(
+ Element element, String BaseURI, StorageResolver storage
+ ) {
+ return null;
+ }
}