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