use of org.apache.xml.security.signature.XMLSignatureInput in project santuario-java by apache.
the class XMLSignatureInputTest method testOctetStreamIsOctetStream.
@org.junit.Test
public void testOctetStreamIsOctetStream() throws IOException {
try (InputStream inputStream = new ByteArrayInputStream(_octetStreamTextInput.getBytes())) {
XMLSignatureInput input = new XMLSignatureInput(inputStream);
assertTrue("Input is octet stream", input.isOctetStream());
}
}
use of org.apache.xml.security.signature.XMLSignatureInput in project santuario-java by apache.
the class XMLSignatureInputTest method testIsInitializedWithOctetStream.
@org.junit.Test
public void testIsInitializedWithOctetStream() throws IOException {
try (InputStream inputStream = new ByteArrayInputStream(_octetStreamTextInput.getBytes())) {
XMLSignatureInput input = new XMLSignatureInput(inputStream);
assertTrue("Input is initialized", input.isInitialized());
}
}
use of org.apache.xml.security.signature.XMLSignatureInput in project santuario-java by apache.
the class ResolverLocalFilesystem method engineResolveURI.
/**
* {@inheritDoc}
*/
@Override
public XMLSignatureInput engineResolveURI(ResourceResolverContext context) throws ResourceResolverException {
try {
// calculate new URI
URI uriNew = getNewURI(context.uriToResolve, context.baseUri);
String fileName = ResolverLocalFilesystem.translateUriToFilename(uriNew.toString());
InputStream inputStream = Files.newInputStream(Paths.get(fileName));
XMLSignatureInput result = new XMLSignatureInput(inputStream);
result.setSecureValidation(context.secureValidation);
result.setSourceURI(uriNew.toString());
return result;
} catch (Exception e) {
throw new ResourceResolverException(e, context.uriToResolve, context.baseUri, "generic.EmptyMessage");
}
}
use of org.apache.xml.security.signature.XMLSignatureInput in project santuario-java by apache.
the class ResolverXPointer method engineResolveURI.
/**
* {@inheritDoc}
*/
@Override
public XMLSignatureInput engineResolveURI(ResourceResolverContext context) throws ResourceResolverException {
Node resultNode = null;
Document doc = context.attr.getOwnerElement().getOwnerDocument();
if (isXPointerSlash(context.uriToResolve)) {
resultNode = doc;
} else if (isXPointerId(context.uriToResolve)) {
String id = getXPointerId(context.uriToResolve);
resultNode = doc.getElementById(id);
if (context.secureValidation) {
Element start = context.attr.getOwnerDocument().getDocumentElement();
if (!XMLUtils.protectAgainstWrappingAttack(start, id)) {
Object[] exArgs = { id };
throw new ResourceResolverException("signature.Verification.MultipleIDs", exArgs, context.uriToResolve, context.baseUri);
}
}
if (resultNode == null) {
Object[] exArgs = { id };
throw new ResourceResolverException("signature.Verification.MissingID", exArgs, context.uriToResolve, context.baseUri);
}
}
XMLSignatureInput result = new XMLSignatureInput(resultNode);
result.setSecureValidation(context.secureValidation);
result.setMIMEType("text/xml");
if (context.baseUri != null && context.baseUri.length() > 0) {
result.setSourceURI(context.baseUri.concat(context.uriToResolve));
} else {
result.setSourceURI(context.uriToResolve);
}
return result;
}
use of org.apache.xml.security.signature.XMLSignatureInput in project xades4j by luisgoncalves.
the class TimeStampDigestInputImpl method addReference.
@Override
public void addReference(Reference r) throws CannotAddDataToDigestInputException {
if (null == r) {
throw new NullPointerException();
}
try {
XMLSignatureInput refData = r.getContentsAfterTransformation();
addToDigestInput(refData, r.getDocument());
} catch (XMLSignatureException ex) {
throw new CannotAddDataToDigestInputException(ex);
}
}
Aggregations