001: /*
002: * CanonicalizationMethod.java
003: *
004: * Created on January 24, 2006, 2:25 PM
005: */
006:
007: /*
008: * The contents of this file are subject to the terms
009: * of the Common Development and Distribution License
010: * (the License). You may not use this file except in
011: * compliance with the License.
012: *
013: * You can obtain a copy of the license at
014: * https://glassfish.dev.java.net/public/CDDLv1.0.html.
015: * See the License for the specific language governing
016: * permissions and limitations under the License.
017: *
018: * When distributing Covered Code, include this CDDL
019: * Header Notice in each file and include the License file
020: * at https://glassfish.dev.java.net/public/CDDLv1.0.html.
021: * If applicable, add the following below the CDDL Header,
022: * with the fields enclosed by brackets [] replaced by
023: * you own identifying information:
024: * "Portions Copyrighted [year] [name of copyright owner]"
025: *
026: * Copyright 2006 Sun Microsystems Inc. All Rights Reserved
027: */
028:
029: package com.sun.xml.ws.security.opt.crypto.dsig;
030:
031: import com.sun.xml.security.core.dsig.CanonicalizationMethodType;
032: import com.sun.xml.wss.logging.LogDomainConstants;
033: import java.io.OutputStream;
034: import java.security.InvalidAlgorithmParameterException;
035: import java.security.spec.AlgorithmParameterSpec;
036: import java.util.List;
037: import java.util.logging.Logger;
038: import javax.xml.bind.annotation.XmlRootElement;
039: import javax.xml.bind.annotation.XmlTransient;
040: import javax.xml.crypto.Data;
041: import javax.xml.crypto.XMLCryptoContext;
042: import javax.xml.crypto.dsig.TransformException;
043: import javax.xml.crypto.dsig.spec.TransformParameterSpec;
044: import com.sun.xml.wss.logging.impl.opt.signature.LogStringsMessages;
045: import java.util.logging.Level;
046:
047: /**
048: *
049: * @author Abhijit Das
050: * @author K.Venugopal@sun.com
051: */
052: @XmlRootElement(name="CanonicalizationMethod",namespace="http://www.w3.org/2000/09/xmldsig#")
053: public class CanonicalizationMethod extends CanonicalizationMethodType
054: implements javax.xml.crypto.dsig.CanonicalizationMethod {
055: @XmlTransient
056: private static final Logger logger = Logger.getLogger(
057: LogDomainConstants.IMPL_OPT_SIGNATURE_DOMAIN,
058: LogDomainConstants.IMPL_OPT_SIGNATURE_DOMAIN_BUNDLE);
059:
060: @XmlTransient
061: private Exc14nCanonicalizer _exc14nCanonicalizer = new Exc14nCanonicalizer();
062: @XmlTransient
063: private AlgorithmParameterSpec _algSpec = null;
064:
065: /** Creates a new instance of CanonicalizationMethod */
066: public CanonicalizationMethod() {
067: }
068:
069: public void setParameterSpec(AlgorithmParameterSpec algSpec) {
070: this ._algSpec = algSpec;
071: }
072:
073: public AlgorithmParameterSpec getParameterSpec() {
074: return _algSpec;
075: }
076:
077: public boolean isFeatureSupported(String string) {
078: //TODO:
079: return false;
080: }
081:
082: public Data transform(Data data, XMLCryptoContext xMLCryptoContext)
083: throws TransformException {
084: if (algorithm == CanonicalizationMethod.EXCLUSIVE) {
085: try {
086: _exc14nCanonicalizer
087: .init((TransformParameterSpec) _algSpec);
088: } catch (InvalidAlgorithmParameterException ex) {
089: logger.log(Level.SEVERE, LogStringsMessages
090: .WSS_1758_TRANSFORM_INIT(), ex);
091: throw new TransformException(ex);
092: }
093: _exc14nCanonicalizer.transform(data, xMLCryptoContext);
094: }
095: return null;
096:
097: }
098:
099: public Data transform(Data data, XMLCryptoContext xMLCryptoContext,
100: OutputStream outputStream) throws TransformException {
101: if (algorithm == CanonicalizationMethod.EXCLUSIVE) {
102: _exc14nCanonicalizer.transform(data, xMLCryptoContext,
103: outputStream);
104: }
105: return null;
106: }
107:
108: public void setContent(List content) {
109: this.content = content;
110: }
111: }
|