001: /*
002: * $Id: UseKeyImpl.java,v 1.1 2007/08/23 12:40:56 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 java.net.URI;
030:
031: import com.sun.xml.ws.security.trust.elements.str.SecurityTokenReference;
032: import com.sun.xml.ws.security.trust.impl.elements.str.SecurityTokenReferenceImpl;
033: import com.sun.xml.ws.security.secext10.SecurityTokenReferenceType;
034: import com.sun.xml.ws.security.Token;
035: import com.sun.xml.ws.security.trust.WSTrustConstants;
036: import com.sun.xml.ws.security.trust.elements.UseKey;
037: import com.sun.xml.ws.security.trust.impl.wssx.bindings.UseKeyType;
038: import java.net.URISyntaxException;
039: import javax.xml.bind.JAXBElement;
040:
041: /**
042: * @author Manveen Kaur
043: */
044: public class UseKeyImpl extends UseKeyType implements UseKey {
045:
046: private String targetType = null;
047:
048: private SecurityTokenReference str = null;
049: private Token token = null;
050:
051: public UseKeyImpl(SecurityTokenReference str) {
052: setSecurityTokenReference(str);
053: setTargetType(WSTrustConstants.STR_TYPE);
054: }
055:
056: public UseKeyImpl(UseKeyType ukType) throws Exception {
057: JAXBElement obj = (JAXBElement) ukType.getAny();
058: String local = obj.getName().getLocalPart();
059: if ("SecurityTokenReference".equals(local)) {
060: SecurityTokenReference str = new SecurityTokenReferenceImpl(
061: (SecurityTokenReferenceType) obj.getValue());
062: setSecurityTokenReference(str);
063: setTargetType(WSTrustConstants.STR_TYPE);
064: } else {
065: //ToDo
066: }
067: }
068:
069: public String getTargetType() {
070: return targetType;
071: }
072:
073: public void setTargetType(String ttype) {
074: targetType = ttype;
075: }
076:
077: public void setSecurityTokenReference(SecurityTokenReference ref) {
078: if (ref != null) {
079: str = ref;
080: JAXBElement<SecurityTokenReferenceType> strElement = (new com.sun.xml.ws.security.secext10.ObjectFactory())
081: .createSecurityTokenReference((SecurityTokenReferenceType) ref);
082: setAny(strElement);
083: }
084: setTargetType(WSTrustConstants.STR_TYPE);
085: token = null;
086: }
087:
088: public SecurityTokenReference getSecurityTokenReference() {
089: return str;
090: }
091:
092: public void setToken(Token token) {
093: if (token != null) {
094: this .token = token;
095: setAny(token);
096: }
097: setTargetType(WSTrustConstants.TOKEN_TYPE);
098: str = null;
099: }
100:
101: public Token getToken() {
102: return token;
103: }
104:
105: public void setSignatureID(URI sigID) {
106: setSig(sigID.toString());
107: }
108:
109: public URI getSignatureID() {
110: try {
111: return new URI(getSig());
112: } catch (URISyntaxException ue) {
113: throw new RuntimeException("URI syntax invalid ", ue);
114: }
115: }
116:
117: }
|