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