01: /*
02: * $Id: SamlKeyIdentifier.java,v 1.5 2006/10/08 18:05:23 kumarjayanti 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.core.reference;
28:
29: import javax.xml.soap.SOAPElement;
30:
31: import org.w3c.dom.Document;
32:
33: import com.sun.xml.wss.impl.MessageConstants;
34: import com.sun.xml.wss.XWSSecurityException;
35: import org.w3c.dom.Node;
36: import org.w3c.dom.NodeList;
37:
38: /**
39: */
40: public class SamlKeyIdentifier extends KeyIdentifier {
41:
42: /** Defaults */
43: private String valueType = MessageConstants.WSSE_SAML_KEY_IDENTIFIER_VALUE_TYPE;
44:
45: /**
46: * Creates an "empty" KeyIdentifier element with default encoding type
47: * and default value type.
48: */
49: public SamlKeyIdentifier(Document doc) throws XWSSecurityException {
50: super (doc);
51: // Set default attributes
52: String vType = valueType;
53: NodeList nodeList = doc
54: .getElementsByTagName(MessageConstants.SAML_ASSERTION_LNAME);
55: if (nodeList.getLength() > 0) {
56: Node assertion = (Node) nodeList.item(0);
57: if (assertion.getNamespaceURI() == MessageConstants.SAML_v2_0_NS) {
58: vType = MessageConstants.WSSE_SAML_v2_0_KEY_IDENTIFIER_VALUE_TYPE;
59: }
60:
61: }
62: // old behavior left for BackwardCompatibility reasons
63: setAttribute("ValueType", vType);
64: }
65:
66: public SamlKeyIdentifier(SOAPElement element)
67: throws XWSSecurityException {
68: super(element);
69: }
70:
71: }
|