01: /*
02: * $Id: BinaryExchangeImpl.java,v 1.1 2007/08/23 12:40:56 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.ws.security.trust.impl.wssx.elements;
28:
29: import com.sun.org.apache.xml.internal.security.exceptions.Base64DecodingException;
30: import com.sun.org.apache.xml.internal.security.utils.Base64;
31: import com.sun.xml.ws.security.trust.elements.BinaryExchange;
32: import com.sun.xml.ws.security.trust.impl.wssx.bindings.BinaryExchangeType;
33:
34: /**
35: *
36: * @author Manveen Kaur (manveen.kaur@sun.com).
37: */
38:
39: public class BinaryExchangeImpl extends BinaryExchangeType implements
40: BinaryExchange {
41:
42: public BinaryExchangeImpl(String encodingType, String valueType,
43: byte[] rawText) {
44: setEncodingType(encodingType);
45: setValueType(valueType);
46: setRawValue(rawText);
47: }
48:
49: public BinaryExchangeImpl(BinaryExchangeType bcType)
50: throws Exception {
51: setEncodingType(bcType.getEncodingType());
52: setValueType(bcType.getValueType());
53: setValue(bcType.getValue());
54: }
55:
56: public byte[] getRawValue() {
57: try {
58: return Base64.decode(getTextValue());
59: } catch (Base64DecodingException de) {
60: throw new RuntimeException("Error while decoding "
61: + de.getMessage());
62: }
63: }
64:
65: public String getTextValue() {
66: return super .getValue();
67: }
68:
69: public void setTextValue(String encodedText) {
70: super .setValue(encodedText);
71: }
72:
73: public void setRawValue(byte[] rawText) {
74: super.setValue(Base64.encode(rawText));
75: }
76:
77: }
|