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