cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject svn commit: r1325349 [1/2] - in /cxf/trunk: rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/ rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/operation/ services/sts/sts-core/src/main/java/org/apache/cxf/sts/ope...
Date Thu, 12 Apr 2012 16:18:01 GMT
Author: coheigea
Date: Thu Apr 12 16:18:00 2012
New Revision: 1325349

URL: http://svn.apache.org/viewvc?rev=1325349&view=rev
Log:
[CXF-4157] - Fixed batch processing in the STS and added a systest

Added:
    cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/operation/RequestCollectionOperation.java
      - copied, changed from r1325343, cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/operation/IssueOperation.java
    cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenRequestCollectionOperation.java
    cxf/trunk/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/batch/
    cxf/trunk/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/batch/BatchRequest.java
    cxf/trunk/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/batch/SAMLBatchUnitTest.java
    cxf/trunk/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/batch/STSServer.java
      - copied, changed from r1325343, cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/operation/IssueOperation.java
    cxf/trunk/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/batch/SimpleBatchSTSClient.java
    cxf/trunk/services/sts/systests/advanced/src/test/resources/org/apache/cxf/systest/sts/batch/
    cxf/trunk/services/sts/systests/advanced/src/test/resources/org/apache/cxf/systest/sts/batch/cxf-client-unit.xml
    cxf/trunk/services/sts/systests/advanced/src/test/resources/org/apache/cxf/systest/sts/batch/cxf-sts.xml
    cxf/trunk/services/sts/systests/advanced/src/test/resources/org/apache/cxf/systest/sts/batch/ws-trust-1.4-service.wsdl
Modified:
    cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/SecurityTokenService.java
    cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/SecurityTokenServiceImpl.java
    cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/SecurityTokenServiceProvider.java
    cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/operation/CancelOperation.java
    cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/operation/IssueOperation.java
    cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/operation/RenewOperation.java
    cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/operation/ValidateOperation.java
    cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenCancelOperation.java
    cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenRenewOperation.java
    cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenValidateOperation.java
    cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/ValidateUnitTest.java

Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/SecurityTokenService.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/SecurityTokenService.java?rev=1325349&r1=1325348&r2=1325349&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/SecurityTokenService.java (original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/SecurityTokenService.java Thu Apr 12 16:18:00 2012
@@ -69,19 +69,6 @@ public interface SecurityTokenService {
         RequestSecurityTokenType request
     );
     
-    @WebResult(name = "RequestSecurityTokenResponseCollection",
-               targetNamespace = "http://docs.oasis-open.org/ws-sx/ws-trust/200512",
-               partName = "responseCollection")
-    @Action(input = "http://docs.oasis-open.org/ws-sx/ws-trust/200512/BatchIssue", 
-            output = "http://docs.oasis-open.org/ws-sx/ws-trust/200512/BatchIssue")
-    @WebMethod(operationName = "Issue")
-    RequestSecurityTokenResponseCollectionType issue(
-        @WebParam(partName = "requestCollection",
-                  name = "RequestSecurityTokenCollection", 
-                  targetNamespace = "http://docs.oasis-open.org/ws-sx/ws-trust/200512")
-        RequestSecurityTokenCollectionType requestCollection
-    );
-    
     @WebResult(name = "RequestSecurityTokenResponse",
               targetNamespace = "http://docs.oasis-open.org/ws-sx/ws-trust/200512",
               partName = "response")
@@ -106,18 +93,6 @@ public interface SecurityTokenService {
                   targetNamespace = "http://docs.oasis-open.org/ws-sx/ws-trust/200512")
         RequestSecurityTokenType request
     );
-    
-    @WebResult(name = "RequestSecurityTokenResponseCollection", 
-               targetNamespace = "http://docs.oasis-open.org/ws-sx/ws-trust/200512", 
-               partName = "responseCollection")
-    @Action(input = "http://docs.oasis-open.org/ws-sx/ws-trust/200512/BatchCancel", 
-            output = "http://docs.oasis-open.org/ws-sx/ws-trust/200512/BatchCancel")
-    @WebMethod(operationName = "Cancel")
-    RequestSecurityTokenResponseCollectionType cancel(
-        @WebParam(partName = "requestCollection", name = "RequestSecurityTokenCollection", 
-                  targetNamespace = "http://docs.oasis-open.org/ws-sx/ws-trust/200512")
-        RequestSecurityTokenCollectionType requestCollection
-    );
 
     @WebResult(name = "RequestSecurityTokenResponse", 
                targetNamespace = "http://docs.oasis-open.org/ws-sx/ws-trust/200512", 
@@ -130,15 +105,14 @@ public interface SecurityTokenService {
                   targetNamespace = "http://docs.oasis-open.org/ws-sx/ws-trust/200512")
         RequestSecurityTokenType request
     );
-    
+
     @WebResult(name = "RequestSecurityTokenResponseCollection", 
-               targetNamespace = "http://docs.oasis-open.org/ws-sx/ws-trust/200512", 
+               targetNamespace = "http://docs.oasis-open.org/ws-sx/ws-trust/200512",
                partName = "responseCollection")
