[jboss-svn-commits] JBL Code SVN: r22727 - in labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta: tests/src/org/jboss/soa/esb/services/security/auth/ws and 1 other directory.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Sat Sep 13 06:25:29 EDT 2008


Author: beve
Date: 2008-09-13 06:25:29 -0400 (Sat, 13 Sep 2008)
New Revision: 22727

Modified:
   labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/soa/esb/services/security/auth/ws/BinarySecurityToken.java
   labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/ws/BinarySecurityTokenTest.java
Log:
Removed the dependency on sun.misc.BASE64Decoder and replaced it with org.apache.commons.codec.binary.Base64.


Modified: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/soa/esb/services/security/auth/ws/BinarySecurityToken.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/soa/esb/services/security/auth/ws/BinarySecurityToken.java	2008-09-13 05:16:47 UTC (rev 22726)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/soa/esb/services/security/auth/ws/BinarySecurityToken.java	2008-09-13 10:25:29 UTC (rev 22727)
@@ -2,17 +2,17 @@
  * JBoss, Home of Professional Open Source Copyright 2008, Red Hat Middleware
  * LLC, and individual contributors by the @authors tag. See the copyright.txt
  * in the distribution for a full listing of individual contributors.
- * 
+ *
  * This is free software; you can redistribute it and/or modify it under the
  * terms of the GNU Lesser General Public License as published by the Free
  * Software Foundation; either version 2.1 of the License, or (at your option)
  * any later version.
- * 
+ *
  * This software is distributed in the hope that it will be useful, but WITHOUT
  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
  * details.
- * 
+ *
  * You should have received a copy of the GNU Lesser General Public License
  * along with this software; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
@@ -26,12 +26,12 @@
 import java.security.cert.CertificateException;
 import java.security.cert.CertificateFactory;
 
-import sun.misc.BASE64Decoder;
+import org.apache.commons.codec.binary.Base64;
 
 /**
  * Represents a WS-Security BinarySecurityToken.
  * <p/>
- * 
+ *
  * @author <a href="mailto:dbevenius at redhat.com">Daniel Bevenius</a>
  *
  */
@@ -41,32 +41,32 @@
 	private String valueType;
 	private Certificate cert;
 	private enum EncodingType { Base64Binary, HexBinary }
-	
+
 	public String getEncodingType()
 	{
 		return encodingType;
 	}
-	
+
 	public void setEncodingType(String encodingType)
 	{
 		this.encodingType = stripNS(encodingType);
 	}
-	
+
 	public String getValueType()
 	{
 		return valueType;
 	}
-	
+
 	public void setValueType(String valueType)
 	{
 		this.valueType = stripNS(valueType);
 	}
-	
+
 	public Certificate getKey()
 	{
 		return cert;
 	}
-	
+
 	public void setKey(final String key)
 	{
 		try
@@ -74,32 +74,28 @@
 			byte[] keyBytes = null;
 			if ( encodingType.equalsIgnoreCase( EncodingType.Base64Binary.toString() ) )
 			{
-    			BASE64Decoder decoder = new BASE64Decoder();
-    			keyBytes = decoder.decodeBuffer(key);
+			    Base64 decoder = new Base64();
+    			keyBytes = decoder.decode(key.getBytes());
 			}
 			else
 			{
 				keyBytes = key.getBytes();
 			}
-				
+
 			CertificateFactory factory = CertificateFactory.getInstance( certificateMatch( valueType ) );
 			cert = factory.generateCertificate( new ByteArrayInputStream( keyBytes ));
-		} 
+		}
 		catch (CertificateException e)
 		{
 			throw new IllegalStateException("Could not create certificate: ", e);
-		} 
-		catch (IOException e)
-		{
-			throw new IllegalStateException("Could not create certificate: ", e);
-		} 
+		}
 	}
