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/03 16:54:07 UTC

[1/2] cxf git commit: Allow custom JAXB Elements in an STS RST

Repository: cxf
Updated Branches:
  refs/heads/master 6d185c2c9 -> d28828e47


Allow custom JAXB Elements in an STS RST


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

Branch: refs/heads/master
Commit: 08f3d92d6c1f5fe02495821fd91cfde51f7ec179
Parents: 6d185c2
Author: Colm O hEigeartaigh <co...@apache.org>
Authored: Thu Aug 3 17:29:05 2017 +0100
Committer: Colm O hEigeartaigh <co...@apache.org>
Committed: Thu Aug 3 17:29:05 2017 +0100

----------------------------------------------------------------------
 .../org/apache/cxf/sts/request/RequestParser.java | 18 +++++++++++-------
 .../apache/cxf/sts/request/TokenRequirements.java | 13 +++++++++++++
 2 files changed, 24 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/08f3d92d/services/sts/sts-core/src/main/java/org/apache/cxf/sts/request/RequestParser.java
----------------------------------------------------------------------
diff --git a/services/sts/sts-core/src/main/java/org/apache/cxf/sts/request/RequestParser.java b/services/sts/sts-core/src/main/java/org/apache/cxf/sts/request/RequestParser.java
index fdd3169..ca91aae 100644
--- a/services/sts/sts-core/src/main/java/org/apache/cxf/sts/request/RequestParser.java
+++ b/services/sts/sts-core/src/main/java/org/apache/cxf/sts/request/RequestParser.java
@@ -120,13 +120,17 @@ public class RequestParser {
                         found = parseKeyRequirements(jaxbElement, keyRequirements, messageContext, stsProperties);
                     }
                     if (!found) {
-                        LOG.log(
-                            Level.WARNING,
-                            "Found a JAXB object of unknown type: " + jaxbElement.getName()
-                        );
-                        throw new STSException(
-                            "An unknown element was received", STSException.BAD_REQUEST
-                        );
+                        if (allowCustomContent) {
+                            tokenRequirements.addCustomContentJAXB(jaxbElement);
+                        } else {
+                            LOG.log(
+                                Level.WARNING,
+                                "Found a JAXB object of unknown type: " + jaxbElement.getName()
+                            );
+                            throw new STSException(
+                                "An unknown element was received", STSException.BAD_REQUEST
+                            );
+                        }
                     }
                 } catch (STSException ex) {
                     LOG.log(Level.WARNING, "", ex);

http://git-wip-us.apache.org/repos/asf/cxf/blob/08f3d92d/services/sts/sts-core/src/main/java/org/apache/cxf/sts/request/TokenRequirements.java
----------------------------------------------------------------------
diff --git a/services/sts/sts-core/src/main/java/org/apache/cxf/sts/request/TokenRequirements.java b/services/sts/sts-core/src/main/java/org/apache/cxf/sts/request/TokenRequirements.java
index a89b205..3021fca 100644
--- a/services/sts/sts-core/src/main/java/org/apache/cxf/sts/request/TokenRequirements.java
+++ b/services/sts/sts-core/src/main/java/org/apache/cxf/sts/request/TokenRequirements.java
@@ -22,6 +22,8 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
+import javax.xml.bind.JAXBElement;
+
 import org.w3c.dom.Element;
 
 import org.apache.cxf.rt.security.claims.ClaimCollection;
@@ -46,6 +48,7 @@ public class TokenRequirements {
     private Renewing renewing;
     private Participants participants;
     private final List<Element> customContent = new ArrayList<>();
+    private final List<JAXBElement<?>> customContentJAXB = new ArrayList<>();
 
     public Renewing getRenewing() {
         return renewing;
@@ -161,4 +164,14 @@ public class TokenRequirements {
         }
     }
 
+    public List<JAXBElement<?>> getCustomContentJAXB() {
+        return Collections.unmodifiableList(customContentJAXB);
+    }
+
+    public void addCustomContentJAXB(JAXBElement<?> jaxbElement) {
+        if (jaxbElement != null) {
+            this.customContentJAXB.add(jaxbElement);
+        }
+    }
+
 }
\ No newline at end of file


[2/2] cxf git commit: Switch to a single custom content list for master

Posted by co...@apache.org.
Switch to a single custom content list for master


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

Branch: refs/heads/master
Commit: d28828e47a06da5ad81de62dcb74b1d9dbc2370d
Parents: 08f3d92
Author: Colm O hEigeartaigh <co...@apache.org>
Authored: Thu Aug 3 17:53:56 2017 +0100
Committer: Colm O hEigeartaigh <co...@apache.org>
Committed: Thu Aug 3 17:53:56 2017 +0100

----------------------------------------------------------------------
 .../apache/cxf/sts/request/RequestParser.java    |  2 +-
 .../cxf/sts/request/TokenRequirements.java       | 19 +++----------------
 .../systest/sts/custom/CustomClaimsHandler.java  |  8 ++++++--
 3 files changed, 10 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/d28828e4/services/sts/sts-core/src/main/java/org/apache/cxf/sts/request/RequestParser.java
----------------------------------------------------------------------
diff --git a/services/sts/sts-core/src/main/java/org/apache/cxf/sts/request/RequestParser.java b/services/sts/sts-core/src/main/java/org/apache/cxf/sts/request/RequestParser.java
index ca91aae..960b9b7 100644
--- a/services/sts/sts-core/src/main/java/org/apache/cxf/sts/request/RequestParser.java
+++ b/services/sts/sts-core/src/main/java/org/apache/cxf/sts/request/RequestParser.java
@@ -121,7 +121,7 @@ public class RequestParser {
                     }
                     if (!found) {
                         if (allowCustomContent) {
-                            tokenRequirements.addCustomContentJAXB(jaxbElement);
+                            tokenRequirements.addCustomContent(jaxbElement);
                         } else {
                             LOG.log(
                                 Level.WARNING,

http://git-wip-us.apache.org/repos/asf/cxf/blob/d28828e4/services/sts/sts-core/src/main/java/org/apache/cxf/sts/request/TokenRequirements.java
----------------------------------------------------------------------
diff --git a/services/sts/sts-core/src/main/java/org/apache/cxf/sts/request/TokenRequirements.java b/services/sts/sts-core/src/main/java/org/apache/cxf/sts/request/TokenRequirements.java
index 3021fca..2f96bb8 100644
--- a/services/sts/sts-core/src/main/java/org/apache/cxf/sts/request/TokenRequirements.java
+++ b/services/sts/sts-core/src/main/java/org/apache/cxf/sts/request/TokenRequirements.java
@@ -22,8 +22,6 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
-import javax.xml.bind.JAXBElement;
-
 import org.w3c.dom.Element;
 
 import org.apache.cxf.rt.security.claims.ClaimCollection;
@@ -47,8 +45,7 @@ public class TokenRequirements {
     private ClaimCollection secondaryClaims;
     private Renewing renewing;
     private Participants participants;
-    private final List<Element> customContent = new ArrayList<>();
-    private final List<JAXBElement<?>> customContentJAXB = new ArrayList<>();
+    private final List<Object> customContent = new ArrayList<>();
 
     public Renewing getRenewing() {
         return renewing;
@@ -154,24 +151,14 @@ public class TokenRequirements {
         this.participants = participants;
     }
 
-    public List<Element> getCustomContent() {
+    public List<Object> getCustomContent() {
         return Collections.unmodifiableList(customContent);
     }
 
-    public void addCustomContent(Element customElement) {
+    public void addCustomContent(Object customElement) {
         if (customElement != null) {
             this.customContent.add(customElement);
         }
     }
 
-    public List<JAXBElement<?>> getCustomContentJAXB() {
-        return Collections.unmodifiableList(customContentJAXB);
-    }
-
-    public void addCustomContentJAXB(JAXBElement<?> jaxbElement) {
-        if (jaxbElement != null) {
-            this.customContentJAXB.add(jaxbElement);
-        }
-    }
-
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cxf/blob/d28828e4/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/custom/CustomClaimsHandler.java
----------------------------------------------------------------------
diff --git a/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/custom/CustomClaimsHandler.java b/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/custom/CustomClaimsHandler.java
index fc43ed8..948aaa9 100644
--- a/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/custom/CustomClaimsHandler.java
+++ b/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/custom/CustomClaimsHandler.java
@@ -49,10 +49,14 @@ public class CustomClaimsHandler implements ClaimsHandler {
 
         if (claims != null && !claims.isEmpty()) {
             ProcessedClaimCollection claimCollection = new ProcessedClaimCollection();
-            List<Element> customContent = parameters.getTokenRequirements().getCustomContent();
+            List<Object> customContent = parameters.getTokenRequirements().getCustomContent();
             boolean foundContent = false;
             if (customContent != null) {
-                for (Element customContentElement : customContent) {
+                for (Object customContentObj : customContent) {
+                    if (!(customContentObj instanceof Element)) {
+                        continue;
+                    }
+                    Element customContentElement = (Element)customContentObj;
                     Element realm = XMLUtils.findElement(customContentElement, "realm", "http://cxf.apache.org/custom");
                     if (realm != null) {
                         String realmStr = realm.getTextContent();