|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.neuclear.xml.xmlsec.XMLSecTools
public final class XMLSecTools
Tools for dealing with XMLSig's.
Usage:
KeyPair kp = ..... // Get RSA Key Pair
Element someElement = ..... // Get Dom4j Element somehow
XMLSecTools.signElement("uri:helloworld",someElement,kp);
if (XMLSecTools.verifySignature(someElement,kp.getPublicKey())) // Do something
In addition there are handy methods for dealing with KeyInfo elements for generating Key's from xml.
| Field Summary | |
|---|---|
static org.dom4j.Namespace |
NS_DS
|
static java.lang.String |
XMLDSIG_NAMESPACE
|
| Method Summary | |
|---|---|
static org.dom4j.Element |
base64ToElement(java.lang.String localName,
byte[] bytes)
Method base64ToElement |
static org.dom4j.Element |
base64ToElement(java.lang.String localName,
java.lang.String data)
Method base64ToElement |
static org.dom4j.Element |
bigIntToElement(java.lang.String localName,
java.math.BigInteger big)
Method base64ToElement |
static byte[] |
canonicalize(Canonicalizer canon,
java.lang.Object node)
Canonicalizes an object based on the given Canonicalizer |
static byte[] |
canonicalize(java.lang.Object node)
This is canonicalizes a node and outputs it as a byte array |
static byte[] |
canonicalizeSubset(org.dom4j.Node node,
java.lang.String xpath)
Canonicalises a subset of the node based on the given xpath. |
static org.dom4j.Element |
createElementInSignatureSpace(java.lang.String elementName)
Used to create an Element within the XMLSignature Standard's namespace |
static org.dom4j.Element |
createKeyInfo(java.security.KeyStore ks,
java.lang.String s)
Creates a KeyInfo Element containing the public key of a key stored in the given keystore. |
static org.dom4j.Element |
createKeyInfo(java.security.PublicKey pub)
Creates a KeyInfo Element containing the XML Encoded KeyInfo of a given public key. |
static org.dom4j.QName |
createQName(java.lang.String name)
Used to create a QName within the XMLSignature Standard's namespace |
static org.dom4j.Text |
createTextWithBigInteger(java.math.BigInteger biginteger)
This method takes an (empty) Element and a BigInteger and adds the base64 encoded BigInteger to the Element. |
static byte[] |
decodeBase64Element(org.dom4j.Element element)
Method decodeBase64Element Takes the Text children of the Element and interprets
them as input for the Base64.decodeBase64Element() function. |
static java.math.BigInteger |
decodeBigIntegerFromElement(org.dom4j.Element element)
Method decodeBigIntegerFromElement |
static java.math.BigInteger |
decodeBigIntegerFromText(org.dom4j.Text text)
Method decodeBigIntegerFromText |
static org.dom4j.Element |
decodeElementBase64(java.lang.String b64)
Decodes a Base64 encoded xml element. |
static java.lang.String |
encodeElementBase64(org.dom4j.Element elem)
Creates a textual representation of an element and encodes the results as a base64. |
static java.lang.String |
encodeElementBase64(SignedElement elem)
Creates a textual representation of an element and encodes the results as a base64. |
static byte[] |
getElementBytes(org.dom4j.Node node)
This takes a node and outputs it as a byte array. |
static org.dom4j.Element |
getSignatureElement(org.dom4j.Element elem)
Attempts to find a Signature within an element |
static boolean |
isInXMLSigNS(org.dom4j.Element xmlSigElement)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String XMLDSIG_NAMESPACE
public static final org.dom4j.Namespace NS_DS
| Method Detail |
|---|
public static org.dom4j.Element createKeyInfo(java.security.KeyStore ks,
java.lang.String s)
throws java.security.KeyStoreException
ks - KeyStore to uses - Identifier of Key
java.security.KeyStoreExceptionpublic static org.dom4j.Element createKeyInfo(java.security.PublicKey pub)
pub - RSA PublicKey to encode
public static org.dom4j.QName createQName(java.lang.String name)
name -
public static org.dom4j.Element createElementInSignatureSpace(java.lang.String elementName)
elementName -
public static org.dom4j.Element getSignatureElement(org.dom4j.Element elem)
throws XMLSecurityException
elem - Element to search.
XMLSecurityExceptionpublic static boolean isInXMLSigNS(org.dom4j.Element xmlSigElement)
public static byte[] getElementBytes(org.dom4j.Node node)
node - Dom4J node to canonicalize
public static byte[] canonicalize(java.lang.Object node)
throws XMLSecurityException
node - Dom4J node to canonicalize
XMLSecurityException
public static byte[] canonicalize(Canonicalizer canon,
java.lang.Object node)
throws XMLSecurityException
canon - node -
XMLSecurityException
public static byte[] canonicalizeSubset(org.dom4j.Node node,
java.lang.String xpath)
node - xpath -
public static java.lang.String encodeElementBase64(org.dom4j.Element elem)
This is useful when passing xml as hidden html form fields.
elem - Element to Encode
public static java.lang.String encodeElementBase64(SignedElement elem)
throws XMLException
This is useful when passing xml as hidden html form fields.
elem - SignedElement to Encode
XMLException
public static org.dom4j.Element decodeElementBase64(java.lang.String b64)
throws XMLSecurityException,
org.neuclear.commons.crypto.CryptoException
b64 - the Encoded string
XMLSecurityException - is thrown if there is a problem parsing the string
org.neuclear.commons.crypto.CryptoException
public static java.math.BigInteger decodeBigIntegerFromElement(org.dom4j.Element element)
throws XMLSecurityException
element -
XMLSecurityException
public static java.math.BigInteger decodeBigIntegerFromText(org.dom4j.Text text)
throws org.neuclear.commons.crypto.CryptoException
text -
org.neuclear.commons.crypto.CryptoExceptionpublic static org.dom4j.Text createTextWithBigInteger(java.math.BigInteger biginteger)
biginteger -
public static byte[] decodeBase64Element(org.dom4j.Element element)
throws XMLSecurityException
Text children of the Element and interprets
them as input for the Base64.decodeBase64Element() function.
element -
XMLSecurityException
public static org.dom4j.Element base64ToElement(java.lang.String localName,
byte[] bytes)
localName - bytes -
public static org.dom4j.Element base64ToElement(java.lang.String localName,
java.lang.String data)
localName - data -
public static org.dom4j.Element bigIntToElement(java.lang.String localName,
java.math.BigInteger big)
localName - big -
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||