Methods Summary |
---|
public void | engineAddContextToElement(org.w3c.dom.Element element)Method engineAddContextToElement
if (element == null) {
throw new IllegalArgumentException("null element");
}
if (this._HMACOutputLength != 0) {
Document doc = element.getOwnerDocument();
Element HMElem = XMLUtils.createElementInSignatureSpace(doc,
Constants._TAG_HMACOUTPUTLENGTH);
Text HMText =
doc.createTextNode(new Integer(this._HMACOutputLength).toString());
HMElem.appendChild(HMText);
XMLUtils.addReturnToElement(element);
element.appendChild(HMElem);
XMLUtils.addReturnToElement(element);
}
|
protected void | engineGetContextFromElement(org.w3c.dom.Element element)Method engineGetContextFromElement
super.engineGetContextFromElement(element);
if (element == null) {
throw new IllegalArgumentException("element null");
}
Text hmaclength =XMLUtils.selectDsNodeText(element.getFirstChild(),
Constants._TAG_HMACOUTPUTLENGTH,0);
if (hmaclength != null) {
this._HMACOutputLength = Integer.parseInt(hmaclength.getData());
}
|
protected java.lang.String | engineGetJCEAlgorithmString()Method engineGetJCEAlgorithmString
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "engineGetJCEAlgorithmString()");
return this._macAlgorithm.getAlgorithm();
|
protected java.lang.String | engineGetJCEProviderName()Method engineGetJCEAlgorithmString
return this._macAlgorithm.getProvider().getName();
|
public abstract java.lang.String | engineGetURI()Method engineGetURI
|
protected void | engineInitSign(java.security.Key secretKey, java.security.SecureRandom secureRandom)Method engineInitSign
throw new XMLSignatureException("algorithms.CannotUseSecureRandomOnMAC");
|
protected void | engineInitSign(java.security.Key secretKey)Method engineInitSign
if (!(secretKey instanceof SecretKey)) {
String supplied = secretKey.getClass().getName();
String needed = SecretKey.class.getName();
Object exArgs[] = { supplied, needed };
throw new XMLSignatureException("algorithms.WrongKeyForThisOperation",
exArgs);
}
try {
this._macAlgorithm.init(secretKey);
} catch (InvalidKeyException ex) {
throw new XMLSignatureException("empty", ex);
}
|
protected void | engineInitSign(java.security.Key secretKey, java.security.spec.AlgorithmParameterSpec algorithmParameterSpec)Method engineInitSign
if (!(secretKey instanceof SecretKey)) {
String supplied = secretKey.getClass().getName();
String needed = SecretKey.class.getName();
Object exArgs[] = { supplied, needed };
throw new XMLSignatureException("algorithms.WrongKeyForThisOperation",
exArgs);
}
try {
this._macAlgorithm.init(secretKey, algorithmParameterSpec);
} catch (InvalidKeyException ex) {
throw new XMLSignatureException("empty", ex);
} catch (InvalidAlgorithmParameterException ex) {
throw new XMLSignatureException("empty", ex);
}
|
protected void | engineInitVerify(java.security.Key secretKey)Proxy method for {@link java.security.Signature#initVerify(java.security.PublicKey)}
which is executed on the internal {@link java.security.Signature} object.
if (!(secretKey instanceof SecretKey)) {
String supplied = secretKey.getClass().getName();
String needed = SecretKey.class.getName();
Object exArgs[] = { supplied, needed };
throw new XMLSignatureException("algorithms.WrongKeyForThisOperation",
exArgs);
}
try {
this._macAlgorithm.init(secretKey);
} catch (InvalidKeyException ex) {
throw new XMLSignatureException("empty", ex);
}
|
protected void | engineSetHMACOutputLength(int HMACOutputLength)Method engineSetHMACOutputLength
this._HMACOutputLength = HMACOutputLength;
|
protected void | engineSetParameter(java.security.spec.AlgorithmParameterSpec params)Proxy method for {@link java.security.Signature#setParameter(java.security.spec.AlgorithmParameterSpec)}
which is executed on the internal {@link java.security.Signature} object.
throw new XMLSignatureException("empty");
|
protected byte[] | engineSign()Proxy method for {@link java.security.Signature#sign()}
which is executed on the internal {@link java.security.Signature} object.
try {
byte[] completeResult = this._macAlgorithm.doFinal();
if ((this._HMACOutputLength == 0) || (this._HMACOutputLength >= 160)) {
return completeResult;
}
return IntegrityHmac.reduceBitLength(completeResult,
this._HMACOutputLength);
} catch (IllegalStateException ex) {
throw new XMLSignatureException("empty", ex);
}
|
protected void | engineUpdate(byte[] input)Proxy method for {@link java.security.Signature#update(byte[])}
which is executed on the internal {@link java.security.Signature} object.
try {
this._macAlgorithm.update(input);
} catch (IllegalStateException ex) {
throw new XMLSignatureException("empty", ex);
}
|
protected void | engineUpdate(byte input)Proxy method for {@link java.security.Signature#update(byte)}
which is executed on the internal {@link java.security.Signature} object.
try {
this._macAlgorithm.update(input);
} catch (IllegalStateException ex) {
throw new XMLSignatureException("empty", ex);
}
|
protected void | engineUpdate(byte[] buf, int offset, int len)Proxy method for {@link java.security.Signature#update(byte[], int, int)}
which is executed on the internal {@link java.security.Signature} object.
try {
this._macAlgorithm.update(buf, offset, len);
} catch (IllegalStateException ex) {
throw new XMLSignatureException("empty", ex);
}
|
protected boolean | engineVerify(byte[] signature)Proxy method for {@link java.security.Signature#verify(byte[])}
which is executed on the internal {@link java.security.Signature} object.
try {
byte[] completeResult = this._macAlgorithm.doFinal();
if ((this._HMACOutputLength == 0) || (this._HMACOutputLength >= 160)) {
return MessageDigestAlgorithm.isEqual(completeResult, signature);
}
byte[] stripped = IntegrityHmac.reduceBitLength(completeResult,
this._HMACOutputLength);
return MessageDigestAlgorithm.isEqual(stripped, signature);
} catch (IllegalStateException ex) {
throw new XMLSignatureException("empty", ex);
}
|
private static byte[] | reduceBitLength(byte[] completeResult, int length)Method reduceBitLength
int bytes = length / 8;
int abits = length % 8;
byte[] strippedResult = new byte[bytes + ((abits == 0)
? 0
: 1)];
System.arraycopy(completeResult, 0, strippedResult, 0, bytes);
if (abits > 0) {
byte[] MASK = { (byte) 0x00, (byte) 0x80, (byte) 0xC0, (byte) 0xE0,
(byte) 0xF0, (byte) 0xF8, (byte) 0xFC, (byte) 0xFE };
strippedResult[bytes] = (byte) (completeResult[bytes] & MASK[abits]);
}
return strippedResult;
|