cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject git commit: Performance optimisation to avoid JAXB parsing just to log the Assertion ID...
Date Mon, 22 Sep 2014 15:53:38 GMT
Repository: cxf-fediz
Updated Branches:
  refs/heads/master a4123e44f -> cefaa41e7


Performance optimisation to avoid JAXB parsing just to log the Assertion ID...


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

Branch: refs/heads/master
Commit: cefaa41e7f501d5657da8e87014df0ea3a70e198
Parents: a4123e4
Author: Colm O hEigeartaigh <coheigea@apache.org>
Authored: Mon Sep 22 16:53:05 2014 +0100
Committer: Colm O hEigeartaigh <coheigea@apache.org>
Committed: Mon Sep 22 16:53:05 2014 +0100

----------------------------------------------------------------------
 .../service/idp/beans/STSClientAction.java      | 34 +++++++++++++-------
 1 file changed, 23 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/cefaa41e/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/STSClientAction.java
----------------------------------------------------------------------
diff --git a/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/STSClientAction.java
b/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/STSClientAction.java
index a7e51a6..948c557 100644
--- a/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/STSClientAction.java
+++ b/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/STSClientAction.java
@@ -52,7 +52,6 @@ import org.apache.cxf.staxutils.W3CDOMStreamWriter;
 import org.apache.cxf.ws.security.tokenstore.SecurityToken;
 import org.apache.cxf.ws.security.trust.STSClient;
 import org.apache.cxf.ws.security.trust.STSUtils;
-import org.apache.wss4j.common.saml.SamlAssertionWrapper;
 import org.apache.wss4j.dom.WSConstants;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -292,21 +291,34 @@ public class STSClientAction {
             }
             throw ex;
         }
-        
-        InputStream is = new ByteArrayInputStream(rpToken.getBytes());
-        Document doc = StaxUtils.read(is);
-        NodeList nd = doc.getElementsByTagName("saml2:Assertion");
-        if (nd.getLength() == 0) {
-            nd = doc.getElementsByTagName("saml1:Assertion");
-        }
-        Element e = (Element) nd.item(0);
-        SamlAssertionWrapper aw = new SamlAssertionWrapper(e);
-        String id = aw.getId();
 
+        String id = getIdFromToken(rpToken);
+        
         LOG.info("[RP_TOKEN={}] successfully created for realm [{}] on behalf of [IDP_TOKEN={}]",
                  id, wtrealm, idpToken.getId());
         return StringEscapeUtils.escapeXml11(rpToken);
     }
+    
+    private String getIdFromToken(String token) throws XMLStreamException {
+        InputStream is = new ByteArrayInputStream(token.getBytes());
+        Document doc = StaxUtils.read(is);
+        NodeList nd = doc.getElementsByTagNameNS(WSConstants.SAML2_NS, "Assertion");
+        
+        String identifier = "ID";
+        if (nd.getLength() == 0) {
+            nd = doc.getElementsByTagNameNS(WSConstants.SAML_NS, "Assertion");
+            identifier = "AssertionID";
+        }
+        
+        if (nd.getLength() > 0) {
+            Element e = (Element) nd.item(0);
+            if (e.hasAttributeNS(null, identifier)) {
+                return e.getAttributeNS(null, identifier);
+            }
+        }
+        
+        return "";
+    }
 
     private SecurityToken getSecurityToken(RequestContext context) throws ProcessingException
{
         String whr = (String) WebUtils.


Mime
View raw message