01: /*
02: * The contents of this file are subject to the terms
03: * of the Common Development and Distribution License
04: * (the License). You may not use this file except in
05: * compliance with the License.
06: *
07: * You can obtain a copy of the license at
08: * https://glassfish.dev.java.net/public/CDDLv1.0.html.
09: * See the License for the specific language governing
10: * permissions and limitations under the License.
11: *
12: * When distributing Covered Code, include this CDDL
13: * Header Notice in each file and include the License file
14: * at https://glassfish.dev.java.net/public/CDDLv1.0.html.
15: * If applicable, add the following below the CDDL Header,
16: * with the fields enclosed by brackets [] replaced by
17: * you own identifying information:
18: * "Portions Copyrighted [year] [name of copyright owner]"
19: *
20: * Copyright 2006 Sun Microsystems Inc. All Rights Reserved
21: */
22:
23: /*
24: * EncryptedKeySHA1Identifier.java
25: *
26: * Created on January 13, 2006, 3:46 PM
27: *
28: * To change this template, choose Tools | Template Manager
29: * and open the template in the editor.
30: */
31:
32: package com.sun.xml.wss.core.reference;
33:
34: import com.sun.xml.wss.impl.MessageConstants;
35: import com.sun.xml.wss.XWSSecurityException;
36: import com.sun.xml.wss.impl.SecurityHeaderException;
37:
38: import com.sun.org.apache.xml.internal.security.exceptions.Base64DecodingException;
39: import com.sun.xml.wss.impl.misc.Base64;
40:
41: import javax.xml.soap.SOAPElement;
42:
43: import org.w3c.dom.Document;
44:
45: import java.util.logging.Level;
46:
47: /**
48: *
49: * @author Ashutosh Shahi
50: */
51: public class EncryptedKeySHA1Identifier extends KeyIdentifier {
52:
53: /**Defaults*/
54: private String encodingType = MessageConstants.BASE64_ENCODING_NS;
55:
56: private String valueType = MessageConstants.EncryptedKeyIdentifier_NS;
57:
58: /**
59: * Creates an "empty" KeyIdentifier element with default encoding type
60: * and default value type.
61: */
62: public EncryptedKeySHA1Identifier(Document doc)
63: throws XWSSecurityException {
64: super (doc);
65: // Set default attributes
66: setAttribute("EncodingType", encodingType);
67: setAttribute("ValueType", valueType);
68: }
69:
70: public EncryptedKeySHA1Identifier(SOAPElement element)
71: throws XWSSecurityException {
72: super (element);
73: }
74:
75: public byte[] getDecodedBase64EncodedValue()
76: throws XWSSecurityException {
77: try {
78: return Base64.decode(getReferenceValue());
79: } catch (Base64DecodingException e) {
80: log.log(Level.SEVERE,
81: "WSS0144.unableto.decode.base64.data",
82: new Object[] { e.getMessage() });
83: throw new SecurityHeaderException(
84: "Unable to decode Base64 encoded data", e);
85: }
86: }
87: }
|