use of java.security.ProviderException in project robovm by robovm.
the class ProviderExceptionTest method testProviderException06.
/**
* Test for <code>ProviderException(String, Throwable)</code> constructor
* Assertion: constructs ProviderException when <code>cause</code> is null
* <code>msg</code> is null
*/
public void testProviderException06() {
ProviderException tE = new ProviderException(null, null);
assertNull("getMessage() must return null", tE.getMessage());
assertNull("getCause() must return null", tE.getCause());
}
use of java.security.ProviderException in project robovm by robovm.
the class ProviderExceptionTest method testProviderException02.
/**
* Test for <code>ProviderException(String)</code> constructor Assertion:
* constructs ProviderException with detail message msg. Parameter
* <code>msg</code> is not null.
*/
public void testProviderException02() {
ProviderException tE;
for (int i = 0; i < msgs.length; i++) {
tE = new ProviderException(msgs[i]);
assertEquals("getMessage() must return: ".concat(msgs[i]), tE.getMessage(), msgs[i]);
assertNull("getCause() must return null", tE.getCause());
}
}
use of java.security.ProviderException in project robovm by robovm.
the class ProviderExceptionTest method testProviderException05.
/**
* Test for <code>ProviderException(Throwable)</code> constructor
* Assertion: constructs ProviderException when <code>cause</code> is not
* null
*/
public void testProviderException05() {
ProviderException tE = new ProviderException(tCause);
if (tE.getMessage() != null) {
String toS = tCause.toString();
String getM = tE.getMessage();
assertTrue("getMessage() should contain ".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.ProviderException in project robovm by robovm.
the class ProviderExceptionTest method testProviderException07.
/**
* Test for <code>ProviderException(String, Throwable)</code> constructor
* Assertion: constructs ProviderException when <code>cause</code> is null
* <code>msg</code> is not null
*/
public void testProviderException07() {
ProviderException tE;
for (int i = 0; i < msgs.length; i++) {
tE = new ProviderException(msgs[i], null);
assertEquals("getMessage() must return: ".concat(msgs[i]), tE.getMessage(), msgs[i]);
assertNull("getCause() must return null", tE.getCause());
}
}
use of java.security.ProviderException in project platform_frameworks_base by android.
the class AndroidKeyStoreHmacSpi method ensureKeystoreOperationInitialized.
private void ensureKeystoreOperationInitialized() throws InvalidKeyException {
if (mChunkedStreamer != null) {
return;
}
if (mKey == null) {
throw new IllegalStateException("Not initialized");
}
KeymasterArguments keymasterArgs = new KeymasterArguments();
keymasterArgs.addEnum(KeymasterDefs.KM_TAG_ALGORITHM, KeymasterDefs.KM_ALGORITHM_HMAC);
keymasterArgs.addEnum(KeymasterDefs.KM_TAG_DIGEST, mKeymasterDigest);
keymasterArgs.addUnsignedInt(KeymasterDefs.KM_TAG_MAC_LENGTH, mMacSizeBits);
OperationResult opResult = mKeyStore.begin(mKey.getAlias(), KeymasterDefs.KM_PURPOSE_SIGN, true, keymasterArgs, // no additional entropy needed for HMAC because it's deterministic
null, mKey.getUid());
if (opResult == null) {
throw new KeyStoreConnectException();
}
// Store operation token and handle regardless of the error code returned by KeyStore to
// ensure that the operation gets aborted immediately if the code below throws an exception.
mOperationToken = opResult.token;
mOperationHandle = opResult.operationHandle;
// If necessary, throw an exception due to KeyStore operation having failed.
InvalidKeyException e = KeyStoreCryptoOperationUtils.getInvalidKeyExceptionForInit(mKeyStore, mKey, opResult.resultCode);
if (e != null) {
throw e;
}
if (mOperationToken == null) {
throw new ProviderException("Keystore returned null operation token");
}
if (mOperationHandle == 0) {
throw new ProviderException("Keystore returned invalid operation handle");
}
mChunkedStreamer = new KeyStoreCryptoOperationChunkedStreamer(new KeyStoreCryptoOperationChunkedStreamer.MainDataStream(mKeyStore, mOperationToken));
}
Aggregations