-	
+
 	private String certificateMatch(final String valueType)
 	{
 		if ( valueType.startsWith("X509") )
 			return "X.509";
-		
+
 		return valueType;
 	}
 
@@ -122,5 +118,5 @@
 		}
 		return value;
 	}
-	
+
 }

Modified: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/ws/BinarySecurityTokenTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/ws/BinarySecurityTokenTest.java	2008-09-13 05:16:47 UTC (rev 22726)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/services/security/auth/ws/BinarySecurityTokenTest.java	2008-09-13 10:25:29 UTC (rev 22727)
@@ -2,17 +2,17 @@
  * JBoss, Home of Professional Open Source Copyright 2008, Red Hat Middleware
  * LLC, and individual contributors by the @authors tag. See the copyright.txt
  * in the distribution for a full listing of individual contributors.
- * 
+ *
  * This is free software; you can redistribute it and/or modify it under the
  * terms of the GNU Lesser General Public License as published by the Free
  * Software Foundation; either version 2.1 of the License, or (at your option)
  * any later version.
- * 
+ *
  * This software is distributed in the hope that it will be useful, but WITHOUT
  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
  * details.
- * 
+ *
  * You should have received a copy of the GNU Lesser General Public License
  * along with this software; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
@@ -24,6 +24,7 @@
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.security.cert.Certificate;
 
 import javax.xml.parsers.ParserConfigurationException;
 
@@ -37,7 +38,7 @@
 
 /**
  * Unittest for {@link BinarySecurityToken}
- * 
+ *
  * @author <a href="mailto:dbevenius at redhat.com">Daniel Bevenius</a>
  *
  */
@@ -46,28 +47,28 @@
 	private String expectedEncoding = "Base64Binary";
 	private String expectedValueType = "X509v3";
 	private BinarySecurityToken token = new BinarySecurityToken();
-	
+
 	@Test
 	public void setEncodingTypeWithNSPrefix()
 	{
 		token.setEncodingType("wsse:" + expectedEncoding);
 		assertEquals( expectedEncoding, token.getEncodingType() );
 	}
-	
+
 	@Test
 	public void setEncodingTypeWithNSPrefix2()
 	{
 		token.setEncodingType("d:" + expectedEncoding);
 		assertEquals( expectedEncoding, token.getEncodingType() );
 	}
-	
+
 	@Test
 	public void setEncodingTypeWithoutNSPrefix()
 	{
 		token.setEncodingType(expectedEncoding);
 		assertEquals( expectedEncoding, token.getEncodingType() );
 	}
-	
+
 	@Test
 	public void setEncodingTypeFullPath()
 	{
@@ -75,7 +76,7 @@
 		token.setEncodingType(url);
 		assertEquals( expectedEncoding, token.getEncodingType() );
 	}
-	
+
 	@Test
 	public void setValueType()
 	{
@@ -83,29 +84,31 @@
 		token.setValueType(url);
 		assertEquals( expectedValueType, token.getValueType() );
 	}
-	
+
 	@Test
 	public void setEncodingType()
 	{
 		token.setEncodingType(expectedEncoding);
 		assertEquals( expectedEncoding, token.getEncodingType() );
 	}
-	
+
 	@Test
 	public void setEncodingTypeNull()
 	{
 		token.setEncodingType(null);
 		assertNull(token.getEncodingType());
 	}
-	
+
 	@Test
 	public void setKey() throws ConfigurationException, SAXException, IOException, ParserConfigurationException
 	{
 		token.setEncodingType(expectedEncoding);
 		token.setValueType(expectedValueType);
 		token.setKey(getExampleCert());
+		Certificate key = token.getKey();
+		assertNotNull(key);
 	}
-	
+
 	private String getExampleCert() throws SAXException, IOException, ParserConfigurationException, ConfigurationException
 	{
 		InputStream inputStream = ClassUtil.getResourceAsStream("cert-example.xml", getClass() );




More information about the jboss-svn-commits mailing list