You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ru...@apache.org on 2006/03/01 12:33:13 UTC
svn commit: r381992 [1/2] - in
/webservices/axis2/trunk/archive/java/scratch/ruchith: ./ trust/ trust/src/
trust/src/org/ trust/src/org/apache/ trust/src/org/apache/axis2/
trust/src/org/apache/axis2/security/
trust/src/org/apache/axis2/security/trust/ ...
Author: ruchithf
Date: Wed Mar 1 03:33:04 2006
New Revision: 381992
URL: http://svn.apache.org/viewcvs?rev=381992&view=rev
Log:
Moving the OM based WS-Trust message element impl into scratch
Added:
webservices/axis2/trunk/archive/java/scratch/ruchith/
webservices/axis2/trunk/archive/java/scratch/ruchith/trust/
webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/
webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/
webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/
webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/
webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/
webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/
webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/Constants.java
webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/TrustException.java
webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/client/
webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/client/STSClient.java
webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/errors.properties
webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/service/
webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/service/SecurityTokenService.java
webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/service/services.xml
webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/
webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/AbstractToken.java
webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/AppliesTo.java
webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/BinarySecret.java
webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/CancelRequestSecurityToken.java
webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/CancelTarget.java
webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/Claims.java
webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/Code.java
webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/CompositeToken.java
webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/ComputedKey.java
webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/Created.java
webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/Entropy.java
webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/Expires.java
webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/IssueRequestSecurityToken.java
webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/KeySize.java
webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/Lifetime.java
webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/Reason.java
webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/Renewing.java
webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/RequestSecurityToken.java
webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/RequestSecurityTokenResponse.java
webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/RequestType.java
webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/TokenType.java
webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/ValueToken.java
Added: webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/Constants.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/Constants.java?rev=381992&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/Constants.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/Constants.java Wed Mar 1 03:33:04 2006
@@ -0,0 +1,129 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.axis2.security.trust;
+
+/**
+ * Constants of the WS-Trust implementation
+ */
+public interface Constants {
+
+ static final String NS_YEAR_PREFIX = "http://schemas.xmlsoap.org/ws/2005/02/";
+ public static final String WST_NS = NS_YEAR_PREFIX + "trust";
+ public static final String WST_PREFIX = "wst";
+
+ //local names of the token used in WS-Trust
+ public interface LN {
+ public static final String TOKEN_TYPE = "TokenType";
+ public static final String REQUEST_TYPE = "RequestType";
+ public static final String KEY_TYPE = "KeyType";
+ public static final String KEY_SIZE = "KeySize";
+ public static final String LIFE_TIME = "Lifetime";
+ public static final String BASE = "Base";
+ public static final String STATUS = "Status";
+ public static final String CODE = "Code";
+ public static final String REASON = "Reason";
+ public static final String RENEWING = "Renewing";
+ public static final String RENEW_TARGET = "RenewTarget";
+ public static final String CANCEL_TARGET = "CancelTarget";
+ public static final String REQUESTED_TOKEN_CANCELLED = "RequestedTokenCancelled";
+ public static final String ALLOWPOSTDATING = "AllowPostdating";
+ public static final String BINARY_SECRET = "BinarySecret";
+ public static final String ENTROPY = "Entropy";
+ public static final String CLAIMS = "Claims";
+ public static final String COMPUTED_KEY = "ComputedKey";
+
+ public static final String REQUEST_SECURITY_TOKEN = "RequestSecurityToken";
+ public static final String REQUEST_SECURITY_TOKEN_RESPONSE = "RequestSecurityTokenResponse";
+ public static final String REQUESTED_SECURITY_TOKEN = "RequestedSecurityToken";
+ public static final String REQUESTED_PROOF_TOKEN = "RequestedProofToken";
+ }
+
+ //Attributes
+ public interface ATTR {
+ public static final String CONTEXT = "Context";
+ public static final String BINARY_SECRET_TYPE = "Type";
+ public static final String CLAIMS_DIALECT = "Dialect";
+ public static final String RENEWING_ALLOW = "Allow";
+ public static final String RENEWING_OK = "OK";
+ }
+
+ //RSTs
+ public interface RST {
+ public static final String PREFIX = WST_NS + "/RST";
+ public static final String ISSUE_SECURITY_TOKEN = PREFIX + "/Issue";
+ public static final String RENEW_SECURITY_TOKEN = PREFIX + "/Renew";
+ public static final String VALIDATE_SECURITY_TOKEN = PREFIX + "/Validate";
+ public static final String CANCEL_SECURITY_TOKEN = PREFIX + "/Cancel";
+ }
+
+ //RSTRs
+ public interface RSTR {
+ public static final String PREFIX = WST_NS + "/RSTR";
+ public static final String ISSUE_SECURITY_TOKEN = PREFIX + "/Issue";
+ public static final String RENEW_SECURITY_TOKEN = PREFIX + "/Renew";
+ public static final String VALIDATE_SECURITY_TOKEN = PREFIX + "/Validate";
+ public static final String CANCEL_SECURITY_TOKEN = PREFIX + "/Cancel";
+ }
+
+ // The request type is specified using following URIs as specified in the WS-Trust specification
+ public interface REQ_TYPE {
+ public static final String ISSUE_SECURITY_TOKEN = WST_NS + "/Issue";
+ public static final String RENEW_SECURITY_TOKEN = WST_NS + "/Renew";
+ public static final String VALIDATE_SECURITY_TOKEN = WST_NS + "/Validate";
+ public static final String CANCEL_SECURITY_TOKEN = WST_NS + "/Cancel";
+ }
+
+ //STATUS
+ public interface STATUS {
+ public static final String PREFIX = WST_NS + "/status";
+ public static final String VALID = PREFIX + "/valid";
+ public static final String INVALID = PREFIX + "/invalid";
+ }
+
+ //Token types
+ public interface TOKEN_TYPE {
+ public static final String RSTR_STATUS = RSTR.PREFIX + "/Status";
+ public final static String UNT = "http://schemas.xmlsoap.org/ws/2004/04/security/sc/unt";
+ public final static String SCT = "http://schemas.xmlsoap.org/ws/2004/04/security/sc/sct";
+ }
+
+ //Binary secret types
+ public interface BINARY_SECRET_TYPE {
+ public static final String ASYMMETRIC_KEY = WST_NS + "/AsymmetricKey";
+ public static final String SYMMETRIC_KEY = WST_NS + "/SymmetricKey";
+ public static final String NONCE_VAL= WST_NS + "/Nonce";
+ }
+
+ //ComputedKey types
+ public interface COMPUTED_KEY_TYPE {
+ public static final String PSHA1 = WST_NS + "/CK/PSHA1";
+ }
+
+ public interface WSU {
+ public static final String NS = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd";
+ public static final String PREFIX = "wsu";
+ public static final String CREATED_LN = "Created";
+ public static final String EXPIRES_LN = "Expires";
+ public static final String ID_ATTR = "Id";
+ }
+
+ public interface WSP {
+ public static final String NS = org.apache.axis2.Constants.URI_POLICY;
+ public static final String PREFIX = "wsp";
+ public static final String APPLIESTO_LN = "AppliesTo";
+ }
+
+}
Added: webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/TrustException.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/TrustException.java?rev=381992&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/TrustException.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/TrustException.java Wed Mar 1 03:33:04 2006
@@ -0,0 +1,147 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.axis2.security.trust;
+
+import java.text.MessageFormat;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class TrustException extends Exception {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final String INVALID_REQUEST = "InvalidRequest";
+ public final static String FAILED_AUTHENTICATION = "FailedAuthentication";
+ public final static String REQUEST_FAILED = "RequestFailed";
+ public final static String INVALID_SECURITY_TOKEN = "InvalidSecurityToken";
+ public final static String AUTHENTICATION_BAD_ELEMENTS = "AuthenticationBadElements";
+ public final static String BAD_REQUEST = "BadRequest";
+ public final static String EXPIREDDATA = "ExpiredData";
+ public final static String INVAILD_TIME_RANGE = "InvaildTimeRange";
+ public final static String INVAILD_SCOPE = "InvaildScope";
+ public final static String RENEW_NEEDED = "RenewNeeded";
+ public final static String UNABLE_TO_RENEW = "UnableToRenew";
+
+ public static final String DESC_INCORRECT_CHILD_ELEM = "incorrectChildElement";
+ public static final String DESC_EXPECTED_CHILD_ELEM = "expectedChildElement";
+ public static final String DESC_CHILD_IN_VALUE_ELEM = "childInValueElement";
+ public static final String DESC_TEXT_IN_COMPOSITE_ELEM = "textInCompositeElement";
+ public final static String ERROR_IN_CONVERTING_TO_OM = "errorInOMConversion";
+ public final static String ERROR_IN_CONVERTING_TO_DOM = "errorInDOMConversion";
+
+ private static ResourceBundle resources;
+
+ private String faultCode;
+ private String faultString;
+
+ static {
+ try {
+ resources = ResourceBundle.getBundle("org.apache.axis2.security.trust.errors");
+ } catch (MissingResourceException e) {
+ throw new RuntimeException(e.getMessage());
+ }
+ }
+
+ /**
+ *
+ * @param faultCode
+ * @param msgId
+ * @param args
+ * @param exception
+ */
+ public TrustException(String faultCode, String msgId, Object[] args, Throwable exception) {
+ super(getMessage(faultCode, null, null),exception);
+ this.faultCode = faultCode;
+ this.faultString = resources.getString(faultCode);
+ }
+
+ /**
+ *
+ * @param faultCode
+ * @param msgId
+ * @param args
+ */
+ public TrustException(String faultCode, String msgId, Object[] args) {
+ super(getMessage(faultCode, null, null));
+ this.faultCode = faultCode;
+ this.faultString = resources.getString(faultCode);
+ }
+
+ /**
+ * This is used to set a custom message in the exception.
+ * @param faultCode
+ * @param msg
+ */
+ public TrustException(String faultCode, String msg) {
+ super(msg);
+ this.faultCode = faultCode;
+ this.faultString = resources.getString(faultCode);
+ }
+
+ /**
+ *
+ * @param faultCode
+ * @param msgId
+ * @param args
+ * @return Returns String.
+ */
+ private static String getMessage(String faultCode, String msgId, Object[] args) {
+ String msg = null;
+ try {
+ msg = resources.getString(faultCode);
+ if (msgId != null) {
+ return msg += (" (" + MessageFormat.format(resources.getString(msgId), args) + ")");
+ }
+ } catch (MissingResourceException e) {
+ throw new RuntimeException("Undefined '" + msgId + "' resource property");
+ }
+ return msg;
+ }
+
+ /**
+ *
+ * @param message
+ */
+ public TrustException(String message) {
+ super(message);
+ }
+
+ /**
+ *
+ * @param message
+ * @param ex
+ */
+ public TrustException(String message, Throwable ex) {
+ super(message,ex);
+ }
+
+
+ /**
+ * Returns the fault code.
+ * @return Returns String.
+ */
+ public String getFaultCode() {
+ return Constants.WST_PREFIX + faultCode;
+ }
+
+ /**
+ * Returns the fault string.
+ * @return Returns String.
+ */
+ public String getFaultString() {
+ return faultString;
+ }
+}
Added: webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/client/STSClient.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/client/STSClient.java?rev=381992&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/client/STSClient.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/client/STSClient.java Wed Mar 1 03:33:04 2006
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.axis2.security.trust.client;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.security.handler.WSSHandlerConstants;
+import org.apache.axis2.security.handler.config.InflowConfiguration;
+import org.apache.axis2.security.handler.config.OutflowConfiguration;
+import org.apache.axis2.security.trust.TrustException;
+import org.apache.axis2.security.trust.token.RequestSecurityToken;
+import org.apache.axis2.security.trust.token.RequestSecurityTokenResponse;
+import org.apache.ws.commons.om.OMElement;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Client to interact with a given SecurityTokenService
+ */
+public class STSClient {
+
+ private String stsUrl;
+
+ private OutflowConfiguration outConfig;
+ private InflowConfiguration inConfig;
+
+ public STSClient(String stsUrl, OutflowConfiguration outConfig, InflowConfiguration inConfig) {
+ this.stsUrl = stsUrl;
+ this.outConfig = outConfig;
+ this.inConfig = inConfig;
+ }
+
+
+ public RequestSecurityTokenResponse doRequest(RequestSecurityToken rst) throws TrustException {
+ try {
+ Options options = new Options();
+ options.setTo(new EndpointReference(this.stsUrl));
+ options.setProperty(WSSHandlerConstants.OUTFLOW_SECURITY, this.outConfig.getProperty());
+ options.setProperty(WSSHandlerConstants.INFLOW_SECURITY, this.inConfig.getProperty());
+
+ ServiceClient sender = new ServiceClient();
+ sender.engageModule(new QName(org.apache.axis2.Constants.MODULE_ADDRESSING));
+ sender.setOptions(options);
+ OMElement res = sender.sendReceive(this.prepareRequst(rst));
+
+ RequestSecurityTokenResponse rstr = new RequestSecurityTokenResponse(res);
+ return rstr;
+ } catch (AxisFault e) {
+ throw new TrustException("Problem in communicating with the SecurityTokenService", e);
+ }
+ }
+
+ /**
+ * Do Encryption and Signing of the request
+ *
+ * @param rst
+ * @return
+ * @throws TrustException
+ */
+ private OMElement prepareRequst(RequestSecurityToken rst) throws TrustException {
+
+ throw new UnsupportedOperationException();
+ }
+
+
+}
Added: webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/errors.properties
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/errors.properties?rev=381992&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/errors.properties (added)
+++ webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/errors.properties Wed Mar 1 03:33:04 2006
@@ -0,0 +1,20 @@
+##Fault codes and fault strings according to the WS-Trust spec
+InvalidRequest = The request was invalid or malformed
+FailedAuthentication = Authentication failed
+RequestFailed = The specified request failed
+InvalidSecurityToken = Security token has been revoked
+AuthenticationBadElements = Insufficient Digest Elements
+BadRequest = The specified RequestSecurityToken is not understood
+ExpiredData = The request data is out of date
+InvaildTimeRange = The requested time range is invaild or unsupported
+InvaildScope = The request scope is invaild or unsupported
+RenewNeeded = A renewable security token has expired
+UnableToRenew = The requested renewal failed
+errorInOMConversion=Error in converting a DOM Element to an OMElement
+errorInDOMOMConversion=Error in converting a OMElement to an DOM Element
+
+#Other additional fault information can be listed here
+incorrectChildElement={\"{0}\"}\"{1}\" element cannot contain a {\"{3}\"}\"{4}\" element
+expectedChildElement={\"{0}\"}\"{1}\" is expected within the {\"{3}\"}\"{4}\" element
+childInValueElement={\"{0}\"}\"{1}\" element cannot contain any child elements. Found {\"{3}\"}\"{4}\"
+textInCompositeElement={\"{0}\"}\"{1}\" composite element cannot contain a value. Found \"{3}\"
Added: webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/service/SecurityTokenService.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/service/SecurityTokenService.java?rev=381992&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/service/SecurityTokenService.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/service/SecurityTokenService.java Wed Mar 1 03:33:04 2006
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.axis2.security.trust.service;
+
+import org.apache.ws.commons.om.OMElement;
+
+/**
+ * SecurityTokenService
+ */
+public class SecurityTokenService {
+
+ public OMElement requestSecurityToken(OMElement request) {
+ throw new UnsupportedOperationException("TODO");
+ }
+
+}
Added: webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/service/services.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/service/services.xml?rev=381992&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/service/services.xml (added)
+++ webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/service/services.xml Wed Mar 1 03:33:04 2006
@@ -0,0 +1,9 @@
+<service name="SecurityTokenService">
+ <description>
+ Axis2 SecurityTokenService
+ </description>
+ <parameter name="ServiceClass" locked="false">org.apache.axis2.security.trust.service.SecurityTokenService</parameter>
+ <operation name="requestSecurityToken">
+ <messageReceiver class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
+ </operation>
+</service>
\ No newline at end of file
Added: webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/AbstractToken.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/AbstractToken.java?rev=381992&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/AbstractToken.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/AbstractToken.java Wed Mar 1 03:33:04 2006
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.axis2.security.trust.token;
+
+import org.apache.axis2.security.trust.Constants;
+import org.apache.axis2.security.trust.TrustException;
+import org.apache.ws.commons.om.OMAbstractFactory;
+import org.apache.ws.commons.om.OMElement;
+import org.apache.ws.commons.om.OMFactory;
+import org.apache.ws.commons.om.OMNamespace;
+import org.apache.ws.commons.om.OMNode;
+import org.apache.ws.commons.om.OMText;
+import org.w3c.dom.Node;
+
+import javax.xml.namespace.QName;
+import java.util.Iterator;
+
+public abstract class AbstractToken {
+
+ protected abstract QName getToken();
+ protected OMFactory factory = OMAbstractFactory.getOMFactory();
+ protected OMElement tokenElement;
+ protected OMNamespace wstNamespace;
+
+ public AbstractToken() {
+ QName token = this.getToken();
+ this.tokenElement = factory.createOMElement(token.getLocalPart(), token.getNamespaceURI(),Constants.WST_PREFIX);
+ wstNamespace = factory.createOMNamespace(Constants.WST_NS, Constants.WST_PREFIX);
+ }
+
+ public AbstractToken(OMElement elem) throws TrustException {
+ QName token = this.getToken();
+ QName el = new QName(elem.getNamespace().getName(), elem.getLocalName());
+ if (!el.equals(token))
+ throw new TrustException(TrustException.INVALID_REQUEST, "badTokenType", new Object[]{el});
+
+ this.tokenElement = elem;
+ this.parse(this.tokenElement);
+ }
+
+ /**
+ * This is called for each of the immediate
+ * child elements of type <code>OMNode.ELEMENT_NODE</code> of this token *
+ * @param element
+ * @throws TrustException
+ */
+ private void parse(OMElement element) throws TrustException {
+ Iterator children = element.getChildElements();
+ while (children.hasNext()) {
+ OMNode child = (OMNode) children.next();
+ switch (child.getType()) {
+ case OMNode.ELEMENT_NODE :
+ this.deserializeChildElement((OMElement)child);
+ break;
+ case Node.TEXT_NODE :
+ this.setElementTextValue((OMText)child);
+ break;
+ }
+
+ }
+
+ // TODO TODO
+ throw new UnsupportedOperationException("TODO");
+ }
+
+
+ /**
+ * This is called for each of the immediate
+ * child elements of type <code>OMNode.ELEMENT_NODE</code> of this token
+ * @param element
+ */
+ protected abstract void deserializeChildElement(OMElement element)throws TrustException;
+
+ /**
+ * This is called with a <code>OMText</code> node of the
+ * current element
+ * @param textNode
+ */
+ protected abstract void setElementTextValue(OMText textNode) throws TrustException;
+
+}
Added: webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/AppliesTo.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/AppliesTo.java?rev=381992&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/AppliesTo.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/AppliesTo.java Wed Mar 1 03:33:04 2006
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.axis2.security.trust.token;
+
+import org.apache.axis2.security.trust.Constants;
+import org.apache.axis2.security.trust.TrustException;
+import org.apache.ws.commons.om.OMElement;
+
+import javax.xml.namespace.QName;
+import java.util.Iterator;
+
+public class AppliesTo extends CompositeToken {
+
+ public static final QName TOKEN = new QName(Constants.WSP.NS, Constants.WSP.APPLIESTO_LN, Constants.WSP.PREFIX);
+
+
+ public AppliesTo() {
+ super();
+ }
+
+ /**
+ * @param elem
+ * @throws TrustException
+ */
+ public AppliesTo(OMElement elem) throws TrustException {
+ super(elem);
+ }
+
+ /**
+ * Adds a token as a child.
+ * This is provided as an extensibility mechanism to add any
+ * child element to the <code>wsp:AppliesTo</code> element
+ * @param token
+ */
+ public void addToken(OMElement token) {
+ this.tokenElement.addChild(token);
+ }
+
+ /**
+ * Retuns an iterator of child elements.
+ * @return Returns Iterator.
+ */
+ public Iterator getChildTokens() {
+ return this.tokenElement.getChildElements();
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.axis2.security.trust.token.AbstractToken#getToken()
+ */
+ protected QName getToken() {
+ return TOKEN;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.axis2.security.trust.token.AbstractToken#deserializeChildElement(org.apache.ws.commons.om.OMElement)
+ */
+ protected void deserializeChildElement(OMElement element)
+ throws TrustException {
+ //DO Nothing - Right now we'r allowing anything to be included here.
+ //TODO: figure out exactly what can come here and complete this
+ }
+
+}
Added: webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/BinarySecret.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/BinarySecret.java?rev=381992&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/BinarySecret.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/BinarySecret.java Wed Mar 1 03:33:04 2006
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.axis2.security.trust.token;
+
+import org.apache.axis2.security.trust.Constants;
+import org.apache.axis2.security.trust.TrustException;
+import org.apache.ws.commons.om.OMElement;
+import org.apache.ws.commons.om.OMNamespace;
+
+import javax.xml.namespace.QName;
+
+public class BinarySecret extends ValueToken {
+
+ public static final QName TOKEN = new QName(Constants.WST_NS,
+ Constants.LN.BINARY_SECRET, Constants.WST_PREFIX);
+
+ public BinarySecret() {
+ super();
+ }
+
+ /**
+ * @param elem
+ * @throws TrustException
+ */
+ public BinarySecret(OMElement elem) throws TrustException {
+ super(elem);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.axis2.security.trust.token.AbstractToken#getToken()
+ */
+ protected QName getToken() {
+ return TOKEN;
+ }
+
+ /**
+ * Sets the value of the .../wst:BinarySecret/@Type attribute
+ * @param type
+ */
+ public void setTypeAttribute(String type) {
+ this.tokenElement.addAttribute(Constants.ATTR.BINARY_SECRET_TYPE, type,
+ null);
+ }
+
+ /**
+ * Retuns the value of the .../wst:BinarySecret/@Type attribute
+ * @return Returns String.
+ */
+ public String getTypeAttribute() {
+ return this.tokenElement.getAttribute(
+ new QName(Constants.ATTR.BINARY_SECRET_TYPE))
+ .getAttributeValue();
+ }
+
+ /**
+ * Adds the given attribute.
+ * @param attribute
+ * @param value
+ * @param namespace
+ */
+ public void addAttribute(String attribute, String value,
+ OMNamespace namespace) {
+ this.tokenElement.addAttribute(attribute, value, namespace);
+ }
+
+ /**
+ * Returns the value of the requested attribute.
+ * @param attribute
+ * @return Returns String.
+ */
+ public String getAttributeValue(QName attribute) {
+ return this.tokenElement.getAttribute(attribute).getAttributeValue();
+ }
+
+}
Added: webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/CancelRequestSecurityToken.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/CancelRequestSecurityToken.java?rev=381992&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/CancelRequestSecurityToken.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/CancelRequestSecurityToken.java Wed Mar 1 03:33:04 2006
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.axis2.security.trust.token;
+
+import org.apache.axis2.security.trust.Constants;
+import org.apache.axis2.security.trust.TrustException;
+import org.apache.ws.commons.om.OMElement;
+import org.apache.ws.security.message.token.SecurityTokenReference;
+
+import javax.xml.namespace.QName;
+
+public class CancelRequestSecurityToken extends RequestSecurityToken {
+
+ CancelTarget cancelTarget;
+
+ public CancelRequestSecurityToken() {
+ super(Constants.REQ_TYPE.CANCEL_SECURITY_TOKEN);
+ }
+
+ /**
+ * @param elem
+ * @throws TrustException
+ */
+ public CancelRequestSecurityToken(OMElement elem) throws TrustException {
+ super(elem);
+ }
+
+ /**
+ * Sets the cancel target with the target token
+ * @param targetToken
+ */
+ public void setCancelTarget(OMElement targetToken) {
+ if(this.cancelTarget == null) {
+ this.cancelTarget = new CancelTarget();
+ this.tokenElement.addChild(this.cancelTarget.tokenElement);
+ }
+
+ this.cancelTarget.setCancelTarget(targetToken);
+ }
+
+ /**
+ * Sets the cancel target with a security token reference
+ * @param securityTokenReference
+ * @throws TrustException
+ */
+ public void setCancelTarget(SecurityTokenReference securityTokenReference) throws TrustException {
+ if(this.cancelTarget == null) {
+ this.cancelTarget = new CancelTarget();
+ this.tokenElement.addChild(this.cancelTarget.tokenElement);
+ }
+ this.cancelTarget.setCancelTarget(securityTokenReference);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.axis2.security.trust.token.RequestSecurityToken#handleSpecificChildren(org.apache.ws.commons.om.OMElement)
+ */
+ protected void handleSpecificChildren(OMElement element) throws TrustException {
+ QName el = new QName(element.getNamespace().getName(), element.getLocalName());
+
+ if(el.equals(CancelTarget.TOKEN)) {
+ this.cancelTarget = new CancelTarget(element);
+ } else {
+ throw new TrustException(TrustException.INVALID_REQUEST,
+ TrustException.DESC_INCORRECT_CHILD_ELEM,
+ new Object[] {
+ TOKEN.getPrefix(),TOKEN.getLocalPart(),
+ el.getNamespaceURI(),el.getLocalPart()});
+ }
+ }
+
+}
Added: webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/CancelTarget.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/CancelTarget.java?rev=381992&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/CancelTarget.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/CancelTarget.java Wed Mar 1 03:33:04 2006
@@ -0,0 +1,144 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.axis2.security.trust.token;
+
+import org.apache.axis2.security.trust.Constants;
+import org.apache.axis2.security.trust.TrustException;
+import org.apache.axis2.security.util.Axis2Util;
+import org.apache.ws.commons.om.OMElement;
+import org.apache.ws.security.WSConstants;
+import org.apache.ws.security.message.token.SecurityTokenReference;
+
+import javax.xml.namespace.QName;
+
+public class CancelTarget extends CompositeToken {
+
+ public static final QName TOKEN = new QName(Constants.WST_NS, Constants.LN.CANCEL_TARGET, Constants.WST_PREFIX);
+
+ private OMElement targetToken;
+ private SecurityTokenReference securityTokenReference;
+
+ public CancelTarget(SecurityTokenReference securityTokenReference) throws TrustException {
+ super();
+ this.securityTokenReference = securityTokenReference;
+ try {
+ this.tokenElement.addChild(Axis2Util.toOM(this.securityTokenReference.getElement()));
+ } catch (Exception e) {
+ throw new TrustException(e.getMessage(), e);
+ }
+ }
+
+ /**
+ * Class is used while creating a new CancelTaget which will
+ * refer to a targetToken rather than a SecurityTokenReference .
+ */
+ public CancelTarget() {
+ super();
+ }
+
+ /**
+ * @param elem
+ * @throws TrustException
+ */
+ public CancelTarget(OMElement elem) throws TrustException {
+ super(elem);
+ }
+
+ /**
+ * Sets the cancel target element.
+ * @param targetToken
+ */
+ public void setCancelTarget(OMElement targetToken) {
+ if(this.securityTokenReference != null) {
+ this.tokenElement.getFirstChildWithName(
+ new QName(WSConstants.WSSE_NS,
+ SecurityTokenReference.SECURITY_TOKEN_REFERENCE))
+ .detach();
+ }
+ if(this.targetToken != null) {
+ this.tokenElement.detach();
+ }
+
+ this.targetToken = targetToken;
+ this.tokenElement.addChild(this.targetToken);
+ }
+
+ /**
+ * Sets the cancel target security token reference.
+ * @param securityTokenReference
+ * @throws TrustException
+ */
+ public void setCancelTarget(SecurityTokenReference securityTokenReference) throws TrustException {
+ if(this.targetToken != null) {
+ this.targetToken.detach();
+ }
+ if(this.securityTokenReference != null) {
+ this.tokenElement.getFirstChildWithName(
+ new QName(WSConstants.WSSE_NS,
+ SecurityTokenReference.SECURITY_TOKEN_REFERENCE))
+ .detach();
+ }
+
+ this.securityTokenReference = securityTokenReference;
+ try {
+ this.tokenElement.addChild(Axis2Util.toOM(this.securityTokenReference.getElement()));
+ } catch (Exception e) {
+ throw new TrustException(e.getMessage(), e);
+ }
+ }
+
+ /**
+ * Returns the security token reference to the token to be cancelled.
+ * @return Returns SecurityTokenReference.
+ */
+ public SecurityTokenReference getSecurityTokenReference() {
+ return securityTokenReference;
+ }
+
+ /**
+ * Returns the target token to be cancelled.
+ * @return Returns OMElement.
+ */
+ public OMElement getTargetToken() {
+ return targetToken;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.axis2.security.trust.token.AbstractToken#getToken()
+ */
+ protected QName getToken() {
+ return TOKEN;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.axis2.security.trust.token.AbstractToken#deserializeChildElement(org.apache.ws.commons.om.OMElement)
+ */
+ protected void deserializeChildElement(OMElement element)
+ throws TrustException {
+ QName el = new QName(element.getNamespace().getName(), element.getLocalName());
+
+ if(el.equals(new QName(WSConstants.WSSE_NS,SecurityTokenReference.SECURITY_TOKEN_REFERENCE)) && this.targetToken == null) {
+ try {
+ this.securityTokenReference = new SecurityTokenReference(Axis2Util.toDOM(element));
+ } catch (Exception e) {
+ throw new TrustException(e.getMessage(), e);
+ }
+ } else if(this.securityTokenReference == null) {
+ this.targetToken = element;
+ }
+ }
+
+}
Added: webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/Claims.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/Claims.java?rev=381992&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/Claims.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/Claims.java Wed Mar 1 03:33:04 2006
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.axis2.security.trust.token;
+
+import org.apache.axis2.security.trust.Constants;
+import org.apache.axis2.security.trust.TrustException;
+import org.apache.ws.commons.om.OMElement;
+
+import javax.xml.namespace.QName;
+import java.util.Iterator;
+
+public class Claims extends CompositeToken {
+
+ public static final QName TOKEN = new QName(Constants.WST_NS,
+ Constants.LN.CLAIMS, Constants.WST_PREFIX);
+
+ public Claims() {
+ super();
+ }
+
+ /**
+ * @param elem
+ * @throws TrustException
+ */
+ public Claims(OMElement elem) throws TrustException {
+ super(elem);
+ }
+
+
+ /**
+ * Sets the value of the wst:Claims/@Dialect
+ * Dialect attribute specifies a URI to indicate the syntax of the claims.
+ * @param value
+ */
+ public void setDialectAttribute(String value) {
+ this.tokenElement.addAttribute(factory.createOMAttribute(
+ Constants.ATTR.CLAIMS_DIALECT, null, value));
+ }
+
+ /**
+ * Returns the value of the wst:Claims/@Dialect
+ * @return Returns String.
+ */
+ public String getDialectAttribute() {
+ return this.tokenElement.getAttribute(
+ new QName(Constants.ATTR.CLAIMS_DIALECT)).getAttributeValue();
+ }
+
+ /**
+ * Adds a token as a child.
+ * This is provided as an extensibility mechanism to add any
+ * child element to the <code>wst:Claims</code> element
+ * @param token
+ */
+ public void addToken(OMElement token) {
+ this.tokenElement.addChild(token);
+ }
+
+ /**
+ * Returns an interator of child elements.
+ * @return Returns Iterator.
+ */
+ public Iterator getChildTokens() {
+ return this.tokenElement.getChildElements();
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.axis2.security.trust.token.AbstractToken#getToken()
+ */
+ protected QName getToken() {
+ return TOKEN;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.axis2.security.trust.token.AbstractToken#deserializeChildElement(org.apache.ws.commons.om.OMElement)
+ */
+ protected void deserializeChildElement(OMElement element)
+ throws TrustException {
+ //Do nothing , since there's no constraint on what can be included here
+ }
+
+}
Added: webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/Code.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/Code.java?rev=381992&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/Code.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/Code.java Wed Mar 1 03:33:04 2006
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.axis2.security.trust.token;
+
+import org.apache.axis2.security.trust.Constants;
+import org.apache.axis2.security.trust.TrustException;
+import org.apache.ws.commons.om.OMElement;
+
+import javax.xml.namespace.QName;
+
+public class Code extends ValueToken {
+
+ public static final QName TOKEN = new QName(Constants.WST_NS, Constants.LN.CODE, Constants.WST_PREFIX);
+
+ public Code(String value) {
+ super();
+ this.valueText = factory.createText(value);
+ this.setElementTextValue(valueText);
+ }
+
+ /**
+ * @param elem
+ * @throws TrustException
+ */
+ public Code(OMElement elem) throws TrustException {
+ super(elem);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.axis2.security.trust.token.AbstractToken#getToken()
+ */
+ protected QName getToken() {
+ return TOKEN;
+ }
+
+}
Added: webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/CompositeToken.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/CompositeToken.java?rev=381992&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/CompositeToken.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/CompositeToken.java Wed Mar 1 03:33:04 2006
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.axis2.security.trust.token;
+
+import org.apache.axis2.security.trust.TrustException;
+import org.apache.ws.commons.om.OMElement;
+import org.apache.ws.commons.om.OMText;
+
+public abstract class CompositeToken extends AbstractToken {
+
+ public CompositeToken() {
+ super();
+ }
+
+ /**
+ * @param elem
+ * @throws TrustException
+ */
+ public CompositeToken(OMElement elem) throws TrustException {
+ super(elem);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.axis2.security.trust.token.AbstractToken#setElementTextValue(org.apache.ws.commons.om.OMText)
+ */
+ protected void setElementTextValue(OMText textNode) throws TrustException {
+ throw new TrustException(TrustException.INVALID_REQUEST,
+ TrustException.DESC_TEXT_IN_COMPOSITE_ELEM,
+ new Object[]{this.getToken().getNamespaceURI(),
+ this.getToken().getLocalPart(),
+ textNode.getText()});
+ }
+
+}
Added: webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/ComputedKey.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/ComputedKey.java?rev=381992&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/ComputedKey.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/ComputedKey.java Wed Mar 1 03:33:04 2006
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.axis2.security.trust.token;
+
+import org.apache.axis2.security.trust.Constants;
+import org.apache.axis2.security.trust.TrustException;
+import org.apache.ws.commons.om.OMElement;
+
+import javax.xml.namespace.QName;
+
+public class ComputedKey extends ValueToken {
+
+ public static final QName TOKEN = new QName(Constants.WST_NS, Constants.LN.COMPUTED_KEY, Constants.WST_PREFIX);
+
+ public ComputedKey() {
+ super();
+ }
+
+ /**
+ * @param elem
+ * @throws TrustException
+ */
+ public ComputedKey(OMElement elem) throws TrustException {
+ super(elem);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.axis2.security.trust.token.AbstractToken#getToken()
+ */
+ protected QName getToken() {
+ return TOKEN;
+ }
+
+}
Added: webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/Created.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/Created.java?rev=381992&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/Created.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/Created.java Wed Mar 1 03:33:04 2006
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.axis2.security.trust.token;
+
+import org.apache.axis2.security.trust.Constants;
+import org.apache.axis2.security.trust.TrustException;
+import org.apache.ws.commons.om.OMElement;
+
+import javax.xml.namespace.QName;
+
+public class Created extends ValueToken {
+
+
+ public static final QName TOKEN = new QName(Constants.WSU.NS, Constants.WSU.CREATED_LN, Constants.WSU.PREFIX);
+
+
+ public Created() {
+ super();
+ }
+
+ /**
+ * @param elem
+ * @throws TrustException
+ */
+ public Created(OMElement elem) throws TrustException {
+ super(elem);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.axis2.security.trust.token.AbstractToken#getToken()
+ */
+ protected QName getToken() {
+ return TOKEN;
+ }
+
+}
Added: webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/Entropy.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/Entropy.java?rev=381992&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/Entropy.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/Entropy.java Wed Mar 1 03:33:04 2006
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.axis2.security.trust.token;
+
+import org.apache.axis2.security.trust.Constants;
+import org.apache.axis2.security.trust.TrustException;
+import org.apache.ws.commons.om.OMElement;
+
+import javax.xml.namespace.QName;
+
+public class Entropy extends CompositeToken {
+
+ public static final QName TOKEN = new QName(Constants.WST_NS,
+ Constants.LN.ENTROPY, Constants.WST_PREFIX);
+
+ private BinarySecret binarySecret;
+
+ public Entropy() {
+ super();
+ }
+
+ /**
+ * @param elem
+ * @throws TrustException
+ */
+ public Entropy(OMElement elem) throws TrustException {
+ super(elem);
+ }
+
+ /**
+ * Sets the binary secret value
+ * @param type The type uri of the binary secret as a <code>String</code>
+ * @param secretValue The binary secret value as a <code>String</code>
+ */
+ public void setBinarySecret(String type, String secretValue) {
+ this.binarySecret = new BinarySecret();
+ this.binarySecret.setTypeAttribute(type);
+ this.binarySecret.setValue(secretValue);
+ }
+
+ public BinarySecret getBinarySecret() {
+ return this.binarySecret;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.axis2.security.trust.token.AbstractToken#getToken()
+ */
+ protected QName getToken() {
+ return TOKEN;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.axis2.security.trust.token.AbstractToken#deserializeChildElement(org.apache.ws.commons.om.OMElement)
+ */
+ protected void deserializeChildElement(OMElement element)
+ throws TrustException {
+ QName el = new QName(element.getNamespace().getName(), element.getLocalName());
+
+ if(el.equals(BinarySecret.TOKEN)) {
+ this.binarySecret = new BinarySecret(element);
+ } else {
+ throw new TrustException(TrustException.INVALID_REQUEST,
+ TrustException.DESC_INCORRECT_CHILD_ELEM,
+ new Object[] {
+ TOKEN.getPrefix(),TOKEN.getLocalPart(),
+ el.getNamespaceURI(),el.getLocalPart()});
+ }
+ }
+
+}
Added: webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/Expires.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/Expires.java?rev=381992&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/Expires.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/Expires.java Wed Mar 1 03:33:04 2006
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.axis2.security.trust.token;
+
+import org.apache.axis2.security.trust.Constants;
+import org.apache.axis2.security.trust.TrustException;
+import org.apache.ws.commons.om.OMElement;
+
+import javax.xml.namespace.QName;
+
+public class Expires extends ValueToken {
+
+ public static final QName TOKEN = new QName(Constants.WSU.NS,
+ Constants.WSU.EXPIRES_LN, Constants.WSU.PREFIX);
+
+ public Expires() {
+ super();
+ }
+
+ /**
+ * @param elem
+ * @throws TrustException
+ */
+ public Expires(OMElement elem) throws TrustException {
+ super(elem);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.axis2.security.trust.token.AbstractToken#getToken()
+ */
+ protected QName getToken() {
+ return TOKEN;
+ }
+
+}
Added: webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/IssueRequestSecurityToken.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/IssueRequestSecurityToken.java?rev=381992&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/IssueRequestSecurityToken.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/IssueRequestSecurityToken.java Wed Mar 1 03:33:04 2006
@@ -0,0 +1,253 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.axis2.security.trust.token;
+
+import org.apache.axis2.security.trust.Constants;
+import org.apache.axis2.security.trust.TrustException;
+import org.apache.ws.commons.om.OMElement;
+import org.apache.ws.commons.om.OMNode;
+
+import javax.xml.namespace.QName;
+import java.util.Iterator;
+
+public class IssueRequestSecurityToken extends RequestSecurityToken {
+
+ private AppliesTo appliesTo;
+ private Claims claims;
+ private Entropy entropy;
+ private Lifetime lifetime;
+ private KeySize keySize;
+ private Renewing renewing;
+
+ public IssueRequestSecurityToken() {
+ super(Constants.REQ_TYPE.ISSUE_SECURITY_TOKEN);
+ }
+
+ /**
+ * @param elem
+ * @throws TrustException
+ */
+ public IssueRequestSecurityToken(OMElement elem) throws TrustException {
+ super(elem);
+ }
+
+ /**
+ * Sets the value of the <code>AppliesTo</code> element.
+ * @param value
+ */
+ public void setAppliesTo(OMElement value) {
+ if(this.appliesTo == null) {
+ this.appliesTo = new AppliesTo();
+ this.tokenElement.addChild(this.appliesTo.tokenElement);
+ }
+
+ this.appliesTo.addToken(value);
+ }
+
+ /**
+ * Returns the first child of the <code>AppliesTo</code> element.
+ * @return Returns OMElement.
+ */
+ public OMElement getAppliesTo() {
+ if(this.appliesTo != null) {
+ Iterator children = this.appliesTo.tokenElement.getChildElements();
+ while (children.hasNext()) {
+ OMNode node = (OMNode) children.next();
+ if(node.getType() == OMNode.ELEMENT_NODE) {
+ //Return the first child element
+ return (OMElement)node;
+ }
+ }
+ //If an child element is not found
+ return null;
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Can be used when setting one claim in the <code>Claims</code> element
+ * @param dialectURI Dialect attribute specifies a URI to indicate the syntax of the claims
+ * @param claimElement
+ */
+ public void setClaims(String dialectURI, OMElement claimElement) {
+ if(this.claims == null) {
+ this.claims = new Claims();
+ this.tokenElement.addChild(this.claims.tokenElement);
+ }
+
+ this.claims.setDialectAttribute(dialectURI);
+ this.claims.addToken(claimElement);
+ }
+
+ /**
+ * This should be used to set a ste of claims in the <code>Claims</code> element
+ * @param dialectURI Dialect attribute specifies a URI to indicate the syntax of the claims
+ * @param claimsElements Iterator of OMElements
+ * @throws TrustException
+ */
+ public void addClaims(String dialectURI, Iterator claimsElements)
+ throws TrustException {
+ if(this.claims == null) {
+ this.claims = new Claims();
+ }
+
+ this.claims.setDialectAttribute(dialectURI);
+ while (claimsElements.hasNext()) {
+ OMNode node = (OMNode) claimsElements.next();
+ if(node.getType() == OMNode.ELEMENT_NODE) {
+ this.claims.addToken((OMElement)node);
+ }
+ }
+ }
+
+ /**
+ * Returns the <code>Claims</code> element.
+ * @return Returns Claims.
+ */
+ public Claims getClaims() {
+ return this.claims;
+ }
+
+
+ /**
+ * Sets the <code>wst:Entropy/wst:BinarySecret</code> value and
+ * <code>wst:Entropy/wst:BinarySecret@Type</code> of the
+ * <code>wst:RequestSecurityToken</code>
+ * @param binarySecretType
+ * @param entropyValue
+ */
+ public void setEntropy(String binarySecretType, String entropyValue) {
+ if(this.entropy == null) {
+ this.entropy = new Entropy();
+ this.tokenElement.addChild(this.entropy.tokenElement);
+ }
+
+ this.entropy.setBinarySecret(binarySecretType, entropyValue);
+ }
+
+ /**
+ * Sets the binary secret of the Entropy element when the its of type <code>Nonce</code>
+ * @see org.apache.axis2.security.trust.Constants.BINARY_SECRET_TYPE#NONCE_VAL
+ * @param nonceValue The nonce value
+ */
+ public void setEntropyNonce(String nonceValue) {
+ this.setEntropy(Constants.BINARY_SECRET_TYPE.NONCE_VAL, nonceValue);
+ }
+
+ /**
+ * Returns the <code>Entropy</code> element
+ * @return Returns Entropy.
+ */
+ public Entropy getEntropy() {
+ return this.entropy;
+ }
+
+
+ /**
+ * Adds a <code>wst:Lifetime</code> element with the given duration to the
+ * <code>wst:RequestSecurityToken</code>
+ * @param lifetimeInMillis
+ */
+ public void setLifetime(long lifetimeInMillis) {
+ if(this.lifetime != null) {
+ this.lifetime.tokenElement.detach();
+ }
+
+ this.lifetime = new Lifetime(lifetimeInMillis);
+ this.tokenElement.addChild(this.lifetime.tokenElement);
+ }
+
+ /**
+ * Retuns the <code>Lifetime</code> element
+ * @return Returns Lifetime.
+ */
+ public Lifetime getLifetime() {
+ return this.lifetime;
+ }
+
+ /**
+ * Sets the <code>wst:KeySize</code> value of the <code>wst:RequestSecurityToken</code>
+ * @param size
+ */
+ public void setKeySize(int size) {
+ if(this.keySize == null) {
+ this.keySize = new KeySize();
+ this.tokenElement.addChild(this.keySize.tokenElement);
+ }
+ this.keySize.setKeySize(size);
+ }
+
+ /**
+ * Retuns the <code>KeySize</code> element
+ * @return Returns KeySize.
+ */
+ public KeySize getKeySize() {
+ return this.keySize;
+ }
+
+ /**
+ * Sets the <code>wst:Renewing</code> element of the
+ * <code>wst:RequestSecurityToken</code>
+ * @param allow
+ * @param ok
+ */
+ public void setRenewing(boolean allow, boolean ok) {
+ if(this.renewing == null) {
+ this.renewing = new Renewing();
+ this.tokenElement.addChild(this.renewing.tokenElement);
+ }
+ this.renewing.setAllow(allow);
+ this.renewing.setOK(ok);
+ }
+
+ /**
+ * Returns the <code>Renewing</code> element
+ * @return Returns Renewing.
+ */
+ public Renewing getRenewing() {
+ return this.renewing;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.axis2.security.trust.token.RequestSecurityToken#handleSpecificChildren(org.apache.ws.commons.om.OMElement)
+ */
+ protected void handleSpecificChildren(OMElement element)
+ throws TrustException {
+ QName el = new QName(element.getNamespace().getName(), element.getLocalName());
+
+ if(el.equals(AppliesTo.TOKEN)) {
+ this.appliesTo = new AppliesTo(element);
+ } else if(el.equals(Claims.TOKEN)) {
+ this.claims = new Claims(element);
+ } else if(el.equals(Entropy.TOKEN)) {
+ this.entropy = new Entropy(element);
+ } else if(el.equals(Lifetime.TOKEN)) {
+ this.lifetime = new Lifetime(element);
+ } else if(el.equals(KeySize.TOKEN)) {
+ this.keySize = new KeySize(element);
+ } else if(el.equals(Renewing.TOKEN)) {
+ this.renewing = new Renewing(element);
+ } else {
+ throw new TrustException(TrustException.INVALID_REQUEST,
+ TrustException.DESC_INCORRECT_CHILD_ELEM,
+ new Object[] {
+ TOKEN.getPrefix(),TOKEN.getLocalPart(),
+ el.getNamespaceURI(),el.getLocalPart()});
+ }
+ }
+
+}
Added: webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/KeySize.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/KeySize.java?rev=381992&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/KeySize.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/KeySize.java Wed Mar 1 03:33:04 2006
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.axis2.security.trust.token;
+
+import org.apache.axis2.security.trust.Constants;
+import org.apache.axis2.security.trust.TrustException;
+import org.apache.ws.commons.om.OMElement;
+
+import javax.xml.namespace.QName;
+
+public class KeySize extends ValueToken {
+
+ public static final QName TOKEN = new QName(Constants.WST_NS,Constants.LN.KEY_SIZE,Constants.WST_PREFIX);
+
+ public KeySize() {
+ super();
+ }
+
+ /**
+ * @param elem
+ * @throws TrustException
+ */
+ public KeySize(OMElement elem) throws TrustException {
+ super(elem);
+ }
+
+ /**
+ * Sets the key size value of the <code>wst:KeySize</code> element
+ * @param keySize
+ */
+ public void setKeySize(int keySize) {
+ this.setValue(Integer.toString(keySize));
+ }
+
+ /**
+ * Returns the key size if set otherwise returns -1
+ * @return Returns the key size if set otherwise returns -1
+ */
+ public int getKeySize() {
+ if(this.getValue() != null)
+ return Integer.parseInt(this.getValue());
+ else
+ return -1;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.axis2.security.trust.token.AbstractToken#getToken()
+ */
+ protected QName getToken() {
+ return TOKEN;
+ }
+}
Added: webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/Lifetime.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/Lifetime.java?rev=381992&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/Lifetime.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/Lifetime.java Wed Mar 1 03:33:04 2006
@@ -0,0 +1,156 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.axis2.security.trust.token;
+
+import org.apache.axis2.security.trust.Constants;
+import org.apache.axis2.security.trust.TrustException;
+import org.apache.ws.commons.om.OMElement;
+
+import javax.xml.namespace.QName;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.TimeZone;
+
+public class Lifetime extends CompositeToken {
+
+ public static final QName TOKEN = new QName(Constants.WST_NS,
+ Constants.LN.LIFE_TIME, Constants.WST_PREFIX);
+
+ private Created created;
+ private Expires expires;
+
+ public Lifetime(String created, String expires) {
+ super();
+
+ this.created = new Created();
+ this.created.setValue(created);
+ this.tokenElement.addChild(this.created.tokenElement);
+
+ this.expires = new Expires();
+ this.expires.setValue(expires);
+ this.tokenElement.addChild(this.expires.tokenElement);
+ }
+
+ /**
+ *
+ * @param lifeTime Lifetime in milliseconds
+ */
+ public Lifetime(long lifeTime) {
+ SimpleDateFormat sdtf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
+ sdtf.setTimeZone(TimeZone.getTimeZone("GMT"));
+
+ Calendar rightNow = Calendar.getInstance();
+ Calendar expires = Calendar.getInstance();
+
+ this.created = new Created();
+ this.created.setValue(sdtf.format(rightNow.getTime()));
+ this.tokenElement.addChild(this.created.tokenElement);
+
+ this.expires = new Expires();
+ long exp = rightNow.getTime().getTime() + lifeTime;
+ expires.setTimeInMillis(exp);
+ this.expires.setValue(sdtf.format(expires.getTime()));
+ this.tokenElement.addChild(this.expires.tokenElement);
+
+ }
+
+ /**
+ * @param elem
+ * @throws TrustException
+ */
+ public Lifetime(OMElement elem) throws TrustException {
+ super(elem);
+ }
+
+ /**
+ * Retuns the value of the <code>wsu:Created</code> child element.
+ * @return Returns String.
+ */
+ public String getCreated() {
+ if(this.created != null)
+ return this.created.getValue();
+ else
+ return null;
+ }
+
+ /**
+ * Returns the value of the <code>wsu:Expires</code> element.
+ * @return Returns String.
+ */
+ public String getExpires() {
+ if(this.expires != null)
+ return this.expires.getValue();
+ else
+ return null;
+ }
+
+
+ /**
+ * Sets the value of the <code>wsu:Created</code>element.
+ * @param value
+ */
+ public void setCreated(String value) {
+ if(this.created != null)
+ this.created.setValue(value);
+ else {
+ this.created = new Created();
+ this.created.setValue(value);
+ this.tokenElement.addChild(this.created.tokenElement);
+ }
+ }
+
+ /**
+ * Sets the value of the <code>wsu:Expires</code> element.
+ * @param value
+ */
+ public void setExpires(String value) {
+ if(this.expires != null)
+ this.expires.setValue(value);
+ else {
+ this.expires = new Expires();
+ this.expires.setValue(value);
+ this.tokenElement.addChild(this.expires.tokenElement);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.axis2.security.trust.token.AbstractToken#getToken()
+ */
+ protected QName getToken() {
+ return TOKEN;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.axis2.security.trust.token.AbstractToken#deserializeChildElement(org.apache.ws.commons.om.OMElement)
+ */
+ protected void deserializeChildElement(OMElement element)
+ throws TrustException {
+ QName el = new QName(element.getNamespace().getName(), element
+ .getLocalName());
+ if(el.equals(Created.TOKEN)) {
+ this.created = new Created(element);
+ } else if(el.equals(Expires.TOKEN)) {
+ this.expires = new Expires(element);
+ } else {
+ throw new TrustException(TrustException.INVALID_REQUEST,
+ TrustException.DESC_INCORRECT_CHILD_ELEM,
+ new Object[] {
+ TOKEN.getPrefix(),TOKEN.getLocalPart(),
+ el.getNamespaceURI(),el.getLocalPart()});
+ }
+ }
+
+}
Added: webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/Reason.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/Reason.java?rev=381992&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/Reason.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/Reason.java Wed Mar 1 03:33:04 2006
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.axis2.security.trust.token;
+
+import org.apache.axis2.security.trust.Constants;
+import org.apache.axis2.security.trust.TrustException;
+import org.apache.ws.commons.om.OMElement;
+
+import javax.xml.namespace.QName;
+
+public class Reason extends ValueToken {
+
+ public static final QName TOKEN = new QName(Constants.WST_NS, Constants.LN.REASON, Constants.WST_PREFIX);
+
+ public Reason(String value) {
+ super();
+ this.valueText = factory.createText(value);
+ this.setElementTextValue(valueText);
+ }
+
+ /**
+ * @param elem
+ * @throws TrustException
+ */
+ public Reason(OMElement elem) throws TrustException {
+ super(elem);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.axis2.security.trust.token.AbstractToken#getToken()
+ */
+ protected QName getToken() {
+ return TOKEN;
+ }
+
+}
Added: webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/Renewing.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/Renewing.java?rev=381992&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/Renewing.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/Renewing.java Wed Mar 1 03:33:04 2006
@@ -0,0 +1,106 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.axis2.security.trust.token;
+
+import org.apache.axis2.security.trust.Constants;
+import org.apache.axis2.security.trust.TrustException;
+import org.apache.ws.commons.om.OMElement;
+import org.apache.ws.commons.om.OMText;
+
+import javax.xml.namespace.QName;
+
+public class Renewing extends AbstractToken {
+
+ public static final QName TOKEN = new QName(Constants.WST_NS,
+ Constants.LN.RENEWING, Constants.WST_PREFIX);
+
+ //to request a renewable token.
+ boolean isAllow;
+
+ //to indicate that a renewable token is acceptable if the requested duration exceeds the limit of the issuance service.
+ boolean isOK;
+
+ public Renewing() {
+ super();
+ //Defaults
+ this.isAllow = true;
+ this.isOK = false;
+ }
+
+ public Renewing(boolean isOK, boolean isAllow) {
+ super();
+
+ this.isAllow = isAllow;
+ this.isOK = isOK;
+
+ this.tokenElement.addAttribute(Constants.ATTR.RENEWING_ALLOW, String.valueOf(this.isAllow), null);
+ this.tokenElement.addAttribute(Constants.ATTR.RENEWING_OK, String.valueOf(this.isOK), null);
+ }
+
+ /**
+ * @param elem
+ * @throws TrustException
+ */
+ public Renewing(OMElement elem) throws TrustException {
+ super(elem);
+ // TODO Auto-generated constructor stub
+ }
+
+
+
+ public boolean isAllow() {
+ return isAllow;
+ }
+
+ public void setAllow(boolean isAllow) {
+ this.isAllow = isAllow;
+ this.tokenElement.addAttribute(Constants.ATTR.RENEWING_ALLOW, String.valueOf(this.isAllow), null);
+ }
+
+ public boolean isOK() {
+ return isOK;
+ }
+
+ public void setOK(boolean isOK) {
+ this.isOK = isOK;
+ this.tokenElement.addAttribute(Constants.ATTR.RENEWING_OK, String.valueOf(this.isOK), null);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.axis2.security.trust.token.AbstractToken#getToken()
+ */
+ protected QName getToken() {
+ return TOKEN;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.axis2.security.trust.token.AbstractToken#deserializeChildElement(org.apache.ws.commons.om.OMElement)
+ */
+ protected void deserializeChildElement(OMElement element)
+ throws TrustException {
+ throw new TrustException(TrustException.INVALID_REQUEST,
+ "There cannot be a child element in this element: " + TOKEN.getLocalPart());
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.axis2.security.trust.token.AbstractToken#setElementTextValue(org.apache.ws.commons.om.OMText)
+ */
+ protected void setElementTextValue(OMText textNode) throws TrustException {
+ throw new TrustException(TrustException.INVALID_REQUEST,
+ "There cannot be a value in this element: " + TOKEN.getLocalPart());
+ }
+
+}
Added: webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/RequestSecurityToken.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/RequestSecurityToken.java?rev=381992&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/RequestSecurityToken.java (added)
+++ webservices/axis2/trunk/archive/java/scratch/ruchith/trust/src/org/apache/axis2/security/trust/token/RequestSecurityToken.java Wed Mar 1 03:33:04 2006
@@ -0,0 +1,183 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.axis2.security.trust.token;
+
+import org.apache.axis2.security.trust.Constants;
+import org.apache.axis2.security.trust.TrustException;
+import org.apache.ws.commons.om.OMElement;
+import org.apache.ws.commons.om.OMNamespace;
+
+import javax.xml.namespace.QName;
+
+
+public abstract class RequestSecurityToken extends CompositeToken {
+
+ protected TokenType tokenTypeElement;
+ protected RequestType requestTypeElement;
+
+ public static final QName TOKEN = new QName(Constants.WST_NS,
+ Constants.LN.REQUESTED_SECURITY_TOKEN, Constants.WST_PREFIX);
+
+ public RequestSecurityToken(String requestType) {
+ super();
+ }
+
+ /**
+ * @param elem
+ * @throws TrustException
+ */
+ public RequestSecurityToken(OMElement elem) throws TrustException {
+ super(elem);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.axis2.security.trust.token.AbstractToken#getToken()
+ */
+ protected QName getToken() {
+ return TOKEN;
+ }
+
+ /**
+ * Sets the <code>wst:RequestType</code> value of this <code>wst:RequestSecurityToken</code>
+ * @param requestType The <code>wst:RequestType</code> uri as a <code>String
+ */
+ public void setRequestType(String requestType) {
+ if(this.requestTypeElement == null) {
+ this.requestTypeElement = new RequestType();
+ this.tokenElement.addChild(this.requestTypeElement.tokenElement);
+ }
+
+ this.requestTypeElement.setValue(requestType);
+
+ }
+
+ /**
+ * Returns the request type if it is set
+ * @return Returns String.
+ */
+ public String getRequestType() {
+ if(this.requestTypeElement != null) {
+ return this.requestTypeElement.getValue();
+ }
+ return null;
+ }
+
+ /**
+ * Sets the <code>wst:TokenType</code> value of this <code>wst:RequestSecurityToken</code>
+ * @param tokenType The <code>wst:TokenType</code> uri as a <code>String</code>
+ */
+ public void setTokenType(String tokenType) {
+ if(this.tokenTypeElement == null) {
+ this.tokenTypeElement = new TokenType();
+ this.tokenElement.addChild(this.tokenTypeElement.tokenElement);
+ }
+
+ this.tokenTypeElement.setValue(tokenType);
+ }
+
+ /**
+ * Returns the token type is set
+ * @return Returns String.
+ */
+ public String getTokenType() {
+ if(this.tokenTypeElement != null) {
+ return tokenTypeElement.getValue();
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.axis2.security.trust.token.AbstractToken#deserializeChildElement(org.apache.ws.commons.om.OMElement)
+ */
+ protected void deserializeChildElement(OMElement element)
+ throws TrustException {
+ QName el = new QName(element.getNamespace().getName(), element.getLocalName());
+ if(el.equals(RequestType.TOKEN)) {
+ this.requestTypeElement = new RequestType(element);
+ } else if(el.equals(TokenType.TOKEN)) {
+ this.tokenTypeElement = new TokenType(element);
+ } else {
+ this.handleSpecificChildren(element);
+ }
+ }
+
+ /**
+ * This is provided as an extensibility mechanism to add any
+ * child element to the <code>wst:RequestSecyrityToken</code> element
+ * @param childToken
+ */
+ public void addToken(OMElement childToken) {
+ this.tokenElement.addChild(childToken);
+ }
+
+ /**
+ * Returns the requested token if available
+ * @param tokenQName
+ * @return Returns OMElement.
+ */
+ public OMElement getToken(QName tokenQName) {
+ return this.tokenElement.getFirstChildWithName(tokenQName);
+ }
+
+ /**
+ * /wst:RequestSecurityToken/@Context
+ * This URI specifies an identifier/context for this request.
+ * @param contextAttrValue
+ */
+ public void setContextAttr(String contextAttrValue) {
+ this.tokenElement.addAttribute(Constants.ATTR.CONTEXT,
+ contextAttrValue, wstNamespace);
+ }
+
+ public String getContextAttrValue() {
+ return this.tokenElement.getAttribute(
+ new QName(wstNamespace.getName(), Constants.ATTR.CONTEXT,
+ wstNamespace.getPrefix())).getAttributeValue();
+ }
+
+ /**
+ * This is provided as an extensibility mechnism to
+ * ass any attrbute to the <code>wst:RequestSecyrityToken</code> element
+ * @param attribute Name of the attr
+ * @param value Attr value
+ * @param namespace Attr namespace
+ */
+ public void addAttribute(String attribute, String value,
+ OMNamespace namespace) {
+ this.tokenElement.addAttribute(attribute, value, namespace);
+ }
+
+ /**
+ * This is to be used to retrieve the value of the
+ * custom attrbutes added to the
+ * <code>wst:RequestSecyrityToken</code>
+ * @param attribute
+ * @return Returns String.
+ */
+ public String getAttributeValue(QName attribute) {
+ return this.tokenElement.getAttribute(attribute).getAttributeValue();
+ }
+
+ public OMElement getRequestElement() {
+ return this.tokenElement;
+ }
+
+ /**
+ * @param element Specific child element
+ */
+ protected abstract void handleSpecificChildren(OMElement element) throws TrustException;
+
+}