001: /*
002: * $Id: CancelTargetImpl.java,v 1.1 2007/08/23 12:40:55 shyam_rao Exp $
003: */
004:
005: /*
006: * The contents of this file are subject to the terms
007: * of the Common Development and Distribution License
008: * (the License). You may not use this file except in
009: * compliance with the License.
010: *
011: * You can obtain a copy of the license at
012: * https://glassfish.dev.java.net/public/CDDLv1.0.html.
013: * See the License for the specific language governing
014: * permissions and limitations under the License.
015: *
016: * When distributing Covered Code, include this CDDL
017: * Header Notice in each file and include the License file
018: * at https://glassfish.dev.java.net/public/CDDLv1.0.html.
019: * If applicable, add the following below the CDDL Header,
020: * with the fields enclosed by brackets [] replaced by
021: * you own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Copyright 2006 Sun Microsystems Inc. All Rights Reserved
025: */
026:
027: package com.sun.xml.ws.security.trust.impl.wssx.elements;
028:
029: import com.sun.xml.ws.security.trust.elements.str.SecurityTokenReference;
030: import com.sun.xml.ws.security.trust.impl.elements.str.SecurityTokenReferenceImpl;
031: import com.sun.xml.ws.security.secext10.SecurityTokenReferenceType;
032: import com.sun.xml.ws.security.Token;
033: import com.sun.xml.ws.security.trust.elements.CancelTarget;
034: import com.sun.xml.ws.security.trust.impl.wssx.bindings.CancelTargetType;
035: import javax.xml.bind.JAXBElement;
036:
037: /**
038: * Defines Binding for requesting security tokens to be cancelled.
039: *
040: * @author Manveen Kaur
041: */
042: public class CancelTargetImpl extends CancelTargetType implements
043: CancelTarget {
044:
045: private String targetType = null;
046:
047: // either STR will be present or the token will be
048: // carried directly. This will typically be a BST.
049: private SecurityTokenReference str = null;
050: private Token token = null;
051:
052: public CancelTargetImpl(SecurityTokenReference str) {
053: setSecurityTokenReference(str);
054: setTargetType(CancelTarget.STR_TARGET_TYPE);
055: }
056:
057: public CancelTargetImpl(Token token) {
058: setToken(token);
059: setTargetType(CancelTarget.CUSTOM_TARGET_TYPE);
060: }
061:
062: public CancelTargetImpl(CancelTargetType ctType) throws Exception {
063: JAXBElement obj = (JAXBElement) ctType.getAny();
064: String local = obj.getName().getLocalPart();
065: if ("SecurityTokenReference".equals(local)) {
066: SecurityTokenReference str = new SecurityTokenReferenceImpl(
067: (SecurityTokenReferenceType) obj.getValue());
068: setSecurityTokenReference(str);
069: setTargetType(CancelTarget.STR_TARGET_TYPE);
070: } else {
071: //ToDo
072: }
073: }
074:
075: public String getTargetType() {
076: return targetType;
077: }
078:
079: public void setTargetType(String ttype) {
080: targetType = ttype;
081: }
082:
083: public void setSecurityTokenReference(SecurityTokenReference ref) {
084: if (ref != null) {
085: str = ref;
086: JAXBElement<SecurityTokenReferenceType> strElement = (new com.sun.xml.ws.security.secext10.ObjectFactory())
087: .createSecurityTokenReference((SecurityTokenReferenceType) ref);
088: setAny(strElement);
089: }
090: setTargetType(CancelTarget.STR_TARGET_TYPE);
091: token = null;
092: }
093:
094: public SecurityTokenReference getSecurityTokenReference() {
095: return str;
096: }
097:
098: public void setToken(Token token) {
099: if (token != null) {
100: this .token = token;
101: setAny(token);
102: }
103: setTargetType(CancelTarget.CUSTOM_TARGET_TYPE);
104: str = null;
105: }
106:
107: public Token getToken() {
108: return token;
109: }
110:
111: }
|