001: /*
002: * $Id: DelegateToImpl.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.WSTrustConstants;
034: import com.sun.xml.ws.security.trust.elements.DelegateTo;
035: import com.sun.xml.ws.security.trust.impl.wssx.bindings.DelegateToType;
036: import javax.xml.bind.JAXBElement;
037:
038: /**
039: * @author Manveen Kaur.
040: */
041: public class DelegateToImpl extends DelegateToType implements
042: DelegateTo {
043:
044: private String targetType = null;
045:
046: private SecurityTokenReference str = null;
047: private Token token = null;
048:
049: public DelegateToImpl(SecurityTokenReference str) {
050: setSecurityTokenReference(str);
051: setTargetType(WSTrustConstants.STR_TYPE);
052: }
053:
054: public DelegateToImpl(Token token) {
055: setToken(token);
056: setTargetType(WSTrustConstants.TOKEN_TYPE);
057: }
058:
059: public DelegateToImpl(DelegateToType ctType) throws Exception {
060: JAXBElement obj = (JAXBElement) ctType.getAny();
061: String local = obj.getName().getLocalPart();
062: if ("SecurityTokenReference".equals(local)) {
063: SecurityTokenReference str = new SecurityTokenReferenceImpl(
064: (SecurityTokenReferenceType) obj.getValue());
065: setSecurityTokenReference(str);
066: setTargetType(WSTrustConstants.STR_TYPE);
067: } else {
068: //ToDo
069: }
070: }
071:
072: public String getTargetType() {
073: return targetType;
074: }
075:
076: public void setTargetType(String ttype) {
077: targetType = ttype;
078: }
079:
080: public void setSecurityTokenReference(SecurityTokenReference ref) {
081: if (ref != null) {
082: str = ref;
083: JAXBElement<SecurityTokenReferenceType> strElement = (new com.sun.xml.ws.security.secext10.ObjectFactory())
084: .createSecurityTokenReference((SecurityTokenReferenceType) ref);
085: setAny(strElement);
086: }
087: setTargetType(WSTrustConstants.STR_TYPE);
088: token = null;
089: }
090:
091: public SecurityTokenReference getSecurityTokenReference() {
092: return str;
093: }
094:
095: public void setToken(Token token) {
096: if (token != null) {
097: this .token = token;
098: setAny(token);
099: }
100: setTargetType(WSTrustConstants.TOKEN_TYPE);
101: str = null;
102: }
103:
104: public Token getToken() {
105: return token;
106: }
107:
108: }
|