001: /*
002: * $Id: RenewTargetImpl.java,v 1.4 2007/05/29 22:11:34 ofung Exp $
003: */
004:
005: /*
006: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
007: *
008: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
009: *
010: * The contents of this file are subject to the terms of either the GNU
011: * General Public License Version 2 only ("GPL") or the Common Development
012: * and Distribution License("CDDL") (collectively, the "License"). You
013: * may not use this file except in compliance with the License. You can obtain
014: * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
015: * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
016: * language governing permissions and limitations under the License.
017: *
018: * When distributing the software, include this License Header Notice in each
019: * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
020: * Sun designates this particular file as subject to the "Classpath" exception
021: * as provided by Sun in the GPL Version 2 section of the License file that
022: * accompanied this code. If applicable, add the following below the License
023: * Header, with the fields enclosed by brackets [] replaced by your own
024: * identifying information: "Portions Copyrighted [year]
025: * [name of copyright owner]"
026: *
027: * Contributor(s):
028: *
029: * If you wish your version of this file to be governed by only the CDDL or
030: * only the GPL Version 2, indicate your decision by adding "[Contributor]
031: * elects to include this software in this distribution under the [CDDL or GPL
032: * Version 2] license." If you don't indicate a single choice of license, a
033: * recipient has the option to distribute your version of this file under
034: * either the CDDL, the GPL Version 2 or to extend the choice of license to
035: * its licensees as provided above. However, if you add GPL Version 2 code
036: * and therefore, elected the GPL Version 2 license, then the option applies
037: * only if the new code is made subject to such option by the copyright
038: * holder.
039: */
040:
041: package com.sun.xml.ws.security.trust.impl.elements;
042:
043: import com.sun.xml.ws.security.trust.elements.str.SecurityTokenReference;
044: import com.sun.xml.ws.security.trust.impl.elements.str.SecurityTokenReferenceImpl;
045: import com.sun.xml.ws.security.secext10.SecurityTokenReferenceType;
046: import com.sun.xml.ws.security.Token;
047: import com.sun.xml.ws.security.trust.WSTrustConstants;
048: import com.sun.xml.ws.security.trust.elements.RenewTarget;
049: import com.sun.xml.ws.security.trust.impl.bindings.RenewTargetType;
050: import javax.xml.bind.JAXBElement;
051:
052: /**
053: * Target specifying the Security token to be renewed.
054: *
055: * @author Manveen Kaur
056: */
057: public class RenewTargetImpl extends RenewTargetType implements
058: RenewTarget {
059:
060: private String targetType = null;
061:
062: private SecurityTokenReference str = null;
063: private Token token = null;
064:
065: public RenewTargetImpl(SecurityTokenReference str) {
066: setSecurityTokenReference(str);
067: setTargetType(WSTrustConstants.STR_TYPE);
068: }
069:
070: public RenewTargetImpl(Token token) {
071: setToken(token);
072: setTargetType(WSTrustConstants.TOKEN_TYPE);
073: }
074:
075: public RenewTargetImpl(RenewTargetType rnType) {
076: final JAXBElement obj = (JAXBElement) rnType.getAny();
077: final String local = obj.getName().getLocalPart();
078: if ("SecurityTokenReference".equals(local)) {
079: final SecurityTokenReference str = new SecurityTokenReferenceImpl(
080: (SecurityTokenReferenceType) obj.getValue());
081: setSecurityTokenReference(str);
082: setTargetType(WSTrustConstants.STR_TYPE);
083: } else {
084: //ToDo
085: }
086: }
087:
088: public String getTargetType() {
089: return targetType;
090: }
091:
092: public final void setTargetType(final String ttype) {
093: targetType = ttype;
094: }
095:
096: public final void setSecurityTokenReference(
097: final SecurityTokenReference ref) {
098: if (ref != null) {
099: str = ref;
100: final JAXBElement<SecurityTokenReferenceType> strElement = (new com.sun.xml.ws.security.secext10.ObjectFactory())
101: .createSecurityTokenReference((SecurityTokenReferenceType) ref);
102: setAny(strElement);
103: }
104: setTargetType(WSTrustConstants.STR_TYPE);
105: token = null;
106: }
107:
108: public SecurityTokenReference getSecurityTokenReference() {
109: return str;
110: }
111:
112: public final void setToken(final Token token) {
113: if (token != null) {
114: this .token = token;
115: setAny(token);
116: }
117: setTargetType(WSTrustConstants.TOKEN_TYPE);
118: str = null;
119: }
120:
121: public Token getToken() {
122: return token;
123: }
124:
125: }
|