-    @Action(input = "http://docs.oasis-open.org/ws-sx/ws-trust/200512/BatchValidate", 
-    output = "http://docs.oasis-open.org/ws-sx/ws-trust/200512/BatchValidate")
-    @WebMethod(operationName = "Validate")
-    RequestSecurityTokenResponseCollectionType validate(
-        @WebParam(partName = "requestCollection", name = "RequestSecurityTokenCollection", 
+    @WebMethod(operationName = "RequestCollection")
+    RequestSecurityTokenResponseCollectionType requestCollection(
+        @WebParam(partName = "requestCollection",
+                  name = "RequestSecurityTokenCollection",
                   targetNamespace = "http://docs.oasis-open.org/ws-sx/ws-trust/200512")
         RequestSecurityTokenCollectionType requestCollection
     );
@@ -155,17 +129,4 @@ public interface SecurityTokenService {
                   targetNamespace = "http://docs.oasis-open.org/ws-sx/ws-trust/200512")
         RequestSecurityTokenType request
     );
-    
-    @WebResult(name = "RequestSecurityTokenResponseCollection", 
-               targetNamespace = "http://docs.oasis-open.org/ws-sx/ws-trust/200512", 
-               partName = "responseCollection")
-    @Action(input = "http://docs.oasis-open.org/ws-sx/ws-trust/200512/BatchRenew", 
-            output = "http://docs.oasis-open.org/ws-sx/ws-trust/200512/BatchRenew")
-    @WebMethod(operationName = "Renew")
-    RequestSecurityTokenResponseCollectionType renew(
-        @WebParam(partName = "requestCollection", 
-                  name = "RequestSecurityTokenCollection", 
-                  targetNamespace = "http://docs.oasis-open.org/ws-sx/ws-trust/200512")
-        RequestSecurityTokenCollectionType requestCollection
-    );
-}
+}
\ No newline at end of file

Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/SecurityTokenServiceImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/SecurityTokenServiceImpl.java?rev=1325349&r1=1325348&r2=1325349&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/SecurityTokenServiceImpl.java (original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/SecurityTokenServiceImpl.java Thu Apr 12 16:18:00 2012
@@ -36,6 +36,7 @@ import org.apache.cxf.ws.security.sts.pr
 import org.apache.cxf.ws.security.sts.provider.operation.IssueSingleOperation;
 import org.apache.cxf.ws.security.sts.provider.operation.KeyExchangeTokenOperation;
 import org.apache.cxf.ws.security.sts.provider.operation.RenewOperation;
+import org.apache.cxf.ws.security.sts.provider.operation.RequestCollectionOperation;
 import org.apache.cxf.ws.security.sts.provider.operation.ValidateOperation;
 
 
@@ -46,6 +47,7 @@ public class SecurityTokenServiceImpl im
     private IssueSingleOperation issueSingleOperation;
     private KeyExchangeTokenOperation keyExchangeTokenOperation;
     private RenewOperation renewOperation;
+    private RequestCollectionOperation requestCollectionOperation;
     private ValidateOperation validateOperation;
     
     @Resource
@@ -72,6 +74,11 @@ public class SecurityTokenServiceImpl im
         this.renewOperation = renewOperation;
     }
 
+    public void setRequestCollectionOperation(
+            RequestCollectionOperation requestCollectionOperation) {
+        this.requestCollectionOperation = requestCollectionOperation;
+    }
+
     public void setValidateOperation(ValidateOperation validateOperation) {
         this.validateOperation = validateOperation;
     }
@@ -83,14 +90,14 @@ public class SecurityTokenServiceImpl im
         }
         return validateOperation.validate(request, context);
     }
-    
-    public RequestSecurityTokenResponseCollectionType validate(
-        RequestSecurityTokenCollectionType requestCollection
-    ) {
-        if (validateOperation == null) {
-            throwUnsupportedOperation("Validate");
+
+
+    public RequestSecurityTokenResponseCollectionType requestCollection(
+            RequestSecurityTokenCollectionType requestCollection) {
+        if (requestCollectionOperation == null) {
+            throwUnsupportedOperation("RequestCollection");
         }
-        return validateOperation.validate(requestCollection, context);
+        return requestCollectionOperation.requestCollection(requestCollection, context);
     }
 
     public RequestSecurityTokenResponseType keyExchangeToken(
@@ -109,15 +116,6 @@ public class SecurityTokenServiceImpl im
         return issueOperation.issue(request, context);
     }
     
-    public RequestSecurityTokenResponseCollectionType issue(
-        RequestSecurityTokenCollectionType requestCollection
-    ) {
-        if (issueOperation == null) {
-            throwUnsupportedOperation("Issue");
-        }
-        return issueOperation.issue(requestCollection, context);
-    }
-
     public RequestSecurityTokenResponseType issueSingle(
             RequestSecurityTokenType request) {
         if (issueSingleOperation == null) {
@@ -133,15 +131,6 @@ public class SecurityTokenServiceImpl im
         }
         return cancelOperation.cancel(request, context);
     }
-    
-    public RequestSecurityTokenResponseCollectionType cancel(
-        RequestSecurityTokenCollectionType requestCollection
-    ) {
-        if (cancelOperation == null) {
-            throwUnsupportedOperation("Cancel");
-        }
-        return cancelOperation.cancel(requestCollection, context);
-    }
 
     public RequestSecurityTokenResponseType renew(
             RequestSecurityTokenType request) {
@@ -151,15 +140,6 @@ public class SecurityTokenServiceImpl im
         return renewOperation.renew(request, context);
     }
     
-    public RequestSecurityTokenResponseCollectionType renew(
-        RequestSecurityTokenCollectionType requestCollection
-    ) {
-        if (renewOperation == null) {
-            throwUnsupportedOperation("Renew");
-        }
-        return renewOperation.renew(requestCollection, context);
-    }
-    
     
     private void throwUnsupportedOperation(String string) {
         try {
@@ -171,4 +151,4 @@ public class SecurityTokenServiceImpl im
         }
     }
 
-}
+}
\ No newline at end of file

Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/SecurityTokenServiceProvider.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/SecurityTokenServiceProvider.java?rev=1325349&r1=1325348&r2=1325349&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/SecurityTokenServiceProvider.java (original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/SecurityTokenServiceProvider.java Thu Apr 12 16:18:00 2012
@@ -54,6 +54,7 @@ import org.apache.cxf.ws.security.sts.pr
 import org.apache.cxf.ws.security.sts.provider.operation.IssueSingleOperation;
 import org.apache.cxf.ws.security.sts.provider.operation.KeyExchangeTokenOperation;
 import org.apache.cxf.ws.security.sts.provider.operation.RenewOperation;
+import org.apache.cxf.ws.security.sts.provider.operation.RequestCollectionOperation;
 import org.apache.cxf.ws.security.sts.provider.operation.ValidateOperation;
 
 @ServiceMode(value = Service.Mode.PAYLOAD)
@@ -63,20 +64,14 @@ public class SecurityTokenServiceProvide
     private static final String WSTRUST_REQUESTTYPE_ELEMENTNAME = "RequestType";
     private static final String WSTRUST_REQUESTTYPE_ISSUE = WSTRUST_13_NAMESPACE
             + "/Issue";
-    private static final String WSTRUST_REQUESTTYPE_BATCH_ISSUE = WSTRUST_13_NAMESPACE
-        + "/BatchIssue";
     private static final String WSTRUST_REQUESTTYPE_CANCEL = WSTRUST_13_NAMESPACE
             + "/Cancel";
-    private static final String WSTRUST_REQUESTTYPE_BATCH_CANCEL = WSTRUST_13_NAMESPACE
-        + "/BatchCancel";
     private static final String WSTRUST_REQUESTTYPE_RENEW = WSTRUST_13_NAMESPACE
             + "/Renew";
-    private static final String WSTRUST_REQUESTTYPE_BATCH_RENEW = WSTRUST_13_NAMESPACE
-        + "/BatchRenew";
     private static final String WSTRUST_REQUESTTYPE_VALIDATE = WSTRUST_13_NAMESPACE
             + "/Validate";
-    private static final String WSTRUST_REQUESTTYPE_BATCH_VALIDATE = WSTRUST_13_NAMESPACE
-        + "/BatchValidate";
+    private static final String WSTRUST_REQUESTTYPE_REQUESTCOLLECTION = WSTRUST_13_NAMESPACE
+            + "/RequestCollection";
     private static final String WSTRUST_REQUESTTYPE_KEYEXCHANGETOKEN = WSTRUST_13_NAMESPACE
             + "/KeyExchangeToken";
     
@@ -88,45 +83,30 @@ public class SecurityTokenServiceProvide
                                                               WebServiceContext.class);
             OPERATION_METHODS.put(WSTRUST_REQUESTTYPE_ISSUE, m);
             
