Repository: cxf
Updated Branches:
  refs/heads/master e2a3839f6 -> 8c0d43fc9


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>


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

Branch: refs/heads/master
Commit: fca2253915f5285a36360b48cb7e1b1c7a95982e
Parents: e2a3839
Author: val <val>
Authored: Tue Sep 5 00:53:26 2017 -0500
Committer: Colm O hEigeartaigh <cohei...@apache.org>
Committed: Wed Sep 6 10:14:08 2017 +0100

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


http://git-wip-us.apache.org/repos/asf/cxf/blob/fca22539/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 a64e722..cd28309 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
@@ -106,6 +106,7 @@ 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;
@@ -183,6 +184,15 @@ public abstract class AbstractOperation {
         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/fca22539/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 496cf94..8e64bfd 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,
@@ -89,6 +89,7 @@ public class TokenIssueOperation extends AbstractOperation 
implements IssueOpera
         return responseCollection;
     }
 
+    
     public RequestSecurityTokenResponseCollectionType issue(
             RequestSecurityTokenCollectionType requestCollection,
             Principal principal,
@@ -354,10 +355,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/fca22539/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 4c1e92b..3f9b264 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/fca22539/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 045772b..fc57692 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,11 +229,13 @@ 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

Reply via email to