cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject [2/3] cxf git commit: Allow custom RST Elements in STS requests
Date Tue, 24 Jan 2017 12:39:00 GMT
Allow custom RST Elements in STS requests


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

Branch: refs/heads/master
Commit: 4a021b75c6a604bf46f9e2679563e7b4ab9223bb
Parents: a3120a0
Author: Colm O hEigeartaigh <coheigea@apache.org>
Authored: Tue Jan 24 10:45:51 2017 +0000
Committer: Colm O hEigeartaigh <coheigea@apache.org>
Committed: Tue Jan 24 10:45:51 2017 +0000

----------------------------------------------------------------------
 .../apache/cxf/sts/operation/AbstractOperation.java | 10 ++++++++++
 .../org/apache/cxf/sts/request/RequestParser.java   | 12 ++++++++++++
 .../apache/cxf/sts/request/TokenRequirements.java   | 16 ++++++++++++++++
 3 files changed, 38 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/4a021b75/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/AbstractOperation.java
----------------------------------------------------------------------
diff --git a/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/AbstractOperation.java
b/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/AbstractOperation.java
index b1360b8..4d4dc88 100644
--- a/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/AbstractOperation.java
+++ b/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/AbstractOperation.java
@@ -103,7 +103,16 @@ public abstract class AbstractOperation {
     protected STSEventListener eventPublisher;
     protected List<TokenDelegationHandler> delegationHandlers = new ArrayList<>();
     protected TokenWrapper tokenWrapper = new DefaultTokenWrapper();
+    protected boolean allowCustomContent;
     
+    public boolean isAllowCustomContent() {
+        return allowCustomContent;
+    }
+
+    public void setAllowCustomContent(boolean allowCustomContent) {
+        this.allowCustomContent = allowCustomContent;
+    }
+
     public TokenWrapper getTokenWrapper() {
         return tokenWrapper;
     }
@@ -189,6 +198,7 @@ public abstract class AbstractOperation {
         stsProperties.configureProperties();
         
         RequestParser requestParser = new RequestParser();
+        requestParser.setAllowCustomContent(allowCustomContent);
         return requestParser.parseRequest(request, messageContext, stsProperties, 
                                           claimsManager.getClaimParsers());
     }

http://git-wip-us.apache.org/repos/asf/cxf/blob/4a021b75/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 d3e58d5..2e705fd 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
@@ -95,6 +95,8 @@ public class RequestParser {
     
     private static final Logger LOG = LogUtils.getL7dLogger(RequestParser.class);
     
+    private boolean allowCustomContent;
+    
     public RequestRequirements parseRequest(
         RequestSecurityTokenType request, Map<String, Object> messageContext, STSPropertiesMBean
stsProperties, 
         List<ClaimsParser> claimsParsers
@@ -144,6 +146,8 @@ public class RequestParser {
                         || STSConstants.WSP_NS_04.equals(element.getNamespaceURI()))) {
                     tokenRequirements.setAppliesTo(element);
                     LOG.fine("Found AppliesTo element");
+                } else if (allowCustomContent) {
+                    tokenRequirements.addCustomContent((Element)requestObject);
                 } else {
                     LOG.log(
                         Level.WARNING, 
@@ -755,4 +759,12 @@ public class RequestParser {
         throw new STSException("Cannot retreive token from reference", STSException.REQUEST_FAILED);
     }
 
+    public boolean isAllowCustomContent() {
+        return allowCustomContent;
+    }
+
+    public void setAllowCustomContent(boolean allowCustomContent) {
+        this.allowCustomContent = allowCustomContent;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/4a021b75/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 7dd360c..45eab81 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
@@ -18,7 +18,12 @@
  */
 package org.apache.cxf.sts.request;
 
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
 import org.w3c.dom.Element;
+
 import org.apache.cxf.rt.security.claims.ClaimCollection;
 
 /**
@@ -40,6 +45,7 @@ public class TokenRequirements {
     private ClaimCollection secondaryClaims;
     private Renewing renewing;
     private Participants participants;
+    private final List<Element> customContent = new ArrayList<>();
     
     public Renewing getRenewing() {
         return renewing;
@@ -145,4 +151,14 @@ public class TokenRequirements {
         this.participants = participants;
     }
 
+    public List<Element> getCustomContent() {
+        return Collections.unmodifiableList(customContent);
+    }
+    
+    public void addCustomContent(Element customElement) {
+        if (customElement != null) {
+            this.customContent.add(customElement);
+        }
+    }
+
 }
\ No newline at end of file


Mime
View raw message