You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by co...@apache.org on 2017/08/04 11:58:06 UTC

cxf-fediz git commit: Used StandardCharsets in a few places

Repository: cxf-fediz
Updated Branches:
  refs/heads/master 935d02631 -> 947f73d11


Used StandardCharsets in a few places


Project: http://git-wip-us.apache.org/repos/asf/cxf-fediz/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf-fediz/commit/947f73d1
Tree: http://git-wip-us.apache.org/repos/asf/cxf-fediz/tree/947f73d1
Diff: http://git-wip-us.apache.org/repos/asf/cxf-fediz/diff/947f73d1

Branch: refs/heads/master
Commit: 947f73d11423de0d365cfa632695b3b83bd53f84
Parents: 935d026
Author: Colm O hEigeartaigh <co...@apache.org>
Authored: Fri Aug 4 12:57:52 2017 +0100
Committer: Colm O hEigeartaigh <co...@apache.org>
Committed: Fri Aug 4 12:57:52 2017 +0100

----------------------------------------------------------------------
 .../cxf/fediz/core/metadata/MetadataWriter.java |  3 +-
 .../fediz/core/processor/SAMLProcessorImpl.java |  5 ++-
 .../cxf/fediz/core/samlsso/SAMLRequestTest.java |  7 +--
 .../samlsso/SAMLResponseConformanceTest.java    |  3 +-
 .../fediz/core/samlsso/SAMLResponseTest.java    |  3 +-
 .../fediz/tomcat8/FederationAuthenticator.java  | 47 +++++++++++---------
 .../idp/beans/samlsso/AuthnRequestParser.java   |  2 +-
 .../idp/beans/samlsso/SamlResponseCreator.java  |  3 +-
 .../beans/samlsso/SamlResponseErrorCreator.java |  3 +-
 .../KerberosAuthenticationProcessingFilter.java |  3 +-
 .../TrustedIdpSAMLProtocolHandler.java          | 13 +++---
 .../cxf/fediz/samlsso/example/SamlSso.java      |  9 ++--
 12 files changed, 57 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/947f73d1/plugins/core/src/main/java/org/apache/cxf/fediz/core/metadata/MetadataWriter.java
----------------------------------------------------------------------
diff --git a/plugins/core/src/main/java/org/apache/cxf/fediz/core/metadata/MetadataWriter.java b/plugins/core/src/main/java/org/apache/cxf/fediz/core/metadata/MetadataWriter.java
index f5b2e77..5f5d121 100644
--- a/plugins/core/src/main/java/org/apache/cxf/fediz/core/metadata/MetadataWriter.java
+++ b/plugins/core/src/main/java/org/apache/cxf/fediz/core/metadata/MetadataWriter.java
@@ -26,6 +26,7 @@ import java.io.OutputStreamWriter;
 import java.io.Writer;
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.nio.charset.StandardCharsets;
 import java.security.cert.X509Certificate;
 import java.util.List;
 
