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 2012/07/11 17:53:50 UTC
svn commit: r1360242 - in /santuario/xml-security-java/trunk: ./
src/main/java/org/apache/xml/security/stax/ext/
src/main/java/org/apache/xml/security/stax/impl/processor/input/
src/main/java/org/apache/xml/security/stax/impl/securityToken/
Author: coheigea
Date: Wed Jul 11 15:53:50 2012
New Revision: 1360242
URL: http://svn.apache.org/viewvc?rev=1360242&view=rev
Log:
Removing Crypto references from Santuario
Modified:
santuario/xml-security-java/trunk/pom.xml
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/SecurityToken.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/XMLSecurityProperties.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/processor/input/AbstractDecryptInputProcessor.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/processor/input/XMLSignatureInputHandler.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/securityToken/SecurityTokenFactory.java
santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/securityToken/SecurityTokenFactoryImpl.java
Modified: santuario/xml-security-java/trunk/pom.xml
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/pom.xml?rev=1360242&r1=1360241&r2=1360242&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/pom.xml (original)
+++ santuario/xml-security-java/trunk/pom.xml Wed Jul 11 15:53:50 2012
@@ -355,6 +355,7 @@
<id>fastinstall</id>
<properties>
<maven.test.skip>true</maven.test.skip>
+ <pmd.skip>true</pmd.skip>
</properties>
</profile>
<profile>
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/SecurityToken.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/SecurityToken.java?rev=1360242&r1=1360241&r2=1360242&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/SecurityToken.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/SecurityToken.java Wed Jul 11 15:53:50 2012
@@ -51,6 +51,11 @@ public interface SecurityToken {
EndorsingEncryptedSupportingTokens,
SignedEndorsingEncryptedSupportingTokens,
}
+
+ public enum KeyInfoUsage {
+ SIGNATURE_VERIFICATION,
+ DECRYPTION
+ }
/**
* Returns the token id aka wsu:Id
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/XMLSecurityProperties.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/XMLSecurityProperties.java?rev=1360242&r1=1360241&r2=1360242&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/XMLSecurityProperties.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/ext/XMLSecurityProperties.java Wed Jul 11 15:53:50 2012
@@ -18,18 +18,14 @@
*/
package org.apache.xml.security.stax.ext;
-import org.apache.xml.security.stax.crypto.Crypto;
-import org.apache.xml.security.stax.crypto.MerlinBase;
-
-import javax.security.auth.callback.CallbackHandler;
-import java.net.URL;
import java.security.Key;
-import java.security.KeyStore;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
+import javax.security.auth.callback.CallbackHandler;
+
/**
* Main configuration class to supply keys etc.
* This class is subject to change in the future.
@@ -69,87 +65,9 @@ public class XMLSecurityProperties {
return inputProcessorList;
}
- private Class<? extends MerlinBase> decryptionCryptoClass;
- private KeyStore decryptionKeyStore;
private CallbackHandler callbackHandler;
/**
- * Returns the decryption keystore
- *
- * @return A keystore for decryption operation
- */
- public KeyStore getDecryptionKeyStore() {
- return decryptionKeyStore;
- }
-
- /**
- * loads a java keystore from the given url for decrypt operations
- *
- * @param url The URL to the keystore
- * @param keyStorePassword The keyStorePassword
- * @throws Exception thrown if something goes wrong while loading the keystore
- */
- public void loadDecryptionKeystore(URL url, char[] keyStorePassword) throws Exception {
- KeyStore keyStore = KeyStore.getInstance("jks");
- keyStore.load(url.openStream(), keyStorePassword);
- this.decryptionKeyStore = keyStore;
- }
-
- /**
- * Returns the decryption crypto class
- *
- * @return
- */
- public Class<? extends MerlinBase> getDecryptionCryptoClass() {
- if (decryptionCryptoClass != null) {
- return decryptionCryptoClass;
- }
- decryptionCryptoClass = org.apache.xml.security.stax.crypto.Merlin.class;
- return decryptionCryptoClass;
- }
-
- /**
- * Sets a custom decryption class
- *
- * @param decryptionCryptoClass
- */
- public void setDecryptionCryptoClass(Class<? extends MerlinBase> decryptionCryptoClass) {
- this.decryptionCryptoClass = decryptionCryptoClass;
- }
-
- private Crypto cachedDecryptionCrypto;
- private KeyStore cachedDecryptionKeyStore;
-
- /**
- * returns the decryptionCrypto for the key-management
- *
- * @return A Crypto instance
- * @throws XMLSecurityException thrown if something goes wrong
- */
- public Crypto getDecryptionCrypto() throws XMLSecurityException {
-
- if (this.getDecryptionKeyStore() == null) {
- throw new XMLSecurityConfigurationException(XMLSecurityException.ErrorCode.FAILURE, "decryptionKeyStoreNotSet");
- }
-
- if (this.getDecryptionKeyStore() == cachedDecryptionKeyStore) {
- return cachedDecryptionCrypto;
- }
-
- Class<? extends MerlinBase> decryptionCryptoClass = this.getDecryptionCryptoClass();
-
- try {
- MerlinBase decryptionCrypto = decryptionCryptoClass.newInstance();
- decryptionCrypto.setKeyStore(this.getDecryptionKeyStore());
- cachedDecryptionCrypto = decryptionCrypto;
- cachedDecryptionKeyStore = this.getDecryptionKeyStore();
- return decryptionCrypto;
- } catch (Exception e) {
- throw new XMLSecurityConfigurationException(XMLSecurityException.ErrorCode.FAILURE, "decryptionCryptoFailure", e);
- }
- }
-
- /**
* returns the password callback handler
*
* @return
@@ -169,90 +87,12 @@ public class XMLSecurityProperties {
private XMLSecurityConstants.Action[] outAction;
- private Class<? extends MerlinBase> encryptionCryptoClass;
- private KeyStore encryptionKeyStore;
- private String encryptionUser;
private X509Certificate encryptionUseThisCertificate;
private String encryptionSymAlgorithm;
private String encryptionCompressionAlgorithm;
private String encryptionKeyTransportAlgorithm;
private final List<SecurePart> encryptionParts = new LinkedList<SecurePart>();
- /**
- * Returns the encryption keystore
- *
- * @return A keystore for encryption operation
- */
- public KeyStore getEncryptionKeyStore() {
- return encryptionKeyStore;
- }
-
- /**
- * loads a java keystore from the given url for encrypt operations
- *
- * @param url The URL to the keystore
- * @param keyStorePassword The keyStorePassword
- * @throws Exception thrown if something goes wrong while loading the keystore
- */
- public void loadEncryptionKeystore(URL url, char[] keyStorePassword) throws Exception {
- KeyStore keyStore = KeyStore.getInstance("jks");
- keyStore.load(url.openStream(), keyStorePassword);
- this.encryptionKeyStore = keyStore;
- }
-
- /**
- * Returns the encryption crypto class
- *
- * @return
- */
- public Class<? extends MerlinBase> getEncryptionCryptoClass() {
- if (encryptionCryptoClass != null) {
- return encryptionCryptoClass;
- }
- encryptionCryptoClass = org.apache.xml.security.stax.crypto.Merlin.class;
- return encryptionCryptoClass;
- }
-
- /**
- * Sets a custom encryption class
- *
- * @param encryptionCryptoClass
- */
- public void setEncryptionCryptoClass(Class<? extends MerlinBase> encryptionCryptoClass) {
- this.encryptionCryptoClass = encryptionCryptoClass;
- }
-
- private Crypto cachedEncryptionCrypto;
- private KeyStore cachedEncryptionKeyStore;
-
- /**
- * returns the encryptionCrypto for the key-management
- *
- * @return A Crypto instance
- * @throws XMLSecurityException thrown if something goes wrong
- */
- public Crypto getEncryptionCrypto() throws XMLSecurityException {
-
- if (this.getEncryptionKeyStore() == null) {
- throw new XMLSecurityConfigurationException(XMLSecurityException.ErrorCode.FAILURE, "encryptionKeyStoreNotSet");
- }
-
- if (this.getEncryptionKeyStore() == cachedEncryptionKeyStore) {
- return cachedEncryptionCrypto;
- }
-
- Class<? extends MerlinBase> encryptionCryptoClass = this.getEncryptionCryptoClass();
-
- try {
- MerlinBase encryptionCrypto = encryptionCryptoClass.newInstance();
- encryptionCrypto.setKeyStore(this.getEncryptionKeyStore());
- cachedEncryptionCrypto = encryptionCrypto;
- cachedEncryptionKeyStore = this.getEncryptionKeyStore();
- return encryptionCrypto;
- } catch (Exception e) {
- throw new XMLSecurityConfigurationException(XMLSecurityException.ErrorCode.FAILURE, "encryptionCryptoFailure", e);
- }
- }
/**
* Adds a part which must be encrypted by the framework
@@ -317,24 +157,6 @@ public class XMLSecurityProperties {
this.encryptionUseThisCertificate = encryptionUseThisCertificate;
}
- /**
- * Returns the alias for the encryption key in the keystore
- *
- * @return the alias for the encryption key in the keystore as string
- */
- public String getEncryptionUser() {
- return encryptionUser;
- }
-
- /**
- * Specifies the the alias for the encryption key in the keystore
- *
- * @param encryptionUser the the alias for the encryption key in the keystore as string
- */
- public void setEncryptionUser(String encryptionUser) {
- this.encryptionUser = encryptionUser;
- }
-
public String getEncryptionCompressionAlgorithm() {
return encryptionCompressionAlgorithm;
}
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/processor/input/AbstractDecryptInputProcessor.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/processor/input/AbstractDecryptInputProcessor.java?rev=1360242&r1=1360241&r2=1360242&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/processor/input/AbstractDecryptInputProcessor.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/processor/input/AbstractDecryptInputProcessor.java Wed Jul 11 15:53:50 2012
@@ -395,8 +395,8 @@ public abstract class AbstractDecryptInp
//retrieve the securityToken which must be used for decryption
return SecurityTokenFactory.getInstance().getSecurityToken(
- keyInfoType, getSecurityProperties().getDecryptionCrypto(),
- getSecurityProperties().getCallbackHandler(), getSecurityProperties(),
+ keyInfoType, SecurityToken.KeyInfoUsage.DECRYPTION,
+ getSecurityProperties(),
inputProcessorChain.getSecurityContext());
}
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/processor/input/XMLSignatureInputHandler.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/processor/input/XMLSignatureInputHandler.java?rev=1360242&r1=1360241&r2=1360242&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/processor/input/XMLSignatureInputHandler.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/processor/input/XMLSignatureInputHandler.java Wed Jul 11 15:53:50 2012
@@ -112,9 +112,8 @@ public class XMLSignatureInputHandler ex
protected SecurityToken retrieveSecurityToken(KeyInfoType keyInfoType,
XMLSecurityProperties securityProperties,
SecurityContext securityContext) throws XMLSecurityException {
- return SecurityTokenFactory.getInstance().getSecurityToken(keyInfoType,
- null,
- securityProperties.getCallbackHandler(),
+ return SecurityTokenFactory.getInstance().getSecurityToken(keyInfoType,
+ SecurityToken.KeyInfoUsage.SIGNATURE_VERIFICATION,
securityProperties,
securityContext);
}
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/securityToken/SecurityTokenFactory.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/securityToken/SecurityTokenFactory.java?rev=1360242&r1=1360241&r2=1360242&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/securityToken/SecurityTokenFactory.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/securityToken/SecurityTokenFactory.java Wed Jul 11 15:53:50 2012
@@ -20,14 +20,11 @@ package org.apache.xml.security.stax.imp
import org.apache.xml.security.binding.xmldsig.KeyInfoType;
import org.apache.xml.security.stax.config.ConfigurationProperties;
-import org.apache.xml.security.stax.crypto.Crypto;
import org.apache.xml.security.stax.ext.SecurityContext;
import org.apache.xml.security.stax.ext.SecurityToken;
import org.apache.xml.security.stax.ext.XMLSecurityException;
import org.apache.xml.security.stax.ext.XMLSecurityProperties;
-import javax.security.auth.callback.CallbackHandler;
-
/**
* Factory to create SecurityToken Objects from keys in XML
*
@@ -60,8 +57,8 @@ public abstract class SecurityTokenFacto
return securityTokenFactory;
}
- public abstract SecurityToken getSecurityToken(KeyInfoType keyInfoType, Crypto crypto,
- final CallbackHandler callbackHandler,
+ public abstract SecurityToken getSecurityToken(KeyInfoType keyInfoType,
+ SecurityToken.KeyInfoUsage keyInfoUsage,
XMLSecurityProperties securityProperties,
SecurityContext securityContext) throws XMLSecurityException;
}
Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/securityToken/SecurityTokenFactoryImpl.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/securityToken/SecurityTokenFactoryImpl.java?rev=1360242&r1=1360241&r2=1360242&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/securityToken/SecurityTokenFactoryImpl.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/stax/impl/securityToken/SecurityTokenFactoryImpl.java Wed Jul 11 15:53:50 2012
@@ -29,7 +29,6 @@ import org.apache.xml.security.binding.x
import org.apache.xml.security.binding.xmldsig.RSAKeyValueType;
import org.apache.xml.security.binding.xmldsig.X509DataType;
import org.apache.xml.security.binding.xmldsig11.ECKeyValueType;
-import org.apache.xml.security.stax.crypto.Crypto;
import org.apache.xml.security.stax.ext.SecurityContext;
import org.apache.xml.security.stax.ext.SecurityToken;
import org.apache.xml.security.stax.ext.XMLSecurityConstants;
@@ -52,15 +51,15 @@ public class SecurityTokenFactoryImpl ex
}
@Override
- public SecurityToken getSecurityToken(KeyInfoType keyInfoType, Crypto crypto,
- final CallbackHandler callbackHandler,
+ public SecurityToken getSecurityToken(KeyInfoType keyInfoType,
+ SecurityToken.KeyInfoUsage keyInfoUsage,
XMLSecurityProperties securityProperties,
SecurityContext securityContext) throws XMLSecurityException {
if (keyInfoType != null) {
final KeyValueType keyValueType
= XMLSecurityUtils.getQNameType(keyInfoType.getContent(), XMLSecurityConstants.TAG_dsig_KeyValue);
if (keyValueType != null) {
- return getSecurityToken(keyValueType, callbackHandler, securityContext);
+ return getSecurityToken(keyValueType, securityProperties.getCallbackHandler(), securityContext);
}
// TODO revisit
final X509DataType x509DataType =
@@ -68,7 +67,7 @@ public class SecurityTokenFactoryImpl ex
if (x509DataType != null) {
X509SecurityToken token =
new X509SecurityToken(XMLSecurityConstants.X509V3Token, securityContext,
- callbackHandler, "", XMLSecurityConstants.XMLKeyIdentifierType.X509_ISSUER_SERIAL);
+ securityProperties.getCallbackHandler(), "", XMLSecurityConstants.XMLKeyIdentifierType.X509_ISSUER_SERIAL);
token.setKey(securityProperties.getSignatureVerificationKey());
return token;
}
@@ -76,7 +75,7 @@ public class SecurityTokenFactoryImpl ex
// TODO revisit
SecretKeySecurityToken token =
- new SecretKeySecurityToken(securityContext, callbackHandler, "",
+ new SecretKeySecurityToken(securityContext, securityProperties.getCallbackHandler(), "",
XMLSecurityConstants.XMLKeyIdentifierType.KEY_VALUE);
token.setKey(securityProperties.getSignatureVerificationKey());
return token;