You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by co...@apache.org on 2018/04/17 09:36:54 UTC

svn commit: r1829349 [2/2] - in /webservices/wss4j/trunk: integration/src/test/java/org/apache/wss4j/integration/test/kerberos/ parent/ ws-security-common/src/main/java/org/apache/wss4j/common/saml/ ws-security-common/src/main/java/org/apache/wss4j/com...

Modified: webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/utils/WSSUtils.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/utils/WSSUtils.java?rev=1829349&r1=1829348&r2=1829349&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/utils/WSSUtils.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/utils/WSSUtils.java Tue Apr 17 09:36:53 2018
@@ -29,7 +29,6 @@ import java.security.cert.CertificateFac
 import java.security.cert.X509Certificate;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Base64;
 import java.util.Iterator;
 import java.util.List;
 
@@ -68,6 +67,7 @@ import org.apache.xml.security.stax.impl
 import org.apache.xml.security.stax.securityEvent.TokenSecurityEvent;
 import org.apache.xml.security.stax.securityToken.InboundSecurityToken;
 import org.apache.xml.security.stax.securityToken.SecurityToken;
+import org.apache.xml.security.utils.XMLUtils;
 
 public class WSSUtils extends XMLSecurityUtils {
 
@@ -131,7 +131,7 @@ public class WSSUtils extends XMLSecurit
             MessageDigest sha = MessageDigest.getInstance("SHA-1");
             sha.reset();
             sha.update(b4);
-            return Base64.getMimeEncoder().encodeToString(sha.digest());
+            return XMLUtils.encodeToString(sha.digest());
         } catch (NoSuchAlgorithmException e) {
             throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, e, "decoding.general");
         }
@@ -253,14 +253,14 @@ public class WSSUtils extends XMLSecurit
         try {
             if (useSingleCertificate) {
                 String encodedCert =
-                    Base64.getMimeEncoder().encodeToString(x509Certificates[0].getEncoded());
+                    XMLUtils.encodeToString(x509Certificates[0].getEncoded());
                 abstractOutputProcessor.createCharactersAndOutputAsEvent(outputProcessorChain, encodedCert);
             } else {
                 try {
                     CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
                     List<X509Certificate> certificates = Arrays.asList(x509Certificates);
                     String encodedCert =
-                        Base64.getMimeEncoder().encodeToString(certificateFactory.generateCertPath(certificates).getEncoded());
+                        XMLUtils.encodeToString(certificateFactory.generateCertPath(certificates).getEncoded());
                     abstractOutputProcessor.createCharactersAndOutputAsEvent(outputProcessorChain, encodedCert);
                 } catch (CertificateException e) {
                     throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, e);
@@ -292,7 +292,7 @@ public class WSSUtils extends XMLSecurit
                                                                    false, attributes);
         byte[] data = new Merlin().getSKIBytesFromCert(x509Certificates[0]);
         abstractOutputProcessor.createCharactersAndOutputAsEvent(outputProcessorChain,
-                                                                 Base64.getMimeEncoder().encodeToString(data));
+                                                                 XMLUtils.encodeToString(data));
         abstractOutputProcessor.createEndElementAndOutputAsEvent(outputProcessorChain,
                                                                  WSSConstants.TAG_WSSE_KEY_IDENTIFIER);
     }
@@ -310,7 +310,7 @@ public class WSSUtils extends XMLSecurit
                                                                    WSSConstants.TAG_WSSE_KEY_IDENTIFIER,
                                                                    false, attributes);
         try {
-            String encodedCert = Base64.getMimeEncoder().encodeToString(x509Certificates[0].getEncoded());
+            String encodedCert = XMLUtils.encodeToString(x509Certificates[0].getEncoded());
             abstractOutputProcessor.createCharactersAndOutputAsEvent(outputProcessorChain, encodedCert);
         } catch (CertificateEncodingException e) {
             throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, e);
