Transformpublic final class Transform extends SignatureElementProxy Implements the behaviour of the ds:Transform element.
This Transform (Factory) class role as the Factory and Proxy of
implemanting class that have the functionality of a Transform
algorithm.
Implements the Factory and Proxy pattern for ds:Transform algorithms. |
Fields Summary |
---|
static Logger | log{@link java.util.logging} logging facility | static boolean | _alreadyInitializedField _alreadyInitialized | static HashMap | _transformHashAll available Transform classes are registered here | protected TransformSpi | transformSpiField transformSpi |
Constructors Summary |
---|
public Transform(Document doc, String algorithmURI, NodeList contextNodes)Constructs {@link Transform}
super(doc);
try {
this._constructionElement.setAttributeNS(null, Constants._ATT_ALGORITHM,
algorithmURI);
Class implementingClass =
Transform.getImplementingClass(algorithmURI);
if(implementingClass == null) {
Object exArgs[] = { algorithmURI };
throw new InvalidTransformException(
"signature.Transform.UnknownTransform", exArgs);
}
if (true) {
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "Create URI \"" + algorithmURI + "\" class \""
+ implementingClass + "\"");
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "The NodeList is " + contextNodes);
}
// create the custom Transform object
this.transformSpi =
(TransformSpi) implementingClass.newInstance();
this.transformSpi.setTransform(this);
// give it to the current document
if (contextNodes != null) {
/*
while (contextNodes.getLength() > 0) {
this._constructionElement.appendChild(contextNodes.item(0));
}
*/
for (int i = 0; i < contextNodes.getLength(); i++) {
this._constructionElement.appendChild(contextNodes.item(i).cloneNode(true));
}
}
} catch (IllegalAccessException ex) {
Object exArgs[] = { algorithmURI };
throw new InvalidTransformException(
"signature.Transform.UnknownTransform", exArgs, ex);
} catch (InstantiationException ex) {
Object exArgs[] = { algorithmURI };
throw new InvalidTransformException(
"signature.Transform.UnknownTransform", exArgs, ex);
}
| public Transform(Element element, String BaseURI)This constructor can only be called from the {@link Transforms} object, so
it's protected.
super(element, BaseURI);
// retrieve Algorithm Attribute from ds:Transform
String AlgorithmURI = element.getAttributeNS(null, Constants._ATT_ALGORITHM);
if ((AlgorithmURI == null) || (AlgorithmURI.length() == 0)) {
Object exArgs[] = { Constants._ATT_ALGORITHM,
Constants._TAG_TRANSFORM };
throw new TransformationException("xml.WrongContent", exArgs);
}
try {
Class implementingClass = (Class) _transformHash.get(AlgorithmURI);
this.transformSpi =
(TransformSpi) implementingClass.newInstance();
this.transformSpi.setTransform(this);
} catch (IllegalAccessException e) {
Object exArgs[] = { AlgorithmURI };
throw new InvalidTransformException(
"signature.Transform.UnknownTransform", exArgs);
} catch (InstantiationException e) {
Object exArgs[] = { AlgorithmURI };
throw new InvalidTransformException(
"signature.Transform.UnknownTransform", exArgs);
} catch (NullPointerException e) {
Object exArgs[] = { AlgorithmURI };
throw new InvalidTransformException(
"signature.Transform.UnknownTransform", exArgs);
}
|
Methods Summary |
---|
public java.lang.String | getBaseLocalName()
return Constants._TAG_TRANSFORM;
| private static java.lang.Class | getImplementingClass(java.lang.String URI)Method getImplementingClass
return (Class)Transform._transformHash.get(URI);
| public static final com.sun.org.apache.xml.internal.security.transforms.Transform | getInstance(org.w3c.dom.Document doc, java.lang.String algorithmURI)Generates a Transform object that implements the specified Transform algorithm URI.
return Transform.getInstance(doc, algorithmURI, (NodeList) null);
| public static final com.sun.org.apache.xml.internal.security.transforms.Transform | getInstance(org.w3c.dom.Document doc, java.lang.String algorithmURI, org.w3c.dom.Element contextChild)Generates a Transform object that implements the specified Transform algorithm URI.
HelperNodeList contextNodes = new HelperNodeList();
contextNodes.appendChild(doc.createTextNode("\n"));
contextNodes.appendChild(contextChild);
contextNodes.appendChild(doc.createTextNode("\n"));
return Transform.getInstance(doc, algorithmURI, contextNodes);
| public static final com.sun.org.apache.xml.internal.security.transforms.Transform | getInstance(org.w3c.dom.Document doc, java.lang.String algorithmURI, org.w3c.dom.NodeList contextNodes)Generates a Transform object that implements the specified Transform algorithm URI.
return new Transform(doc, algorithmURI, contextNodes);
| public final java.lang.String | getURI()Returns the URI representation of Transformation algorithm
return this._constructionElement.getAttributeNS(null, Constants._ATT_ALGORITHM);
| public static void | init()Initalizes for this {@link Transform}
if (!_alreadyInitialized) {
_transformHash = new HashMap(10);
_alreadyInitialized = true;
}
| public com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput | performTransform(com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput input, java.io.OutputStream os)Transforms the input, and generats {@link XMLSignatureInput} as output.
XMLSignatureInput result = null;
try {
result = transformSpi.enginePerformTransform(input,os);
} catch (ParserConfigurationException ex) {
Object exArgs[] = { this.getURI(), "ParserConfigurationException" };
throw new CanonicalizationException(
"signature.Transform.ErrorDuringTransform", exArgs, ex);
} catch (SAXException ex) {
Object exArgs[] = { this.getURI(), "SAXException" };
throw new CanonicalizationException(
"signature.Transform.ErrorDuringTransform", exArgs, ex);
}
return result;
| public com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput | performTransform(com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput input)Transforms the input, and generats {@link XMLSignatureInput} as output.
XMLSignatureInput result = null;
try {
result = transformSpi.enginePerformTransform(input);
} catch (ParserConfigurationException ex) {
Object exArgs[] = { this.getURI(), "ParserConfigurationException" };
throw new CanonicalizationException(
"signature.Transform.ErrorDuringTransform", exArgs, ex);
} catch (SAXException ex) {
Object exArgs[] = { this.getURI(), "SAXException" };
throw new CanonicalizationException(
"signature.Transform.ErrorDuringTransform", exArgs, ex);
}
return result;
| public static void | register(java.lang.String algorithmURI, java.lang.String implementingClass)Registers implementing class of the Transform algorithm with algorithmURI
{
// are we already registered?
Class registeredClass = Transform.getImplementingClass(algorithmURI);
if ((registeredClass != null) ) {
Object exArgs[] = { algorithmURI, registeredClass };
throw new AlgorithmAlreadyRegisteredException(
"algorithm.alreadyRegistered", exArgs);
}
ClassLoader cl = (ClassLoader) AccessController.doPrivileged(
new PrivilegedAction() {
public Object run() {
return Thread.currentThread().getContextClassLoader();
}
});
try {
Transform._transformHash.put
(algorithmURI, Class.forName(implementingClass, true, cl));
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
|
|