本文整理汇总了Java中org.apache.xml.security.transforms.Transform类的典型用法代码示例。如果您正苦于以下问题:Java Transform类的具体用法?Java Transform怎么用?Java Transform使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Transform类属于org.apache.xml.security.transforms包,在下文中一共展示了Transform类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: enginePerformTransform
import org.apache.xml.security.transforms.Transform; //导入依赖的package包/类
/**
* @inheritDoc
*/
protected XMLSignatureInput enginePerformTransform(
XMLSignatureInput input, OutputStream os, Transform transformObject
) throws TransformationException {
/**
* If the actual input is an octet stream, then the application MUST
* convert the octet stream to an XPath node-set suitable for use by
* Canonical XML with Comments. (A subsequent application of the
* REQUIRED Canonical XML algorithm would strip away these comments.)
*
* ...
*
* The evaluation of this expression includes all of the document's nodes
* (including comments) in the node-set representing the octet stream.
*/
Node signatureElement = transformObject.getElement();
signatureElement = searchSignatureElement(signatureElement);
input.setExcludeNode(signatureElement);
input.addNodeFilter(new EnvelopedNodeFilter(signatureElement));
return input;
}
示例2: enginePerformTransform
import org.apache.xml.security.transforms.Transform; //导入依赖的package包/类
protected XMLSignatureInput enginePerformTransform(
XMLSignatureInput input, OutputStream os, Transform transformObject
) throws CanonicalizationException {
Canonicalizer20010315OmitComments c14n = new Canonicalizer20010315OmitComments();
c14n.setSecureValidation(secureValidation);
if (os != null) {
c14n.setWriter(os);
}
byte[] result = null;
result = c14n.engineCanonicalize(input);
XMLSignatureInput output = new XMLSignatureInput(result);
output.setSecureValidation(secureValidation);
if (os != null) {
output.setOutputStream(os);
}
return output;
}
示例3: enginePerformTransform
import org.apache.xml.security.transforms.Transform; //导入依赖的package包/类
protected XMLSignatureInput enginePerformTransform(
XMLSignatureInput input, OutputStream os, Transform transform
) throws CanonicalizationException {
Canonicalizer11_OmitComments c14n = new Canonicalizer11_OmitComments();
c14n.setSecureValidation(secureValidation);
if (os != null) {
c14n.setWriter(os);
}
byte[] result = null;
result = c14n.engineCanonicalize(input);
XMLSignatureInput output = new XMLSignatureInput(result);
output.setSecureValidation(secureValidation);
if (os != null) {
output.setOutputStream(os);
}
return output;
}
示例4: enginePerformTransform
import org.apache.xml.security.transforms.Transform; //导入依赖的package包/类
/** @inheritDoc */
protected XMLSignatureInput enginePerformTransform(
XMLSignatureInput input, OutputStream os, Transform transformObject
) throws CanonicalizationException {
Canonicalizer20010315WithComments c14n = new Canonicalizer20010315WithComments();
c14n.setSecureValidation(secureValidation);
if (os != null) {
c14n.setWriter(os);
}
byte[] result = null;
result = c14n.engineCanonicalize(input);
XMLSignatureInput output = new XMLSignatureInput(result);
output.setSecureValidation(secureValidation);
if (os != null) {
output.setOutputStream(os);
}
return output;
}
示例5: enginePerformTransform
import org.apache.xml.security.transforms.Transform; //导入依赖的package包/类
protected XMLSignatureInput enginePerformTransform(
XMLSignatureInput input, OutputStream os, Transform transform
) throws CanonicalizationException {
Canonicalizer11_WithComments c14n = new Canonicalizer11_WithComments();
c14n.setSecureValidation(secureValidation);
if (os != null) {
c14n.setWriter(os);
}
byte[] result = null;
result = c14n.engineCanonicalize(input);
XMLSignatureInput output = new XMLSignatureInput(result);
output.setSecureValidation(secureValidation);
if (os != null) {
output.setOutputStream(os);
}
return output;
}
示例6: createTransform
import org.apache.xml.security.transforms.Transform; //导入依赖的package包/类
/**
* Creates a Transform element for a given algorithm.
* @param algorithm algorithm
* @param parametersMarshallingProvider algorithm parameters marshaller
* @param document the target XML document
* @return the Transform
* @throws UnsupportedAlgorithmException if the algorithm is not supported
*/
public static Transform createTransform(Algorithm algorithm, AlgorithmsParametersMarshallingProvider parametersMarshallingProvider, Document document) throws UnsupportedAlgorithmException
{
List<Node> params = parametersMarshallingProvider.marshalParameters(algorithm, document);
try
{
if (null == params)
{
return new Transform(document, algorithm.getUri());
}
else
{
return new Transform(document, algorithm.getUri(), DOMHelper.nodeList(params));
}
}
catch (InvalidTransformException ex)
{
throw new UnsupportedAlgorithmException("C14N algorithm not supported in the XML Signature provider", algorithm.getUri(), ex);
}
}
示例7: addToDigestInput
import org.apache.xml.security.transforms.Transform; //导入依赖的package包/类
private void addToDigestInput(XMLSignatureInput refData, Document doc) throws CannotAddDataToDigestInputException
{
try
{
if (refData.isNodeSet() || refData.isElement())
{
Transform c14nTransform = TransformUtils.createTransform(this.c14n, this.parametersMarshallingProvider, doc);
refData = c14nTransform.performTransform(refData);
// Fall through to add the bytes resulting from the canonicalization.
}
if (refData.isByteArray())
{
digestInput.write(refData.getBytes());
} else if (refData.isOctetStream())
{
StreamUtils.readWrite(refData.getOctetStream(), digestInput);
}
}
catch (Exception ex)
{
throw new CannotAddDataToDigestInputException(ex);
}
}
示例8: staticInit
import org.apache.xml.security.transforms.Transform; //导入依赖的package包/类
private synchronized void
staticInit() {
if (!staticallyInitialized) {
org.apache.xml.security.Init.init();
if (addJceProviders) {
/*
* The last provider added has precedence, that is if JuiCE can be added
* then WSS4J uses this provider.
*/
addJceProvider("BC", "org.bouncycastle.jce.provider.BouncyCastleProvider");
addJceProvider("JuiCE", "org.apache.security.juice.provider.JuiCEProviderOpenSSL");
}
//Transform.init();
try {
Transform.register(
STRTransform.implementedTransformURI,
"org.apache.ws.security.transform.STRTransform"
);
} catch (Exception ex) {
if (log.isDebugEnabled()) {
log.debug(ex.getMessage(), ex);
}
}
staticallyInitialized = true;
}
}
示例9: processExclusiveTransform
import org.apache.xml.security.transforms.Transform; //导入依赖的package包/类
/**
* Populate the inclusive namspace prefixes on the specified Apache (exclusive) transform object.
*
* @param signature the Apache XMLSignature object
* @param transform the Apache Transform object representing an exclusive transform
*/
private void processExclusiveTransform(XMLSignature signature, Transform transform) {
// Namespaces that aren't visibly used, such as those used in QName attribute values, would
// be stripped out by exclusive canonicalization. Need to make sure they aren't by explicitly
// telling the transformer about them.
log.debug("Adding list of inclusive namespaces for signature exclusive canonicalization transform");
LazySet<String> inclusiveNamespacePrefixes = new LazySet<String>();
populateNamespacePrefixes(inclusiveNamespacePrefixes, signableObject);
if (inclusiveNamespacePrefixes != null && inclusiveNamespacePrefixes.size() > 0) {
InclusiveNamespaces inclusiveNamespaces = new InclusiveNamespaces(signature.getDocument(),
inclusiveNamespacePrefixes);
transform.getElement().appendChild(inclusiveNamespaces.getElement());
}
}
示例10: enginePerformTransform
import org.apache.xml.security.transforms.Transform; //导入依赖的package包/类
/**
* Method enginePerformTransform
*
* @param input
* @return {@link XMLSignatureInput} as the result of transformation
* @throws TransformationException
*/
protected XMLSignatureInput enginePerformTransform(
XMLSignatureInput input, OutputStream os, Transform transformObject
) throws TransformationException {
Object exArgs[] = { implementedTransformURI };
throw new TransformationException("signature.Transform.NotYetImplemented", exArgs);
}
示例11: enginePerformTransform
import org.apache.xml.security.transforms.Transform; //导入依赖的package包/类
protected XMLSignatureInput enginePerformTransform(
XMLSignatureInput input, OutputStream os, Transform transformObject
) throws CanonicalizationException {
try {
String inclusiveNamespaces = null;
if (transformObject.length(
InclusiveNamespaces.ExclusiveCanonicalizationNamespace,
InclusiveNamespaces._TAG_EC_INCLUSIVENAMESPACES) == 1
) {
Element inclusiveElement =
XMLUtils.selectNode(
transformObject.getElement().getFirstChild(),
InclusiveNamespaces.ExclusiveCanonicalizationNamespace,
InclusiveNamespaces._TAG_EC_INCLUSIVENAMESPACES,
0
);
inclusiveNamespaces =
new InclusiveNamespaces(
inclusiveElement, transformObject.getBaseURI()
).getInclusiveNamespaces();
}
Canonicalizer20010315ExclWithComments c14n =
new Canonicalizer20010315ExclWithComments();
c14n.setSecureValidation(secureValidation);
if (os != null) {
c14n.setWriter(os);
}
byte[] result = c14n.engineCanonicalize(input, inclusiveNamespaces);
XMLSignatureInput output = new XMLSignatureInput(result);
output.setSecureValidation(secureValidation);
return output;
} catch (XMLSecurityException ex) {
throw new CanonicalizationException(ex);
}
}
示例12: test1
import org.apache.xml.security.transforms.Transform; //导入依赖的package包/类
/**
* Make sure Transform.performTransform does not throw NullPointerException.
* See bug 41927 for more info.
*/
@org.junit.Test
public void test1() throws Exception {
File file1 = null;
File file2 = null;
if (BASEDIR != null && !"".equals(BASEDIR)) {
file1 = new File(BASEDIR + SEP + SOURCE_PATH, SIGNATURE_FILE);
file2 = new File(BASEDIR + SEP + SOURCE_PATH, STYLESHEET_FILE);
} else {
file1 = new File(SOURCE_PATH, SIGNATURE_FILE);
file1 = new File(SOURCE_PATH, STYLESHEET_FILE);
}
Document doc1 = getDocument(file1);
Document doc2 = getDocument(file2);
XPathFactory xpf = XPathFactory.newInstance();
XPath xpath = xpf.newXPath();
xpath.setNamespaceContext(new DSNamespaceContext());
String expression = "//ds:Transform[1]";
Element transformEl =
(Element) xpath.evaluate(expression, doc1, XPathConstants.NODE);
Transform transform =
new Transform(doc1, Transforms.TRANSFORM_XSLT, transformEl.getChildNodes());
transform.performTransform(new XMLSignatureInput(doc2));
}
示例13: transform
import org.apache.xml.security.transforms.Transform; //导入依赖的package包/类
public byte[] transform(final DSSDocument input) throws DSSException {
try {
final String dssTransformAlgorithm = dssTransform.getAlgorithm();
final NodeList childNodes = document.getFirstChild().getChildNodes();
final Transform transformObject = new Transform(document, dssTransformAlgorithm, childNodes);
final byte[] bytes = DSSUtils.toByteArray(input);
final XMLSignatureInput xmlSignatureInput = new XMLSignatureInput(bytes);
final XMLSignatureInput xmlSignatureInputOut = transformObject.performTransform(xmlSignatureInput);
return xmlSignatureInputOut.getBytes();
} catch (Exception e) {
throw new DSSException(e);
}
}
示例14: processExclusiveTransform
import org.apache.xml.security.transforms.Transform; //导入依赖的package包/类
/**
* Populate the inclusive namspace prefixes on the specified Apache (exclusive) transform object.
*
* @param signature the Apache XMLSignature object
* @param transform the Apache Transform object representing an exclusive transform
*/
private void processExclusiveTransform(XMLSignature signature, Transform transform) {
// Namespaces that aren't visibly used, such as those used in QName attribute values, would
// be stripped out by exclusive canonicalization. Need to make sure they aren't by explicitly
// telling the transformer about them.
log.debug("Adding list of inclusive namespaces for signature exclusive canonicalization transform");
HashSet<String> inclusiveNamespacePrefixes = new HashSet<String>();
populateNamespacePrefixes(inclusiveNamespacePrefixes, signableObject);
if (inclusiveNamespacePrefixes != null && inclusiveNamespacePrefixes.size() > 0) {
InclusiveNamespaces inclusiveNamespaces = new InclusiveNamespaces(signature.getDocument(),
inclusiveNamespacePrefixes);
transform.getElement().appendChild(inclusiveNamespaces.getElement());
}
}
示例15: enginePerformTransform
import org.apache.xml.security.transforms.Transform; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
protected XMLSignatureInput enginePerformTransform(
XMLSignatureInput input, OutputStream os, Transform _transformObject)
throws IOException,
CanonicalizationException, InvalidCanonicalizerException,
TransformationException, ParserConfigurationException,
SAXException {
return enginePerformTransform(input, _transformObject);
}