use of java.security.SignatureException in project j2objc by google.
the class SignatureExceptionTest method testSignatureException03.
/**
* Test for <code>SignatureException(String)</code> constructor Assertion:
* constructs SignatureException when <code>msg</code> is null
*/
public void testSignatureException03() {
String msg = null;
SignatureException tE = new SignatureException(msg);
assertNull("getMessage() must return null.", tE.getMessage());
assertNull("getCause() must return null", tE.getCause());
}
use of java.security.SignatureException in project j2objc by google.
the class SignatureExceptionTest method testSignatureException02.
/**
* Test for <code>SignatureException(String)</code> constructor Assertion:
* constructs SignatureException with detail message msg. Parameter
* <code>msg</code> is not null.
*/
public void testSignatureException02() {
SignatureException tE;
for (int i = 0; i < msgs.length; i++) {
tE = new SignatureException(msgs[i]);
assertEquals("getMessage() must return: ".concat(msgs[i]), tE.getMessage(), msgs[i]);
assertNull("getCause() must return null", tE.getCause());
}
}
use of java.security.SignatureException in project j2objc by google.
the class SignatureExceptionTest method testSignatureException08.
/**
* Test for <code>SignatureException(String, Throwable)</code> constructor
* Assertion: constructs SignatureException when <code>cause</code> is not
* null <code>msg</code> is null
*/
public void testSignatureException08() {
SignatureException tE = new SignatureException(null, tCause);
if (tE.getMessage() != null) {
String toS = tCause.toString();
String getM = tE.getMessage();
assertTrue("getMessage() must should ".concat(toS), (getM.indexOf(toS) != -1));
}
assertNotNull("getCause() must not return null", tE.getCause());
assertEquals("getCause() must return ".concat(tCause.toString()), tE.getCause(), tCause);
}
use of java.security.SignatureException in project j2objc by google.
the class SignatureExceptionTest method testSignatureException06.
/**
* Test for <code>SignatureException(String, Throwable)</code> constructor
* Assertion: constructs SignatureException when <code>cause</code> is
* null <code>msg</code> is null
*/
public void testSignatureException06() {
SignatureException tE = new SignatureException(null, null);
assertNull("getMessage() must return null", tE.getMessage());
assertNull("getCause() must return null", tE.getCause());
}
use of java.security.SignatureException in project j2objc by google.
the class X509CRLImpl method verify.
/**
* Verifies that this CRL was signed using the
* private key that corresponds to the given public key,
* and that the signature verification was computed by
* the given provider.
*
* @param key the PublicKey used to carry out the verification.
* @param sigProvider the name of the signature provider.
*
* @exception NoSuchAlgorithmException on unsupported signature
* algorithms.
* @exception InvalidKeyException on incorrect key.
* @exception NoSuchProviderException on incorrect provider.
* @exception SignatureException on signature errors.
* @exception CRLException on encoding errors.
*/
public synchronized void verify(PublicKey key, String sigProvider) throws CRLException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException {
if (sigProvider == null) {
sigProvider = "";
}
if ((verifiedPublicKey != null) && verifiedPublicKey.equals(key)) {
// this public key. Make sure providers match, too.
if (sigProvider.equals(verifiedProvider)) {
return;
}
}
if (signedCRL == null) {
throw new CRLException("Uninitialized CRL");
}
Signature sigVerf = null;
if (sigProvider.length() == 0) {
sigVerf = Signature.getInstance(sigAlgId.getName());
} else {
sigVerf = Signature.getInstance(sigAlgId.getName(), sigProvider);
}
sigVerf.initVerify(key);
if (tbsCertList == null) {
throw new CRLException("Uninitialized CRL");
}
sigVerf.update(tbsCertList, 0, tbsCertList.length);
if (!sigVerf.verify(signature)) {
throw new SignatureException("Signature does not match.");
}
verifiedPublicKey = key;
verifiedProvider = sigProvider;
}
Aggregations