You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by co...@apache.org on 2012/04/12 18:18:01 UTC
svn commit: r1325349 [2/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...
Added: cxf/trunk/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/batch/SimpleBatchSTSClient.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/batch/SimpleBatchSTSClient.java?rev=1325349&view=auto
==============================================================================
--- cxf/trunk/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/batch/SimpleBatchSTSClient.java (added)
+++ cxf/trunk/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/batch/SimpleBatchSTSClient.java Thu Apr 12 16:18:00 2012
@@ -0,0 +1,1085 @@
+/**
+ * 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.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.security.PublicKey;
+import java.security.cert.X509Certificate;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.logging.Logger;
+
+import javax.security.auth.callback.CallbackHandler;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.transform.dom.DOMSource;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusException;
+import org.apache.cxf.binding.soap.SoapBindingConstants;
+import org.apache.cxf.binding.soap.model.SoapOperationInfo;
+import org.apache.cxf.common.classloader.ClassLoaderUtils;
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.util.ModCountCopyOnWriteArrayList;
+import org.apache.cxf.common.util.StringUtils;
+import org.apache.cxf.configuration.Configurable;
+import org.apache.cxf.configuration.Configurer;
+import org.apache.cxf.databinding.source.SourceDataBinding;
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.endpoint.ClientImpl;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.endpoint.EndpointException;
+import org.apache.cxf.endpoint.EndpointImpl;
+import org.apache.cxf.feature.AbstractFeature;
+import org.apache.cxf.helpers.CastUtils;
+import org.apache.cxf.helpers.DOMUtils;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.interceptor.Interceptor;
+import org.apache.cxf.interceptor.InterceptorProvider;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.resource.ResourceManager;
+import org.apache.cxf.service.Service;
+import org.apache.cxf.service.model.BindingInfo;
+import org.apache.cxf.service.model.BindingOperationInfo;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.service.model.MessagePartInfo;
+import org.apache.cxf.staxutils.StaxUtils;
+import org.apache.cxf.staxutils.W3CDOMStreamWriter;
+import org.apache.cxf.transport.Conduit;
+import org.apache.cxf.ws.addressing.EndpointReferenceType;
+import org.apache.cxf.ws.addressing.VersionTransformer;
+import org.apache.cxf.ws.policy.EffectivePolicy;
+import org.apache.cxf.ws.policy.PolicyBuilder;
+import org.apache.cxf.ws.policy.PolicyEngine;
+import org.apache.cxf.ws.policy.builder.primitive.PrimitiveAssertion;
+import org.apache.cxf.ws.security.SecurityConstants;
+import org.apache.cxf.ws.security.policy.model.AlgorithmSuite;
+import org.apache.cxf.ws.security.policy.model.Binding;
+import org.apache.cxf.ws.security.policy.model.Trust10;
+import org.apache.cxf.ws.security.policy.model.Trust13;
+import org.apache.cxf.ws.security.tokenstore.SecurityToken;
+import org.apache.cxf.ws.security.trust.STSUtils;
+import org.apache.cxf.ws.security.trust.TrustException;
+import org.apache.cxf.wsdl.EndpointReferenceUtils;
+import org.apache.cxf.wsdl11.WSDLServiceFactory;
+import org.apache.neethi.Policy;
+import org.apache.neethi.PolicyComponent;
+import org.apache.ws.security.WSConstants;
+import org.apache.ws.security.WSDocInfo;
+import org.apache.ws.security.WSSConfig;
+import org.apache.ws.security.WSSecurityEngineResult;
+import org.apache.ws.security.WSSecurityException;
+import org.apache.ws.security.components.crypto.Crypto;
+import org.apache.ws.security.components.crypto.CryptoFactory;
+import org.apache.ws.security.components.crypto.CryptoType;
+import org.apache.ws.security.conversation.ConversationException;
+import org.apache.ws.security.conversation.dkalgo.P_SHA1;
+import org.apache.ws.security.handler.RequestData;
+import org.apache.ws.security.message.token.BinarySecurity;
+import org.apache.ws.security.message.token.Reference;
+import org.apache.ws.security.processor.EncryptedKeyProcessor;
+import org.apache.ws.security.processor.X509Util;
+import org.apache.ws.security.util.Base64;
+import org.apache.ws.security.util.WSSecurityUtil;
+import org.apache.ws.security.util.XmlSchemaDateFormat;
+import org.apache.xml.security.keys.content.X509Data;
+import org.apache.xml.security.keys.content.keyvalues.DSAKeyValue;
+import org.apache.xml.security.keys.content.keyvalues.RSAKeyValue;
+
+/**
+ * A primitive STSClient for batch tokens. Note that this contains a number of hacks and should NOT be
+ * used for production use.
+ */
+public class SimpleBatchSTSClient implements Configurable, InterceptorProvider {
+ private static final Logger LOG = LogUtils.getL7dLogger(SimpleBatchSTSClient.class);
+
+ protected Bus bus;
+ protected String name = "default.sts-client";
+ protected Client client;
+ protected String location;
+
+ protected String wsdlLocation;
+ protected QName serviceName;
+ protected QName endpointName;
+
+ protected Policy policy;
+ protected String soapVersion = SoapBindingConstants.SOAP11_BINDING_ID;
+ protected int keySize = 256;
+ protected boolean requiresEntropy = true;
+ protected Element template;
+ protected Element claims;
+ protected AlgorithmSuite algorithmSuite;
+ protected String namespace = STSUtils.WST_NS_05_12;
+ protected String addressingNamespace;
+ protected Object onBehalfOf;
+ protected boolean enableAppliesTo = true;
+
+ protected boolean useCertificateForConfirmationKeyInfo;
+ protected boolean isSecureConv;
+ protected boolean isSpnego;
+ protected boolean enableLifetime;
+ protected int ttl = 300;
+ protected boolean allowRenewing = true;
+ protected boolean allowRenewingAfterExpiry;
+
+ protected Object actAs;
+ protected String tokenType;
+ protected String keyType;
+ protected boolean sendKeyType = true;
+ protected Message message;
+ protected String context;
+
+ protected Map<String, Object> ctx = new HashMap<String, Object>();
+
+ protected List<Interceptor<? extends Message>> in
+ = new ModCountCopyOnWriteArrayList<Interceptor<? extends Message>>();
+ protected List<Interceptor<? extends Message>> out
+ = new ModCountCopyOnWriteArrayList<Interceptor<? extends Message>>();
+ protected List<Interceptor<? extends Message>> outFault
+ = new ModCountCopyOnWriteArrayList<Interceptor<? extends Message>>();
+ protected List<Interceptor<? extends Message>> inFault
+ = new ModCountCopyOnWriteArrayList<Interceptor<? extends Message>>();
+ protected List<AbstractFeature> features;
+
+ public SimpleBatchSTSClient(Bus b) {
+ bus = b;
+ }
+
+ public String getBeanName() {
+ return name;
+ }
+
+ public void setBeanName(String s) {
+ name = s;
+ }
+
+ public void setLocation(String location) {
+ this.location = location;
+ }
+
+ public void setMessage(Message message) {
+ this.message = message;
+ }
+
+ public void setTtl(int ttl) {
+ this.ttl = ttl;
+ }
+
+ public void setEnableLifetime(boolean enableLifetime) {
+ this.enableLifetime = enableLifetime;
+ }
+
+ /**
+ * Sets the WS-P policy that is applied to communications between this client and the remote server
+ * if no value is supplied for {@link #setWsdlLocation(String)}.
+ * <p/>
+ * Accepts {@link Policy} or {@link Element} as input.
+ *
+ * @param newPolicy the policy object
+ *
+ * @throws IllegalArgumentException if {@code newPolicy} is not one of the supported types.
+ */
+ public void setPolicy(Object newPolicy) {
+ if (newPolicy instanceof Policy) {
+ this.setPolicyInternal((Policy) newPolicy);
+ } else if (newPolicy instanceof Element) {
+ this.setPolicyInternal((Element) newPolicy);
+ } else {
+ throw new IllegalArgumentException("Unsupported policy object. Type must be "
+ + "org.apache.neethi.Policy or org.w3c.dom.Element.");
+ }
+ }
+
+ public void setSoap12() {
+ soapVersion = SoapBindingConstants.SOAP12_BINDING_ID;
+ }
+
+ public void setSoap11() {
+ soapVersion = SoapBindingConstants.SOAP11_BINDING_ID;
+ }
+
+ public void setSoap11(boolean b) {
+ if (b) {
+ setSoap11();
+ } else {
+ setSoap12();
+ }
+ }
+
+ public void setAddressingNamespace(String ad) {
+ addressingNamespace = ad;
+ }
+
+ public void setTrust(Trust10 trust) {
+ if (trust != null) {
+ namespace = STSUtils.WST_NS_05_02;
+ requiresEntropy = trust.isRequireClientEntropy();
+ }
+ }
+
+ public void setTrust(Trust13 trust) {
+ if (trust != null) {
+ namespace = STSUtils.WST_NS_05_12;
+ requiresEntropy = trust.isRequireClientEntropy();
+ }
+ }
+
+ public boolean isRequiresEntropy() {
+ return requiresEntropy;
+ }
+
+ public void setRequiresEntropy(boolean requiresEntropy) {
+ this.requiresEntropy = requiresEntropy;
+ }
+
+ public boolean isSecureConv() {
+ return isSecureConv;
+ }
+
+ public void setSecureConv(boolean secureConv) {
+ this.isSecureConv = secureConv;
+ }
+
+ public boolean isSpnego() {
+ return isSpnego;
+ }
+
+ public void setSpnego(boolean spnego) {
+ this.isSpnego = spnego;
+ }
+
+ public boolean isAllowRenewing() {
+ return allowRenewing;
+ }
+
+ public void setAllowRenewing(boolean allowRenewing) {
+ this.allowRenewing = allowRenewing;
+ }
+
+ public boolean isAllowRenewingAfterExpiry() {
+ return allowRenewingAfterExpiry;
+ }
+
+ public void setAllowRenewingAfterExpiry(boolean allowRenewingAfterExpiry) {
+ this.allowRenewingAfterExpiry = allowRenewingAfterExpiry;
+ }
+
+ public boolean isEnableAppliesTo() {
+ return enableAppliesTo;
+ }
+
+ public void setEnableAppliesTo(boolean enableAppliesTo) {
+ this.enableAppliesTo = enableAppliesTo;
+ }
+
+ public String getContext() {
+ return context;
+ }
+
+ public void setContext(String context) {
+ this.context = context;
+ }
+
+ public void setAlgorithmSuite(AlgorithmSuite ag) {
+ algorithmSuite = ag;
+ }
+
+ public Map<String, Object> getRequestContext() {
+ return ctx;
+ }
+
+ public void setProperties(Map<String, Object> p) {
+ ctx.putAll(p);
+ }
+
+ public Map<String, Object> getProperties() {
+ return ctx;
+ }
+
+ public void setWsdlLocation(String wsdl) {
+ wsdlLocation = wsdl;
+ }
+ public String getWsdlLocation() {
+ return wsdlLocation;
+ }
+
+ public void setServiceName(String qn) {
+ serviceName = QName.valueOf(qn);
+ }
+
+ public void setEndpointName(String qn) {
+ endpointName = QName.valueOf(qn);
+ }
+
+ public void setServiceQName(QName qn) {
+ serviceName = qn;
+ }
+ public QName getServiceQName() {
+ return serviceName;
+ }
+
+ public void setEndpointQName(QName qn) {
+ endpointName = qn;
+ }
+ public QName getEndpointQName() {
+ return endpointName;
+ }
+
+ public void setActAs(Object actAs) {
+ this.actAs = actAs;
+ }
+
+ public void setKeySize(int i) {
+ keySize = i;
+ }
+
+ public int getKeySize() {
+ return keySize;
+ }
+
+ public void setTokenType(String tokenType) {
+ this.tokenType = tokenType;
+ }
+
+ public String getTokenType() {
+ return tokenType;
+ }
+
+ public void setSendKeyType(boolean sendKeyType) {
+ this.sendKeyType = sendKeyType;
+ }
+
+ public void setKeyType(String keyType) {
+ this.keyType = keyType;
+ }
+
+ @Deprecated
+ public void setOnBehalfOfElement(Element onBehalfOfElement) {
+ this.onBehalfOf = onBehalfOfElement;
+ }
+
+ public void setOnBehalfOf(Object onBehalfOf) {
+ this.onBehalfOf = onBehalfOf;
+ }
+
+ /**
+ * Indicate whether to use the signer's public X509 certificate for the subject confirmation key info
+ * when creating a RequestsSecurityToken message. If the property is set to 'false', only the public key
+ * value will be provided in the request. If the property is set to 'true' the complete certificate will
+ * be sent in the request.
+ *
+ * Note: this setting is only applicable for assertions that use an asymmetric proof key
+ */
+ public void setUseCertificateForConfirmationKeyInfo(boolean useCertificate) {
+ this.useCertificateForConfirmationKeyInfo = useCertificate;
+ }
+
+ public boolean isUseCertificateForConfirmationKeyInfo() {
+ return useCertificateForConfirmationKeyInfo;
+ }
+
+ protected void setPolicyInternal(Policy newPolicy) {
+ this.policy = newPolicy;
+ if (algorithmSuite == null) {
+ Iterator<?> i = policy.getAlternatives();
+ while (i.hasNext() && algorithmSuite == null) {
+ List<PolicyComponent> p = CastUtils.cast((List<?>)i.next());
+ for (PolicyComponent p2 : p) {
+ if (p2 instanceof Binding) {
+ algorithmSuite = ((Binding)p2).getAlgorithmSuite();
+ }
+ }
+ }
+ }
+ }
+
+ protected void setPolicyInternal(Element newPolicy) {
+ this.setPolicyInternal(bus.getExtension(PolicyBuilder.class).getPolicy(newPolicy));
+ }
+
+ public Client getClient() throws BusException, EndpointException {
+ if (client == null) {
+ createClient();
+ }
+ return client;
+ }
+
+ protected String findMEXLocation(EndpointReferenceType ref) {
+ if (ref.getMetadata() != null && ref.getMetadata().getAny() != null) {
+ for (Object any : ref.getMetadata().getAny()) {
+ if (any instanceof Element) {
+ String addr = findMEXLocation((Element)any);
+ if (addr != null) {
+ return addr;
+ }
+ }
+ }
+ }
+ return EndpointReferenceUtils.getAddress(ref);
+ }
+ protected String findMEXLocation(Element ref) {
+ Element el = DOMUtils.getFirstElement(ref);
+ while (el != null) {
+ if (el.getLocalName().equals("Address")
+ && VersionTransformer.isSupported(el.getNamespaceURI())
+ && "MetadataReference".equals(ref.getLocalName())) {
+ return DOMUtils.getContent(el);
+ } else {
+ String ad = findMEXLocation(el);
+ if (ad != null) {
+ return ad;
+ }
+ }
+ el = DOMUtils.getNextElement(el);
+ }
+ return null;
+ }
+ protected void createClient() throws BusException, EndpointException {
+ if (client != null) {
+ return;
+ }
+ bus.getExtension(Configurer.class).configureBean(name, this);
+
+ if (wsdlLocation != null) {
+ WSDLServiceFactory factory = new WSDLServiceFactory(bus, wsdlLocation, serviceName);
+ SourceDataBinding dataBinding = new SourceDataBinding();
+ factory.setDataBinding(dataBinding);
+ Service service = factory.create();
+ service.setDataBinding(dataBinding);
+ EndpointInfo ei = service.getEndpointInfo(endpointName);
+ Endpoint endpoint = new EndpointImpl(bus, service, ei);
+ client = new ClientImpl(bus, endpoint);
+ } else {
+ Endpoint endpoint = STSUtils.createSTSEndpoint(bus, namespace, null, location, soapVersion,
+ policy, endpointName);
+
+ client = new ClientImpl(bus, endpoint);
+ }
+
+ client.getInFaultInterceptors().addAll(inFault);
+ client.getInInterceptors().addAll(in);
+ client.getOutInterceptors().addAll(out);
+ client.getOutFaultInterceptors().addAll(outFault);
+ in = null;
+ out = null;
+ inFault = null;
+ outFault = null;
+ if (features != null) {
+ for (AbstractFeature f : features) {
+ f.initialize(client, bus);
+ }
+ }
+ }
+
+ protected BindingOperationInfo findOperation(String suffix) {
+ BindingInfo bi = client.getEndpoint().getBinding().getBindingInfo();
+ for (BindingOperationInfo boi : bi.getOperations()) {
+ SoapOperationInfo soi = boi.getExtensor(SoapOperationInfo.class);
+ if (soi != null && soi.getAction() != null && soi.getAction().endsWith(suffix)) {
+ PolicyEngine pe = bus.getExtension(PolicyEngine.class);
+ Conduit conduit = client.getConduit();
+ EffectivePolicy effectivePolicy = pe.getEffectiveClientRequestPolicy(client.getEndpoint()
+ .getEndpointInfo(), boi, conduit);
+ setPolicyInternal(effectivePolicy.getPolicy());
+ return boi;
+ }
+ }
+ //operation is not correct as the Action is not set correctly. Let's see if
+ //we can at least find it by name and then set the action and such manually later.
+ for (BindingOperationInfo boi : bi.getOperations()) {
+ if (boi.getInput().getMessageInfo().getMessageParts().size() > 0) {
+ MessagePartInfo mpi = boi.getInput().getMessageInfo().getMessagePart(0);
+ if ("RequestSecurityToken".equals(mpi.getConcreteName().getLocalPart())) {
+ return boi;
+ }
+ }
+ }
+ return null;
+ }
+
+ public List<SecurityToken> requestBatchSecurityTokens(BatchRequest batchRequest) throws Exception {
+ createClient();
+ BindingOperationInfo boi = findOperation("/RST/RequestCollection");
+
+ client.getRequestContext().putAll(ctx);
+ client.getRequestContext().put(SoapBindingConstants.SOAP_ACTION, batchRequest.getAction());
+
+ W3CDOMStreamWriter writer = new W3CDOMStreamWriter();
+ writer.writeStartElement("wst", "RequestSecurityTokenCollection", namespace);
+ writer.writeNamespace("wst", namespace);
+
+ List<String> tokenTypes = batchRequest.getTokenTypes();
+ for (int i = 0; i < tokenTypes.size(); i++) {
+ writer.writeStartElement("wst", "RequestSecurityToken", namespace);
+ writer.writeNamespace("wst", namespace);
+
+ addRequestType(batchRequest.getRequestType(), writer);
+ if (enableAppliesTo) {
+ addAppliesTo(writer, batchRequest.getAppliesTo().get(i));
+ }
+
+ writeKeyType(writer, batchRequest.getKeyTypes().get(i));
+
+ addLifetime(writer);
+
+ addTokenType(writer, tokenTypes.get(i));
+
+ writer.writeEndElement();
+ }
+ writer.writeEndElement();
+
+ Object obj[] = client.invoke(boi, new DOMSource(writer.getDocument().getDocumentElement()));
+
+ Element responseCollection = getDocumentElement((DOMSource)obj[0]);
+ Node child = responseCollection.getFirstChild();
+ List<SecurityToken> tokens = new ArrayList<SecurityToken>();
+ while (child != null) {
+ if (child instanceof Element
+ && "RequestSecurityTokenResponse".equals(((Element)child).getLocalName())) {
+ SecurityToken token =
+ createSecurityToken((Element)child, null);
+ tokens.add(token);
+ }
+ child = child.getNextSibling();
+ }
+
+ return tokens;
+ }
+
+ protected byte[] writeElementsForRSTSymmetricKey(W3CDOMStreamWriter writer,
+ boolean wroteKeySize) throws Exception {
+ byte[] requestorEntropy = null;
+
+ if (!wroteKeySize && (!isSecureConv || keySize != 256)) {
+ addKeySize(keySize, writer);
+ }
+
+ if (requiresEntropy) {
+ writer.writeStartElement("wst", "Entropy", namespace);
+ writer.writeStartElement("wst", "BinarySecret", namespace);
+ writer.writeAttribute("Type", namespace + "/Nonce");
+ if (algorithmSuite == null) {
+ requestorEntropy = WSSecurityUtil.generateNonce(keySize / 8);
+ } else {
+ requestorEntropy = WSSecurityUtil
+ .generateNonce(algorithmSuite.getMaximumSymmetricKeyLength() / 8);
+ }
+ writer.writeCharacters(Base64.encode(requestorEntropy));
+
+ writer.writeEndElement();
+ writer.writeEndElement();
+ writer.writeStartElement("wst", "ComputedKeyAlgorithm", namespace);
+ writer.writeCharacters(namespace + "/CK/PSHA1");
+ writer.writeEndElement();
+ }
+ return requestorEntropy;
+ }
+
+
+ protected void writeElementsForRSTPublicKey(W3CDOMStreamWriter writer,
+ X509Certificate cert) throws Exception {
+ writer.writeStartElement("wst", "UseKey", namespace);
+ writer.writeStartElement("dsig", "KeyInfo", "http://www.w3.org/2000/09/xmldsig#");
+ writer.writeNamespace("dsig", "http://www.w3.org/2000/09/xmldsig#");
+
+ boolean useCert = useCertificateForConfirmationKeyInfo;
+ String useCertStr = (String)getProperty(SecurityConstants.STS_TOKEN_USE_CERT_FOR_KEYINFO);
+ if (useCertStr != null) {
+ useCert = Boolean.parseBoolean(useCertStr);
+ }
+ if (useCert) {
+ X509Data certElem = new X509Data(writer.getDocument());
+ certElem.addCertificate(cert);
+ writer.getCurrentNode().appendChild(certElem.getElement());
+ } else {
+ writer.writeStartElement("dsig", "KeyValue", "http://www.w3.org/2000/09/xmldsig#");
+ PublicKey key = cert.getPublicKey();
+ String pubKeyAlgo = key.getAlgorithm();
+ if ("DSA".equalsIgnoreCase(pubKeyAlgo)) {
+ DSAKeyValue dsaKeyValue = new DSAKeyValue(writer.getDocument(), key);
+ writer.getCurrentNode().appendChild(dsaKeyValue.getElement());
+ } else if ("RSA".equalsIgnoreCase(pubKeyAlgo)) {
+ RSAKeyValue rsaKeyValue = new RSAKeyValue(writer.getDocument(), key);
+ writer.getCurrentNode().appendChild(rsaKeyValue.getElement());
+ }
+ writer.writeEndElement();
+ }
+
+ writer.writeEndElement();
+ writer.writeEndElement();
+ }
+
+ protected void addBinaryExchange(
+ String binaryExchange,
+ W3CDOMStreamWriter writer
+ ) throws XMLStreamException {
+ writer.writeStartElement("wst", "BinaryExchange", namespace);
+ writer.writeAttribute("EncodingType", BinarySecurity.BASE64_ENCODING);
+ writer.writeAttribute("ValueType", namespace + "/spnego");
+ writer.writeCharacters(binaryExchange);
+ writer.writeEndElement();
+ }
+
+ protected void addKeySize(int keysize, W3CDOMStreamWriter writer) throws XMLStreamException {
+ writer.writeStartElement("wst", "KeySize", namespace);
+ writer.writeCharacters(Integer.toString(keysize));
+ writer.writeEndElement();
+ }
+
+ protected void addRequestType(String requestType, W3CDOMStreamWriter writer) throws XMLStreamException {
+ writer.writeStartElement("wst", "RequestType", namespace);
+ writer.writeCharacters(requestType);
+ writer.writeEndElement();
+ }
+
+ protected Element getDocumentElement(DOMSource ds) {
+ Node nd = ds.getNode();
+ if (nd instanceof Document) {
+ nd = ((Document)nd).getDocumentElement();
+ }
+ return (Element)nd;
+ }
+
+ protected PrimitiveAssertion getAddressingAssertion() {
+ String ns = "http://schemas.xmlsoap.org/ws/2004/08/addressing/policy";
+ String local = "UsingAddressing";
+ if ("http://www.w3.org/2005/08/addressing".equals(addressingNamespace)) {
+ ns = "http://www.w3.org/2007/02/addressing/metadata";
+ local = "Addressing";
+ }
+ return new PrimitiveAssertion(new QName(ns, local), true);
+ }
+
+ protected boolean useSecondaryParameters() {
+ return !STSUtils.WST_NS_05_02.equals(namespace);
+ }
+
+ protected String writeKeyType(W3CDOMStreamWriter writer, String keyTypeToWrite)
+ throws XMLStreamException {
+ if (isSecureConv) {
+ if (keyTypeToWrite == null) {
+ writer.writeStartElement("wst", "TokenType", namespace);
+ writer.writeCharacters(STSUtils.getTokenTypeSCT(namespace));
+ writer.writeEndElement();
+ keyTypeToWrite = namespace + "/SymmetricKey";
+ }
+ } else if (keyTypeToWrite == null && sendKeyType) {
+ writer.writeStartElement("wst", "KeyType", namespace);
+ writer.writeCharacters(namespace + "/SymmetricKey");
+ writer.writeEndElement();
+ keyTypeToWrite = namespace + "/SymmetricKey";
+ } else if (keyTypeToWrite != null) {
+ writer.writeStartElement("wst", "KeyType", namespace);
+ writer.writeCharacters(keyTypeToWrite);
+ writer.writeEndElement();
+ }
+ return keyTypeToWrite;
+ }
+
+ protected X509Certificate getCert(Crypto crypto) throws Exception {
+ String alias = (String)getProperty(SecurityConstants.STS_TOKEN_USERNAME);
+ if (alias == null) {
+ alias = crypto.getDefaultX509Identifier();
+ }
+ if (alias == null) {
+ throw new Fault("No alias specified for retrieving PublicKey", LOG);
+ }
+ CryptoType cryptoType = new CryptoType(CryptoType.TYPE.ALIAS);
+ cryptoType.setAlias(alias);
+
+ X509Certificate certs[] = crypto.getX509Certificates(cryptoType);
+ if (certs == null || certs.length == 0) {
+ throw new Fault("Could not get X509Certificate for alias " + alias, LOG);
+ }
+ return certs[0];
+ }
+
+ protected void addLifetime(XMLStreamWriter writer) throws XMLStreamException {
+ Date creationTime = new Date();
+ Date expirationTime = new Date();
+ expirationTime.setTime(creationTime.getTime() + (ttl * 1000L));
+
+ XmlSchemaDateFormat fmt = new XmlSchemaDateFormat();
+ writer.writeStartElement("wst", "Lifetime", namespace);
+ writer.writeNamespace("wsu", WSConstants.WSU_NS);
+ writer.writeStartElement("wsu", "Created", WSConstants.WSU_NS);
+ writer.writeCharacters(fmt.format(creationTime));
+ writer.writeEndElement();
+
+ writer.writeStartElement("wsu", "Expires", WSConstants.WSU_NS);
+ writer.writeCharacters(fmt.format(expirationTime));
+ writer.writeEndElement();
+ writer.writeEndElement();
+ }
+
+ protected void addAppliesTo(XMLStreamWriter writer, String appliesTo) throws XMLStreamException {
+ if (appliesTo != null && addressingNamespace != null) {
+ writer.writeStartElement("wsp", "AppliesTo", "http://schemas.xmlsoap.org/ws/2004/09/policy");
+ writer.writeNamespace("wsp", "http://schemas.xmlsoap.org/ws/2004/09/policy");
+ writer.writeStartElement("wsa", "EndpointReference", addressingNamespace);
+ writer.writeNamespace("wsa", addressingNamespace);
+ writer.writeStartElement("wsa", "Address", addressingNamespace);
+ writer.writeCharacters(appliesTo);
+ writer.writeEndElement();
+ writer.writeEndElement();
+ writer.writeEndElement();
+ }
+ }
+
+ protected void addTokenType(XMLStreamWriter writer, String token) throws XMLStreamException {
+ if (token != null) {
+ writer.writeStartElement("wst", "TokenType", namespace);
+ writer.writeCharacters(token);
+ writer.writeEndElement();
+ }
+ }
+
+ protected void addClaims(XMLStreamWriter writer) throws XMLStreamException {
+ if (claims != null) {
+ StaxUtils.copy(claims, writer);
+ }
+ }
+
+ protected SecurityToken createSecurityToken(Element el, byte[] requestorEntropy)
+ throws WSSecurityException {
+
+ if ("RequestSecurityTokenResponseCollection".equals(el.getLocalName())) {
+ el = DOMUtils.getFirstElement(el);
+ }
+ if (!"RequestSecurityTokenResponse".equals(el.getLocalName())) {
+ throw new Fault("Unexpected element " + el.getLocalName(), LOG);
+ }
+ el = DOMUtils.getFirstElement(el);
+ Element rst = null;
+ Element rar = null;
+ Element rur = null;
+ Element rpt = null;
+ Element lte = null;
+ Element entropy = null;
+ String tt = null;
+
+ while (el != null) {
+ String ln = el.getLocalName();
+ if (namespace.equals(el.getNamespaceURI())) {
+ if ("Lifetime".equals(ln)) {
+ lte = el;
+ } else if ("RequestedSecurityToken".equals(ln)) {
+ rst = DOMUtils.getFirstElement(el);
+ } else if ("RequestedAttachedReference".equals(ln)) {
+ rar = DOMUtils.getFirstElement(el);
+ } else if ("RequestedUnattachedReference".equals(ln)) {
+ rur = DOMUtils.getFirstElement(el);
+ } else if ("RequestedProofToken".equals(ln)) {
+ rpt = el;
+ } else if ("Entropy".equals(ln)) {
+ entropy = el;
+ } else if ("TokenType".equals(ln)) {
+ tt = DOMUtils.getContent(el);
+ }
+ }
+ el = DOMUtils.getNextElement(el);
+ }
+ Element rstDec = rst;
+ String id = findID(rar, rur, rstDec);
+ if (StringUtils.isEmpty(id)) {
+ throw new TrustException("NO_ID", LOG);
+ }
+ SecurityToken token = new SecurityToken(id, rstDec, lte);
+ token.setAttachedReference(rar);
+ token.setUnattachedReference(rur);
+ token.setIssuerAddress(location);
+ token.setTokenType(tt);
+
+ byte[] secret = null;
+
+ if (rpt != null) {
+ Element child = DOMUtils.getFirstElement(rpt);
+ QName childQname = DOMUtils.getElementQName(child);
+ if (childQname.equals(new QName(namespace, "BinarySecret"))) {
+ // First check for the binary secret
+ String b64Secret = DOMUtils.getContent(child);
+ secret = Base64.decode(b64Secret);
+ } else if (childQname.equals(new QName(WSConstants.ENC_NS, WSConstants.ENC_KEY_LN))) {
+ secret = decryptKey(child);
+ } else if (childQname.equals(new QName(namespace, "ComputedKey"))) {
+ // Handle the computed key
+ Element computedKeyChild = entropy == null ? null : DOMUtils.getFirstElement(entropy);
+ byte[] serviceEntr = null;
+
+ if (computedKeyChild != null) {
+ QName computedKeyChildQName = DOMUtils.getElementQName(computedKeyChild);
+ if (computedKeyChildQName.equals(new QName(WSConstants.ENC_NS, WSConstants.ENC_KEY_LN))) {
+ serviceEntr = decryptKey(computedKeyChild);
+ } else if (computedKeyChildQName.equals(new QName(namespace, "BinarySecret"))) {
+ String content = DOMUtils.getContent(computedKeyChild);
+ serviceEntr = Base64.decode(content);
+ }
+ }
+
+ if (serviceEntr != null) {
+ // Right now we only use PSHA1 as the computed key algo
+ P_SHA1 psha1 = new P_SHA1();
+
+ int length = (keySize > 0) ? keySize : 256;
+ if (algorithmSuite != null) {
+ length = (keySize > 0) ? keySize : algorithmSuite.getMaximumSymmetricKeyLength();
+ }
+ try {
+ secret = psha1.createKey(requestorEntropy, serviceEntr, 0, length / 8);
+ } catch (ConversationException e) {
+ throw new TrustException("DERIVED_KEY_ERROR", LOG, e);
+ }
+ } else {
+ // Service entropy missing
+ throw new TrustException("NO_ENTROPY", LOG);
+ }
+ }
+ } else if (requestorEntropy != null) {
+ // Use requester entropy as the key
+ secret = requestorEntropy;
+ }
+ token.setSecret(secret);
+
+ return token;
+ }
+
+ protected byte[] decryptKey(Element child) throws TrustException, WSSecurityException {
+ String encryptionAlgorithm = X509Util.getEncAlgo(child);
+ // For the SPNEGO case just return the decoded cipher value and decrypt it later
+ if (encryptionAlgorithm != null && encryptionAlgorithm.endsWith("spnego#GSS_Wrap")) {
+ // Get the CipherValue
+ Element tmpE =
+ WSSecurityUtil.getDirectChildElement(child, "CipherData", WSConstants.ENC_NS);
+ byte[] cipherValue = null;
+ if (tmpE != null) {
+ tmpE =
+ WSSecurityUtil.getDirectChildElement(tmpE, "CipherValue", WSConstants.ENC_NS);
+ if (tmpE != null) {
+ String content = DOMUtils.getContent(tmpE);
+ cipherValue = Base64.decode(content);
+ }
+ }
+ if (cipherValue == null) {
+ throw new WSSecurityException(WSSecurityException.INVALID_SECURITY, "noCipher");
+ }
+ return cipherValue;
+ } else {
+ try {
+ EncryptedKeyProcessor proc = new EncryptedKeyProcessor();
+ WSDocInfo docInfo = new WSDocInfo(child.getOwnerDocument());
+ RequestData data = new RequestData();
+ data.setWssConfig(WSSConfig.getNewInstance());
+ data.setDecCrypto(createCrypto(true));
+ data.setCallbackHandler(createHandler());
+ List<WSSecurityEngineResult> result =
+ proc.handleToken(child, data, docInfo);
+ return
+ (byte[])result.get(0).get(
+ WSSecurityEngineResult.TAG_SECRET
+ );
+ } catch (IOException e) {
+ throw new TrustException("ENCRYPTED_KEY_ERROR", LOG, e);
+ }
+ }
+ }
+
+ protected CallbackHandler createHandler() {
+ Object o = getProperty(SecurityConstants.CALLBACK_HANDLER);
+ if (o instanceof String) {
+ try {
+ Class<?> cls = ClassLoaderUtils.loadClass((String)o, this.getClass());
+ o = cls.newInstance();
+ } catch (Exception e) {
+ throw new Fault(e);
+ }
+ }
+ return (CallbackHandler)o;
+ }
+
+ protected Object getProperty(String s) {
+ Object o = ctx.get(s);
+ if (o == null) {
+ o = client.getEndpoint().getEndpointInfo().getProperty(s);
+ }
+ if (o == null) {
+ o = client.getEndpoint().getEndpointInfo().getBinding().getProperty(s);
+ }
+ if (o == null) {
+ o = client.getEndpoint().getService().get(s);
+ }
+ return o;
+ }
+
+ protected Crypto createCrypto(boolean decrypt) throws IOException, WSSecurityException {
+ Crypto crypto = (Crypto)getProperty(SecurityConstants.STS_TOKEN_CRYPTO + (decrypt ? ".decrypt" : ""));
+ if (crypto != null) {
+ return crypto;
+ }
+
+ Object o = getProperty(SecurityConstants.STS_TOKEN_PROPERTIES + (decrypt ? ".decrypt" : ""));
+ Properties properties = null;
+ if (o instanceof Properties) {
+ properties = (Properties)o;
+ } else if (o instanceof String) {
+ ResourceManager rm = bus.getExtension(ResourceManager.class);
+ URL url = rm.resolveResource((String)o, URL.class);
+ if (url == null) {
+ url = ClassLoaderUtils.getResource((String)o, this.getClass());
+ }
+ if (url != null) {
+ properties = new Properties();
+ InputStream ins = url.openStream();
+ properties.load(ins);
+ ins.close();
+ } else {
+ throw new Fault("Could not find properties file " + (String)o, LOG);
+ }
+ } else if (o instanceof URL) {
+ properties = new Properties();
+ InputStream ins = ((URL)o).openStream();
+ properties.load(ins);
+ ins.close();
+ }
+
+ if (properties != null) {
+ return CryptoFactory.getInstance(properties);
+ }
+ if (decrypt) {
+ return createCrypto(false);
+ }
+ return null;
+ }
+
+ protected String findID(Element rar, Element rur, Element rst) {
+ String id = null;
+ if (rst != null) {
+ QName elName = DOMUtils.getElementQName(rst);
+ if (elName.equals(new QName(WSConstants.SAML_NS, "Assertion"))
+ && rst.hasAttributeNS(null, "AssertionID")) {
+ id = rst.getAttributeNS(null, "AssertionID");
+ } else if (elName.equals(new QName(WSConstants.SAML2_NS, "Assertion"))
+ && rst.hasAttributeNS(null, "ID")) {
+ id = rst.getAttributeNS(null, "ID");
+ }
+ if (id == null) {
+ id = this.getIDFromSTR(rst);
+ }
+ }
+ if (id == null && rar != null) {
+ id = this.getIDFromSTR(rar);
+ }
+ if (id == null && rur != null) {
+ id = this.getIDFromSTR(rur);
+ }
+ if (id == null && rst != null) {
+ id = rst.getAttributeNS(WSConstants.WSU_NS, "Id");
+ }
+ return id;
+ }
+
+ protected String getIDFromSTR(Element el) {
+ Element child = DOMUtils.getFirstElement(el);
+ if (child == null) {
+ return null;
+ }
+ QName elName = DOMUtils.getElementQName(child);
+ if (elName.equals(new QName(WSConstants.SIG_NS, "KeyInfo"))
+ || elName.equals(new QName(WSConstants.WSSE_NS, "KeyIdentifier"))) {
+ return DOMUtils.getContent(child);
+ } else if (elName.equals(Reference.TOKEN)) {
+ return child.getAttribute("URI");
+ } else if (elName.equals(new QName(STSUtils.SCT_NS_05_02, "Identifier"))
+ || elName.equals(new QName(STSUtils.SCT_NS_05_12, "Identifier"))) {
+ return DOMUtils.getContent(child);
+ }
+ return null;
+ }
+
+ public void setTemplate(Element rstTemplate) {
+ template = rstTemplate;
+ }
+
+ public void setClaims(Element rstClaims) {
+ claims = rstClaims;
+ }
+
+ public List<Interceptor<? extends Message>> getOutFaultInterceptors() {
+ if (client != null) {
+ return client.getOutFaultInterceptors();
+ }
+ return outFault;
+ }
+
+ public List<Interceptor<? extends Message>> getInFaultInterceptors() {
+ if (client != null) {
+ return client.getInFaultInterceptors();
+ }
+ return inFault;
+ }
+
+ public List<Interceptor<? extends Message>> getInInterceptors() {
+ if (client != null) {
+ return client.getInInterceptors();
+ }
+ return in;
+ }
+
+ public List<Interceptor<? extends Message>> getOutInterceptors() {
+ if (client != null) {
+ return client.getOutInterceptors();
+ }
+ return out;
+ }
+
+ public void setInInterceptors(List<Interceptor<? extends Message>> interceptors) {
+ getInInterceptors().addAll(interceptors);
+ }
+
+ public void setInFaultInterceptors(List<Interceptor<? extends Message>> interceptors) {
+ getInFaultInterceptors().addAll(interceptors);
+ }
+
+ public void setOutInterceptors(List<Interceptor<? extends Message>> interceptors) {
+ getOutInterceptors().addAll(interceptors);
+ }
+
+ public void setOutFaultInterceptors(List<Interceptor<? extends Message>> interceptors) {
+ getOutFaultInterceptors().addAll(interceptors);
+ }
+
+ public void setFeatures(List<AbstractFeature> f) {
+ features = f;
+ }
+ public List<AbstractFeature> getFeatures() {
+ return features;
+ }
+}
Added: cxf/trunk/services/sts/systests/advanced/src/test/resources/org/apache/cxf/systest/sts/batch/cxf-client-unit.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/systests/advanced/src/test/resources/org/apache/cxf/systest/sts/batch/cxf-client-unit.xml?rev=1325349&view=auto
==============================================================================
--- cxf/trunk/services/sts/systests/advanced/src/test/resources/org/apache/cxf/systest/sts/batch/cxf-client-unit.xml (added)
+++ cxf/trunk/services/sts/systests/advanced/src/test/resources/org/apache/cxf/systest/sts/batch/cxf-client-unit.xml Thu Apr 12 16:18:00 2012
@@ -0,0 +1,52 @@
+<!--
+ 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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:jaxws="http://cxf.apache.org/jaxws"
+ xmlns:cxf="http://cxf.apache.org/core"
+ xmlns:http="http://cxf.apache.org/transports/http/configuration"
+ xmlns:sec="http://cxf.apache.org/configuration/security"
+ xsi:schemaLocation="
+http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
+http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
+http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
+http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd">
+
+ <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
+
+ <cxf:bus>
+ <cxf:features>
+ <cxf:logging/>
+ </cxf:features>
+ </cxf:bus>
+
+ <http:conduit name="https://localhost:.*">
+ <http:tlsClientParameters disableCNCheck="true">
+ <sec:trustManagers>
+ <sec:keyStore type="jks" password="cspass" resource="clientstore.jks"/>
+ </sec:trustManagers>
+ <sec:keyManagers keyPassword="ckpass">
+ <sec:keyStore type="jks" password="cspass" resource="clientstore.jks"/>
+ </sec:keyManagers>
+ </http:tlsClientParameters>
+ </http:conduit>
+
+</beans>
+
Added: cxf/trunk/services/sts/systests/advanced/src/test/resources/org/apache/cxf/systest/sts/batch/cxf-sts.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/systests/advanced/src/test/resources/org/apache/cxf/systest/sts/batch/cxf-sts.xml?rev=1325349&view=auto
==============================================================================
--- cxf/trunk/services/sts/systests/advanced/src/test/resources/org/apache/cxf/systest/sts/batch/cxf-sts.xml (added)
+++ cxf/trunk/services/sts/systests/advanced/src/test/resources/org/apache/cxf/systest/sts/batch/cxf-sts.xml Thu Apr 12 16:18:00 2012
@@ -0,0 +1,182 @@
+<!--
+ 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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:cxf="http://cxf.apache.org/core"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:sec="http://cxf.apache.org/configuration/security"
+ xmlns:http="http://cxf.apache.org/transports/http/configuration"
+ xmlns:httpj="http://cxf.apache.org/transports/http-jetty/configuration"
+ xmlns:jaxws="http://cxf.apache.org/jaxws"
+ xmlns:util="http://www.springframework.org/schema/util"
+ xsi:schemaLocation="
+ http://cxf.apache.org/core
+ http://cxf.apache.org/schemas/core.xsd
+ http://cxf.apache.org/configuration/security
+ http://cxf.apache.org/schemas/configuration/security.xsd
+ http://cxf.apache.org/jaxws
+ http://cxf.apache.org/schemas/jaxws.xsd
+ http://cxf.apache.org/transports/http/configuration
+ http://cxf.apache.org/schemas/configuration/http-conf.xsd
+ http://cxf.apache.org/transports/http-jetty/configuration
+ http://cxf.apache.org/schemas/configuration/http-jetty.xsd
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/util
+ http://www.springframework.org/schema/util/spring-util-2.0.xsd">
+
+ <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
+
+ <cxf:bus>
+ <cxf:features>
+ <cxf:logging/>
+ </cxf:features>
+ </cxf:bus>
+
+ <bean id="transportSTSProviderBean"
+ class="org.apache.cxf.ws.security.sts.provider.SecurityTokenServiceProvider">
+ <property name="issueOperation" ref="transportIssueDelegate" />
+ <property name="validateOperation" ref="transportValidateDelegate" />
+ <property name="requestCollectionOperation" ref="transportRequestCollectionDelegate" />
+ </bean>
+
+ <bean id="transportIssueDelegate" class="org.apache.cxf.sts.operation.TokenIssueOperation">
+ <property name="tokenProviders" ref="transportTokenProviders" />
+ <property name="services" ref="transportService" />
+ <property name="stsProperties" ref="transportSTSProperties" />
+ <property name="claimsManager" ref="claimsManager" />
+ <property name="tokenStore" ref="defaultTokenStore" />
+ </bean>
+
+ <bean id="transportValidateDelegate" class="org.apache.cxf.sts.operation.TokenValidateOperation">
+ <property name="tokenProviders" ref="transportTokenProviders" />
+ <property name="tokenValidators" ref="transportTokenValidators" />
+ <property name="stsProperties" ref="transportSTSProperties" />
+ <property name="tokenStore" ref="defaultTokenStore" />
+ </bean>
+
+ <bean id="transportRequestCollectionDelegate"
+ class="org.apache.cxf.sts.operation.TokenRequestCollectionOperation">
+ <property name="issueSingleOperation" ref="transportIssueDelegate" />
+ <property name="validateOperation" ref="transportValidateDelegate" />
+ </bean>
+
+ <bean id="defaultTokenStore" class="org.apache.cxf.sts.cache.DefaultInMemoryTokenStore">
+ </bean>
+
+ <util:list id="transportTokenProviders">
+ <ref bean="transportSamlTokenProvider" />
+ </util:list>
+
+ <util:list id="transportTokenValidators">
+ <ref bean="transportSamlTokenValidator" />
+ </util:list>
+
+ <bean id="transportSamlTokenProvider" class="org.apache.cxf.sts.token.provider.SAMLTokenProvider">
+ <property name="attributeStatementProviders" ref="attributeStatementProvidersList" />
+ <property name="conditionsProvider" ref="SAMLConditionsProvider"/>
+ </bean>
+
+ <util:list id="attributeStatementProvidersList">
+ <ref bean="defaultAttributeProvider" />
+ <ref bean="customAttributeProvider" />
+ </util:list>
+
+ <bean id="defaultAttributeProvider"
+ class="org.apache.cxf.sts.token.provider.DefaultAttributeStatementProvider">
+ </bean>
+
+ <bean id="customAttributeProvider"
+ class="org.apache.cxf.systest.sts.deployment.CustomAttributeStatementProvider">
+ </bean>
+
+ <bean id="claimsManager" class="org.apache.cxf.sts.claims.ClaimsManager">
+ <property name="claimHandlers" ref="claimHandlerList" />
+ </bean>
+
+ <util:list id="claimHandlerList">
+ <ref bean="customClaimsHandler" />
+ </util:list>
+
+ <bean id="customClaimsHandler"
+ class="org.apache.cxf.systest.sts.deployment.CustomClaimsHandler">
+ </bean>
+
+ <bean id="transportX509TokenValidator" class="org.apache.cxf.sts.token.validator.X509TokenValidator">
+ </bean>
+
+ <bean id="transportSamlTokenValidator" class="org.apache.cxf.sts.token.validator.SAMLTokenValidator">
+ </bean>
+
+ <bean id="SAMLConditionsProvider" class="org.apache.cxf.sts.token.provider.DefaultConditionsProvider">
+ <property name="acceptClientLifetime" value="true"/>
+ </bean>
+
+ <bean id="transportService" class="org.apache.cxf.sts.service.StaticService">
+ <property name="endpoints" ref="transportEndpoints" />
+ </bean>
+
+ <util:list id="transportEndpoints">
+ <value>https://localhost:(\d)*/doubleit/services/doubleittransport.*
+ </value>
+ </util:list>
+
+ <bean id="transportSTSProperties" class="org.apache.cxf.sts.StaticSTSProperties">
+ <property name="signaturePropertiesFile" value="stsKeystore.properties" />
+ <property name="signatureUsername" value="mystskey" />
+ <property name="callbackHandlerClass"
+ value="org.apache.cxf.systest.sts.common.CommonCallbackHandler" />
+ <property name="encryptionPropertiesFile" value="stsKeystore.properties" />
+ <property name="issuer" value="DoubleItSTSIssuer" />
+ <property name="encryptionUsername" value="myservicekey" />
+ </bean>
+
+ <jaxws:endpoint id="localSTS" implementor="#transportSTSProviderBean"
+ address="https://localhost:${testutil.ports.STSServer}/SecurityTokenService/Transport"
+ wsdlLocation="src/test/resources/org/apache/cxf/systest/sts/batch/ws-trust-1.4-service.wsdl"
+ xmlns:ns1="http://docs.oasis-open.org/ws-sx/ws-trust/200512/"
+ depends-on="ClientAuthHttpsSettings" serviceName="ns1:SecurityTokenService"
+ endpointName="ns1:Transport_Port">
+ </jaxws:endpoint>
+
+ <httpj:engine-factory id="ClientAuthHttpsSettings"
+ bus="cxf">
+ <httpj:engine port="${testutil.ports.STSServer}">
+ <httpj:tlsServerParameters>
+ <sec:trustManagers>
+ <sec:keyStore type="jks" password="stsspass" resource="stsstore.jks" />
+ </sec:trustManagers>
+ <sec:keyManagers keyPassword="stskpass">
+ <sec:keyStore type="jks" password="stsspass" resource="stsstore.jks" />
+ </sec:keyManagers>
+ <sec:cipherSuitesFilter>
+ <sec:include>.*_EXPORT_.*</sec:include>
+ <sec:include>.*_EXPORT1024_.*</sec:include>
+ <sec:include>.*_WITH_DES_.*</sec:include>
+ <sec:include>.*_WITH_AES_.*</sec:include>
+ <sec:include>.*_WITH_NULL_.*</sec:include>
+ <sec:exclude>.*_DH_anon_.*</sec:exclude>
+ </sec:cipherSuitesFilter>
+ <sec:clientAuthentication want="true"
+ required="true" />
+ </httpj:tlsServerParameters>
+ </httpj:engine>
+ </httpj:engine-factory>
+
+</beans>
+
Added: cxf/trunk/services/sts/systests/advanced/src/test/resources/org/apache/cxf/systest/sts/batch/ws-trust-1.4-service.wsdl
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/systests/advanced/src/test/resources/org/apache/cxf/systest/sts/batch/ws-trust-1.4-service.wsdl?rev=1325349&view=auto
==============================================================================
--- cxf/trunk/services/sts/systests/advanced/src/test/resources/org/apache/cxf/systest/sts/batch/ws-trust-1.4-service.wsdl (added)
+++ cxf/trunk/services/sts/systests/advanced/src/test/resources/org/apache/cxf/systest/sts/batch/ws-trust-1.4-service.wsdl Thu Apr 12 16:18:00 2012
@@ -0,0 +1,298 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<wsdl:definitions
+ targetNamespace="http://docs.oasis-open.org/ws-sx/ws-trust/200512/"
+ xmlns:tns="http://docs.oasis-open.org/ws-sx/ws-trust/200512/"
+ xmlns:wstrust="http://docs.oasis-open.org/ws-sx/ws-trust/200512/"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:wsap10="http://www.w3.org/2006/05/addressing/wsdl"
+ xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
+ xmlns:wsp="http://www.w3.org/ns/ws-policy"
+ xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
+ xmlns:wst="http://docs.oasis-open.org/ws-sx/ws-trust/200512"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata">
+ >
+
+ <wsdl:types>
+ <xs:schema elementFormDefault="qualified" targetNamespace='http://docs.oasis-open.org/ws-sx/ws-trust/200512'>
+
+ <xs:element name='RequestSecurityToken' type='wst:AbstractRequestSecurityTokenType' />
+ <xs:element name='RequestSecurityTokenResponse' type='wst:AbstractRequestSecurityTokenType' />
+
+ <xs:complexType name='AbstractRequestSecurityTokenType' >
+ <xs:sequence>
+ <xs:any namespace='##any' processContents='lax' minOccurs='0' maxOccurs='unbounded' />
+ </xs:sequence>
+ <xs:attribute name='Context' type='xs:anyURI' use='optional' />
+ <xs:anyAttribute namespace='##other' processContents='lax' />
+ </xs:complexType>
+ <xs:element name='RequestSecurityTokenCollection' type='wst:RequestSecurityTokenCollectionType' />
+ <xs:complexType name='RequestSecurityTokenCollectionType' >
+ <xs:sequence>
+ <xs:element name='RequestSecurityToken' type='wst:AbstractRequestSecurityTokenType' minOccurs='2' maxOccurs='unbounded'/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:element name='RequestSecurityTokenResponseCollection' type='wst:RequestSecurityTokenResponseCollectionType' />
+ <xs:complexType name='RequestSecurityTokenResponseCollectionType' >
+ <xs:sequence>
+ <xs:element ref='wst:RequestSecurityTokenResponse' minOccurs='1' maxOccurs='unbounded' />
+ </xs:sequence>
+ <xs:anyAttribute namespace='##other' processContents='lax' />
+ </xs:complexType>
+
+ </xs:schema>
+ </wsdl:types>
+
+ <!-- WS-Trust defines the following GEDs -->
+ <wsdl:message name="RequestSecurityTokenMsg">
+ <wsdl:part name="request" element="wst:RequestSecurityToken" />
+ </wsdl:message>
+ <wsdl:message name="RequestSecurityTokenResponseMsg">
+ <wsdl:part name="response"
+ element="wst:RequestSecurityTokenResponse" />
+ </wsdl:message>
+ <wsdl:message name="RequestSecurityTokenCollectionMsg">
+ <wsdl:part name="requestCollection"
+ element="wst:RequestSecurityTokenCollection"/>
+ </wsdl:message>
+ <wsdl:message name="RequestSecurityTokenResponseCollectionMsg">
+ <wsdl:part name="responseCollection"
+ element="wst:RequestSecurityTokenResponseCollection"/>
+ </wsdl:message>
+
+ <!-- This portType an example of a Requestor (or other) endpoint that
+ Accepts SOAP-based challenges from a Security Token Service -->
+ <wsdl:portType name="WSSecurityRequestor">
+ <wsdl:operation name="Challenge">
+ <wsdl:input message="tns:RequestSecurityTokenResponseMsg"/>
+ <wsdl:output message="tns:RequestSecurityTokenResponseMsg"/>
+ </wsdl:operation>
+ </wsdl:portType>
+
+ <!-- This portType is an example of an STS supporting full protocol -->
+ <wsdl:portType name="STS">
+ <wsdl:operation name="Cancel">
+ <wsdl:input wsam:Action="http://docs.oasis-open.org/ws-sx/ws-trust/200512/RST/Cancel" message="tns:RequestSecurityTokenMsg"/>
+ <wsdl:output wsam:Action="http://docs.oasis-open.org/ws-sx/ws-trust/200512/RSTR/CancelFinal" message="tns:RequestSecurityTokenResponseMsg"/>
+ </wsdl:operation>
+ <wsdl:operation name="Issue">
+ <wsdl:input wsam:Action="http://docs.oasis-open.org/ws-sx/ws-trust/200512/RST/Issue" message="tns:RequestSecurityTokenMsg"/>
+ <wsdl:output wsam:Action="http://docs.oasis-open.org/ws-sx/ws-trust/200512/RSTRC/IssueFinal" message="tns:RequestSecurityTokenResponseCollectionMsg"/>
+ </wsdl:operation>
+ <wsdl:operation name="Renew">
+ <wsdl:input wsam:Action="http://docs.oasis-open.org/ws-sx/ws-trust/200512/RST/Renew" message="tns:RequestSecurityTokenMsg"/>
+ <wsdl:output wsam:Action="http://docs.oasis-open.org/ws-sx/ws-trust/200512/RSTR/RenewFinal" message="tns:RequestSecurityTokenResponseMsg"/>
+ </wsdl:operation>
+ <wsdl:operation name="Validate">
+ <wsdl:input wsam:Action="http://docs.oasis-open.org/ws-sx/ws-trust/200512/RST/Validate" message="tns:RequestSecurityTokenMsg"/>
+ <wsdl:output wsam:Action="http://docs.oasis-open.org/ws-sx/ws-trust/200512/RSTR/ValidateFinal" message="tns:RequestSecurityTokenResponseMsg"/>
+ </wsdl:operation>
+ <wsdl:operation name="KeyExchangeToken">
+ <wsdl:input wsam:Action="http://docs.oasis-open.org/ws-sx/ws-trust/200512/RST/KET" message="tns:RequestSecurityTokenMsg"/>
+ <wsdl:output wsam:Action="http://docs.oasis-open.org/ws-sx/ws-trust/200512/RSTR/KETFinal" message="tns:RequestSecurityTokenResponseMsg"/>
+ </wsdl:operation>
+ <wsdl:operation name="RequestCollection">
+ <wsdl:input message="tns:RequestSecurityTokenCollectionMsg"/>
+ <wsdl:output message="tns:RequestSecurityTokenResponseCollectionMsg"/>
+ </wsdl:operation>
+ </wsdl:portType>
+
+ <!-- This portType is an example of an endpoint that accepts
+ Unsolicited RequestSecurityTokenResponse messages -->
+ <wsdl:portType name="SecurityTokenResponseService">
+ <wsdl:operation name="RequestSecurityTokenResponse">
+ <wsdl:input message="tns:RequestSecurityTokenResponseMsg"/>
+ </wsdl:operation>
+ </wsdl:portType>
+
+ <wsdl:binding name="Transport_Binding" type="wstrust:STS">
+ <wsp:PolicyReference URI="#Transport_policy" />
+ <soap:binding style="document"
+ transport="http://schemas.xmlsoap.org/soap/http" />
+ <wsdl:operation name="Issue">
+ <soap:operation
+ soapAction="http://docs.oasis-open.org/ws-sx/ws-trust/200512/RST/Issue" />
+ <wsdl:input>
+ <wsp:PolicyReference
+ URI="#Input_policy" />
+ <soap:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <wsp:PolicyReference
+ URI="#Output_policy" />
+ <soap:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="Validate">
+ <soap:operation
+ soapAction="http://docs.oasis-open.org/ws-sx/ws-trust/200512/RST/Validate" />
+ <wsdl:input>
+ <wsp:PolicyReference
+ URI="#Input_policy" />
+ <soap:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <wsp:PolicyReference
+ URI="#Output_policy" />
+ <soap:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="Cancel">
+ <soap:operation
+ soapAction="http://docs.oasis-open.org/ws-sx/ws-trust/200512/RST/Cancel" />
+ <wsdl:input>
+ <soap:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="Renew">
+ <soap:operation
+ soapAction="http://docs.oasis-open.org/ws-sx/ws-trust/200512/RST/Renew" />
+ <wsdl:input>
+ <soap:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="KeyExchangeToken">
+ <soap:operation
+ soapAction="http://docs.oasis-open.org/ws-sx/ws-trust/200512/RST/KeyExchangeToken" />
+ <wsdl:input>
+ <soap:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="RequestCollection">
+ <soap:operation
+ soapAction="http://docs.oasis-open.org/ws-sx/ws-trust/200512/BatchIssue" />
+ <wsdl:input>
+ <soap:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+
+ <wsdl:service name="SecurityTokenService">
+ <wsdl:port name="Transport_Port" binding="tns:Transport_Binding">
+ <soap:address location="https://localhost:8084/SecurityTokenService/Transport" />
+ </wsdl:port>
+ </wsdl:service>
+
+ <wsp:Policy wsu:Id="Transport_policy">
+ <wsp:ExactlyOne>
+ <wsp:All>
+ <wsap10:UsingAddressing/>
+ <sp:TransportBinding
+ xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">
+ <wsp:Policy>
+ <sp:TransportToken>
+ <wsp:Policy>
+ <sp:HttpsToken>
+ <wsp:Policy>
+ <sp:RequireClientCertificate />
+ </wsp:Policy>
+ </sp:HttpsToken>
+ </wsp:Policy>
+ </sp:TransportToken>
+ <sp:AlgorithmSuite>
+ <wsp:Policy>
+ <sp:TripleDesRsa15 />
+ </wsp:Policy>
+ </sp:AlgorithmSuite>
+ <sp:Layout>
+ <wsp:Policy>
+ <sp:Lax />
+ </wsp:Policy>
+ </sp:Layout>
+ <sp:IncludeTimestamp />
+ </wsp:Policy>
+ </sp:TransportBinding>
+ <sp:Wss11
+ xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">
+ <wsp:Policy>
+ <sp:MustSupportRefKeyIdentifier />
+ <sp:MustSupportRefIssuerSerial />
+ <sp:MustSupportRefThumbprint />
+ <sp:MustSupportRefEncryptedKey />
+ </wsp:Policy>
+ </sp:Wss11>
+ <sp:Trust13
+ xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">
+ <wsp:Policy>
+ <sp:MustSupportIssuedTokens />
+ <sp:RequireClientEntropy />
+ <sp:RequireServerEntropy />
+ </wsp:Policy>
+ </sp:Trust13>
+ </wsp:All>
+ </wsp:ExactlyOne>
+ </wsp:Policy>
+
+ <wsp:Policy wsu:Id="Input_policy">
+ <wsp:ExactlyOne>
+ <wsp:All>
+ <sp:SignedParts
+ xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">
+ <sp:Body />
+ <sp:Header Name="To"
+ Namespace="http://www.w3.org/2005/08/addressing" />
+ <sp:Header Name="From"
+ Namespace="http://www.w3.org/2005/08/addressing" />
+ <sp:Header Name="FaultTo"
+ Namespace="http://www.w3.org/2005/08/addressing" />
+ <sp:Header Name="ReplyTo"
+ Namespace="http://www.w3.org/2005/08/addressing" />
+ <sp:Header Name="MessageID"
+ Namespace="http://www.w3.org/2005/08/addressing" />
+ <sp:Header Name="RelatesTo"
+ Namespace="http://www.w3.org/2005/08/addressing" />
+ <sp:Header Name="Action"
+ Namespace="http://www.w3.org/2005/08/addressing" />
+ </sp:SignedParts>
+ <sp:EncryptedParts
+ xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">
+ <sp:Body />
+ </sp:EncryptedParts>
+ </wsp:All>
+ </wsp:ExactlyOne>
+ </wsp:Policy>
+
+ <wsp:Policy wsu:Id="Output_policy">
+ <wsp:ExactlyOne>
+ <wsp:All>
+ <sp:SignedParts
+ xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">
+ <sp:Body />
+ <sp:Header Name="To"
+ Namespace="http://www.w3.org/2005/08/addressing" />
+ <sp:Header Name="From"
+ Namespace="http://www.w3.org/2005/08/addressing" />
+ <sp:Header Name="FaultTo"
+ Namespace="http://www.w3.org/2005/08/addressing" />
+ <sp:Header Name="ReplyTo"
+ Namespace="http://www.w3.org/2005/08/addressing" />
+ <sp:Header Name="MessageID"
+ Namespace="http://www.w3.org/2005/08/addressing" />
+ <sp:Header Name="RelatesTo"
+ Namespace="http://www.w3.org/2005/08/addressing" />
+ <sp:Header Name="Action"
+ Namespace="http://www.w3.org/2005/08/addressing" />
+ </sp:SignedParts>
+ <sp:EncryptedParts
+ xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">
+ <sp:Body />
+ </sp:EncryptedParts>
+ </wsp:All>
+ </wsp:ExactlyOne>
+ </wsp:Policy>
+
+</wsdl:definitions>