-
Notifications
You must be signed in to change notification settings - Fork 21
/
EncryptedKeySHA1Identifier.java
64 lines (52 loc) · 1.92 KB
/
EncryptedKeySHA1Identifier.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
* Copyright (c) 1997, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package com.sun.xml.wss.core.reference;
import com.sun.xml.wss.impl.MessageConstants;
import com.sun.xml.wss.XWSSecurityException;
import com.sun.xml.wss.impl.SecurityHeaderException;
import org.apache.xml.security.exceptions.Base64DecodingException;
import com.sun.xml.wss.impl.misc.Base64;
import jakarta.xml.soap.SOAPElement;
import org.w3c.dom.Document;
import java.util.logging.Level;
/**
*
* @author Ashutosh Shahi
*/
public class EncryptedKeySHA1Identifier extends KeyIdentifier{
/**Defaults*/
private String encodingType = MessageConstants.BASE64_ENCODING_NS;
private String valueType = MessageConstants.EncryptedKeyIdentifier_NS;
/**
* Creates an "empty" KeyIdentifier element with default encoding type
* and default value type.
*/
public EncryptedKeySHA1Identifier(Document doc) throws XWSSecurityException {
super(doc);
// Set default attributes
setAttribute("EncodingType", encodingType);
setAttribute("ValueType", valueType);
}
public EncryptedKeySHA1Identifier(SOAPElement element)
throws XWSSecurityException {
super(element);
}
public byte[] getDecodedBase64EncodedValue() throws XWSSecurityException {
try {
return Base64.decode(getReferenceValue());
} catch (Base64DecodingException e) {
log.log(Level.SEVERE, "WSS0144.unableto.decode.base64.data",
new Object[] {e.getMessage()});
throw new SecurityHeaderException(
"Unable to decode Base64 encoded data",
e);
}
}
}