@@ -335,7 +335,7 @@ public class WSSUtils extends XMLSecurit
             MessageDigest sha = MessageDigest.getInstance("SHA-1");
             byte[] data = sha.digest(x509Certificates[0].getEncoded());
             abstractOutputProcessor.createCharactersAndOutputAsEvent(outputProcessorChain,
-                                                                     Base64.getMimeEncoder().encodeToString(data));
+                                                                     XMLUtils.encodeToString(data));
         } catch (CertificateEncodingException | NoSuchAlgorithmException e) {
             throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, e);
         }
@@ -350,7 +350,7 @@ public class WSSUtils extends XMLSecurit
             MessageDigest sha = MessageDigest.getInstance("SHA-1");
             byte[] data = sha.digest(key.getEncoded());
             createEncryptedKeySha1IdentifierStructure(abstractOutputProcessor, outputProcessorChain,
-                                                      Base64.getMimeEncoder().encodeToString(data));
+                                                      XMLUtils.encodeToString(data));
         } catch (NoSuchAlgorithmException e) {
             throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, e);
         }

Modified: webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/validate/BinarySecurityTokenValidatorImpl.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/validate/BinarySecurityTokenValidatorImpl.java?rev=1829349&r1=1829348&r2=1829349&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/validate/BinarySecurityTokenValidatorImpl.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/validate/BinarySecurityTokenValidatorImpl.java Tue Apr 17 09:36:53 2018
@@ -18,8 +18,6 @@
  */
 package org.apache.wss4j.stax.validate;
 
-import java.util.Base64;
-
 import org.apache.wss4j.binding.wss10.BinarySecurityTokenType;
 import org.apache.wss4j.common.crypto.Crypto;
 import org.apache.wss4j.common.ext.WSSecurityException;
@@ -32,6 +30,7 @@ import org.apache.wss4j.stax.impl.securi
 import org.apache.wss4j.stax.impl.securityToken.X509PKIPathv1SecurityTokenImpl;
 import org.apache.xml.security.exceptions.XMLSecurityException;
 import org.apache.xml.security.stax.securityToken.InboundSecurityToken;
+import org.apache.xml.security.utils.XMLUtils;
 
 public class BinarySecurityTokenValidatorImpl implements BinarySecurityTokenValidator {
 
@@ -50,7 +49,7 @@ public class BinarySecurityTokenValidato
                     new Object[] {binarySecurityTokenType.getEncodingType()});
         }
 
