J. Duke | 319a3b9 | 2007-12-01 00:00:00 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * reserved comment block |
| 3 | * DO NOT REMOVE OR ALTER! |
| 4 | */ |
| 5 | |
| 6 | /* |
| 7 | * Copyright 1999-2004 The Apache Software Foundation. |
| 8 | * |
| 9 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 10 | * you may not use this file except in compliance with the License. |
| 11 | * You may obtain a copy of the License at |
| 12 | * |
| 13 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 14 | * |
| 15 | * Unless required by applicable law or agreed to in writing, software |
| 16 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 18 | * See the License for the specific language governing permissions and |
| 19 | * limitations under the License. |
| 20 | * |
| 21 | */ |
| 22 | package com.sun.org.apache.xml.internal.security.transforms; |
| 23 | |
| 24 | |
| 25 | |
| 26 | import java.io.IOException; |
| 27 | import java.io.OutputStream; |
| 28 | |
| 29 | import javax.xml.parsers.ParserConfigurationException; |
| 30 | |
| 31 | import com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException; |
| 32 | import com.sun.org.apache.xml.internal.security.c14n.InvalidCanonicalizerException; |
| 33 | import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput; |
| 34 | import org.xml.sax.SAXException; |
| 35 | |
| 36 | |
| 37 | /** |
| 38 | * Base class which all Transform algorithms extend. The common methods that |
| 39 | * have to be overridden are the {@link #enginePerformTransform(XMLSignatureInput)} method. |
| 40 | * |
| 41 | * @author Christian Geuer-Pollmann |
| 42 | */ |
| 43 | public abstract class TransformSpi { |
| 44 | |
| 45 | /** {@link java.util.logging} logging facility */ |
| 46 | static java.util.logging.Logger log = |
| 47 | java.util.logging.Logger.getLogger(TransformSpi.class.getName()); |
| 48 | |
| 49 | protected Transform _transformObject = null; |
| 50 | protected void setTransform(Transform transform) { |
| 51 | this._transformObject = transform; |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * The mega method which MUST be implemented by the Transformation Algorithm. |
| 56 | * |
| 57 | * @param input {@link XMLSignatureInput} as the input of transformation |
| 58 | * @param os where to output this transformation. |
| 59 | * @return {@link XMLSignatureInput} as the result of transformation |
| 60 | * @throws CanonicalizationException |
| 61 | * @throws IOException |
| 62 | * @throws InvalidCanonicalizerException |
| 63 | * @throws ParserConfigurationException |
| 64 | * @throws SAXException |
| 65 | * @throws TransformationException |
| 66 | */ |
| 67 | protected XMLSignatureInput enginePerformTransform( |
| 68 | XMLSignatureInput input, OutputStream os) |
| 69 | throws IOException, |
| 70 | CanonicalizationException, InvalidCanonicalizerException, |
| 71 | TransformationException, ParserConfigurationException, |
| 72 | SAXException { |
| 73 | return enginePerformTransform(input); |
| 74 | } |
| 75 | /** |
| 76 | * The mega method which MUST be implemented by the Transformation Algorithm. |
| 77 | * |
| 78 | * @param input {@link XMLSignatureInput} as the input of transformation |
| 79 | * @return {@link XMLSignatureInput} as the result of transformation |
| 80 | * @throws CanonicalizationException |
| 81 | * @throws IOException |
| 82 | * @throws InvalidCanonicalizerException |
| 83 | * @throws ParserConfigurationException |
| 84 | * @throws SAXException |
| 85 | * @throws TransformationException |
| 86 | */ |
| 87 | protected abstract XMLSignatureInput enginePerformTransform( |
| 88 | XMLSignatureInput input) |
| 89 | throws IOException, |
| 90 | CanonicalizationException, InvalidCanonicalizerException, |
| 91 | TransformationException, ParserConfigurationException, |
| 92 | SAXException; |
| 93 | |
| 94 | /** |
| 95 | * Returns the URI representation of <code>Transformation algorithm</code> |
| 96 | * |
| 97 | * @return the URI representation of <code>Transformation algorithm</code> |
| 98 | */ |
| 99 | protected abstract String engineGetURI(); |
| 100 | } |