-            m = IssueOperation.class.getDeclaredMethod("issue", 
-                                                       RequestSecurityTokenCollectionType.class, 
-                                                       WebServiceContext.class);
-            OPERATION_METHODS.put(WSTRUST_REQUESTTYPE_BATCH_ISSUE, m);
-            
             m = CancelOperation.class.getDeclaredMethod("cancel", 
                                                        RequestSecurityTokenType.class, 
                                                        WebServiceContext.class);
             OPERATION_METHODS.put(WSTRUST_REQUESTTYPE_CANCEL, m);
             
-            m = CancelOperation.class.getDeclaredMethod("cancel", 
-                                                        RequestSecurityTokenCollectionType.class, 
-                                                        WebServiceContext.class);
-            OPERATION_METHODS.put(WSTRUST_REQUESTTYPE_BATCH_CANCEL, m);
-            
             m = RenewOperation.class.getDeclaredMethod("renew", 
                                                        RequestSecurityTokenType.class, 
                                                        WebServiceContext.class);
             OPERATION_METHODS.put(WSTRUST_REQUESTTYPE_RENEW, m);
             
-            m = RenewOperation.class.getDeclaredMethod("renew", 
-                                                       RequestSecurityTokenCollectionType.class, 
-                                                       WebServiceContext.class);
-            OPERATION_METHODS.put(WSTRUST_REQUESTTYPE_BATCH_RENEW, m);
-            
             m = ValidateOperation.class.getDeclaredMethod("validate", 
                                                        RequestSecurityTokenType.class, 
                                                        WebServiceContext.class);
             OPERATION_METHODS.put(WSTRUST_REQUESTTYPE_VALIDATE, m);
             
-            m = ValidateOperation.class.getDeclaredMethod("validate", 
-                                                          RequestSecurityTokenCollectionType.class, 
-                                                          WebServiceContext.class);
-            OPERATION_METHODS.put(WSTRUST_REQUESTTYPE_BATCH_VALIDATE, m);
-            
             m = KeyExchangeTokenOperation.class.getDeclaredMethod("keyExchangeToken", 
                                                        RequestSecurityTokenType.class, 
                                                        WebServiceContext.class);
             OPERATION_METHODS.put(WSTRUST_REQUESTTYPE_KEYEXCHANGETOKEN, m);
+            
+            m = RequestCollectionOperation.class.getDeclaredMethod("requestCollection", 
+                                                       RequestSecurityTokenCollectionType.class, 
+                                                       WebServiceContext.class);
+            OPERATION_METHODS.put(WSTRUST_REQUESTTYPE_REQUESTCOLLECTION, m);
         } catch (Exception ex) {
             ex.printStackTrace();
         }
@@ -142,6 +122,7 @@ public class SecurityTokenServiceProvide
     private IssueSingleOperation issueSingleOperation;
     private KeyExchangeTokenOperation keyExchangeTokenOperation;
     private RenewOperation renewOperation;
+    private RequestCollectionOperation requestCollectionOperation;
     private ValidateOperation validateOperation;
     private Map<String, Object> operationMap = new HashMap<String, Object>();
 
@@ -199,6 +180,13 @@ public class SecurityTokenServiceProvide
         operationMap.put(WSTRUST_REQUESTTYPE_RENEW, renewOperation);
     }
 
+    public void setRequestCollectionOperation(
+            RequestCollectionOperation requestCollectionOperation) {
+        this.requestCollectionOperation = requestCollectionOperation;
+        operationMap.put(WSTRUST_REQUESTTYPE_REQUESTCOLLECTION,
+                requestCollectionOperation);
+    }
+
     public void setValidateOperation(ValidateOperation validateOperation) {
         this.validateOperation = validateOperation;
         operationMap.put(WSTRUST_REQUESTTYPE_VALIDATE, validateOperation);
@@ -213,31 +201,8 @@ public class SecurityTokenServiceProvide
             Object operationImpl = null;
             Method method = null;
             if (obj instanceof RequestSecurityTokenCollectionType) {
-                RequestSecurityTokenCollectionType rstCollection = (RequestSecurityTokenCollectionType)obj;
-                List<RequestSecurityTokenType> typeList = rstCollection.getRequestSecurityToken();
-                String requestType = null;
-                for (RequestSecurityTokenType rst : typeList) {
-                    List<?> objectList = rst.getAny();
-                    for (Object o : objectList) {
-                        if (o instanceof JAXBElement) {
-                            QName qname = ((JAXBElement<?>) o).getName();
-                            if (qname.equals(new QName(WSTRUST_13_NAMESPACE,
-                                    WSTRUST_REQUESTTYPE_ELEMENTNAME))) {
-                                String val = ((JAXBElement<?>) o).getValue().toString();
-                                // All batch requests must have the same RequestType
-                                if (requestType != null && !requestType.equals(val)) {
-                                    operationImpl = null;
-                                    method = null;
-                                    break;
-                                } else {
-                                    requestType = val;
-                                }
-                                operationImpl = operationMap.get(val);
-                                method = OPERATION_METHODS.get(val);
-                            }
-                        }
-                    }
-                }
+                operationImpl = operationMap.get(WSTRUST_REQUESTTYPE_REQUESTCOLLECTION);
+                method = OPERATION_METHODS.get(WSTRUST_REQUESTTYPE_REQUESTCOLLECTION);
             } else {
                 RequestSecurityTokenType rst = (RequestSecurityTokenType)obj;
                 List<?> objectList = rst.getAny();
@@ -248,7 +213,7 @@ public class SecurityTokenServiceProvide
                                 WSTRUST_REQUESTTYPE_ELEMENTNAME))) {
                             String val = ((JAXBElement<?>) o).getValue().toString();
                             operationImpl = operationMap.get(val);
-                            method = OPERATION_METHODS.get(val);
+                            method =  OPERATION_METHODS.get(val);
                             break;
                         }
                     }
