01: /*
02: * BinarySecretStrategy.java
03: *
04: * Created on January 4, 2006, 3:22 PM
05: */
06:
07: /*
08: * The contents of this file are subject to the terms
09: * of the Common Development and Distribution License
10: * (the License). You may not use this file except in
11: * compliance with the License.
12: *
13: * You can obtain a copy of the license at
14: * https://glassfish.dev.java.net/public/CDDLv1.0.html.
15: * See the License for the specific language governing
16: * permissions and limitations under the License.
17: *
18: * When distributing Covered Code, include this CDDL
19: * Header Notice in each file and include the License file
20: * at https://glassfish.dev.java.net/public/CDDLv1.0.html.
21: * If applicable, add the following below the CDDL Header,
22: * with the fields enclosed by brackets [] replaced by
23: * you own identifying information:
24: * "Portions Copyrighted [year] [name of copyright owner]"
25: *
26: * Copyright 2006 Sun Microsystems Inc. All Rights Reserved
27: */
28:
29: package com.sun.xml.wss.impl.keyinfo;
30:
31: import com.sun.xml.wss.impl.misc.Base64;
32: import com.sun.xml.wss.XWSSecurityException;
33: import com.sun.xml.wss.core.KeyInfoHeaderBlock;
34: import com.sun.xml.wss.core.SecurityTokenReference;
35: import com.sun.xml.wss.impl.SecurableSoapMessage;
36: import com.sun.xml.wss.logging.LogDomainConstants;
37: import java.security.cert.X509Certificate;
38: import java.util.logging.Level;
39: import java.util.logging.Logger;
40:
41: /**
42: *
43: * @author Abhijit Das
44: */
45: public class BinarySecretStrategy extends KeyInfoStrategy {
46:
47: private byte[] secret = null;
48:
49: protected static final Logger log = Logger.getLogger(
50: LogDomainConstants.WSS_API_DOMAIN,
51: LogDomainConstants.WSS_API_DOMAIN_BUNDLE);
52:
53: /**
54: * Creates a new instance of BinarySecretStrategy
55: */
56: public BinarySecretStrategy() {
57: }
58:
59: public BinarySecretStrategy(byte[] secret) {
60: this .secret = secret;
61: }
62:
63: public void insertKey(KeyInfoHeaderBlock keyInfo,
64: SecurableSoapMessage secureMsg, String x509TokenId)
65: throws XWSSecurityException {
66: //TODO: need to rework this
67: // keyInfo.addBinarySecret(secret);
68: }
69:
70: public void insertKey(SecurityTokenReference tokenRef,
71: SecurableSoapMessage secureMsg) throws XWSSecurityException {
72: log.log(Level.SEVERE, "WSS0703.unsupported.operation");
73: throw new UnsupportedOperationException(
74: "A ds:BinarySecret can't be put under a wsse:SecurityTokenReference");
75: }
76:
77: public void setCertificate(X509Certificate cert) {
78: log.log(Level.SEVERE, "WSS0705.unsupported.operation");
79: throw new UnsupportedOperationException(
80: "Setting a certificate is not a supported operation for ds:BinarySecret strategy");
81: }
82:
83: public String getAlias() {
84: return Base64.encode(secret);
85: }
86:
87: public void setSecret(byte[] secret) {
88: this.secret = secret;
89: }
90:
91: }
|