cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject [1/2] cxf git commit: Allow custom JAXB Elements in an STS RST
Date Thu, 03 Aug 2017 16:54:07 GMT
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 <coheigea@apache.org>
Authored: Thu Aug 3 17:29:05 2017 +0100
Committer: Colm O hEigeartaigh <coheigea@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


Mime
View raw message