01: /*
02: * $Id: X509IssuerSerialStrategy.java,v 1.5 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: package com.sun.xml.wss.impl.keyinfo;
27:
28: import java.security.cert.X509Certificate;
29:
30: import org.w3c.dom.Document;
31:
32: import java.util.logging.Logger;
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: import com.sun.xml.wss.core.reference.X509IssuerSerial;
41:
42: /**
43: * @author Vishal Mahajan
44: */
45: public class X509IssuerSerialStrategy extends KeyInfoStrategy {
46:
47: protected static final Logger log = Logger.getLogger(
48: LogDomainConstants.WSS_API_DOMAIN,
49: LogDomainConstants.WSS_API_DOMAIN_BUNDLE);
50:
51: X509Certificate cert = null;
52:
53: String alias = null;
54: boolean forSigning;
55:
56: public X509IssuerSerialStrategy() {
57:
58: }
59:
60: public X509IssuerSerialStrategy(String alias, boolean forSigning) {
61: this .alias = alias;
62: this .forSigning = forSigning;
63: this .cert = null;
64: }
65:
66: public void insertKey(SecurityTokenReference tokenRef,
67: SecurableSoapMessage secureMsg) throws XWSSecurityException {
68: X509IssuerSerial x509IssuerSerial = new X509IssuerSerial(
69: secureMsg.getSOAPPart(), cert);
70: tokenRef.setReference(x509IssuerSerial);
71: }
72:
73: public void insertKey(KeyInfoHeaderBlock keyInfo,
74: SecurableSoapMessage secureMsg, String x509TokenId) // x509TokenId can be ignored
75: throws XWSSecurityException {
76:
77: Document ownerDoc = keyInfo.getOwnerDocument();
78: SecurityTokenReference tokenRef = new SecurityTokenReference(
79: ownerDoc);
80: X509IssuerSerial x509IssuerSerial = new X509IssuerSerial(
81: ownerDoc, cert);
82: tokenRef.setReference(x509IssuerSerial);
83: keyInfo.addSecurityTokenReference(tokenRef);
84: }
85:
86: public void setCertificate(X509Certificate cert) {
87: this .cert = cert;
88: }
89:
90: public String getAlias() {
91: return alias;
92: }
93: }
|