-        byte[] securityTokenData = Base64.getMimeDecoder().decode(binarySecurityTokenType.getValue());
+        byte[] securityTokenData = XMLUtils.decode(binarySecurityTokenType.getValue());
 
         try {
             if (WSSConstants.NS_X509_V3_TYPE.equals(binarySecurityTokenType.getValueType())) {

Modified: webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/validate/JAASUsernameTokenValidatorImpl.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/validate/JAASUsernameTokenValidatorImpl.java?rev=1829349&r1=1829348&r2=1829349&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/validate/JAASUsernameTokenValidatorImpl.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/validate/JAASUsernameTokenValidatorImpl.java Tue Apr 17 09:36:53 2018
@@ -18,8 +18,6 @@
  */
 package org.apache.wss4j.stax.validate;
 
-import java.util.Base64;
-
 import javax.security.auth.Subject;
 import javax.security.auth.callback.CallbackHandler;
 import javax.security.auth.login.LoginContext;
@@ -37,6 +35,7 @@ import org.apache.wss4j.stax.securityTok
 import org.apache.wss4j.stax.impl.securityToken.UsernameSecurityTokenImpl;
 import org.apache.xml.security.stax.ext.XMLSecurityUtils;
 import org.apache.xml.security.stax.securityToken.InboundSecurityToken;
+import org.apache.xml.security.utils.XMLUtils;
 
 /**
  * This class validates a processed UsernameToken, where Username/password validation is delegated
@@ -107,7 +106,7 @@ public class JAASUsernameTokenValidatorI
             if (!WSSConstants.SOAPMESSAGE_NS10_BASE64_ENCODING.equals(encodedNonce.getEncodingType())) {
                 throw new WSSecurityException(WSSecurityException.ErrorCode.UNSUPPORTED_SECURITY_TOKEN, "badTokenType01");
             }
-            nonceVal = Base64.getMimeDecoder().decode(encodedNonce.getValue());
+            nonceVal = XMLUtils.decode(encodedNonce.getValue());
         }
 
         final AttributedDateTime attributedDateTimeCreated =

Modified: webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/validate/UsernameTokenValidatorImpl.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/validate/UsernameTokenValidatorImpl.java?rev=1829349&r1=1829348&r2=1829349&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/validate/UsernameTokenValidatorImpl.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/validate/UsernameTokenValidatorImpl.java Tue Apr 17 09:36:53 2018
@@ -18,8 +18,6 @@
  */
 package org.apache.wss4j.stax.validate;
 
-import java.util.Base64;
-
 import org.apache.wss4j.binding.wss10.AttributedString;
 import org.apache.wss4j.binding.wss10.EncodedString;
 import org.apache.wss4j.binding.wss10.PasswordString;
@@ -34,6 +32,7 @@ import org.apache.wss4j.stax.utils.WSSUt
 import org.apache.wss4j.stax.impl.securityToken.UsernameSecurityTokenImpl;
 import org.apache.xml.security.stax.ext.XMLSecurityUtils;
 import org.apache.xml.security.stax.securityToken.InboundSecurityToken;
+import org.apache.xml.security.utils.XMLUtils;
 
 public class UsernameTokenValidatorImpl implements UsernameTokenValidator {
 
@@ -90,7 +89,7 @@ public class UsernameTokenValidatorImpl
                 XMLSecurityUtils.getQNameType(usernameTokenType.getAny(), WSSConstants.TAG_WSSE_NONCE);
         byte[] nonceVal = null;
         if (encodedNonce != null && encodedNonce.getValue() != null) {
-            nonceVal = Base64.getMimeDecoder().decode(encodedNonce.getValue());
+            nonceVal = XMLUtils.decode(encodedNonce.getValue());
         }
 
         final AttributedDateTime attributedDateTimeCreated =

Modified: webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/EncDecryptionTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/EncDecryptionTest.java?rev=1829349&r1=1829348&r2=1829349&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/EncDecryptionTest.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/EncDecryptionTest.java Tue Apr 17 09:36:53 2018
@@ -27,7 +27,6 @@ import java.security.KeyStore;
 import java.security.Security;
 import java.security.cert.X509Certificate;
 import java.util.ArrayList;
-import java.util.Base64;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -79,6 +78,7 @@ import org.apache.xml.security.stax.secu
 import org.apache.xml.security.stax.securityEvent.EncryptedElementSecurityEvent;
 import org.apache.xml.security.stax.securityEvent.SecurityEvent;
 import org.apache.xml.security.stax.securityEvent.SecurityEventConstants;
+import org.apache.xml.security.utils.XMLUtils;
 import org.bouncycastle.jce.provider.BouncyCastleProvider;
 import org.junit.Assert;
 import org.junit.Test;
@@ -2189,7 +2189,7 @@ public class EncDecryptionTest extends A
                 securityProperties.setEncryptionKeyTransportAlgorithm("http://www.w3.org/2009/xmlenc11#rsa-oaep");
                 securityProperties.setEncryptionKeyTransportDigestAlgorithm("http://www.w3.org/2001/04/xmldsig-more#sha384");
                 securityProperties.setEncryptionKeyTransportMGFAlgorithm("http://www.w3.org/2009/xmlenc11#mgf1sha384");
-                securityProperties.setEncryptionKeyTransportOAEPParams(Base64.getMimeDecoder().decode("ZHVtbXkxMjM=".getBytes(StandardCharsets.UTF_8)));
+                securityProperties.setEncryptionKeyTransportOAEPParams(XMLUtils.decode("ZHVtbXkxMjM=".getBytes(StandardCharsets.UTF_8)));
 
                 InputStream sourceDocument = this.getClass().getClassLoader().getResourceAsStream("testdata/plain-soap-1.1.xml");
                 baos = doOutboundSecurity(securityProperties, sourceDocument);

Modified: webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/ReplayTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/ReplayTest.java?rev=1829349&r1=1829348&r2=1829349&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/ReplayTest.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/ReplayTest.java Tue Apr 17 09:36:53 2018
@@ -21,7 +21,6 @@ package org.apache.wss4j.stax.test;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.InputStream;
-import java.util.Base64;
 import java.util.Properties;
 
 import javax.xml.stream.XMLStreamException;
@@ -44,6 +43,7 @@ import org.apache.wss4j.stax.test.saml.S
 import org.apache.wss4j.stax.test.utils.StAX2DOM;
 import org.apache.wss4j.stax.validate.SamlTokenValidatorImpl;
 import org.apache.xml.security.exceptions.XMLSecurityException;
+import org.apache.xml.security.utils.XMLUtils;
 import org.junit.Assert;
 import org.junit.Test;
 import org.w3c.dom.Document;
@@ -56,7 +56,7 @@ public class ReplayTest extends Abstract
         byte[] nonceValue;
         try {
             nonceValue = WSSConstants.generateBytes(10);
-            String cacheKey = key + Base64.getEncoder().encodeToString(nonceValue);
+            String cacheKey = key + XMLUtils.encodeToString(nonceValue);
             return replayCacheFactory.newReplayCache(cacheKey, null);
         } catch (XMLSecurityException e) {
             throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, e);

Modified: webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/UsernameTokenTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/UsernameTokenTest.java?rev=1829349&r1=1829348&r2=1829349&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/UsernameTokenTest.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/UsernameTokenTest.java Tue Apr 17 09:36:53 2018
@@ -25,7 +25,6 @@ import java.nio.charset.StandardCharsets
 import java.time.ZoneOffset;
 import java.time.ZonedDateTime;
 import java.util.ArrayList;
-import java.util.Base64;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -57,6 +56,7 @@ import org.apache.wss4j.stax.test.utils.
 import org.apache.xml.security.exceptions.XMLSecurityException;
 import org.apache.xml.security.stax.securityEvent.SecurityEvent;
 import org.apache.xml.security.stax.securityEvent.SecurityEventListener;
+import org.apache.xml.security.utils.XMLUtils;
 import org.junit.Assert;
 import org.junit.Test;
 import org.w3c.dom.Document;
@@ -832,7 +832,7 @@ public class UsernameTokenTest extends A
         byte[] nonceValue;
         try {
             nonceValue = WSSConstants.generateBytes(10);
-            String cacheKey = key + Base64.getEncoder().encodeToString(nonceValue);
+            String cacheKey = key + XMLUtils.encodeToString(nonceValue);
             return replayCacheFactory.newReplayCache(cacheKey, null);
         } catch (XMLSecurityException e) {
             throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, e);

Modified: webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/utils/SecretKeyCallbackHandler.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/utils/SecretKeyCallbackHandler.java?rev=1829349&r1=1829348&r2=1829349&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/utils/SecretKeyCallbackHandler.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/utils/SecretKeyCallbackHandler.java Tue Apr 17 09:36:53 2018
@@ -22,13 +22,13 @@ package org.apache.wss4j.stax.test.utils
 import org.apache.wss4j.common.ext.WSPasswordCallback;
 import org.apache.wss4j.common.ext.WSSecurityException;
 import org.apache.wss4j.common.util.KeyUtils;
+import org.apache.xml.security.utils.XMLUtils;
 
 import javax.security.auth.callback.Callback;
 import javax.security.auth.callback.CallbackHandler;
 import javax.security.auth.callback.UnsupportedCallbackException;
 
 import java.io.IOException;
-import java.util.Base64;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -68,7 +68,7 @@ public class SecretKeyCallbackHandler im
     public void setOutboundSecret(byte[] secret) throws WSSecurityException {
         outboundSecret = secret;
         byte[] encodedBytes = KeyUtils.generateDigest(outboundSecret);
-        String identifier = Base64.getMimeEncoder().encodeToString(encodedBytes);
+        String identifier = XMLUtils.encodeToString(encodedBytes);
         addSecretKey(identifier, outboundSecret);
     }
 }