@@ -67,7 +68,7 @@ public class MetadataWriter {
     ) throws ProcessingException {
 
         try (ByteArrayOutputStream bout = new ByteArrayOutputStream(4096)) {
-            Writer streamWriter = new OutputStreamWriter(bout, "UTF-8");
+            Writer streamWriter = new OutputStreamWriter(bout, StandardCharsets.UTF_8);
             XMLStreamWriter writer = XML_OUTPUT_FACTORY.createXMLStreamWriter(streamWriter);
 
             Protocol protocol = config.getProtocol();

http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/947f73d1/plugins/core/src/main/java/org/apache/cxf/fediz/core/processor/SAMLProcessorImpl.java
----------------------------------------------------------------------
diff --git a/plugins/core/src/main/java/org/apache/cxf/fediz/core/processor/SAMLProcessorImpl.java b/plugins/core/src/main/java/org/apache/cxf/fediz/core/processor/SAMLProcessorImpl.java
index 6233c60..7b2abc9 100644
--- a/plugins/core/src/main/java/org/apache/cxf/fediz/core/processor/SAMLProcessorImpl.java
+++ b/plugins/core/src/main/java/org/apache/cxf/fediz/core/processor/SAMLProcessorImpl.java
@@ -23,6 +23,7 @@ import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
 import java.security.PrivateKey;
 import java.security.Signature;
 import java.util.Date;
@@ -395,7 +396,7 @@ public class SAMLProcessorImpl extends AbstractFedizProcessor {
         sb.append("&" + SAMLSSOConstants.SIG_ALG).append('=').append(URLEncoder.encode(sigAlgo, "UTF-8"));
         String requestToSign = sb.toString();
 
-        signature.update(requestToSign.getBytes("UTF-8"));
+        signature.update(requestToSign.getBytes(StandardCharsets.UTF_8));
         byte[] signBytes = signature.sign();
 
         String encodedSignature = Base64.encode(signBytes);
@@ -406,7 +407,7 @@ public class SAMLProcessorImpl extends AbstractFedizProcessor {
     protected String encodeAuthnRequest(Element authnRequest) throws IOException {
         String requestMessage = DOM2Writer.nodeToString(authnRequest);
 
-        byte[] deflatedBytes = CompressionUtils.deflate(requestMessage.getBytes("UTF-8"));
+        byte[] deflatedBytes = CompressionUtils.deflate(requestMessage.getBytes(StandardCharsets.UTF_8));
 
         return Base64.encode(deflatedBytes);
     }

http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/947f73d1/plugins/core/src/test/java/org/apache/cxf/fediz/core/samlsso/SAMLRequestTest.java
----------------------------------------------------------------------
diff --git a/plugins/core/src/test/java/org/apache/cxf/fediz/core/samlsso/SAMLRequestTest.java b/plugins/core/src/test/java/org/apache/cxf/fediz/core/samlsso/SAMLRequestTest.java
index 33b5f47..517f874 100644
--- a/plugins/core/src/test/java/org/apache/cxf/fediz/core/samlsso/SAMLRequestTest.java
+++ b/plugins/core/src/test/java/org/apache/cxf/fediz/core/samlsso/SAMLRequestTest.java
@@ -24,6 +24,7 @@ import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.net.URL;
 import java.net.URLDecoder;
+import java.nio.charset.StandardCharsets;
 import java.util.Map;
 
 import javax.servlet.http.HttpServletRequest;
@@ -172,7 +173,7 @@ public class SAMLRequestTest {
         byte[] deflatedToken = Base64.decode(URLDecoder.decode(samlRequest, "UTF-8"));
         InputStream tokenStream = CompressionUtils.inflate(deflatedToken);
 
-        Document requestDoc = DOMUtils.readXml(new InputStreamReader(tokenStream, "UTF-8"));
+        Document requestDoc = DOMUtils.readXml(new InputStreamReader(tokenStream, StandardCharsets.UTF_8));
         AuthnRequest request =
             (AuthnRequest)OpenSAMLUtil.fromDom(requestDoc.getDocumentElement());
 
@@ -222,7 +223,7 @@ public class SAMLRequestTest {
         byte[] deflatedToken = Base64.decode(URLDecoder.decode(samlRequest, "UTF-8"));
         InputStream tokenStream = CompressionUtils.inflate(deflatedToken);
 
-        Document requestDoc = DOMUtils.readXml(new InputStreamReader(tokenStream, "UTF-8"));
+        Document requestDoc = DOMUtils.readXml(new InputStreamReader(tokenStream, StandardCharsets.UTF_8));
         LogoutRequest request =
             (LogoutRequest)OpenSAMLUtil.fromDom(requestDoc.getDocumentElement());
 
@@ -248,4 +249,4 @@ public class SAMLRequestTest {
             redirectionURL.substring(redirectionURL.indexOf("Signature=") + "Signature=".length());
         Assert.assertTrue(signature != null && signature.length() > 0);
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/947f73d1/plugins/core/src/test/java/org/apache/cxf/fediz/core/samlsso/SAMLResponseConformanceTest.java
----------------------------------------------------------------------
diff --git a/plugins/core/src/test/java/org/apache/cxf/fediz/core/samlsso/SAMLResponseConformanceTest.java b/plugins/core/src/test/java/org/apache/cxf/fediz/core/samlsso/SAMLResponseConformanceTest.java
index 5e93cc7..aa11e6c 100644
--- a/plugins/core/src/test/java/org/apache/cxf/fediz/core/samlsso/SAMLResponseConformanceTest.java
+++ b/plugins/core/src/test/java/org/apache/cxf/fediz/core/samlsso/SAMLResponseConformanceTest.java
@@ -23,6 +23,7 @@ import java.io.File;
 import java.io.IOException;
 import java.net.URL;
 import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
 import java.util.Collections;
 import java.util.UUID;
 
@@ -1217,7 +1218,7 @@ public class SAMLResponseConformanceTest {
     private String encodeResponse(Element response) throws IOException {
         String responseMessage = DOM2Writer.nodeToString(response);
 
-        byte[] deflatedBytes = CompressionUtils.deflate(responseMessage.getBytes("UTF-8"));
+        byte[] deflatedBytes = CompressionUtils.deflate(responseMessage.getBytes(StandardCharsets.UTF_8));
 
         return Base64.encode(deflatedBytes);
     }

http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/947f73d1/plugins/core/src/test/java/org/apache/cxf/fediz/core/samlsso/SAMLResponseTest.java
----------------------------------------------------------------------
diff --git a/plugins/core/src/test/java/org/apache/cxf/fediz/core/samlsso/SAMLResponseTest.java b/plugins/core/src/test/java/org/apache/cxf/fediz/core/samlsso/SAMLResponseTest.java
index 18add14..a0b3681 100644
--- a/plugins/core/src/test/java/org/apache/cxf/fediz/core/samlsso/SAMLResponseTest.java
+++ b/plugins/core/src/test/java/org/apache/cxf/fediz/core/samlsso/SAMLResponseTest.java
@@ -24,6 +24,7 @@ import java.io.IOException;
 import java.math.BigInteger;
 import java.net.URL;
 import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
 import java.util.Collections;
 import java.util.List;
 import java.util.UUID;
@@ -1379,7 +1380,7 @@ public class SAMLResponseTest {
     private String encodeResponse(Element response) throws IOException {
         String responseMessage = DOM2Writer.nodeToString(response);
 
-        byte[] deflatedBytes = CompressionUtils.deflate(responseMessage.getBytes("UTF-8"));
+        byte[] deflatedBytes = CompressionUtils.deflate(responseMessage.getBytes(StandardCharsets.UTF_8));
 
         return Base64.encode(deflatedBytes);
     }

http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/947f73d1/plugins/tomcat8/src/main/java/org/apache/cxf/fediz/tomcat8/FederationAuthenticator.java
----------------------------------------------------------------------
diff --git a/plugins/tomcat8/src/main/java/org/apache/cxf/fediz/tomcat8/FederationAuthenticator.java b/plugins/tomcat8/src/main/java/org/apache/cxf/fediz/tomcat8/FederationAuthenticator.java
index e3da1db..9981997 100644
--- a/plugins/tomcat8/src/main/java/org/apache/cxf/fediz/tomcat8/FederationAuthenticator.java
+++ b/plugins/tomcat8/src/main/java/org/apache/cxf/fediz/tomcat8/FederationAuthenticator.java
@@ -374,8 +374,20 @@ public class FederationAuthenticator extends FormAuthenticator {
     protected boolean checkUserAuthentication(Request request, HttpServletResponse response, FedizContext fedCtx) {
         // Have we already authenticated someone?
         Principal principal = request.getUserPrincipal();
+        Session session = request.getSessionInternal();
         // String ssoId = (String) request.getNote(Constants.REQ_SSOID_NOTE);
-        if (principal != null) {
+        if (principal != null && session != null) {
+            if (!session.isValid()) {
+                // Session has expired
+                LOG.warn("Session has expired. Clean up and redirect");
+
+                session.removeNote(FEDERATION_NOTE);
+                session.setPrincipal(null);
+                request.getSession().removeAttribute(SECURITY_TOKEN);
+
+                return false;
+            }
+
             LOG.debug("Already authenticated '{}'", principal.getName());
 
             // Associate the session with any existing SSO session
@@ -396,28 +408,23 @@ public class FederationAuthenticator extends FormAuthenticator {
 
     protected boolean validateToken(Request request, HttpServletResponse response, FedizContext fedConfig) {
         Session session = request.getSessionInternal();
-        if (session != null) {
+        FedizResponse wfRes = (FedizResponse)session.getNote(FEDERATION_NOTE);
+        Date tokenExpires = wfRes.getTokenExpires();
+        if (tokenExpires == null) {
+            LOG.debug("Token doesn't expire");
+            return true;
+        }
 
-            FedizResponse wfRes = (FedizResponse)session.getNote(FEDERATION_NOTE);
-            Date tokenExpires = wfRes.getTokenExpires();
-            if (tokenExpires == null) {
-                LOG.debug("Token doesn't expire");
-                return true;
-            }
+        Date currentTime = new Date();
+        if (!currentTime.after(tokenExpires)) {
+            return true;
+        }
 
-            Date currentTime = new Date();
-            if (!currentTime.after(tokenExpires)) {
-                return true;
-            } else {
-                LOG.warn("Token already expired. Clean up and redirect");
+        LOG.warn("Token already expired. Clean up and redirect");
 
-                session.removeNote(FEDERATION_NOTE);
-                session.setPrincipal(null);
-                request.getSession().removeAttribute(SECURITY_TOKEN);
-            }
-        } else {
-            LOG.debug("Session should not be null after authentication");
-        }
+        session.removeNote(FEDERATION_NOTE);
+        session.setPrincipal(null);
+        request.getSession().removeAttribute(SECURITY_TOKEN);
         return false;
     }
 

http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/947f73d1/services/idp-core/src/main/java/org/apache/cxf/fediz/service/idp/beans/samlsso/AuthnRequestParser.java
----------------------------------------------------------------------
diff --git a/services/idp-core/src/main/java/org/apache/cxf/fediz/service/idp/beans/samlsso/AuthnRequestParser.java b/services/idp-core/src/main/java/org/apache/cxf/fediz/service/idp/beans/samlsso/AuthnRequestParser.java
index 3bd4c53..3110eb1 100644
--- a/services/idp-core/src/main/java/org/apache/cxf/fediz/service/idp/beans/samlsso/AuthnRequestParser.java
+++ b/services/idp-core/src/main/java/org/apache/cxf/fediz/service/idp/beans/samlsso/AuthnRequestParser.java
@@ -181,7 +181,7 @@ public class AuthnRequestParser {
              ? new DeflateEncoderDecoder().inflateToken(deflatedToken)
                  : new ByteArrayInputStream(deflatedToken);
 
-        Document responseDoc = StaxUtils.read(new InputStreamReader(tokenStream, "UTF-8"));
+        Document responseDoc = StaxUtils.read(new InputStreamReader(tokenStream, StandardCharsets.UTF_8));
         AuthnRequest request =
             (AuthnRequest)OpenSAMLUtil.fromDom(responseDoc.getDocumentElement());
         if (LOG.isDebugEnabled()) {

http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/947f73d1/services/idp-core/src/main/java/org/apache/cxf/fediz/service/idp/beans/samlsso/SamlResponseCreator.java
----------------------------------------------------------------------
diff --git a/services/idp-core/src/main/java/org/apache/cxf/fediz/service/idp/beans/samlsso/SamlResponseCreator.java b/services/idp-core/src/main/java/org/apache/cxf/fediz/service/idp/beans/samlsso/SamlResponseCreator.java
index dadbe13..dd0d65e 100644
--- a/services/idp-core/src/main/java/org/apache/cxf/fediz/service/idp/beans/samlsso/SamlResponseCreator.java
+++ b/services/idp-core/src/main/java/org/apache/cxf/fediz/service/idp/beans/samlsso/SamlResponseCreator.java
@@ -19,6 +19,7 @@
 package org.apache.cxf.fediz.service.idp.beans.samlsso;
 
 import java.io.IOException;
+import java.nio.charset.StandardCharsets;
 import java.util.Collections;
 import java.util.List;
 
@@ -169,7 +170,7 @@ public class SamlResponseCreator {
 
         if (supportDeflateEncoding) {
             DeflateEncoderDecoder encoder = new DeflateEncoderDecoder();
-            byte[] deflatedBytes = encoder.deflateToken(responseMessage.getBytes("UTF-8"));
+            byte[] deflatedBytes = encoder.deflateToken(responseMessage.getBytes(StandardCharsets.UTF_8));
 
             return Base64Utility.encode(deflatedBytes);
         }

http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/947f73d1/services/idp-core/src/main/java/org/apache/cxf/fediz/service/idp/beans/samlsso/SamlResponseErrorCreator.java
----------------------------------------------------------------------
diff --git a/services/idp-core/src/main/java/org/apache/cxf/fediz/service/idp/beans/samlsso/SamlResponseErrorCreator.java b/services/idp-core/src/main/java/org/apache/cxf/fediz/service/idp/beans/samlsso/SamlResponseErrorCreator.java
index a35e3c2..761883a 100644
--- a/services/idp-core/src/main/java/org/apache/cxf/fediz/service/idp/beans/samlsso/SamlResponseErrorCreator.java
+++ b/services/idp-core/src/main/java/org/apache/cxf/fediz/service/idp/beans/samlsso/SamlResponseErrorCreator.java
@@ -19,6 +19,7 @@
 package org.apache.cxf.fediz.service.idp.beans.samlsso;
 
 import java.io.IOException;
+import java.nio.charset.StandardCharsets;
 
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -79,7 +80,7 @@ public class SamlResponseErrorCreator {
 
         if (supportDeflateEncoding) {
             DeflateEncoderDecoder encoder = new DeflateEncoderDecoder();
-            byte[] deflatedBytes = encoder.deflateToken(responseMessage.getBytes("UTF-8"));
+            byte[] deflatedBytes = encoder.deflateToken(responseMessage.getBytes(StandardCharsets.UTF_8));
 
             return Base64Utility.encode(deflatedBytes);
         }

http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/947f73d1/services/idp-core/src/main/java/org/apache/cxf/fediz/service/idp/kerberos/KerberosAuthenticationProcessingFilter.java
----------------------------------------------------------------------
diff --git a/services/idp-core/src/main/java/org/apache/cxf/fediz/service/idp/kerberos/KerberosAuthenticationProcessingFilter.java b/services/idp-core/src/main/java/org/apache/cxf/fediz/service/idp/kerberos/KerberosAuthenticationProcessingFilter.java
index 5594b58..10499c8 100644
--- a/services/idp-core/src/main/java/org/apache/cxf/fediz/service/idp/kerberos/KerberosAuthenticationProcessingFilter.java
+++ b/services/idp-core/src/main/java/org/apache/cxf/fediz/service/idp/kerberos/KerberosAuthenticationProcessingFilter.java
@@ -34,6 +34,7 @@
 package org.apache.cxf.fediz.service.idp.kerberos;
 
 import java.io.IOException;
+import java.nio.charset.StandardCharsets;
 
 import javax.servlet.FilterChain;
 import javax.servlet.ServletException;
@@ -98,7 +99,7 @@ public class KerberosAuthenticationProcessingFilter extends GenericFilterBean {
             if (logger.isDebugEnabled()) {
                 logger.debug("Received Negotiate Header for request " + request.getRequestURL() + ": " + header);
             }
-            byte[] base64Token = header.substring(10).getBytes("UTF-8");
+            byte[] base64Token = header.substring(10).getBytes(StandardCharsets.UTF_8);
             byte[] kerberosTicket = Base64.decode(base64Token);
             KerberosServiceRequestToken authenticationRequest = new KerberosServiceRequestToken(kerberosTicket);
             authenticationRequest.setDetails(authenticationDetailsSource.buildDetails(request));

http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/947f73d1/services/idp-core/src/main/java/org/apache/cxf/fediz/service/idp/protocols/TrustedIdpSAMLProtocolHandler.java
----------------------------------------------------------------------
diff --git a/services/idp-core/src/main/java/org/apache/cxf/fediz/service/idp/protocols/TrustedIdpSAMLProtocolHandler.java b/services/idp-core/src/main/java/org/apache/cxf/fediz/service/idp/protocols/TrustedIdpSAMLProtocolHandler.java
index 390ba96..49728d1 100644
--- a/services/idp-core/src/main/java/org/apache/cxf/fediz/service/idp/protocols/TrustedIdpSAMLProtocolHandler.java
+++ b/services/idp-core/src/main/java/org/apache/cxf/fediz/service/idp/protocols/TrustedIdpSAMLProtocolHandler.java
@@ -27,6 +27,7 @@ import java.io.UnsupportedEncodingException;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
 import java.security.PrivateKey;
 import java.security.Signature;
 import java.security.cert.X509Certificate;
@@ -221,7 +222,7 @@ public class TrustedIdpSAMLProtocolHandler extends AbstractTrustedIdpProtocolHan
         LOG.debug(requestMessage);
 
         DeflateEncoderDecoder encoder = new DeflateEncoderDecoder();
-        byte[] deflatedBytes = encoder.deflateToken(requestMessage.getBytes("UTF-8"));
+        byte[] deflatedBytes = encoder.deflateToken(requestMessage.getBytes(StandardCharsets.UTF_8));
 
         return Base64Utility.encode(deflatedBytes);
     }
@@ -275,7 +276,7 @@ public class TrustedIdpSAMLProtocolHandler extends AbstractTrustedIdpProtocolHan
             + SSOConstants.RELAY_STATE + "=" + relayState + "&"
             + SSOConstants.SIG_ALG + "=" + URLEncoder.encode(sigAlgo, "UTF-8");
 
-        signature.update(requestToSign.getBytes("UTF-8"));
+        signature.update(requestToSign.getBytes(StandardCharsets.UTF_8));
         byte[] signBytes = signature.sign();
 
         String encodedSignature = Base64.encode(signBytes);
@@ -303,16 +304,12 @@ public class TrustedIdpSAMLProtocolHandler extends AbstractTrustedIdpProtocolHan
                 throw ExceptionUtils.toBadRequestException(ex, null);
             }
         } else {
-            try {
-                tokenStream = new ByteArrayInputStream(samlResponseDecoded.getBytes("UTF-8"));
-            } catch (UnsupportedEncodingException ex) {
-                throw ExceptionUtils.toBadRequestException(ex, null);
-            }
+            tokenStream = new ByteArrayInputStream(samlResponseDecoded.getBytes(StandardCharsets.UTF_8));
         }
 
         Document responseDoc = null;
         try {
-            responseDoc = StaxUtils.read(new InputStreamReader(tokenStream, "UTF-8"));
+            responseDoc = StaxUtils.read(new InputStreamReader(tokenStream, StandardCharsets.UTF_8));
         } catch (Exception ex) {
             throw new WebApplicationException(400);
         }

http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/947f73d1/systests/federation/samlIdpWebapp/src/main/java/org/apache/cxf/fediz/samlsso/example/SamlSso.java
----------------------------------------------------------------------
diff --git a/systests/federation/samlIdpWebapp/src/main/java/org/apache/cxf/fediz/samlsso/example/SamlSso.java b/systests/federation/samlIdpWebapp/src/main/java/org/apache/cxf/fediz/samlsso/example/SamlSso.java
index 3ec6688..ff7f4d5 100644
--- a/systests/federation/samlIdpWebapp/src/main/java/org/apache/cxf/fediz/samlsso/example/SamlSso.java
+++ b/systests/federation/samlIdpWebapp/src/main/java/org/apache/cxf/fediz/samlsso/example/SamlSso.java
@@ -24,6 +24,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.UnsupportedEncodingException;
+import java.nio.charset.StandardCharsets;
 import java.util.Collections;
 import java.util.zip.DataFormatException;
 
@@ -172,9 +173,9 @@ public class SamlSso {
         byte[] deflatedBytes = null;
         if (redirect) {
             DeflateEncoderDecoder encoder = new DeflateEncoderDecoder();
-            deflatedBytes = encoder.deflateToken(responseMessage.getBytes("UTF-8"));
+            deflatedBytes = encoder.deflateToken(responseMessage.getBytes(StandardCharsets.UTF_8));
         } else {
-            deflatedBytes = responseMessage.getBytes("UTF-8");
+            deflatedBytes = responseMessage.getBytes(StandardCharsets.UTF_8);
         }
 
         return Base64Utility.encode(deflatedBytes);
@@ -186,7 +187,7 @@ public class SamlSso {
 
         InputStream tokenStream = new DeflateEncoderDecoder().inflateToken(deflatedToken);
 
-        Document responseDoc = StaxUtils.read(new InputStreamReader(tokenStream, "UTF-8"));
+        Document responseDoc = StaxUtils.read(new InputStreamReader(tokenStream, StandardCharsets.UTF_8));
         AuthnRequest request =
             (AuthnRequest)OpenSAMLUtil.fromDom(responseDoc.getDocumentElement());
         System.out.println(DOM2Writer.nodeToString(responseDoc));
@@ -196,7 +197,7 @@ public class SamlSso {
     protected javax.ws.rs.core.Response postBindingResponse(String relayState, String racs, String responseStr)
         throws IOException {
         InputStream inputStream = this.getClass().getResourceAsStream("/TemplateSAMLResponse.xml");
-        String responseTemplate = IOUtils.toString(inputStream, "UTF-8");
+        String responseTemplate = IOUtils.toString(inputStream, StandardCharsets.UTF_8.name());
         inputStream.close();
 
         // Perform Redirect to RACS