@@ -339,8 +304,12 @@ public class SecurityTokenServiceProvide
         return renewOperation;
     }
 
+    public RequestCollectionOperation getRequestCollectionOperation() {
+        return requestCollectionOperation;
+    }
+
     public ValidateOperation getValidateOperation() {
         return validateOperation;
     }
 
-}
+}
\ No newline at end of file

Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/operation/CancelOperation.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/operation/CancelOperation.java?rev=1325349&r1=1325348&r2=1325349&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/operation/CancelOperation.java (original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/operation/CancelOperation.java Thu Apr 12 16:18:00 2012
@@ -21,8 +21,6 @@ package org.apache.cxf.ws.security.sts.p
 
 import javax.xml.ws.WebServiceContext;
 
-import org.apache.cxf.ws.security.sts.provider.model.RequestSecurityTokenCollectionType;
-import org.apache.cxf.ws.security.sts.provider.model.RequestSecurityTokenResponseCollectionType;
 import org.apache.cxf.ws.security.sts.provider.model.RequestSecurityTokenResponseType;
 import org.apache.cxf.ws.security.sts.provider.model.RequestSecurityTokenType;
 
@@ -31,7 +29,4 @@ public interface CancelOperation {
     RequestSecurityTokenResponseType cancel(RequestSecurityTokenType request,
                                             WebServiceContext context);
     
-    RequestSecurityTokenResponseCollectionType cancel(RequestSecurityTokenCollectionType request,
-                                            WebServiceContext context);
-
 }

Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/operation/IssueOperation.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/operation/IssueOperation.java?rev=1325349&r1=1325348&r2=1325349&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/operation/IssueOperation.java (original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/operation/IssueOperation.java Thu Apr 12 16:18:00 2012
@@ -21,7 +21,6 @@ package org.apache.cxf.ws.security.sts.p
 
 import javax.xml.ws.WebServiceContext;
 
-import org.apache.cxf.ws.security.sts.provider.model.RequestSecurityTokenCollectionType;
 import org.apache.cxf.ws.security.sts.provider.model.RequestSecurityTokenResponseCollectionType;
 import org.apache.cxf.ws.security.sts.provider.model.RequestSecurityTokenType;
 
@@ -31,8 +30,4 @@ public interface IssueOperation {
             RequestSecurityTokenType request,
             WebServiceContext context);
     
-    RequestSecurityTokenResponseCollectionType issue(
-            RequestSecurityTokenCollectionType requestCollection,
-            WebServiceContext context);
-
 }

Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/operation/RenewOperation.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/operation/RenewOperation.java?rev=1325349&r1=1325348&r2=1325349&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/operation/RenewOperation.java (original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/operation/RenewOperation.java Thu Apr 12 16:18:00 2012
@@ -21,8 +21,6 @@ package org.apache.cxf.ws.security.sts.p
 
 import javax.xml.ws.WebServiceContext;
 
-import org.apache.cxf.ws.security.sts.provider.model.RequestSecurityTokenCollectionType;
-import org.apache.cxf.ws.security.sts.provider.model.RequestSecurityTokenResponseCollectionType;
 import org.apache.cxf.ws.security.sts.provider.model.RequestSecurityTokenResponseType;
 import org.apache.cxf.ws.security.sts.provider.model.RequestSecurityTokenType;
 
@@ -31,6 +29,4 @@ public interface RenewOperation {
     RequestSecurityTokenResponseType renew(RequestSecurityTokenType request,
                                            WebServiceContext context);
 
-    RequestSecurityTokenResponseCollectionType renew(RequestSecurityTokenCollectionType request,
-                                           WebServiceContext context);
 }

Copied: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/operation/RequestCollectionOperation.java (from r1325343, cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/operation/IssueOperation.java)
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/operation/RequestCollectionOperation.java?p2=cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/operation/RequestCollectionOperation.java&p1=cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/operation/IssueOperation.java&r1=1325343&r2=1325349&rev=1325349&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/operation/IssueOperation.java (original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/operation/RequestCollectionOperation.java Thu Apr 12 16:18:00 2012
@@ -23,16 +23,11 @@ import javax.xml.ws.WebServiceContext;
 
 import org.apache.cxf.ws.security.sts.provider.model.RequestSecurityTokenCollectionType;
 import org.apache.cxf.ws.security.sts.provider.model.RequestSecurityTokenResponseCollectionType;
-import org.apache.cxf.ws.security.sts.provider.model.RequestSecurityTokenType;
 
-public interface IssueOperation {
+public interface RequestCollectionOperation {
 
-    RequestSecurityTokenResponseCollectionType issue(
-            RequestSecurityTokenType request,
-            WebServiceContext context);
-    
-    RequestSecurityTokenResponseCollectionType issue(
+    RequestSecurityTokenResponseCollectionType requestCollection(
             RequestSecurityTokenCollectionType requestCollection,
             WebServiceContext context);
 
-}
+}
\ No newline at end of file

Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/operation/ValidateOperation.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/operation/ValidateOperation.java?rev=1325349&r1=1325348&r2=1325349&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/operation/ValidateOperation.java (original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/operation/ValidateOperation.java Thu Apr 12 16:18:00 2012
@@ -21,8 +21,6 @@ package org.apache.cxf.ws.security.sts.p
 
 import javax.xml.ws.WebServiceContext;
 
-import org.apache.cxf.ws.security.sts.provider.model.RequestSecurityTokenCollectionType;
-import org.apache.cxf.ws.security.sts.provider.model.RequestSecurityTokenResponseCollectionType;
 import org.apache.cxf.ws.security.sts.provider.model.RequestSecurityTokenResponseType;
 import org.apache.cxf.ws.security.sts.provider.model.RequestSecurityTokenType;
 
@@ -31,7 +29,4 @@ public interface ValidateOperation {
     RequestSecurityTokenResponseType validate(RequestSecurityTokenType request,
                                               WebServiceContext context);
     
-    RequestSecurityTokenResponseCollectionType validate(RequestSecurityTokenCollectionType request,
-                                              WebServiceContext context);
-
 }

Modified: cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenCancelOperation.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenCancelOperation.java?rev=1325349&r1=1325348&r2=1325349&view=diff
==============================================================================
--- cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenCancelOperation.java (original)
+++ cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenCancelOperation.java Thu Apr 12 16:18:00 2012
@@ -39,8 +39,6 @@ import org.apache.cxf.sts.token.cancelle
 import org.apache.cxf.sts.token.canceller.TokenCancellerParameters;
 import org.apache.cxf.sts.token.canceller.TokenCancellerResponse;
 import org.apache.cxf.ws.security.sts.provider.STSException;
-import org.apache.cxf.ws.security.sts.provider.model.RequestSecurityTokenCollectionType;
-import org.apache.cxf.ws.security.sts.provider.model.RequestSecurityTokenResponseCollectionType;
 import org.apache.cxf.ws.security.sts.provider.model.RequestSecurityTokenResponseType;
 import org.apache.cxf.ws.security.sts.provider.model.RequestSecurityTokenType;
 import org.apache.cxf.ws.security.sts.provider.model.RequestedTokenCancelledType;
@@ -64,18 +62,6 @@ public class TokenCancelOperation extend
         return tokencancellers;
     }
     
-    public RequestSecurityTokenResponseCollectionType cancel(
-        RequestSecurityTokenCollectionType requestCollection, WebServiceContext context
-    ) {
-        RequestSecurityTokenResponseCollectionType responseCollection = 
-            QNameConstants.WS_TRUST_FACTORY.createRequestSecurityTokenResponseCollectionType();
-        for (RequestSecurityTokenType request : requestCollection.getRequestSecurityToken()) {
-            RequestSecurityTokenResponseType response = cancel(request, context);
-            responseCollection.getRequestSecurityTokenResponse().add(response);
-        }
-        return responseCollection;
-    }
-    
     public RequestSecurityTokenResponseType cancel(
         RequestSecurityTokenType request, WebServiceContext context
     ) {

Modified: cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenRenewOperation.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenRenewOperation.java?rev=1325349&r1=1325348&r2=1325349&view=diff
==============================================================================
--- cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenRenewOperation.java (original)
+++ cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenRenewOperation.java Thu Apr 12 16:18:00 2012
@@ -45,8 +45,6 @@ import org.apache.cxf.sts.token.renewer.
 import org.apache.cxf.sts.token.validator.TokenValidatorResponse;
 import org.apache.cxf.ws.security.sts.provider.STSException;
 import org.apache.cxf.ws.security.sts.provider.model.LifetimeType;
-import org.apache.cxf.ws.security.sts.provider.model.RequestSecurityTokenCollectionType;
-import org.apache.cxf.ws.security.sts.provider.model.RequestSecurityTokenResponseCollectionType;
 import org.apache.cxf.ws.security.sts.provider.model.RequestSecurityTokenResponseType;
 import org.apache.cxf.ws.security.sts.provider.model.RequestSecurityTokenType;
 import org.apache.cxf.ws.security.sts.provider.model.RequestedReferenceType;
@@ -71,18 +69,6 @@ public class TokenRenewOperation extends
         return tokenRenewers;
     }
 
-    public RequestSecurityTokenResponseCollectionType renew(
-        RequestSecurityTokenCollectionType requestCollection, WebServiceContext context
-    ) {
-        RequestSecurityTokenResponseCollectionType responseCollection = 
-            QNameConstants.WS_TRUST_FACTORY.createRequestSecurityTokenResponseCollectionType();
-        for (RequestSecurityTokenType request : requestCollection.getRequestSecurityToken()) {
-            RequestSecurityTokenResponseType response = renew(request, context);
-            responseCollection.getRequestSecurityTokenResponse().add(response);
-        }
-        return responseCollection;
-    }
-    
     public RequestSecurityTokenResponseType renew(
         RequestSecurityTokenType request, WebServiceContext context
     ) {

Added: cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenRequestCollectionOperation.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenRequestCollectionOperation.java?rev=1325349&view=auto
==============================================================================
--- cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenRequestCollectionOperation.java (added)
+++ cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenRequestCollectionOperation.java Thu Apr 12 16:18:00 2012
@@ -0,0 +1,181 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.sts.operation;
+
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.xml.bind.JAXBElement;
+import javax.xml.namespace.QName;
+import javax.xml.ws.WebServiceContext;
+
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.sts.QNameConstants;
+import org.apache.cxf.sts.STSConstants;
+import org.apache.cxf.ws.security.sts.provider.STSException;
+import org.apache.cxf.ws.security.sts.provider.model.RequestSecurityTokenCollectionType;
+import org.apache.cxf.ws.security.sts.provider.model.RequestSecurityTokenResponseCollectionType;
+import org.apache.cxf.ws.security.sts.provider.model.RequestSecurityTokenResponseType;
+import org.apache.cxf.ws.security.sts.provider.model.RequestSecurityTokenType;
+import org.apache.cxf.ws.security.sts.provider.operation.CancelOperation;
+import org.apache.cxf.ws.security.sts.provider.operation.IssueSingleOperation;
+import org.apache.cxf.ws.security.sts.provider.operation.RenewOperation;
+import org.apache.cxf.ws.security.sts.provider.operation.RequestCollectionOperation;
+import org.apache.cxf.ws.security.sts.provider.operation.ValidateOperation;
+
+/**
+ * An implementation of the RequestCollectionOperation interface. It is composed of the different 
+ * Operation implementations
+ */
+public class TokenRequestCollectionOperation extends AbstractOperation
+    implements RequestCollectionOperation {
+    
+    public static final String WSTRUST_REQUESTTYPE_BATCH_ISSUE = STSConstants.WST_NS_05_12
+        + "/BatchIssue";
+    public static final String WSTRUST_REQUESTTYPE_BATCH_CANCEL = STSConstants.WST_NS_05_12
+        + "/BatchCancel";
+    public static final String WSTRUST_REQUESTTYPE_BATCH_RENEW = STSConstants.WST_NS_05_12
+        + "/BatchRenew";
+    public static final String WSTRUST_REQUESTTYPE_BATCH_VALIDATE = STSConstants.WST_NS_05_12
+        + "/BatchValidate";
+    
+    static final Logger LOG = LogUtils.getL7dLogger(TokenRequestCollectionOperation.class);
+    
+    private IssueSingleOperation issueSingleOperation;
+    private ValidateOperation validateOperation;
+    private RenewOperation renewOperation;
+    private CancelOperation cancelOperation;
+
+    public RequestSecurityTokenResponseCollectionType requestCollection(
+        RequestSecurityTokenCollectionType requestCollection,
+        WebServiceContext context) {
+        RequestSecurityTokenResponseCollectionType responseCollection = 
+            QNameConstants.WS_TRUST_FACTORY.createRequestSecurityTokenResponseCollectionType();
+        
+        String requestType = null;
+        for (RequestSecurityTokenType request : requestCollection.getRequestSecurityToken()) {
+            List<?> objectList = request.getAny();
+            for (Object o : objectList) {
+                if (o instanceof JAXBElement) {
+                    QName qname = ((JAXBElement<?>) o).getName();
+                    if (qname.equals(new QName(STSConstants.WST_NS_05_12, "RequestType"))) {
+                        String val = ((JAXBElement<?>) o).getValue().toString();
+                        // All batch requests must have the same RequestType
+                        if (val == null || (requestType != null && !requestType.equals(val))) {
+                            LOG.log(
+                                Level.WARNING, 
+                                "All RequestSecurityTokenCollection elements do not share the same"
+                                + "RequestType"
+                            );
+                            throw new STSException(
+                                "Error in requesting a token", STSException.REQUEST_FAILED
+                            );
+                        } else {
+                            requestType = val;
+                        }
+                    }
+                }
+            }
+            
+            RequestSecurityTokenResponseType response = handleRequest(request, context, requestType);
+            responseCollection.getRequestSecurityTokenResponse().add(response);
+        }
+        return responseCollection;
+    }
+    
+    public RequestSecurityTokenResponseType handleRequest(
+            RequestSecurityTokenType request,
+            WebServiceContext context,
+            String requestType
+    ) {
+        if (WSTRUST_REQUESTTYPE_BATCH_ISSUE.equals(requestType)) {
+            if (issueSingleOperation == null) {
+                LOG.log(Level.WARNING, "IssueSingleOperation is null");
+                throw new STSException(
+                    "Error in requesting a token", STSException.REQUEST_FAILED
+                );
+            }
+            return issueSingleOperation.issueSingle(request, context);
+        } else if (WSTRUST_REQUESTTYPE_BATCH_VALIDATE.equals(requestType)) {
+            if (validateOperation == null) {
+                LOG.log(Level.WARNING, "ValidateOperation is null");
+                throw new STSException(
+                    "Error in requesting a token", STSException.REQUEST_FAILED
+                );
+            }
+            return validateOperation.validate(request, context);
+        } else if (WSTRUST_REQUESTTYPE_BATCH_CANCEL.equals(requestType)) {
+            if (cancelOperation == null) {
+                LOG.log(Level.WARNING, "CancelOperation is null");
+                throw new STSException(
+                    "Error in requesting a token", STSException.REQUEST_FAILED
+                );
+            }
+            return cancelOperation.cancel(request, context);
+        } else if (WSTRUST_REQUESTTYPE_BATCH_RENEW.equals(requestType)) {
+            if (renewOperation == null) {
+                LOG.log(Level.WARNING, "RenewOperation is null");
+                throw new STSException(
+                    "Error in requesting a token", STSException.REQUEST_FAILED
+                );
+            }
+            return renewOperation.renew(request, context);
+        } else {
+            LOG.log(Level.WARNING, "Unknown operation requested");
+            throw new STSException(
+                "Error in requesting a token", STSException.REQUEST_FAILED
+            );
+        }
+    }
+    
+    public IssueSingleOperation getIssueSingleOperation() {
+        return issueSingleOperation;
+    }
+
+    public void setIssueSingleOperation(IssueSingleOperation issueSingleOperation) {
+        this.issueSingleOperation = issueSingleOperation;
+    }
+
+    public ValidateOperation getValidateOperation() {
+        return validateOperation;
+    }
+
+    public void setValidateOperation(ValidateOperation validateOperation) {
+        this.validateOperation = validateOperation;
+    }
+
+    public RenewOperation getRenewOperation() {
+        return renewOperation;
+    }
+
+    public void setRenewOperation(RenewOperation renewOperation) {
+        this.renewOperation = renewOperation;
+    }
+
+    public CancelOperation getCancelOperation() {
+        return cancelOperation;
+    }
+
+    public void setCancelOperation(CancelOperation cancelOperation) {
+        this.cancelOperation = cancelOperation;
+    }
+
+}

Modified: cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenValidateOperation.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenValidateOperation.java?rev=1325349&r1=1325348&r2=1325349&view=diff
==============================================================================
--- cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenValidateOperation.java (original)
+++ cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenValidateOperation.java Thu Apr 12 16:18:00 2012
@@ -42,8 +42,6 @@ import org.apache.cxf.sts.token.provider
 import org.apache.cxf.sts.token.validator.TokenValidatorResponse;
 import org.apache.cxf.ws.security.sts.provider.STSException;
 import org.apache.cxf.ws.security.sts.provider.model.LifetimeType;
-import org.apache.cxf.ws.security.sts.provider.model.RequestSecurityTokenCollectionType;
-import org.apache.cxf.ws.security.sts.provider.model.RequestSecurityTokenResponseCollectionType;
 import org.apache.cxf.ws.security.sts.provider.model.RequestSecurityTokenResponseType;
 import org.apache.cxf.ws.security.sts.provider.model.RequestSecurityTokenType;
 import org.apache.cxf.ws.security.sts.provider.model.RequestedReferenceType;
@@ -58,20 +56,7 @@ import org.apache.ws.security.WSSecurity
 public class TokenValidateOperation extends AbstractOperation implements ValidateOperation {
 
     private static final Logger LOG = LogUtils.getL7dLogger(TokenValidateOperation.class);
-
    
-    public RequestSecurityTokenResponseCollectionType validate(
-        RequestSecurityTokenCollectionType requestCollection, WebServiceContext context
-    ) {
-        RequestSecurityTokenResponseCollectionType responseCollection = 
-            QNameConstants.WS_TRUST_FACTORY.createRequestSecurityTokenResponseCollectionType();
-        for (RequestSecurityTokenType request : requestCollection.getRequestSecurityToken()) {
-            RequestSecurityTokenResponseType response = validate(request, context);
-            responseCollection.getRequestSecurityTokenResponse().add(response);
-        }
-        return responseCollection;
-    }
-
     public RequestSecurityTokenResponseType validate(
         RequestSecurityTokenType request, 
         WebServiceContext context

Modified: cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/ValidateUnitTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/ValidateUnitTest.java?rev=1325349&r1=1325348&r2=1325349&view=diff
==============================================================================
--- cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/ValidateUnitTest.java (original)
+++ cxf/trunk/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/ValidateUnitTest.java Thu Apr 12 16:18:00 2012
@@ -99,7 +99,10 @@ public class ValidateUnitTest extends or
      */
     @org.junit.Test
     public void testValidateMultipleTokens() throws Exception {
+        TokenRequestCollectionOperation requestCollectionOperation = 
+            new TokenRequestCollectionOperation();
         TokenValidateOperation validateOperation = new TokenValidateOperation();
+        requestCollectionOperation.setValidateOperation(validateOperation);
         
         // Add Token Validator
         List<TokenValidator> validatorList = new ArrayList<TokenValidator>();
@@ -119,6 +122,14 @@ public class ValidateUnitTest extends or
                 QNameConstants.TOKEN_TYPE, String.class, STSConstants.STATUS
             );
         request.getAny().add(tokenType);
+        
+        JAXBElement<String> requestType = 
+            new JAXBElement<String>(
+                QNameConstants.REQUEST_TYPE, String.class, 
+                TokenRequestCollectionOperation.WSTRUST_REQUESTTYPE_BATCH_VALIDATE
+            );
+        request.getAny().add(requestType);
+        
         ValidateTargetType validateTarget = new ValidateTargetType();
         JAXBElement<BinarySecurityTokenType> token = createToken();
         validateTarget.setAny(token);
@@ -131,6 +142,7 @@ public class ValidateUnitTest extends or
         
         request = new RequestSecurityTokenType();
         request.getAny().add(tokenType);
+        request.getAny().add(requestType);
         validateTarget.setAny(token);
         request.getAny().add(validateTargetType);
         requestCollection.getRequestSecurityToken().add(request);
@@ -142,7 +154,7 @@ public class ValidateUnitTest extends or
         
         // Validate a token
         RequestSecurityTokenResponseCollectionType response = 
-            validateOperation.validate(requestCollection, webServiceContext);
+            requestCollectionOperation.requestCollection(requestCollection, webServiceContext);
         List<RequestSecurityTokenResponseType> securityTokenResponse = 
             response.getRequestSecurityTokenResponse();
         assertEquals(securityTokenResponse.size(), 2);

Added: cxf/trunk/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/batch/BatchRequest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/batch/BatchRequest.java?rev=1325349&view=auto
==============================================================================
--- cxf/trunk/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/batch/BatchRequest.java (added)
+++ cxf/trunk/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/batch/BatchRequest.java Thu Apr 12 16:18:00 2012
@@ -0,0 +1,63 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.systest.sts.batch;
+
+import java.util.List;
+
+public class BatchRequest {
+
+    List<String> tokenTypes;
+    List<String> keyTypes;
+    String requestType;
+    String action;
+    List<String> appliesTo;
+    
+    public List<String> getTokenTypes() {
+        return tokenTypes;
+    }
+    public void setTokenTypes(List<String> tokenTypes) {
+        this.tokenTypes = tokenTypes;
+    }
+    public List<String> getKeyTypes() {
+        return keyTypes;
+    }
+    public void setKeyTypes(List<String> keyTypes) {
+        this.keyTypes = keyTypes;
+    }
+    public String getRequestType() {
+        return requestType;
+    }
+    public void setRequestType(String requestType) {
+        this.requestType = requestType;
+    }
+    public String getAction() {
+        return action;
+    }
+    public void setAction(String action) {
+        this.action = action;
+    }
+    public List<String> getAppliesTo() {
+        return appliesTo;
+    }
+    public void setAppliesTo(List<String> appliesTo) {
+        this.appliesTo = appliesTo;
+    }
+    
+    
+}

Added: cxf/trunk/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/batch/SAMLBatchUnitTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/batch/SAMLBatchUnitTest.java?rev=1325349&view=auto
==============================================================================
--- cxf/trunk/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/batch/SAMLBatchUnitTest.java (added)
+++ cxf/trunk/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/batch/SAMLBatchUnitTest.java Thu Apr 12 16:18:00 2012
@@ -0,0 +1,127 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.systest.sts.batch;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.systest.sts.common.SecurityTestUtil;
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.apache.cxf.ws.security.SecurityConstants;
+import org.apache.cxf.ws.security.tokenstore.SecurityToken;
+import org.junit.BeforeClass;
+import org.opensaml.common.xml.SAMLConstants;
+
+/**
+ * In this test case, a CXF client requests a number of SAML Tokens from an STS using batch processing.
+ * It uses a simple STSClient implementation to request both a SAML 1.1 and 2.0 token at the same time.
+ */
+public class SAMLBatchUnitTest extends AbstractBusClientServerTestBase {
+    
+    static final String STSPORT = allocatePort(STSServer.class);
+    
+    @BeforeClass
+    public static void startServers() throws Exception {
+        assertTrue(
+                   "Server failed to launch",
+                   // run the server in the same process
+                   // set this to false to fork
+                   launchServer(STSServer.class, true)
+        );
+    }
+    
+    @org.junit.AfterClass
+    public static void cleanup() {
+        SecurityTestUtil.cleanup();
+    }
+
+    @org.junit.Test
+    public void testBatchIssueSAMLTokens() throws Exception {
+        SpringBusFactory bf = new SpringBusFactory();
+        URL busFile = SAMLBatchUnitTest.class.getResource("cxf-client-unit.xml");
+
+        Bus bus = bf.createBus(busFile.toString());
+        SpringBusFactory.setDefaultBus(bus);
+        SpringBusFactory.setThreadDefaultBus(bus);
+        
+        String wsdlLocation = 
+            "https://localhost:" + STSPORT + "/SecurityTokenService/Transport?wsdl";
+        
+        BatchRequest request = new BatchRequest();
+        List<String> appliesTo = new ArrayList<String>();
+        appliesTo.add("https://localhost:8081/doubleit/services/doubleittransportsaml1");
+        appliesTo.add("https://localhost:8081/doubleit/services/doubleittransportsaml2");
+        request.setAppliesTo(appliesTo);
+        
+        request.setAction("http://docs.oasis-open.org/ws-sx/ws-trust/200512/BatchIssue");
+        request.setRequestType("http://docs.oasis-open.org/ws-sx/ws-trust/200512/BatchIssue");
+        
+        List<String> tokenTypes = new ArrayList<String>();
+        tokenTypes.add("http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1");
+        tokenTypes.add("http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV2.0");
+        request.setTokenTypes(tokenTypes);
+        List<String> keyTypes = new ArrayList<String>();
+        keyTypes.add("http://docs.oasis-open.org/ws-sx/ws-trust/200512/Bearer");
+        keyTypes.add("http://docs.oasis-open.org/ws-sx/ws-trust/200512/Bearer");
+        request.setKeyTypes(keyTypes);
+        
+        // Request the token
+        List<SecurityToken> tokens = requestSecurityToken(bus, wsdlLocation, request);
+        assertTrue(tokens != null && tokens.size() == 2);
+        
+        assertTrue(tokens.get(0).getToken().getLocalName().equals("Assertion"));
+        assertTrue(tokens.get(0).getToken().getNamespaceURI().equals(SAMLConstants.SAML1_NS));
+        assertTrue(tokens.get(1).getToken().getLocalName().equals("Assertion"));
+        assertTrue(tokens.get(1).getToken().getNamespaceURI().equals(SAMLConstants.SAML20_NS));
+    }
+    
+    
+    private List<SecurityToken> requestSecurityToken(
+        Bus bus, String wsdlLocation, BatchRequest request
+    ) throws Exception {
+        SimpleBatchSTSClient stsClient = new SimpleBatchSTSClient(bus);
+        stsClient.setWsdlLocation(wsdlLocation);
+        stsClient.setServiceName("{http://docs.oasis-open.org/ws-sx/ws-trust/200512/}SecurityTokenService");
+        stsClient.setEndpointName("{http://docs.oasis-open.org/ws-sx/ws-trust/200512/}Transport_Port");
+
+        Map<String, Object> properties = new HashMap<String, Object>();
+        properties.put(SecurityConstants.USERNAME, "alice");
+        properties.put(
+            SecurityConstants.CALLBACK_HANDLER, 
+            "org.apache.cxf.systest.sts.common.CommonCallbackHandler"
+        );
+        properties.put(SecurityConstants.STS_TOKEN_PROPERTIES, "serviceKeystore.properties");
+        
+        stsClient.setEnableLifetime(true);
+
+        stsClient.setProperties(properties);
+        stsClient.setRequiresEntropy(true);
+        stsClient.setKeySize(128);
+        stsClient.setAddressingNamespace("http://www.w3.org/2005/08/addressing");
+
+        return stsClient.requestBatchSecurityTokens(request);
+    }
+    
+    
+}

Copied: cxf/trunk/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/batch/STSServer.java (from r1325343, cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/operation/IssueOperation.java)
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/batch/STSServer.java?p2=cxf/trunk/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/batch/STSServer.java&p1=cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/operation/IssueOperation.java&r1=1325343&r2=1325349&rev=1325349&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/sts/provider/operation/IssueOperation.java (original)
+++ cxf/trunk/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/batch/STSServer.java Thu Apr 12 16:18:00 2012
@@ -16,23 +16,35 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+package org.apache.cxf.systest.sts.batch;
 
-package org.apache.cxf.ws.security.sts.provider.operation;
+import java.net.URL;
 
-import javax.xml.ws.WebServiceContext;
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
 
-import org.apache.cxf.ws.security.sts.provider.model.RequestSecurityTokenCollectionType;
-import org.apache.cxf.ws.security.sts.provider.model.RequestSecurityTokenResponseCollectionType;
-import org.apache.cxf.ws.security.sts.provider.model.RequestSecurityTokenType;
+public class STSServer extends AbstractBusTestServerBase {
 
-public interface IssueOperation {
+    public STSServer() {
 
-    RequestSecurityTokenResponseCollectionType issue(
-            RequestSecurityTokenType request,
-            WebServiceContext context);
-    
-    RequestSecurityTokenResponseCollectionType issue(
-            RequestSecurityTokenCollectionType requestCollection,
-            WebServiceContext context);
+    }
+
+    protected void run()  {
+        URL busFile = STSServer.class.getResource("cxf-sts.xml");
+        Bus busLocal = new SpringBusFactory().createBus(busFile);
+        BusFactory.setDefaultBus(busLocal);
+        setBus(busLocal);
 
+        try {
+            new STSServer();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+    
+    public static void main(String args[]) {
+        new STSServer().run();
+    }
 }



Mime
View raw message