001: /*
002: * The contents of this file are subject to the terms
003: * of the Common Development and Distribution License
004: * (the License). You may not use this file except in
005: * compliance with the License.
006: *
007: * You can obtain a copy of the license at
008: * https://glassfish.dev.java.net/public/CDDLv1.0.html.
009: * See the License for the specific language governing
010: * permissions and limitations under the License.
011: *
012: * When distributing Covered Code, include this CDDL
013: * Header Notice in each file and include the License file
014: * at https://glassfish.dev.java.net/public/CDDLv1.0.html.
015: * If applicable, add the following below the CDDL Header,
016: * with the fields enclosed by brackets [] replaced by
017: * you own identifying information:
018: * "Portions Copyrighted [year] [name of copyright owner]"
019: *
020: * Copyright 2006 Sun Microsystems Inc. All Rights Reserved
021: */
022:
023: /*
024: * IssuedTokenContextImpl.java
025: *
026: * Created on December 14, 2005, 3:44 PM
027: *
028: * To change this template, choose Tools | Template Manager
029: * and open the template in the editor.
030: */
031:
032: package com.sun.xml.ws.security.impl;
033:
034: import com.sun.org.apache.xml.internal.security.encryption.EncryptedKey;
035: import com.sun.org.apache.xml.internal.security.encryption.XMLEncryptionException;
036: import com.sun.xml.ws.security.*;
037: import com.sun.xml.wss.XWSSecurityException;
038: import java.net.URI;
039: import java.security.Key;
040: import java.security.cert.X509Certificate;
041: import java.util.ArrayList;
042: import com.sun.org.apache.xml.internal.security.encryption.XMLCipher;
043:
044: import java.util.Date;
045:
046: import javax.security.auth.Subject;
047:
048: /**
049: *
050: * @author Abhijit Das
051: */
052: public class IssuedTokenContextImpl implements IssuedTokenContext {
053:
054: X509Certificate x509Certificate = null;
055: Token securityToken = null;
056: Token associatedProofToken = null;
057: Token secTokenReference = null;
058: Token unAttachedSecTokenReference = null;
059: ArrayList securityPolicies = new ArrayList();
060: Object otherPartyEntropy = null;
061: Object selfEntropy = null;
062: URI computedKeyAlgorithm;
063: byte[] proofKey = null; // used in SecureConversation
064: SecurityContextTokenInfo sctInfo = null; // used in SecureConversation
065: Date creationTime = null;
066: Date expiryTime = null;
067: String username = null;
068: String endPointAddress = null;
069: Subject subject;
070:
071: public X509Certificate getRequestorCertificate() {
072: return x509Certificate;
073: }
074:
075: public void setRequestorCertificate(X509Certificate cert) {
076: this .x509Certificate = cert;
077: }
078:
079: public Subject getRequestorSubject() {
080: return subject;
081: }
082:
083: public void setRequestorSubject(Subject subject) {
084: this .subject = subject;
085: }
086:
087: public String getRequestorUsername() {
088: return username;
089: }
090:
091: public void setRequestorUsername(String username) {
092: this .username = username;
093: }
094:
095: public void setSecurityToken(Token securityToken) {
096: this .securityToken = securityToken;
097: }
098:
099: public Token getSecurityToken() {
100: return securityToken;
101: }
102:
103: public void setAssociatedProofToken(Token associatedProofToken) {
104: this .associatedProofToken = associatedProofToken;
105: }
106:
107: public Token getAssociatedProofToken() {
108: return associatedProofToken;
109: }
110:
111: public Token getAttachedSecurityTokenReference() {
112: return secTokenReference;
113: }
114:
115: public void setAttachedSecurityTokenReference(
116: Token secTokenReference) {
117: this .secTokenReference = secTokenReference;
118: }
119:
120: public Token getUnAttachedSecurityTokenReference() {
121: return unAttachedSecTokenReference;
122: }
123:
124: public void setUnAttachedSecurityTokenReference(
125: Token secTokenReference) {
126: this .unAttachedSecTokenReference = secTokenReference;
127: }
128:
129: public ArrayList getSecurityPolicy() {
130: return securityPolicies;
131: }
132:
133: public void setOtherPartyEntropy(Object otherPartyEntropy) {
134: this .otherPartyEntropy = otherPartyEntropy;
135: }
136:
137: public Object getOtherPartyEntropy() {
138: return otherPartyEntropy;
139: }
140:
141: public Key getDecipheredOtherPartyEntropy(Key privKey)
142: throws XWSSecurityException {
143: try {
144: return getDecipheredOtherPartyEntropy(
145: getOtherPartyEntropy(), privKey);
146: } catch (XMLEncryptionException xee) {
147: throw new XWSSecurityException(xee);
148: }
149: }
150:
151: private Key getDecipheredOtherPartyEntropy(Object encryptedKey,
152: Key privKey) throws XMLEncryptionException {
153: if (encryptedKey instanceof EncryptedKey) {
154: EncryptedKey encKey = (EncryptedKey) encryptedKey;
155: XMLCipher cipher = XMLCipher.getInstance();
156: cipher.setKEK(privKey);
157: cipher.decryptKey(encKey);
158: return null;
159: } else {
160: return null;
161: }
162: }
163:
164: public void setSelfEntropy(Object selfEntropy) {
165: this .selfEntropy = selfEntropy;
166: }
167:
168: public Object getSelfEntropy() {
169: return selfEntropy;
170: }
171:
172: public URI getComputedKeyAlgorithmFromProofToken() {
173: return computedKeyAlgorithm;
174: }
175:
176: public void setComputedKeyAlgorithmFromProofToken(
177: URI computedKeyAlgorithm) {
178: this .computedKeyAlgorithm = computedKeyAlgorithm;
179: }
180:
181: public void setProofKey(byte[] key) {
182: this .proofKey = key;
183: }
184:
185: public byte[] getProofKey() {
186: return proofKey;
187: }
188:
189: public Date getCreationTime() {
190: return creationTime;
191: }
192:
193: public Date getExpirationTime() {
194: return expiryTime;
195: }
196:
197: public void setCreationTime(Date date) {
198: creationTime = date;
199: }
200:
201: public void setExpirationTime(Date date) {
202: expiryTime = date;
203: }
204:
205: /**
206: * set the endpointaddress
207: */
208: public void setEndpointAddress(String endPointAddress) {
209: this .endPointAddress = endPointAddress;
210: }
211:
212: /**
213: *get the endpoint address
214: */
215: public String getEndpointAddress() {
216: return this .endPointAddress;
217: }
218:
219: public void destroy() {
220:
221: }
222:
223: public SecurityContextTokenInfo getSecurityContextTokenInfo() {
224: return sctInfo;
225: }
226:
227: public void setSecurityContextTokenInfo(
228: SecurityContextTokenInfo sctInfo) {
229: this.sctInfo = sctInfo;
230: }
231:
232: }
|