[WSS4J] wss4j/src/org/apache/ws/axis/security WSDoAllReceiver.java,1.12,1.13 WSDoAllSender.java,1.20,1.21

[email protected] Tue, 10 Feb 2004 13:13:30 -0800
Newsgroups gmane.text.xml.wss4j
Message-ID <[email protected]>
Update of /cvsroot/wss4j/wss4j/src/org/apache/ws/axis/security
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26216/src/org/apache/ws/axis/security

Modified Files:
	WSDoAllReceiver.java WSDoAllSender.java 
Log Message:
Patch for "Using wss4j from within a SecurityDomain" from "Jason Essington" <[email protected]> 


Index: WSDoAllReceiver.java
===================================================================
RCS file: /cvsroot/wss4j/wss4j/src/org/apache/ws/axis/security/WSDoAllReceiver.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- WSDoAllReceiver.java	10 Feb 2004 15:55:56 -0000	1.12
+++ WSDoAllReceiver.java	10 Feb 2004 21:13:12 -0000	1.13
@@ -263,41 +263,67 @@
 		}
 	} 
 	
-	private void decodeSignatureParameter() throws AxisFault {
+	/**
+	 * Hook to allow subclasses to load their Signature Crypto however they see fit.
+	 */
+	protected Crypto loadSignatureCrypto() throws AxisFault {
+		Crypto crypto = null;
 		if ((sigPropFile = (String) getOption(WSDoAllConstants.SIG_PROP_FILE))
 			== null) {
 			sigPropFile =
 				(String) msgContext.getProperty(WSDoAllConstants.SIG_PROP_FILE);
 		}
 		if (sigPropFile != null) {
-			if ((sigCrypto = (Crypto) cryptos.get(sigPropFile)) == null) {
-				sigCrypto = CryptoFactory.getInstance(sigPropFile);
-				cryptos.put(sigPropFile, sigCrypto);
+			if ((crypto = (Crypto) cryptos.get(sigPropFile)) == null) {
+				crypto = CryptoFactory.getInstance(sigPropFile);
+				cryptos.put(sigPropFile, crypto);
 			}
 		} else {
 			throw new AxisFault("WSDoAllReceiver: Signature: no crypto property file");
 		}
+		return crypto;
 	}
 	
-	/*
-	 * Set and check the decryption specific parameters, if necessary
-	 * take over signatur crypto instance.
-	 */ 
-
-	private void decodeDecryptionParameter() throws AxisFault {
+	/**
+	 * Hook to allow subclasses to load their Decryption Crypto however they see fit.
+	 */
+	protected Crypto loadDecryptionCrypto() throws AxisFault {
+		Crypto crypto = null;
 		if ((decPropFile = (String) getOption(WSDoAllConstants.DEC_PROP_FILE))
 			== null) {
 			decPropFile =
 				(String) msgContext.getProperty(WSDoAllConstants.DEC_PROP_FILE);
 		}
 		if (decPropFile != null) {
-			if ((decCrypto = (Crypto) cryptos.get(decPropFile)) == null) {
-				decCrypto = CryptoFactory.getInstance(decPropFile);
-				cryptos.put(decPropFile, decCrypto);
+			if ((crypto = (Crypto) cryptos.get(decPropFile)) == null) {
+				crypto = CryptoFactory.getInstance(decPropFile);
+				cryptos.put(decPropFile, crypto);
 			}
-		} else if ((decCrypto = sigCrypto) == null) {
+		} else if ((crypto = sigCrypto) == null) {
 			throw new AxisFault("WSDoAllReceiver: Encryption: no crypto property file");
 		}
+		return crypto;
+	}
+	
+	private void decodeSignatureParameter() throws AxisFault {
+		sigCrypto = loadSignatureCrypto();
+		/* There are currently no other signature parameters that need to be handled 
+		 * here, but we call the load crypto hook rather than just changing the visibility
+		 * of this method to maintain parity with WSDoAllSender.
+		 */
+	}
+	
+	/*
+	 * Set and check the decryption specific parameters, if necessary
+	 * take over signatur crypto instance.
+	 */ 
+
+	private void decodeDecryptionParameter() throws AxisFault {
+		decCrypto = loadDecryptionCrypto();
+		/* There are currently no other decryption parameters that need to be handled 
+		 * here, but we call the load crypto hook rather than just changing the visibility
+		 * of this method to maintain parity with WSDoAllSender.
+		 */
 	}
 
 	/**

Index: WSDoAllSender.java
===================================================================
RCS file: /cvsroot/wss4j/wss4j/src/org/apache/ws/axis/security/WSDoAllSender.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- WSDoAllSender.java	21 Jan 2004 12:14:42 -0000	1.20
+++ WSDoAllSender.java	10 Feb 2004 21:13:12 -0000	1.21
@@ -362,6 +362,7 @@
 					break;
 			}
 		}
+      
 		/*
 		 * If required convert the resulting document into a message first. 
 		 * The outputDOM() method performs the necessary c14n call. After 
@@ -399,6 +400,58 @@
 		}
 	}
 	
+	/**
+	 * Hook to allow subclasses to load their Signature Crypto however they see fit.
+	 */
+	protected Crypto loadSignatureCrypto() throws AxisFault {
+		Crypto crypto = null;
+		/*
+		 * Get crypto property file for signature. If none specified
+		 * throw fault, otherwise get a crypto instance.
+		 */
+		String sigPropFile = null;
+		if ((sigPropFile = (String) getOption(WSDoAllConstants.SIG_PROP_FILE))
+		== null) {
+			sigPropFile =
+				(String) msgContext.getProperty(WSDoAllConstants.SIG_PROP_FILE);
+		}
+		if (sigPropFile != null) {
+			if ((crypto = (Crypto) cryptos.get(sigPropFile)) == null) {
+				crypto = CryptoFactory.getInstance(sigPropFile);
+				cryptos.put(sigPropFile, crypto);
+			}
+		} else {
+			throw new AxisFault("WSDoAllSender: Signature: no crypto property file");
+		}
+		return crypto;
+	}
+	
+	/**
+	 * Hook to allow subclasses to load their Encryption Crypto however they see fit.
+	 */
+	protected Crypto loadEncryptionCrypto() throws AxisFault {
+		Crypto crypto = null;
+		/*
+		 * Get encryption crypto property file. If non specified
+		 * take crypto instance from signature, if that fails: throw fault
+		 */
+		String encPropFile = null;
+		if ((encPropFile = (String) getOption(WSDoAllConstants.ENC_PROP_FILE))
+		== null) {
+			encPropFile =
+				(String) msgContext.getProperty(WSDoAllConstants.ENC_PROP_FILE);
+		}
+		if (encPropFile != null) {
+			if ((crypto = (Crypto) cryptos.get(encPropFile)) == null) {
+				crypto = CryptoFactory.getInstance(encPropFile);
+				cryptos.put(encPropFile, crypto);
+			}
+		} else if ((crypto = sigCrypto) == null) {
+			throw new AxisFault("WSDoAllSender: Encryption: no crypto property file");
+		}
+		return crypto;
+	}
+	
 	private void decodeUTParameter() throws AxisFault {
 		if ((pwType = (String) getOption(WSDoAllConstants.PASSWORD_TYPE))
 			== null) {
@@ -417,25 +470,8 @@
 	}
 
 	private void decodeSignatureParameter() throws AxisFault {
-		/*
-		 * Get crypto property file for signature. If none specified
-		 * throw fault, otherwise get a crypto instance.
-		 */
-		String sigPropFile = null;
-		if ((sigPropFile = (String) getOption(WSDoAllConstants.SIG_PROP_FILE))
-			== null) {
-			sigPropFile =
-				(String) msgContext.getProperty(WSDoAllConstants.SIG_PROP_FILE);
-		}
-		if (sigPropFile != null) {
-			if ((sigCrypto = (Crypto) cryptos.get(sigPropFile)) == null) {
-				sigCrypto = CryptoFactory.getInstance(sigPropFile);
-				cryptos.put(sigPropFile, sigCrypto);
-			}
-		} else {
-			throw new AxisFault("WSDoAllSender: Signature: no crypto property file");
-		}
 
+		sigCrypto = loadSignatureCrypto();
 		String tmpS = null;
 		if ((tmpS = (String) getOption(WSDoAllConstants.SIG_KEY_ID)) == null) {
 			tmpS = (String) msgContext.getProperty(WSDoAllConstants.SIG_KEY_ID);
@@ -468,25 +504,7 @@
 	}
 	
 	private void decodeEncryptionParameter() throws AxisFault {
-		/*
-		 * Get encryption crypto property file. If non specified
-		 * take crypto instance from signature, if that fails: throw fault
-		 */
-		String encPropFile = null;
-		if ((encPropFile = (String) getOption(WSDoAllConstants.ENC_PROP_FILE))
-			== null) {
-			encPropFile =
-				(String) msgContext.getProperty(WSDoAllConstants.ENC_PROP_FILE);
-		}
-		if (encPropFile != null) {
-			if ((encCrypto = (Crypto) cryptos.get(encPropFile)) == null) {
-				encCrypto = CryptoFactory.getInstance(encPropFile);
-				cryptos.put(encPropFile, encCrypto);
-			}
-		} else if ((encCrypto = sigCrypto) == null) {
-			throw new AxisFault("WSDoAllSender: Encryption: no crypto property file");
-		}
-
+		encCrypto = loadEncryptionCrypto();
 		if ((encUser = (String) getOption(WSDoAllConstants.ENCRYPTION_USER))
 			== null) {
 			encUser =



-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn