Repository: cxf
Updated Branches:
  refs/heads/3.1.x-fixes 46d5cebc9 -> c47e3ae4c


Added switch to disable the generation of a Lifetime element in a class derived 
from AbstractOperation. This closes #311.

Signed-off-by: Colm O hEigeartaigh <cohei...@apache.org>

# Conflicts:
#       
services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/AbstractOperation.java
#       
services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenIssueOperation.java
#       
services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenRenewOperation.java
#       
services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenValidateOperation.java


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

Branch: refs/heads/3.1.x-fixes
Commit: 51db38c5d11ac39aad26895cb0c9b5012de885a6
Parents: 46d5ceb
Author: val <val>
Authored: Tue Sep 5 00:53:26 2017 -0500
Committer: Colm O hEigeartaigh <cohei...@apache.org>
Committed: Wed Sep 6 10:19:53 2017 +0100

----------------------------------------------------------------------
 .../apache/cxf/sts/operation/AbstractOperation.java   | 11 ++++++++++-
 .../apache/cxf/sts/operation/TokenIssueOperation.java | 13 ++++++++-----
 .../apache/cxf/sts/operation/TokenRenewOperation.java | 10 ++++++----
 .../cxf/sts/operation/TokenValidateOperation.java     | 14 ++++++++------
 4 files changed, 32 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/51db38c5/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 733d909..53d7099 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
@@ -104,7 +104,8 @@ public abstract class AbstractOperation {
     protected List<TokenDelegationHandler> delegationHandlers = new 
ArrayList<>();
     protected TokenWrapper tokenWrapper = new DefaultTokenWrapper();
     protected boolean allowCustomContent;
-    
+    protected boolean includeLifetimeElement = true;
+
     public boolean isAllowCustomContent() {
         return allowCustomContent;
     }
@@ -180,6 +181,14 @@ public abstract class AbstractOperation {
     public void setClaimsManager(ClaimsManager claimsManager) {
         this.claimsManager = claimsManager;
     }
+
+    public void setIncludeLifetimeElement(boolean value) {
+        this.includeLifetimeElement = value;
+    }
+
+    public boolean getIncludeLifetimeElement() {
+        return this.includeLifetimeElement;
+    }
     
     /**
      * Check the arguments from the STSProvider and parse the request.

http://git-wip-us.apache.org/repos/asf/cxf/blob/51db38c5/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenIssueOperation.java
----------------------------------------------------------------------
diff --git 
a/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenIssueOperation.java
 
b/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenIssueOperation.java
index cffd284..5e9821d 100644
--- 
a/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenIssueOperation.java
+++ 
b/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenIssueOperation.java
@@ -75,7 +75,7 @@ import 
org.apache.xml.security.exceptions.XMLSecurityException;
 public class TokenIssueOperation extends AbstractOperation implements 
IssueOperation, IssueSingleOperation {
 
     static final Logger LOG = LogUtils.getL7dLogger(TokenIssueOperation.class);
-
+    
 
     public RequestSecurityTokenResponseCollectionType issue(
             RequestSecurityTokenType request,
@@ -354,10 +354,13 @@ public class TokenIssueOperation extends 
AbstractOperation implements IssueOpera
         }
 
         // Lifetime
-        LifetimeType lifetime = 
-            createLifetime(tokenResponse.getCreated(), 
tokenResponse.getExpires());
-        JAXBElement<LifetimeType> lifetimeType = 
QNameConstants.WS_TRUST_FACTORY.createLifetime(lifetime);
-        response.getAny().add(lifetimeType);
+        if (includeLifetimeElement) {
+            LifetimeType lifetime =
+                createLifetime(tokenResponse.getCreated(), 
tokenResponse.getExpires());
+            JAXBElement<LifetimeType> lifetimeType =
+                QNameConstants.WS_TRUST_FACTORY.createLifetime(lifetime);
+            response.getAny().add(lifetimeType);
+        }
 
         // KeySize
         long keySize = tokenResponse.getKeySize();

http://git-wip-us.apache.org/repos/asf/cxf/blob/51db38c5/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenRenewOperation.java
----------------------------------------------------------------------
diff --git 
a/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenRenewOperation.java
 
b/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenRenewOperation.java
index a21a1f0..40afe8a 100644
--- 
a/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenRenewOperation.java
+++ 
b/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenRenewOperation.java
@@ -270,10 +270,12 @@ public class TokenRenewOperation extends 
AbstractOperation implements RenewOpera
         response.getAny().add(tokenRequirements.getAppliesTo());
 
         // Lifetime
-        LifetimeType lifetime = 
-            createLifetime(tokenRenewerResponse.getCreated(), 
tokenRenewerResponse.getExpires());
-        JAXBElement<LifetimeType> lifetimeType = 
QNameConstants.WS_TRUST_FACTORY.createLifetime(lifetime);
-        response.getAny().add(lifetimeType);
+        if (includeLifetimeElement) {
+            LifetimeType lifetime =
+                createLifetime(tokenRenewerResponse.getCreated(), 
tokenRenewerResponse.getExpires());
+            JAXBElement<LifetimeType> lifetimeType = 
QNameConstants.WS_TRUST_FACTORY.createLifetime(lifetime);
+            response.getAny().add(lifetimeType);
+        }
 
         return response;
     }

http://git-wip-us.apache.org/repos/asf/cxf/blob/51db38c5/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenValidateOperation.java
----------------------------------------------------------------------
diff --git 
a/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenValidateOperation.java
 
b/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenValidateOperation.java
index 4976356..a1befe4 100644
--- 
a/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenValidateOperation.java
+++ 
b/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenValidateOperation.java
@@ -229,12 +229,14 @@ public class TokenValidateOperation extends 
AbstractOperation implements Validat
             response.getAny().add(requestedToken);
             
             // Lifetime
-            LifetimeType lifetime = 
-                createLifetime(tokenProviderResponse.getCreated(), 
tokenProviderResponse.getExpires());
-            JAXBElement<LifetimeType> lifetimeType =
-                QNameConstants.WS_TRUST_FACTORY.createLifetime(lifetime);
-            response.getAny().add(lifetimeType);
-            
+            if (includeLifetimeElement) {
+                LifetimeType lifetime =
+                    createLifetime(tokenProviderResponse.getCreated(), 
tokenProviderResponse.getExpires());
+                JAXBElement<LifetimeType> lifetimeType =
+                    QNameConstants.WS_TRUST_FACTORY.createLifetime(lifetime);
+                response.getAny().add(lifetimeType);
+            }
+
             if (returnReferences) {
                 // RequestedAttachedReference
                 TokenReference attachedReference = 
tokenProviderResponse.getAttachedReference();

Reply via email to