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/10 12:37:05 UTC
svn commit: r1069340 [1/2] - in
/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security:
./ keys/ keys/content/ keys/content/keyvalues/ keys/content/x509/
Author: coheigea
Date: Thu Feb 10 11:37:05 2011
New Revision: 1069340
URL: http://svn.apache.org/viewvc?rev=1069340&view=rev
Log:
[SANTUARIO-259] - Refactoring of KeyInfo stuff.
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/content/KeyInfoContent.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/content/KeyName.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/content/KeyValue.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/content/MgmtData.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/content/PGPData.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/content/RetrievalMethod.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/content/SPKIData.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/content/X509Data.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/content/keyvalues/DSAKeyValue.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/content/keyvalues/KeyValueContent.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/content/keyvalues/RSAKeyValue.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/content/x509/XMLX509CRL.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=1069340&r1=1069339&r2=1069340&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 Thu Feb 10 11:37:05 2011
@@ -120,18 +120,6 @@ public class Init {
long XX_parsing_end = System.currentTimeMillis();
long XX_configure_i18n_start = 0;
- {
- XX_configure_reg_keyInfo_start = System.currentTimeMillis();
- try {
- KeyInfo.init();
- } catch (Exception e) {
- e.printStackTrace();
-
- throw e;
- }
- XX_configure_reg_keyInfo_end = System.currentTimeMillis();
- }
-
long XX_configure_reg_transforms_start=0;
long XX_configure_reg_jcemapper_start=0;
long XX_configure_reg_sigalgos_start=0;
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=1069340&r1=1069339&r2=1069340&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 Thu Feb 10 11:37:05 2011
@@ -16,13 +16,10 @@
*/
package org.apache.xml.security.keys;
-
-
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.Iterator;
import java.util.List;
@@ -56,7 +53,6 @@ import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-
/**
* This class stand for KeyInfo Element that may contain keys, names,
* certificates and other public key management information,
@@ -87,1101 +83,1104 @@ import org.w3c.dom.NodeList;
* The <CODE>containsXXX()</CODE> methods return <I>whether</I> the KeyInfo
* contains the corresponding type.
*
- * @author $Author$
*/
public class KeyInfo extends SignatureElementProxy {
- /** {@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(KeyInfo.class.getName());
-
- List x509Datas=null;
- List encryptedKeys=null;
-
+
// We need at least one StorageResolver otherwise
// the KeyResolvers would not be called.
// The default StorageResolver is null.
+
+ private List<X509Data> x509Datas = null;
+ private List<EncryptedKey> encryptedKeys = null;
- static final List nullList;
+ private static final List<StorageResolver> nullList;
static {
- List list = new ArrayList();
+ List<StorageResolver> list = new ArrayList<StorageResolver>(1);
list.add(null);
- nullList = Collections.unmodifiableList(list);
+ nullList = java.util.Collections.unmodifiableList(list);
+ }
+
+ /** Field storageResolvers */
+ private List<StorageResolver> storageResolvers = nullList;
+
+ /**
+ * Stores the individual (per-KeyInfo) {@link KeyResolver}s
+ */
+ private List internalKeyResolvers = null;
+
+ /**
+ * Constructor KeyInfo
+ * @param doc
+ */
+ public KeyInfo(Document doc) {
+ super(doc);
+
+ XMLUtils.addReturnToElement(this.constructionElement);
+ }
+
+ /**
+ * Constructor KeyInfo
+ *
+ * @param element
+ * @param BaseURI
+ * @throws XMLSecurityException
+ */
+ public KeyInfo(Element element, String BaseURI) throws XMLSecurityException {
+ super(element, BaseURI);
+ }
+
+ /**
+ * Sets the <code>Id</code> attribute
+ *
+ * @param Id ID
+ */
+ public void setId(String Id) {
+ if (Id != null) {
+ this.constructionElement.setAttributeNS(null, Constants._ATT_ID, Id);
+ IdResolver.registerElementById(this.constructionElement, Id);
+ }
+ }
+
+ /**
+ * Returns the <code>Id</code> attribute
+ *
+ * @return the <code>Id</code> attribute
+ */
+ public String getId() {
+ return this.constructionElement.getAttributeNS(null, Constants._ATT_ID);
+ }
+
+ /**
+ * Method addKeyName
+ *
+ * @param keynameString
+ */
+ public void addKeyName(String keynameString) {
+ this.add(new KeyName(this.doc, keynameString));
+ }
+
+ /**
+ * Method add
+ *
+ * @param keyname
+ */
+ public void add(KeyName keyname) {
+ this.constructionElement.appendChild(keyname.getElement());
+ XMLUtils.addReturnToElement(this.constructionElement);
+ }
+
+ /**
+ * Method addKeyValue
+ *
+ * @param pk
+ */
+ public void addKeyValue(PublicKey pk) {
+ this.add(new KeyValue(this.doc, pk));
+ }
+
+ /**
+ * Method addKeyValue
+ *
+ * @param unknownKeyValueElement
+ */
+ public void addKeyValue(Element unknownKeyValueElement) {
+ this.add(new KeyValue(this.doc, unknownKeyValueElement));
+ }
+
+ /**
+ * Method add
+ *
+ * @param dsakeyvalue
+ */
+ public void add(DSAKeyValue dsakeyvalue) {
+ this.add(new KeyValue(this.doc, dsakeyvalue));
+ }
+
+ /**
+ * Method add
+ *
+ * @param rsakeyvalue
+ */
+ public void add(RSAKeyValue rsakeyvalue) {
+ this.add(new KeyValue(this.doc, rsakeyvalue));
+ }
+
+ /**
+ * Method add
+ *
+ * @param pk
+ */
+ public void add(PublicKey pk) {
+ this.add(new KeyValue(this.doc, pk));
+ }
+
+ /**
+ * Method add
+ *
+ * @param keyvalue
+ */
+ public void add(KeyValue keyvalue) {
+ this.constructionElement.appendChild(keyvalue.getElement());
+ XMLUtils.addReturnToElement(this.constructionElement);
+ }
+
+ /**
+ * Method addMgmtData
+ *
+ * @param mgmtdata
+ */
+ public void addMgmtData(String mgmtdata) {
+ this.add(new MgmtData(this.doc, mgmtdata));
+ }
+
+ /**
+ * Method add
+ *
+ * @param mgmtdata
+ */
+ public void add(MgmtData mgmtdata) {
+ this.constructionElement.appendChild(mgmtdata.getElement());
+ XMLUtils.addReturnToElement(this.constructionElement);
+ }
+
+ /**
+ * Method addPGPData
+ *
+ * @param pgpdata
+ */
+ public void add(PGPData pgpdata) {
+ this.constructionElement.appendChild(pgpdata.getElement());
+ XMLUtils.addReturnToElement(this.constructionElement);
+ }
+
+ /**
+ * Method addRetrievalMethod
+ *
+ * @param URI
+ * @param transforms
+ * @param Type
+ */
+ public void addRetrievalMethod(String URI, Transforms transforms, String Type) {
+ this.add(new RetrievalMethod(this.doc, URI, transforms, Type));
+ }
+
+ /**
+ * Method add
+ *
+ * @param retrievalmethod
+ */
+ public void add(RetrievalMethod retrievalmethod) {
+ this.constructionElement.appendChild(retrievalmethod.getElement());
+ XMLUtils.addReturnToElement(this.constructionElement);
+ }
+
+ /**
+ * Method add
+ *
+ * @param spkidata
+ */
+ public void add(SPKIData spkidata) {
+ this.constructionElement.appendChild(spkidata.getElement());
+ XMLUtils.addReturnToElement(this.constructionElement);
+ }
+
+ /**
+ * Method addX509Data
+ *
+ * @param x509data
+ */
+ public void add(X509Data x509data) {
+ if (x509Datas == null) {
+ x509Datas = new ArrayList<X509Data>();
+ }
+ x509Datas.add(x509data);
+ this.constructionElement.appendChild(x509data.getElement());
+ XMLUtils.addReturnToElement(this.constructionElement);
+ }
+
+ /**
+ * Method addEncryptedKey
+ *
+ * @param encryptedKey
+ * @throws XMLEncryptionException
+ */
+
+ public void add(EncryptedKey encryptedKey)
+ throws XMLEncryptionException {
+ if (encryptedKeys == null) {
+ encryptedKeys = new ArrayList<EncryptedKey>();
+ }
+ encryptedKeys.add(encryptedKey);
+ XMLCipher cipher = XMLCipher.getInstance();
+ this.constructionElement.appendChild(cipher.martial(encryptedKey));
+ }
+
+ /**
+ * Method addUnknownElement
+ *
+ * @param element
+ */
+ public void addUnknownElement(Element element) {
+ this.constructionElement.appendChild(element);
+ XMLUtils.addReturnToElement(this.constructionElement);
+ }
+
+ /**
+ * Method lengthKeyName
+ *
+ * @return the number of the KeyName tags
+ */
+ public int lengthKeyName() {
+ return this.length(Constants.SignatureSpecNS, Constants._TAG_KEYNAME);
}
- /**
- * Constructor KeyInfo
- * @param doc
- */
- public KeyInfo(Document doc) {
-
- super(doc);
-
- XMLUtils.addReturnToElement(this.constructionElement);
-
- }
-
- /**
- * Constructor KeyInfo
- *
- * @param element
- * @param BaseURI
- * @throws XMLSecurityException
- */
- public KeyInfo(Element element, String BaseURI) throws XMLSecurityException {
- super(element, BaseURI);
- // _storageResolvers.add(null);
-
- }
-
- /**
- * Sets the <code>Id</code> attribute
- *
- * @param Id ID
- */
- public void setId(String Id) {
-
- if ((Id != null)) {
- this.constructionElement.setAttributeNS(null, Constants._ATT_ID, Id);
- IdResolver.registerElementById(this.constructionElement, Id);
- }
- }
-
- /**
- * Returns the <code>Id</code> attribute
- *
- * @return the <code>Id</code> attribute
- */
- public String getId() {
- return this.constructionElement.getAttributeNS(null, Constants._ATT_ID);
- }
-
- /**
- * Method addKeyName
- *
- * @param keynameString
- */
- public void addKeyName(String keynameString) {
- this.add(new KeyName(this.doc, keynameString));
- }
-
- /**
- * Method add
- *
- * @param keyname
- */
- public void add(KeyName keyname) {
-
- this.constructionElement.appendChild(keyname.getElement());
- XMLUtils.addReturnToElement(this.constructionElement);
- }
-
- /**
- * Method addKeyValue
- *
- * @param pk
- */
- public void addKeyValue(PublicKey pk) {
- this.add(new KeyValue(this.doc, pk));
- }
-
- /**
- * Method addKeyValue
- *
- * @param unknownKeyValueElement
- */
- public void addKeyValue(Element unknownKeyValueElement) {
- this.add(new KeyValue(this.doc, unknownKeyValueElement));
- }
-
- /**
- * Method add
- *
- * @param dsakeyvalue
- */
- public void add(DSAKeyValue dsakeyvalue) {
- this.add(new KeyValue(this.doc, dsakeyvalue));
- }
-
- /**
- * Method add
- *
- * @param rsakeyvalue
- */
- public void add(RSAKeyValue rsakeyvalue) {
- this.add(new KeyValue(this.doc, rsakeyvalue));
- }
-
- /**
- * Method add
- *
- * @param pk
- */
- public void add(PublicKey pk) {
- this.add(new KeyValue(this.doc, pk));
- }
-
- /**
- * Method add
- *
- * @param keyvalue
- */
- public void add(KeyValue keyvalue) {
- this.constructionElement.appendChild(keyvalue.getElement());
- XMLUtils.addReturnToElement(this.constructionElement);
- }
-
- /**
- * Method addMgmtData
- *
- * @param mgmtdata
- */
- public void addMgmtData(String mgmtdata) {
- this.add(new MgmtData(this.doc, mgmtdata));
- }
-
- /**
- * Method add
- *
- * @param mgmtdata
- */
- public void add(MgmtData mgmtdata) {
- this.constructionElement.appendChild(mgmtdata.getElement());
- XMLUtils.addReturnToElement(this.constructionElement);
- }
-
- /**
- * Method addPGPData
- *
- * @param pgpdata
- */
- public void add(PGPData pgpdata) {
- this.constructionElement.appendChild(pgpdata.getElement());
- XMLUtils.addReturnToElement(this.constructionElement);
- }
-
- /**
- * Method addRetrievalMethod
- *
- * @param URI
- * @param transforms
- * @param Type
- */
- public void addRetrievalMethod(String URI, Transforms transforms,
- String Type) {
- this.add(new RetrievalMethod(this.doc, URI, transforms, Type));
- }
-
- /**
- * Method add
- *
- * @param retrievalmethod
- */
- public void add(RetrievalMethod retrievalmethod) {
- this.constructionElement.appendChild(retrievalmethod.getElement());
- XMLUtils.addReturnToElement(this.constructionElement);
- }
-
- /**
- * Method add
- *
- * @param spkidata
- */
- public void add(SPKIData spkidata) {
- this.constructionElement.appendChild(spkidata.getElement());
- XMLUtils.addReturnToElement(this.constructionElement);
- }
-
- /**
- * Method addX509Data
- *
- * @param x509data
- */
- public void add(X509Data x509data) {
- if (x509Datas==null)
- x509Datas=new ArrayList();
- x509Datas.add(x509data);
- this.constructionElement.appendChild(x509data.getElement());
- XMLUtils.addReturnToElement(this.constructionElement);
- }
-
- /**
- * Method addEncryptedKey
- *
- * @param encryptedKey
- * @throws XMLEncryptionException
- */
-
- public void add(EncryptedKey encryptedKey)
- throws XMLEncryptionException {
- if (encryptedKeys==null)
- encryptedKeys=new ArrayList();
- encryptedKeys.add(encryptedKey);
- XMLCipher cipher = XMLCipher.getInstance();
- this.constructionElement.appendChild(cipher.martial(encryptedKey));
- }
-
- /**
- * Method addUnknownElement
- *
- * @param element
- */
- public void addUnknownElement(Element element) {
- this.constructionElement.appendChild(element);
- XMLUtils.addReturnToElement(this.constructionElement);
- }
-
- /**
- * Method lengthKeyName
- *
- * @return the number of the KeyName tags
- */
- public int lengthKeyName() {
- return this.length(Constants.SignatureSpecNS, Constants._TAG_KEYNAME);
- }
-
- /**
- * Method lengthKeyValue
- *
- *@return the number of the KeyValue tags
- */
- public int lengthKeyValue() {
- return this.length(Constants.SignatureSpecNS, Constants._TAG_KEYVALUE);
- }
-
- /**
- * Method lengthMgmtData
- *
- *@return the number of the MgmtData tags
- */
- public int lengthMgmtData() {
- return this.length(Constants.SignatureSpecNS, Constants._TAG_MGMTDATA);
- }
-
- /**
- * Method lengthPGPData
- *
- *@return the number of the PGPDat. tags
- */
- public int lengthPGPData() {
- return this.length(Constants.SignatureSpecNS, Constants._TAG_PGPDATA);
- }
-
- /**
- * Method lengthRetrievalMethod
- *
- *@return the number of the RetrievalMethod tags
- */
- public int lengthRetrievalMethod() {
- return this.length(Constants.SignatureSpecNS,
- Constants._TAG_RETRIEVALMETHOD);
- }
-
- /**
- * Method lengthSPKIData
- *
- *@return the number of the SPKIData tags
- */
- public int lengthSPKIData() {
- return this.length(Constants.SignatureSpecNS, Constants._TAG_SPKIDATA);
- }
-
- /**
- * Method lengthX509Data
- *
- *@return the number of the X509Data tags
- */
- public int lengthX509Data() {
- if (x509Datas!=null) {
- return x509Datas.size();
- }
- return this.length(Constants.SignatureSpecNS, Constants._TAG_X509DATA);
- }
-
- /**
- * Method lengthUnknownElement
- * NOTE posibly buggy.
- *@return the number of the UnknownElement tags
- */
- public int lengthUnknownElement() {
-
- int res = 0;
- NodeList nl = this.constructionElement.getChildNodes();
-
- for (int i = 0; i < nl.getLength(); i++) {
- Node current = nl.item(i);
-
- /**
- * $todo$ using this method, we don't see unknown Elements
- * from Signature NS; revisit
- */
- if ((current.getNodeType() == Node.ELEMENT_NODE)
- && current.getNamespaceURI()
- .equals(Constants.SignatureSpecNS)) {
- res++;
- }
- }
-
- return res;
- }
-
- /**
- * Method itemKeyName
- *
- * @param i
- * @return the asked KeyName element, null if the index is too big
- * @throws XMLSecurityException
- */
- public KeyName itemKeyName(int i) throws XMLSecurityException {
-
- Element e = XMLUtils.selectDsNode(this.constructionElement.getFirstChild(),
- Constants._TAG_KEYNAME,i);
-
- if (e != null) {
- return new KeyName(e, this.baseURI);
- }
- return null;
- }
-
- /**
- * Method itemKeyValue
- *
- * @param i
- * @return the asked KeyValue element, null if the index is too big
- * @throws XMLSecurityException
- */
- public KeyValue itemKeyValue(int i) throws XMLSecurityException {
-
- Element e = XMLUtils.selectDsNode(this.constructionElement.getFirstChild(),
- Constants._TAG_KEYVALUE,i);
-
- if (e != null) {
- return new KeyValue(e, this.baseURI);
- }
- return null;
- }
-
- /**
- * Method itemMgmtData
- *
- * @param i
- *@return the asked MgmtData element, null if the index is too big
- * @throws XMLSecurityException
- */
- public MgmtData itemMgmtData(int i) throws XMLSecurityException {
-
- Element e = XMLUtils.selectDsNode(this.constructionElement.getFirstChild(),
- Constants._TAG_MGMTDATA,i);
-
- if (e != null) {
- return new MgmtData(e, this.baseURI);
- }
- return null;
- }
-
- /**
- * Method itemPGPData
- *
- * @param i
- *@return the asked PGPData element, null if the index is too big
- * @throws XMLSecurityException
- */
- public PGPData itemPGPData(int i) throws XMLSecurityException {
-
- Element e = XMLUtils.selectDsNode(this.constructionElement.getFirstChild(),
- Constants._TAG_PGPDATA,i);
-
- if (e != null) {
- return new PGPData(e, this.baseURI);
- }
- return null;
- }
-
- /**
- * Method itemRetrievalMethod
- *
- * @param i
- *@return the asked RetrievalMethod element, null if the index is too big
- * @throws XMLSecurityException
- */
- public RetrievalMethod itemRetrievalMethod(int i)
- throws XMLSecurityException {
-
- Element e = XMLUtils.selectDsNode(this.constructionElement.getFirstChild(),
- Constants._TAG_RETRIEVALMETHOD,i);
-
- if (e != null) {
- return new RetrievalMethod(e, this.baseURI);
- }
- return null;
- }
-
- /**
- * Method itemSPKIData
- *
- * @param i
- *@return the asked SPKIData element, null if the index is too big
- * @throws XMLSecurityException
- */
- public SPKIData itemSPKIData(int i) throws XMLSecurityException {
-
- Element e = XMLUtils.selectDsNode(this.constructionElement.getFirstChild(),
- Constants._TAG_SPKIDATA,i);
-
- if (e != null) {
- return new SPKIData(e, this.baseURI);
- }
- return null;
- }
-
- /**
- * Method itemX509Data
- *@return the asked X509Data element, null if the index is too big
- * @param i
- *
- * @throws XMLSecurityException
- */
- public X509Data itemX509Data(int i) throws XMLSecurityException {
- if (x509Datas!=null) {
- return (X509Data) x509Datas.get(i);
- }
- Element e = XMLUtils.selectDsNode(this.constructionElement.getFirstChild(),
- Constants._TAG_X509DATA,i);
-
- if (e != null) {
- return new X509Data(e, this.baseURI);
- }
- return null;
- }
-
- /**
- * Method itemEncryptedKey
- *
- * @param i
- * @return the asked EncryptedKey element, null if the index is too big
- * @throws XMLSecurityException
- */
-
- public EncryptedKey itemEncryptedKey(int i) throws XMLSecurityException {
- if (encryptedKeys!=null) {
- return (EncryptedKey) encryptedKeys.get(i);
+ /**
+ * Method lengthKeyValue
+ *
+ *@return the number of the KeyValue tags
+ */
+ public int lengthKeyValue() {
+ return this.length(Constants.SignatureSpecNS, Constants._TAG_KEYVALUE);
+ }
+
+ /**
+ * Method lengthMgmtData
+ *
+ *@return the number of the MgmtData tags
+ */
+ public int lengthMgmtData() {
+ return this.length(Constants.SignatureSpecNS, Constants._TAG_MGMTDATA);
+ }
+
+ /**
+ * Method lengthPGPData
+ *
+ *@return the number of the PGPDat. tags
+ */
+ public int lengthPGPData() {
+ return this.length(Constants.SignatureSpecNS, Constants._TAG_PGPDATA);
+ }
+
+ /**
+ * Method lengthRetrievalMethod
+ *
+ *@return the number of the RetrievalMethod tags
+ */
+ public int lengthRetrievalMethod() {
+ return this.length(Constants.SignatureSpecNS, Constants._TAG_RETRIEVALMETHOD);
+ }
+
+ /**
+ * Method lengthSPKIData
+ *
+ *@return the number of the SPKIData tags
+ */
+ public int lengthSPKIData() {
+ return this.length(Constants.SignatureSpecNS, Constants._TAG_SPKIDATA);
+ }
+
+ /**
+ * Method lengthX509Data
+ *
+ *@return the number of the X509Data tags
+ */
+ public int lengthX509Data() {
+ if (x509Datas != null) {
+ return x509Datas.size();
+ }
+ return this.length(Constants.SignatureSpecNS, Constants._TAG_X509DATA);
+ }
+
+ /**
+ * Method lengthUnknownElement
+ * NOTE possibly buggy.
+ * @return the number of the UnknownElement tags
+ */
+ public int lengthUnknownElement() {
+ int res = 0;
+ NodeList nl = this.constructionElement.getChildNodes();
+
+ for (int i = 0; i < nl.getLength(); i++) {
+ Node current = nl.item(i);
+
+ /**
+ * $todo$ using this method, we don't see unknown Elements
+ * from Signature NS; revisit
+ */
+ if ((current.getNodeType() == Node.ELEMENT_NODE)
+ && current.getNamespaceURI().equals(Constants.SignatureSpecNS)) {
+ res++;
+ }
+ }
+
+ return res;
+ }
+
+ /**
+ * Method itemKeyName
+ *
+ * @param i
+ * @return the asked KeyName element, null if the index is too big
+ * @throws XMLSecurityException
+ */
+ public KeyName itemKeyName(int i) throws XMLSecurityException {
+
+ Element e =
+ XMLUtils.selectDsNode(
+ this.constructionElement.getFirstChild(), Constants._TAG_KEYNAME, i);
+
+ if (e != null) {
+ return new KeyName(e, this.baseURI);
+ }
+ return null;
+ }
+
+ /**
+ * Method itemKeyValue
+ *
+ * @param i
+ * @return the asked KeyValue element, null if the index is too big
+ * @throws XMLSecurityException
+ */
+ public KeyValue itemKeyValue(int i) throws XMLSecurityException {
+
+ Element e =
+ XMLUtils.selectDsNode(
+ this.constructionElement.getFirstChild(), Constants._TAG_KEYVALUE, i);
+
+ if (e != null) {
+ return new KeyValue(e, this.baseURI);
+ }
+ return null;
+ }
+
+ /**
+ * Method itemMgmtData
+ *
+ * @param i
+ * @return the asked MgmtData element, null if the index is too big
+ * @throws XMLSecurityException
+ */
+ public MgmtData itemMgmtData(int i) throws XMLSecurityException {
+
+ Element e =
+ XMLUtils.selectDsNode(
+ this.constructionElement.getFirstChild(), Constants._TAG_MGMTDATA, i);
+
+ if (e != null) {
+ return new MgmtData(e, this.baseURI);
+ }
+ return null;
+ }
+
+ /**
+ * Method itemPGPData
+ *
+ * @param i
+ * @return the asked PGPData element, null if the index is too big
+ * @throws XMLSecurityException
+ */
+ public PGPData itemPGPData(int i) throws XMLSecurityException {
+
+ Element e =
+ XMLUtils.selectDsNode(
+ this.constructionElement.getFirstChild(), Constants._TAG_PGPDATA, i);
+
+ if (e != null) {
+ return new PGPData(e, this.baseURI);
+ }
+ return null;
+ }
+
+ /**
+ * Method itemRetrievalMethod
+ *
+ * @param i
+ *@return the asked RetrievalMethod element, null if the index is too big
+ * @throws XMLSecurityException
+ */
+ public RetrievalMethod itemRetrievalMethod(int i) throws XMLSecurityException {
+
+ Element e =
+ XMLUtils.selectDsNode(
+ this.constructionElement.getFirstChild(), Constants._TAG_RETRIEVALMETHOD, i);
+
+ if (e != null) {
+ return new RetrievalMethod(e, this.baseURI);
+ }
+ return null;
+ }
+
+ /**
+ * Method itemSPKIData
+ *
+ * @param i
+ * @return the asked SPKIData element, null if the index is too big
+ * @throws XMLSecurityException
+ */
+ public SPKIData itemSPKIData(int i) throws XMLSecurityException {
+
+ Element e =
+ XMLUtils.selectDsNode(
+ this.constructionElement.getFirstChild(), Constants._TAG_SPKIDATA, i);
+
+ if (e != null) {
+ return new SPKIData(e, this.baseURI);
+ }
+ return null;
+ }
+
+ /**
+ * Method itemX509Data
+ *
+ * @param i
+ * @return the asked X509Data element, null if the index is too big
+ * @throws XMLSecurityException
+ */
+ public X509Data itemX509Data(int i) throws XMLSecurityException {
+ if (x509Datas != null) {
+ return x509Datas.get(i);
+ }
+ Element e =
+ XMLUtils.selectDsNode(
+ this.constructionElement.getFirstChild(), Constants._TAG_X509DATA, i);
+
+ if (e != null) {
+ return new X509Data(e, this.baseURI);
+ }
+ return null;
+ }
+
+ /**
+ * Method itemEncryptedKey
+ *
+ * @param i
+ * @return the asked EncryptedKey element, null if the index is too big
+ * @throws XMLSecurityException
+ */
+ public EncryptedKey itemEncryptedKey(int i) throws XMLSecurityException {
+ if (encryptedKeys != null) {
+ return encryptedKeys.get(i);
+ }
+ Element e =
+ XMLUtils.selectXencNode(
+ this.constructionElement.getFirstChild(), EncryptionConstants._TAG_ENCRYPTEDKEY, i);
+
+ if (e != null) {
+ XMLCipher cipher = XMLCipher.getInstance();
+ cipher.init(XMLCipher.UNWRAP_MODE, null);
+ return cipher.loadEncryptedKey(e);
+ }
+ return null;
+ }
+
+ /**
+ * Method itemUnknownElement
+ *
+ * @param i index
+ * @return the element number of the unknown elements
+ */
+ public Element itemUnknownElement(int i) {
+ NodeList nl = this.constructionElement.getChildNodes();
+ int res = 0;
+
+ for (int j = 0; j < nl.getLength(); j++) {
+ Node current = nl.item(j);
+
+ /**
+ * $todo$ using this method, we don't see unknown Elements
+ * from Signature NS; revisit
+ */
+ if ((current.getNodeType() == Node.ELEMENT_NODE)
+ && current.getNamespaceURI().equals(Constants.SignatureSpecNS)) {
+ res++;
+
+ if (res == i) {
+ return (Element) current;
}
- Element e =
- XMLUtils.selectXencNode(this.constructionElement.getFirstChild(),
- EncryptionConstants._TAG_ENCRYPTEDKEY,i);
-
- if (e != null) {
- XMLCipher cipher = XMLCipher.getInstance();
- cipher.init(XMLCipher.UNWRAP_MODE, null);
- return cipher.loadEncryptedKey(e);
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Method isEmpty
+ *
+ * @return true if the element has no descendants.
+ */
+ public boolean isEmpty() {
+ return this.constructionElement.getFirstChild() == null;
+ }
+
+ /**
+ * Method containsKeyName
+ *
+ * @return If the KeyInfo contains a KeyName node
+ */
+ public boolean containsKeyName() {
+ return this.lengthKeyName() > 0;
+ }
+
+ /**
+ * Method containsKeyValue
+ *
+ * @return If the KeyInfo contains a KeyValue node
+ */
+ public boolean containsKeyValue() {
+ return this.lengthKeyValue() > 0;
+ }
+
+ /**
+ * Method containsMgmtData
+ *
+ * @return If the KeyInfo contains a MgmtData node
+ */
+ public boolean containsMgmtData() {
+ return this.lengthMgmtData() > 0;
+ }
+
+ /**
+ * Method containsPGPData
+ *
+ * @return If the KeyInfo contains a PGPData node
+ */
+ public boolean containsPGPData() {
+ return this.lengthPGPData() > 0;
+ }
+
+ /**
+ * Method containsRetrievalMethod
+ *
+ * @return If the KeyInfo contains a RetrievalMethod node
+ */
+ public boolean containsRetrievalMethod() {
+ return this.lengthRetrievalMethod() > 0;
+ }
+
+ /**
+ * Method containsSPKIData
+ *
+ * @return If the KeyInfo contains a SPKIData node
+ */
+ public boolean containsSPKIData() {
+ return this.lengthSPKIData() > 0;
+ }
+
+ /**
+ * Method containsUnknownElement
+ *
+ * @return If the KeyInfo contains a UnknownElement node
+ */
+ public boolean containsUnknownElement() {
+ return this.lengthUnknownElement() > 0;
+ }
+
+ /**
+ * Method containsX509Data
+ *
+ * @return If the KeyInfo contains a X509Data node
+ */
+ public boolean containsX509Data() {
+ return this.lengthX509Data() > 0;
+ }
+
+ /**
+ * This method returns the public key.
+ *
+ * @return If the KeyInfo contains a PublicKey node
+ * @throws KeyResolverException
+ */
+ public PublicKey getPublicKey() throws KeyResolverException {
+ PublicKey pk = this.getPublicKeyFromInternalResolvers();
+
+ if (pk != null) {
+ if (log.isDebugEnabled()) {
+ log.debug("I could find a key using the per-KeyInfo key resolvers");
+ }
+
+ return pk;
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("I couldn't find a key using the per-KeyInfo key resolvers");
+ }
+
+ pk = this.getPublicKeyFromStaticResolvers();
+
+ if (pk != null) {
+ if (log.isDebugEnabled()) {
+ log.debug("I could find a key using the system-wide key resolvers");
+ }
+
+ return pk;
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("I couldn't find a key using the system-wide key resolvers");
+ }
+
+ return null;
+ }
+
+ /**
+ * Searches the library wide KeyResolvers for public keys
+ *
+ * @return The public key contained in this Node.
+ * @throws KeyResolverException
+ */
+ PublicKey getPublicKeyFromStaticResolvers() throws KeyResolverException {
+ int length = KeyResolver.length();
+ int storageLength = this.storageResolvers.size();
+ Iterator it = KeyResolver.iterator();
+ for (int i = 0; i < length; i++) {
+ KeyResolverSpi keyResolver = (KeyResolverSpi) it.next();
+ Node currentChild = this.constructionElement.getFirstChild();
+ String uri = this.getBaseURI();
+ while (currentChild != null) {
+ if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
+ for (int k = 0; k < storageLength; k++) {
+ StorageResolver storage =
+ (StorageResolver) this.storageResolvers.get(k);
+
+ PublicKey pk =
+ keyResolver.engineLookupAndResolvePublicKey(
+ (Element) currentChild, uri, storage
+ );
+
+ if (pk != null) {
+ KeyResolver.hit(it);
+ return pk;
+ }
+ }
+ }
+ currentChild = currentChild.getNextSibling();
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Searches the per-KeyInfo KeyResolvers for public keys
+ *
+ * @return The public key contained in this Node.
+ * @throws KeyResolverException
+ */
+ PublicKey getPublicKeyFromInternalResolvers() throws KeyResolverException {
+ int length=lengthInternalKeyResolver();
+ int storageLength=this.storageResolvers.size();
+ for (int i = 0; i < length; i++) {
+ KeyResolverSpi keyResolver = this.itemInternalKeyResolver(i);
+ if (log.isDebugEnabled())
+ log.debug("Try " + keyResolver.getClass().getName());
+
+ Node currentChild=this.constructionElement.getFirstChild();
+ String uri=this.getBaseURI();
+ while (currentChild!=null) {
+ if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
+ for (int k = 0; k < storageLength; k++) {
+ StorageResolver storage =
+ (StorageResolver) this.storageResolvers.get(k);
+ PublicKey pk = keyResolver
+ .engineLookupAndResolvePublicKey((Element) currentChild, uri, storage);
+
+ if (pk != null) {
+ return pk;
+ }
+ }
}
- return null;
- }
+ currentChild=currentChild.getNextSibling();
+ }
+ }
+
+ return null;
+ }
- /**
- * Method itemUnknownElement
- *
- * @param i index
- * @return the element number of the unknown elemens
- */
- public Element itemUnknownElement(int i) {
-
- NodeList nl = this.constructionElement.getChildNodes();
- int res = 0;
-
- for (int j = 0; j < nl.getLength(); j++) {
- Node current = nl.item(j);
-
- /**
- * $todo$ using this method, we don't see unknown Elements
- * from Signature NS; revisit
- */
- if ((current.getNodeType() == Node.ELEMENT_NODE)
- && current.getNamespaceURI()
- .equals(Constants.SignatureSpecNS)) {
- res++;
+ /**
+ * Method getX509Certificate
+ *
+ * @return The certificate contained in this KeyInfo
+ * @throws KeyResolverException
+ */
+ public X509Certificate getX509Certificate() throws KeyResolverException {
+ // First search using the individual resolvers from the user
+ X509Certificate cert = this.getX509CertificateFromInternalResolvers();
+
+ if (cert != null) {
+ if (log.isDebugEnabled()) {
+ log.debug("I could find a X509Certificate using the per-KeyInfo key resolvers");
+ }
- if (res == i) {
- return (Element) current;
+ return cert;
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("I couldn't find a X509Certificate using the per-KeyInfo key resolvers");
+ }
+
+ // Then use the system-wide Resolvers
+ cert = this.getX509CertificateFromStaticResolvers();
+
+ if (cert != null) {
+ if (log.isDebugEnabled()) {
+ log.debug("I could find a X509Certificate using the system-wide key resolvers");
}
- }
- }
- return null;
- }
+ return cert;
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("I couldn't find a X509Certificate using the system-wide key resolvers");
+ }
+
+ return null;
+ }
+
+ /**
+ * This method uses each System-wide {@link KeyResolver} to search the
+ * child elements. Each combination of {@link KeyResolver} and child element
+ * is checked against all {@link StorageResolver}s.
+ *
+ * @return The certificate contained in this KeyInfo
+ * @throws KeyResolverException
+ */
+ X509Certificate getX509CertificateFromStaticResolvers()
+ throws KeyResolverException {
+ if (log.isDebugEnabled()) {
+ log.debug(
+ "Start getX509CertificateFromStaticResolvers() with " + KeyResolver.length()
+ + " resolvers"
+ );
+ }
+ String uri = this.getBaseURI();
+ int length = KeyResolver.length();
+ int storageLength = this.storageResolvers.size();
+ Iterator it = KeyResolver.iterator();
+ for (int i = 0; i < length; i++) {
+ KeyResolverSpi keyResolver = (KeyResolverSpi) it.next();
+ X509Certificate cert = applyCurrentResolver(uri, storageLength, keyResolver);
+ if (cert != null) {
+ KeyResolver.hit(it);
+ return cert;
+ }
+ }
+ return null;
+ }
- /**
- * Method isEmpty
- *
- * @return true if the element has no descedants.
- */
- public boolean isEmpty() {
- return this.constructionElement.getFirstChild()==null;
- }
-
- /**
- * Method containsKeyName
- *
- * @return If the KeyInfo contains a KeyName node
- */
- public boolean containsKeyName() {
- return this.lengthKeyName() > 0;
- }
-
- /**
- * Method containsKeyValue
- *
- * @return If the KeyInfo contains a KeyValue node
- */
- public boolean containsKeyValue() {
- return this.lengthKeyValue() > 0;
- }
-
- /**
- * Method containsMgmtData
- *
- * @return If the KeyInfo contains a MgmtData node
- */
- public boolean containsMgmtData() {
- return this.lengthMgmtData() > 0;
- }
-
- /**
- * Method containsPGPData
- *
- * @return If the KeyInfo contains a PGPData node
- */
- public boolean containsPGPData() {
- return this.lengthPGPData() > 0;
- }
-
- /**
- * Method containsRetrievalMethod
- *
- * @return If the KeyInfo contains a RetrievalMethod node
- */
- public boolean containsRetrievalMethod() {
- return this.lengthRetrievalMethod() > 0;
- }
-
- /**
- * Method containsSPKIData
- *
- * @return If the KeyInfo contains a SPKIData node
- */
- public boolean containsSPKIData() {
- return this.lengthSPKIData() > 0;
- }
-
- /**
- * Method containsUnknownElement
- *
- * @return If the KeyInfo contains a UnknownElement node
- */
- public boolean containsUnknownElement() {
- return this.lengthUnknownElement() > 0;
- }
-
- /**
- * Method containsX509Data
- *
- * @return If the KeyInfo contains a X509Data node
- */
- public boolean containsX509Data() {
- return this.lengthX509Data() > 0;
- }
-
- /**
- * This method returns the public key.
- *
- * @return If the KeyInfo contains a PublicKey node
- * @throws KeyResolverException
- */
-
- public PublicKey getPublicKey() throws KeyResolverException {
-
- PublicKey pk = this.getPublicKeyFromInternalResolvers();
-
- if (pk != null) {
- log.debug("I could find a key using the per-KeyInfo key resolvers");
-
- return pk;
- }
- log.debug("I couldn't find a key using the per-KeyInfo key resolvers");
-
- pk = this.getPublicKeyFromStaticResolvers();
-
- if (pk != null) {
- log.debug("I could find a key using the system-wide key resolvers");
-
- return pk;
- }
- log.debug("I couldn't find a key using the system-wide key resolvers");
-
- return null;
- }
-
- /**
- * Searches the library wide KeyResolvers for public keys
- *
- * @return The public key contained in this Node.
- * @throws KeyResolverException
- */
- PublicKey getPublicKeyFromStaticResolvers() throws KeyResolverException {
- int length=KeyResolver.length();
- int storageLength=this._storageResolvers.size();
- Iterator it= KeyResolver.iterator();
- for (int i = 0; i < length; i++) {
- KeyResolverSpi keyResolver = (KeyResolverSpi) it.next();
- Node currentChild=this.constructionElement.getFirstChild();
- String uri= this.getBaseURI();
- while (currentChild!=null) {
- if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
- for (int k = 0; k < storageLength; k++) {
- StorageResolver storage =
- (StorageResolver) this._storageResolvers.get(k);
-
- PublicKey pk =
- keyResolver.engineLookupAndResolvePublicKey((Element) currentChild,
- uri,
- storage);
-
- if (pk != null) {
- KeyResolver.hit(it);
- return pk;
- }
- }
+ private X509Certificate applyCurrentResolver(
+ String uri, int storageLength, KeyResolverSpi keyResolver
+ ) throws KeyResolverException {
+ Node currentChild = this.constructionElement.getFirstChild();
+ while (currentChild != null) {
+ if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
+ for (int k = 0; k < storageLength; k++) {
+ StorageResolver storage =
+ (StorageResolver) this.storageResolvers.get(k);
+
+ X509Certificate cert =
+ keyResolver.engineLookupResolveX509Certificate(
+ (Element) currentChild, uri, storage
+ );
+
+ if (cert != null) {
+ return cert;
+ }
+ }
}
- currentChild=currentChild.getNextSibling();
- }
- }
- return null;
- }
-
- /**
- * Searches the per-KeyInfo KeyResolvers for public keys
- *
- * @return The public key contained in this Node.
- * @throws KeyResolverException
- */
- PublicKey getPublicKeyFromInternalResolvers() throws KeyResolverException {
- int length=lengthInternalKeyResolver();
- int storageLength=this._storageResolvers.size();
- for (int i = 0; i < length; i++) {
- KeyResolverSpi keyResolver = this.itemInternalKeyResolver(i);
- if (log.isDebugEnabled())
+ currentChild = currentChild.getNextSibling();
+ }
+ return null;
+ }
+
+ /**
+ * Method getX509CertificateFromInternalResolvers
+ *
+ * @return The certificate contained in this KeyInfo
+ * @throws KeyResolverException
+ */
+ X509Certificate getX509CertificateFromInternalResolvers()
+ throws KeyResolverException {
+ if (log.isDebugEnabled()) {
+ log.debug(
+ "Start getX509CertificateFromInternalResolvers() with "
+ + this.lengthInternalKeyResolver() + " resolvers"
+ );
+ }
+ String uri=this.getBaseURI();
+ int storageLength=this.storageResolvers.size();
+ for (int i = 0; i < this.lengthInternalKeyResolver(); i++) {
+ KeyResolverSpi keyResolver = this.itemInternalKeyResolver(i);
+ if (log.isDebugEnabled()) {
log.debug("Try " + keyResolver.getClass().getName());
+ }
+ X509Certificate cert= applyCurrentResolver(uri, storageLength, keyResolver);
+ if (cert!=null) {
+ return cert;
+ }
+ }
- Node currentChild=this.constructionElement.getFirstChild();
- String uri=this.getBaseURI();
- while (currentChild!=null) {
- if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
- for (int k = 0; k < storageLength; k++) {
- StorageResolver storage =
- (StorageResolver) this._storageResolvers.get(k);
- PublicKey pk = keyResolver
- .engineLookupAndResolvePublicKey((Element) currentChild, uri, storage);
-
- if (pk != null) {
- return pk;
- }
- }
+ return null;
+ }
+
+ /**
+ * This method returns a secret (symmetric) key. This is for XML Encryption.
+ * @return the secret key contained in this KeyInfo
+ * @throws KeyResolverException
+ */
+ public SecretKey getSecretKey() throws KeyResolverException {
+ SecretKey sk = this.getSecretKeyFromInternalResolvers();
+
+ if (sk != null) {
+ if (log.isDebugEnabled()) {
+ log.debug("I could find a secret key using the per-KeyInfo key resolvers");
+ }
+
+ return sk;
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("I couldn't find a secret key using the per-KeyInfo key resolvers");
+ }
+
+ sk = this.getSecretKeyFromStaticResolvers();
+
+ if (sk != null) {
+ if (log.isDebugEnabled()) {
+ log.debug("I could find a secret key using the system-wide key resolvers");
}
- currentChild=currentChild.getNextSibling();
- }
- }
-
- return null;
- }
-
- /**
- * Method getX509Certificate
- *
- * @return The certificate contained in this KeyInfo
- * @throws KeyResolverException
- */
- public X509Certificate getX509Certificate() throws KeyResolverException {
-
- // First search using the individual resolvers from the user
- X509Certificate cert = this.getX509CertificateFromInternalResolvers();
-
- if (cert != null) {
- log.debug(
- "I could find a X509Certificate using the per-KeyInfo key resolvers");
-
- return cert;
- }
- log.debug(
- "I couldn't find a X509Certificate using the per-KeyInfo key resolvers");
-
-
- // Then use the system-wide Resolvers
- cert = this.getX509CertificateFromStaticResolvers();
-
- if (cert != null) {
- log.debug(
- "I could find a X509Certificate using the system-wide key resolvers");
-
- return cert;
- }
- log.debug(
- "I couldn't find a X509Certificate using the system-wide key resolvers");
-
-
- return null;
- }
-
- /**
- * This method uses each System-wide {@link KeyResolver} to search the
- * child elements. Each combination of {@link KeyResolver} and child element
- * is checked against all {@link StorageResolver}s.
- *
- * @return The certificate contined in this KeyInfo
- * @throws KeyResolverException
- */
- X509Certificate getX509CertificateFromStaticResolvers()
- throws KeyResolverException {
- if (log.isDebugEnabled())
- log.debug("Start getX509CertificateFromStaticResolvers() with "
- + KeyResolver.length() + " resolvers");
- String uri=this.getBaseURI();
- int length= KeyResolver.length();
- int storageLength=this._storageResolvers.size();
- Iterator it = KeyResolver.iterator();
- for (int i = 0; i <length; i++) {
- KeyResolverSpi keyResolver = (KeyResolverSpi) it.next();
- X509Certificate cert= applyCurrentResolver(uri, storageLength, keyResolver);
- if (cert!=null) {
- KeyResolver.hit(it);
- return cert;
- }
- }
- return null;
- }
-
- private X509Certificate applyCurrentResolver(String uri, int storageLength, KeyResolverSpi keyResolver) throws KeyResolverException {
- Node currentChild=this.constructionElement.getFirstChild();
- while (currentChild!=null) {
- if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
- for (int k = 0; k < storageLength; k++) {
- StorageResolver storage =
- (StorageResolver) this._storageResolvers.get(k);
-
- X509Certificate cert = keyResolver
- .engineLookupResolveX509Certificate((Element) currentChild, uri,
- storage);
-
- if (cert != null) {
- return cert;
- }
- }
+
+ return sk;
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("I couldn't find a secret key using the system-wide key resolvers");
+ }
+
+ return null;
+ }
+
+ /**
+ * Searches the library wide KeyResolvers for Secret keys
+ *
+ * @return the secret key contained in this KeyInfo
+ * @throws KeyResolverException
+ */
+
+ SecretKey getSecretKeyFromStaticResolvers() throws KeyResolverException {
+ final int length=KeyResolver.length();
+ int storageLength=this.storageResolvers.size();
+ Iterator it = KeyResolver.iterator();
+ for (int i = 0; i < length; i++) {
+ KeyResolverSpi keyResolver = (KeyResolverSpi) it.next();
+
+ Node currentChild=this.constructionElement.getFirstChild();
+ String uri=this.getBaseURI();
+ while (currentChild!=null) {
+ if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
+ for (int k = 0; k < storageLength; k++) {
+ StorageResolver storage =
+ (StorageResolver) this.storageResolvers.get(k);
+
+ SecretKey sk =
+ keyResolver.engineLookupAndResolveSecretKey((Element) currentChild,
+ uri,
+ storage);
+
+ if (sk != null) {
+ return sk;
+ }
+ }
+ }
+ currentChild=currentChild.getNextSibling();
}
- currentChild=currentChild.getNextSibling();
- }
- return null;
- }
-
- /**
- * Method getX509CertificateFromInternalResolvers
- *
- * @return The certificate contined in this KeyInfo
- * @throws KeyResolverException
- */
- X509Certificate getX509CertificateFromInternalResolvers()
- throws KeyResolverException {
- if (log.isDebugEnabled())
- log.debug("Start getX509CertificateFromInternalResolvers() with "
- + this.lengthInternalKeyResolver() + " resolvers");
- String uri=this.getBaseURI();
- int storageLength=this._storageResolvers.size();
- for (int i = 0; i < this.lengthInternalKeyResolver(); i++) {
- KeyResolverSpi keyResolver = this.itemInternalKeyResolver(i);
- if (log.isDebugEnabled())
+ }
+ return null;
+ }
+
+ /**
+ * Searches the per-KeyInfo KeyResolvers for secret keys
+ *
+ * @return the secret key contained in this KeyInfo
+ * @throws KeyResolverException
+ */
+
+ SecretKey getSecretKeyFromInternalResolvers() throws KeyResolverException {
+ int storageLength=this.storageResolvers.size();
+ for (int i = 0; i < this.lengthInternalKeyResolver(); i++) {
+ KeyResolverSpi keyResolver = this.itemInternalKeyResolver(i);
+ if (log.isDebugEnabled())
log.debug("Try " + keyResolver.getClass().getName());
- X509Certificate cert= applyCurrentResolver(uri, storageLength, keyResolver);
- if (cert!=null) {
- return cert;
- }
- }
-
- return null;
- }
-
- /**
- * This method returns a secret (symmetric) key. This is for XML Encryption.
- * @return the secret key contained in this KeyInfo
- * @throws KeyResolverException
- */
- public SecretKey getSecretKey() throws KeyResolverException {
- SecretKey sk = this.getSecretKeyFromInternalResolvers();
-
- if (sk != null) {
- log.debug("I could find a secret key using the per-KeyInfo key resolvers");
-
- return sk;
- }
- log.debug("I couldn't find a secret key using the per-KeyInfo key resolvers");
-
-
- sk = this.getSecretKeyFromStaticResolvers();
-
- if (sk != null) {
- log.debug("I could find a secret key using the system-wide key resolvers");
-
- return sk;
- }
- log.debug("I couldn't find a secret key using the system-wide key resolvers");
-
-
- return null;
- }
-
- /**
- * Searches the library wide KeyResolvers for Secret keys
- *
- * @return the secret key contained in this KeyInfo
- * @throws KeyResolverException
- */
-
- SecretKey getSecretKeyFromStaticResolvers() throws KeyResolverException {
- final int length=KeyResolver.length();
- int storageLength=this._storageResolvers.size();
- Iterator it = KeyResolver.iterator();
- for (int i = 0; i < length; i++) {
- KeyResolverSpi keyResolver = (KeyResolverSpi) it.next();
-
- Node currentChild=this.constructionElement.getFirstChild();
- String uri=this.getBaseURI();
- while (currentChild!=null) {
- if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
- for (int k = 0; k < storageLength; k++) {
- StorageResolver storage =
- (StorageResolver) this._storageResolvers.get(k);
-
- SecretKey sk =
- keyResolver.engineLookupAndResolveSecretKey((Element) currentChild,
- uri,
- storage);
-
- if (sk != null) {
- return sk;
- }
- }
+
+ Node currentChild=this.constructionElement.getFirstChild();
+ String uri=this.getBaseURI();
+ while (currentChild!=null) {
+ if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
+ for (int k = 0; k < storageLength; k++) {
+ StorageResolver storage =
+ (StorageResolver) this.storageResolvers.get(k);
+
+ SecretKey sk = keyResolver
+ .engineLookupAndResolveSecretKey((Element) currentChild, uri, storage);
+
+ if (sk != null) {
+ return sk;
+ }
+ }
+ }
+ currentChild=currentChild.getNextSibling();
}
- currentChild=currentChild.getNextSibling();
- }
- }
- return null;
- }
-
- /**
- * Searches the per-KeyInfo KeyResolvers for secret keys
- *
- * @return the secret key contained in this KeyInfo
- * @throws KeyResolverException
- */
-
- SecretKey getSecretKeyFromInternalResolvers() throws KeyResolverException {
- int storageLength=this._storageResolvers.size();
- for (int i = 0; i < this.lengthInternalKeyResolver(); i++) {
- KeyResolverSpi keyResolver = this.itemInternalKeyResolver(i);
- if (log.isDebugEnabled())
- log.debug("Try " + keyResolver.getClass().getName());
-
- Node currentChild=this.constructionElement.getFirstChild();
- String uri=this.getBaseURI();
- while (currentChild!=null) {
- if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
- for (int k = 0; k < storageLength; k++) {
- StorageResolver storage =
- (StorageResolver) this._storageResolvers.get(k);
-
- SecretKey sk = keyResolver
- .engineLookupAndResolveSecretKey((Element) currentChild, uri, storage);
-
- if (sk != null) {
- return sk;
- }
+ }
+
+ return null;
+ }
+
+ /**
+ * This method returns a private key. This is for Key Transport in XML Encryption.
+ * @return the private key contained in this KeyInfo
+ * @throws KeyResolverException
+ */
+ public PrivateKey getPrivateKey() throws KeyResolverException {
+ PrivateKey pk = this.getPrivateKeyFromInternalResolvers();
+
+ if (pk != null) {
+ if (log.isDebugEnabled()) {
+ log.debug("I could find a private key using the per-KeyInfo key resolvers");
+ }
+ return pk;
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("I couldn't find a secret key using the per-KeyInfo key resolvers");
+ }
+
+ pk = this.getPrivateKeyFromStaticResolvers();
+ if (pk != null) {
+ if (log.isDebugEnabled()) {
+ log.debug("I could find a private key using the system-wide key resolvers");
+ }
+ return pk;
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("I couldn't find a private key using the system-wide key resolvers");
+ }
+
+ return null;
+ }
+
+ /**
+ * Searches the library wide KeyResolvers for Private keys
+ *
+ * @return the private key contained in this KeyInfo
+ * @throws KeyResolverException
+ */
+ PrivateKey getPrivateKeyFromStaticResolvers() throws KeyResolverException {
+ final int length=KeyResolver.length();
+ Iterator it = KeyResolver.iterator();
+ for (int i = 0; i < length; i++) {
+ KeyResolverSpi keyResolver = (KeyResolverSpi) it.next();
+
+ Node currentChild=this.constructionElement.getFirstChild();
+ String uri=this.getBaseURI();
+ while (currentChild!=null) {
+ if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
+ // not using StorageResolvers at the moment
+ // since they cannot return private keys
+ StorageResolver storage = null;
+ PrivateKey pk = keyResolver.engineLookupAndResolvePrivateKey(
+ (Element) currentChild,
+ uri,
+ storage);
+
+ if (pk != null) {
+ return pk;
+ }
}
- }
- currentChild=currentChild.getNextSibling();
- }
- }
-
- return null;
- }
-
- /**
- * This method returns a private key. This is for Key Transport in XML Encryption.
- * @return the private key contained in this KeyInfo
- * @throws KeyResolverException
- */
- public PrivateKey getPrivateKey() throws KeyResolverException {
- PrivateKey pk = this.getPrivateKeyFromInternalResolvers();
-
- if (pk != null) {
- log.debug("I could find a private key using the per-KeyInfo key resolvers");
- return pk;
- }
- log.debug("I couldn't find a secret key using the per-KeyInfo key resolvers");
-
- pk = this.getPrivateKeyFromStaticResolvers();
- if (pk != null) {
- log.debug("I could find a private key using the system-wide key resolvers");
- return pk;
- }
- log.debug("I couldn't find a private key using the system-wide key resolvers");
-
- return null;
- }
-
- /**
- * Searches the library wide KeyResolvers for Private keys
- *
- * @return the private key contained in this KeyInfo
- * @throws KeyResolverException
- */
- PrivateKey getPrivateKeyFromStaticResolvers() throws KeyResolverException {
- final int length=KeyResolver.length();
- Iterator it = KeyResolver.iterator();
- for (int i = 0; i < length; i++) {
- KeyResolverSpi keyResolver = (KeyResolverSpi) it.next();
-
- Node currentChild=this.constructionElement.getFirstChild();
- String uri=this.getBaseURI();
- while (currentChild!=null) {
- if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
- // not using StorageResolvers at the moment
- // since they cannot return private keys
- StorageResolver storage = null;
- PrivateKey pk = keyResolver.engineLookupAndResolvePrivateKey(
- (Element) currentChild,
- uri,
- storage);
-
- if (pk != null) {
- return pk;
- }
+ currentChild=currentChild.getNextSibling();
}
- currentChild=currentChild.getNextSibling();
- }
- }
- return null;
- }
-
- /**
- * Searches the per-KeyInfo KeyResolvers for private keys
- *
- * @return the private key contained in this KeyInfo
- * @throws KeyResolverException
- */
-
- PrivateKey getPrivateKeyFromInternalResolvers() throws KeyResolverException {
- for (int i = 0; i < this.lengthInternalKeyResolver(); i++) {
- KeyResolverSpi keyResolver = this.itemInternalKeyResolver(i);
- if (log.isDebugEnabled())
- log.debug("Try " + keyResolver.getClass().getName());
-
- Node currentChild=this.constructionElement.getFirstChild();
- String uri=this.getBaseURI();
- while (currentChild!=null) {
- if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
- // not using StorageResolvers at the moment
- // since they cannot return private keys
- StorageResolver storage = null;
- PrivateKey pk = keyResolver
- .engineLookupAndResolvePrivateKey((Element) currentChild, uri, storage);
-
- if (pk != null) {
- return pk;
- }
- }
- currentChild=currentChild.getNextSibling();
- }
- }
-
- return null;
- }
-
- /**
- * Stores the individual (per-KeyInfo) {@link KeyResolver}s
- */
- List _internalKeyResolvers = null;
-
- /**
- * This method is used to add a custom {@link KeyResolverSpi} to a KeyInfo
- * object.
- *
- * @param realKeyResolver
- */
- public void registerInternalKeyResolver(KeyResolverSpi realKeyResolver) {
- if (_internalKeyResolvers==null) {
- _internalKeyResolvers=new ArrayList();
- }
- this._internalKeyResolvers.add(realKeyResolver);
- }
-
- /**
- * Method lengthInternalKeyResolver
- * @return the length of the key
- */
- int lengthInternalKeyResolver() {
- if (_internalKeyResolvers==null)
- return 0;
- return this._internalKeyResolvers.size();
- }
-
- /**
- * Method itemInternalKeyResolver
- *
- * @param i the index
- * @return the KeyResolverSpi for the index.
- */
- KeyResolverSpi itemInternalKeyResolver(int i) {
- return (KeyResolverSpi) this._internalKeyResolvers.get(i);
- }
-
- /** Field _storageResolvers */
- List _storageResolvers = nullList;
-
- /**
- * Method addStorageResolver
- *
- * @param storageResolver
- */
- public void addStorageResolver(StorageResolver storageResolver) {
- if (_storageResolvers == nullList) {
- // Replace the default null StorageResolver
- _storageResolvers = new ArrayList();
- }
- this._storageResolvers.add(storageResolver);
- }
-
- //J-
- static boolean _alreadyInitialized = false;
- /** init the keyinfo (Still needed?)*/
- public static void init() {
+ }
+ return null;
+ }
- if (!KeyInfo._alreadyInitialized) {
- if (KeyInfo.log == null) {
+ /**
+ * Searches the per-KeyInfo KeyResolvers for private keys
+ *
+ * @return the private key contained in this KeyInfo
+ * @throws KeyResolverException
+ */
+
+ PrivateKey getPrivateKeyFromInternalResolvers() throws KeyResolverException {
+ for (int i = 0; i < this.lengthInternalKeyResolver(); i++) {
+ KeyResolverSpi keyResolver = this.itemInternalKeyResolver(i);
+ if (log.isDebugEnabled())
+ log.debug("Try " + keyResolver.getClass().getName());
- /**
- * $todo$ why the hell does the static initialization from the
- * start not work ?
- */
- KeyInfo.log =
- org.apache.commons.logging.LogFactory.getLog(KeyInfo.class.getName());
+ Node currentChild=this.constructionElement.getFirstChild();
+ String uri=this.getBaseURI();
+ while (currentChild!=null) {
+ if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
+ // not using StorageResolvers at the moment
+ // since they cannot return private keys
+ StorageResolver storage = null;
+ PrivateKey pk = keyResolver
+ .engineLookupAndResolvePrivateKey((Element) currentChild, uri, storage);
+
+ if (pk != null) {
+ return pk;
+ }
+ }
+ currentChild=currentChild.getNextSibling();
+ }
+ }
+
+ return null;
+ }
- log.error("Had to assign log in the init() function");
- }
+ /**
+ * This method is used to add a custom {@link KeyResolverSpi} to a KeyInfo
+ * object.
+ *
+ * @param realKeyResolver
+ */
+ public void registerInternalKeyResolver(KeyResolverSpi realKeyResolver) {
+ if (internalKeyResolvers==null) {
+ internalKeyResolvers=new ArrayList();
+ }
+ this.internalKeyResolvers.add(realKeyResolver);
+ }
+
+ /**
+ * Method lengthInternalKeyResolver
+ * @return the length of the key
+ */
+ int lengthInternalKeyResolver() {
+ if (internalKeyResolvers==null)
+ return 0;
+ return this.internalKeyResolvers.size();
+ }
- // KeyInfo._contentHandlerHash = new HashMap(10);
- KeyInfo._alreadyInitialized = true;
- }
- }
-
- /** @inheritDoc */
- public String getBaseLocalName() {
- return Constants._TAG_KEYINFO;
- }
+ /**
+ * Method itemInternalKeyResolver
+ *
+ * @param i the index
+ * @return the KeyResolverSpi for the index.
+ */
+ KeyResolverSpi itemInternalKeyResolver(int i) {
+ return (KeyResolverSpi) this.internalKeyResolvers.get(i);
+ }
+
+ /**
+ * Method addStorageResolver
+ *
+ * @param storageResolver
+ */
+ public void addStorageResolver(StorageResolver storageResolver) {
+ if (storageResolvers == nullList) {
+ // Replace the default null StorageResolver
+ storageResolvers = new ArrayList<StorageResolver>();
+ }
+ this.storageResolvers.add(storageResolver);
+ }
+
+
+ /** @inheritDoc */
+ public String getBaseLocalName() {
+ return Constants._TAG_KEYINFO;
+ }
}
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/content/KeyInfoContent.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/content/KeyInfoContent.java?rev=1069340&r1=1069339&r2=1069340&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/content/KeyInfoContent.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/content/KeyInfoContent.java Thu Feb 10 11:37:05 2011
@@ -17,10 +17,6 @@
*/
package org.apache.xml.security.keys.content;
-
-
-
-
/**
* Empty interface just to identify Elements that can be cildren of ds:KeyInfo.
*
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/content/KeyName.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/content/KeyName.java?rev=1069340&r1=1069339&r2=1069340&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/content/KeyName.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/content/KeyName.java Thu Feb 10 11:37:05 2011
@@ -23,46 +23,44 @@ import org.w3c.dom.Document;
import org.w3c.dom.Element;
/**
- *
* @author $Author$
*/
public class KeyName extends SignatureElementProxy implements KeyInfoContent {
- /**
- * Constructor KeyName
- *
- * @param element
- * @param BaseURI
- * @throws XMLSecurityException
- */
- public KeyName(Element element, String BaseURI) throws XMLSecurityException {
- super(element, BaseURI);
- }
-
- /**
- * Constructor KeyName
- *
- * @param doc
- * @param keyName
- */
- public KeyName(Document doc, String keyName) {
-
- super(doc);
-
- this.addText(keyName);
- }
-
- /**
- * Method getKeyName
- *
- * @return key name
- */
- public String getKeyName() {
- return this.getTextFromTextChild();
- }
-
- /** @inheritDoc */
- public String getBaseLocalName() {
- return Constants._TAG_KEYNAME;
- }
+ /**
+ * Constructor KeyName
+ *
+ * @param element
+ * @param BaseURI
+ * @throws XMLSecurityException
+ */
+ public KeyName(Element element, String BaseURI) throws XMLSecurityException {
+ super(element, BaseURI);
+ }
+
+ /**
+ * Constructor KeyName
+ *
+ * @param doc
+ * @param keyName
+ */
+ public KeyName(Document doc, String keyName) {
+ super(doc);
+
+ this.addText(keyName);
+ }
+
+ /**
+ * Method getKeyName
+ *
+ * @return key name
+ */
+ public String getKeyName() {
+ return this.getTextFromTextChild();
+ }
+
+ /** @inheritDoc */
+ public String getBaseLocalName() {
+ return Constants._TAG_KEYNAME;
+ }
}
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/content/KeyValue.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/content/KeyValue.java?rev=1069340&r1=1069339&r2=1069340&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/content/KeyValue.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/content/KeyValue.java Thu Feb 10 11:37:05 2011
@@ -46,7 +46,6 @@ public class KeyValue extends SignatureE
* @param dsaKeyValue
*/
public KeyValue(Document doc, DSAKeyValue dsaKeyValue) {
-
super(doc);
XMLUtils.addReturnToElement(this.constructionElement);
@@ -61,7 +60,6 @@ public class KeyValue extends SignatureE
* @param rsaKeyValue
*/
public KeyValue(Document doc, RSAKeyValue rsaKeyValue) {
-
super(doc);
XMLUtils.addReturnToElement(this.constructionElement);
@@ -76,7 +74,6 @@ public class KeyValue extends SignatureE
* @param unknownKeyValue
*/
public KeyValue(Document doc, Element unknownKeyValue) {
-
super(doc);
XMLUtils.addReturnToElement(this.constructionElement);
@@ -91,7 +88,6 @@ public class KeyValue extends SignatureE
* @param pk
*/
public KeyValue(Document doc, PublicKey pk) {
-
super(doc);
XMLUtils.addReturnToElement(this.constructionElement);
@@ -116,8 +112,7 @@ public class KeyValue extends SignatureE
* @param BaseURI
* @throws XMLSecurityException
*/
- public KeyValue(Element element, String BaseURI)
- throws XMLSecurityException {
+ public KeyValue(Element element, String BaseURI) throws XMLSecurityException {
super(element, BaseURI);
}
@@ -128,19 +123,18 @@ public class KeyValue extends SignatureE
* @throws XMLSecurityException
*/
public PublicKey getPublicKey() throws XMLSecurityException {
+ Element rsa =
+ XMLUtils.selectDsNode(
+ this.constructionElement.getFirstChild(), Constants._TAG_RSAKEYVALUE, 0);
- Element rsa = XMLUtils.selectDsNode
- (this.constructionElement.getFirstChild(),
- Constants._TAG_RSAKEYVALUE,0);
-
if (rsa != null) {
RSAKeyValue kv = new RSAKeyValue(rsa, this.baseURI);
return kv.getPublicKey();
}
- Element dsa = XMLUtils.selectDsNode
- (this.constructionElement.getFirstChild(),
- Constants._TAG_DSAKEYVALUE,0);
+ Element dsa =
+ XMLUtils.selectDsNode(
+ this.constructionElement.getFirstChild(), Constants._TAG_DSAKEYVALUE, 0);
if (dsa != null) {
DSAKeyValue kv = new DSAKeyValue(dsa, this.baseURI);
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/content/MgmtData.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/content/MgmtData.java?rev=1069340&r1=1069339&r2=1069340&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/content/MgmtData.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/content/MgmtData.java Thu Feb 10 11:37:05 2011
@@ -23,47 +23,45 @@ import org.w3c.dom.Document;
import org.w3c.dom.Element;
/**
- *
* @author $Author$
*/
public class MgmtData extends SignatureElementProxy implements KeyInfoContent {
- /**
- * Constructor MgmtData
- *
- * @param element
- * @param BaseURI
- * @throws XMLSecurityException
- */
- public MgmtData(Element element, String BaseURI)
- throws XMLSecurityException {
- super(element, BaseURI);
- }
-
- /**
- * Constructor MgmtData
- *
- * @param doc
- * @param mgmtData
- */
- public MgmtData(Document doc, String mgmtData) {
-
- super(doc);
-
- this.addText(mgmtData);
- }
-
- /**
- * Method getMgmtData
- *
- * @return the managment data
- */
- public String getMgmtData() {
- return this.getTextFromTextChild();
- }
-
- /** @inheritDoc */
- public String getBaseLocalName() {
- return Constants._TAG_MGMTDATA;
- }
+ /**
+ * Constructor MgmtData
+ *
+ * @param element
+ * @param BaseURI
+ * @throws XMLSecurityException
+ */
+ public MgmtData(Element element, String BaseURI)
+ throws XMLSecurityException {
+ super(element, BaseURI);
+ }
+
+ /**
+ * Constructor MgmtData
+ *
+ * @param doc
+ * @param mgmtData
+ */
+ public MgmtData(Document doc, String mgmtData) {
+ super(doc);
+
+ this.addText(mgmtData);
+ }
+
+ /**
+ * Method getMgmtData
+ *
+ * @return the managment data
+ */
+ public String getMgmtData() {
+ return this.getTextFromTextChild();
+ }
+
+ /** @inheritDoc */
+ public String getBaseLocalName() {
+ return Constants._TAG_MGMTDATA;
+ }
}
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/content/PGPData.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/content/PGPData.java?rev=1069340&r1=1069339&r2=1069340&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/content/PGPData.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/content/PGPData.java Thu Feb 10 11:37:05 2011
@@ -22,25 +22,24 @@ import org.apache.xml.security.utils.Sig
import org.w3c.dom.Element;
/**
- *
* @author $Author$
* $todo$ Implement
*/
public class PGPData extends SignatureElementProxy implements KeyInfoContent {
- /**
- * Constructor PGPData
- *
- * @param element
- * @param BaseURI
- * @throws XMLSecurityException
- */
- public PGPData(Element element, String BaseURI) throws XMLSecurityException {
- super(element, BaseURI);
- }
+ /**
+ * Constructor PGPData
+ *
+ * @param element
+ * @param BaseURI
+ * @throws XMLSecurityException
+ */
+ public PGPData(Element element, String BaseURI) throws XMLSecurityException {
+ super(element, BaseURI);
+ }
- /** @inheritDoc */
- public String getBaseLocalName() {
- return Constants._TAG_PGPDATA;
- }
+ /** @inheritDoc */
+ public String getBaseLocalName() {
+ return Constants._TAG_PGPDATA;
+ }
}
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/content/RetrievalMethod.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/content/RetrievalMethod.java?rev=1069340&r1=1069339&r2=1069340&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/content/RetrievalMethod.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/keys/content/RetrievalMethod.java Thu Feb 10 11:37:05 2011
@@ -26,118 +26,104 @@ import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-/**
- *
- * @author $Author$
- */
-public class RetrievalMethod extends SignatureElementProxy
- implements KeyInfoContent {
+public class RetrievalMethod extends SignatureElementProxy implements KeyInfoContent {
- //J-
/** DSA retrieval */
- public static final String TYPE_DSA = Constants.SignatureSpecNS + "DSAKeyValue";
- /** RSA retrieval */
- public static final String TYPE_RSA = Constants.SignatureSpecNS + "RSAKeyValue";
- /** PGP retrieval */
- public static final String TYPE_PGP = Constants.SignatureSpecNS + "PGPData";
- /** SPKI retrieval */
- public static final String TYPE_SPKI = Constants.SignatureSpecNS + "SPKIData";
- /** MGMT retrieval */
- public static final String TYPE_MGMT = Constants.SignatureSpecNS + "MgmtData";
- /** X509 retrieval */
- public static final String TYPE_X509 = Constants.SignatureSpecNS + "X509Data";
- /** RAWX509 retrieval */
- public static final String TYPE_RAWX509 = Constants.SignatureSpecNS + "rawX509Certificate";
- //J+
-
- /**
- * Constructor RetrievalMethod
- *
- * @param element
- * @param BaseURI
- * @throws XMLSecurityException
- */
- public RetrievalMethod(Element element, String BaseURI)
- throws XMLSecurityException {
- super(element, BaseURI);
- }
-
- /**
- * Constructor RetrievalMethod
- *
- * @param doc
- * @param URI
- * @param transforms
- * @param Type
- */
- public RetrievalMethod(Document doc, String URI, Transforms transforms,
- String Type) {
-
- super(doc);
-
- this.constructionElement.setAttributeNS(null, Constants._ATT_URI, URI);
-
- if (Type != null) {
- this.constructionElement.setAttributeNS(null, Constants._ATT_TYPE, Type);
- }
-
- if (transforms != null) {
- this.constructionElement.appendChild(transforms.getElement());
- XMLUtils.addReturnToElement(this.constructionElement);
- }
- }
-
- /**
- * Method getURIAttr
- *
- * @return the URI attribute
- */
- public Attr getURIAttr() {
- return this.constructionElement.getAttributeNodeNS(null, Constants._ATT_URI);
- }
-
- /**
- * Method getURI
- *
- *
- * @return URI string
- */
- public String getURI() {
- return this.getURIAttr().getNodeValue();
- }
-
- /** @return the type*/
- public String getType() {
- return this.constructionElement.getAttributeNS(null, Constants._ATT_TYPE);
- }
-
- /**
- * Method getTransforms
- *
- *
- * @throws XMLSecurityException
- * @return the transforamitons
- */
- public Transforms getTransforms() throws XMLSecurityException {
-
- try {
- Element transformsElem =
- XMLUtils.selectDsNode(this.constructionElement.getFirstChild(),
- Constants
- ._TAG_TRANSFORMS, 0);
-
- if (transformsElem != null) {
- return new Transforms(transformsElem, this.baseURI);
- }
-
- return null;
- } catch (XMLSignatureException ex) {
- throw new XMLSecurityException("empty", ex);
- }
- }
-
- /** @inheritDoc */
- public String getBaseLocalName() {
- return Constants._TAG_RETRIEVALMETHOD;
- }
+ public static final String TYPE_DSA = Constants.SignatureSpecNS + "DSAKeyValue";
+ /** RSA retrieval */
+ public static final String TYPE_RSA = Constants.SignatureSpecNS + "RSAKeyValue";
+ /** PGP retrieval */
+ public static final String TYPE_PGP = Constants.SignatureSpecNS + "PGPData";
+ /** SPKI retrieval */
+ public static final String TYPE_SPKI = Constants.SignatureSpecNS + "SPKIData";
+ /** MGMT retrieval */
+ public static final String TYPE_MGMT = Constants.SignatureSpecNS + "MgmtData";
+ /** X509 retrieval */
+ public static final String TYPE_X509 = Constants.SignatureSpecNS + "X509Data";
+ /** RAWX509 retrieval */
+ public static final String TYPE_RAWX509 = Constants.SignatureSpecNS + "rawX509Certificate";
+
+ /**
+ * Constructor RetrievalMethod
+ *
+ * @param element
+ * @param BaseURI
+ * @throws XMLSecurityException
+ */
+ public RetrievalMethod(Element element, String BaseURI) throws XMLSecurityException {
+ super(element, BaseURI);
+ }
+
+ /**
+ * Constructor RetrievalMethod
+ *
+ * @param doc
+ * @param URI
+ * @param transforms
+ * @param Type
+ */
+ public RetrievalMethod(Document doc, String URI, Transforms transforms, String Type) {
+ super(doc);
+
+ this.constructionElement.setAttributeNS(null, Constants._ATT_URI, URI);
+
+ if (Type != null) {
+ this.constructionElement.setAttributeNS(null, Constants._ATT_TYPE, Type);
+ }
+
+ if (transforms != null) {
+ this.constructionElement.appendChild(transforms.getElement());
+ XMLUtils.addReturnToElement(this.constructionElement);
+ }
+ }
+
+ /**
+ * Method getURIAttr
+ *
+ * @return the URI attribute
+ */
+ public Attr getURIAttr() {
+ return this.constructionElement.getAttributeNodeNS(null, Constants._ATT_URI);
+ }
+
+ /**
+ * Method getURI
+ *
+ * @return URI string
+ */
+ public String getURI() {
+ return this.getURIAttr().getNodeValue();
+ }
+
+ /** @return the type*/
+ public String getType() {
+ return this.constructionElement.getAttributeNS(null, Constants._ATT_TYPE);
+ }
+
+ /**
+ * Method getTransforms
+ *
+ * @throws XMLSecurityException
+ * @return the transformations
+ */
+ public Transforms getTransforms() throws XMLSecurityException {
+ try {
+ Element transformsElem =
+ XMLUtils.selectDsNode(
+ this.constructionElement.getFirstChild(), Constants._TAG_TRANSFORMS, 0);
+
+ if (transformsElem != null) {
+ return new Transforms(transformsElem, this.baseURI);
+ }
+
+ return null;
+ } catch (XMLSignatureException ex) {
+ throw new XMLSecurityException("empty", ex);
+ }
+ }
+
+ /** @inheritDoc */
+ public String getBaseLocalName() {
+ return Constants._TAG_RETRIEVALMETHOD;
+ }
}