use of java.security.KeyException in project robovm by robovm.
the class KeyExceptionTest method testKeyException05.
/**
* Test for <code>KeyException(Throwable)</code> constructor Assertion:
* constructs KeyException when <code>cause</code> is not null
*/
public void testKeyException05() {
KeyException tE = new KeyException(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.KeyException in project robovm by robovm.
the class KeyExceptionTest method testKeyException04.
/**
* Test for <code>KeyException(Throwable)</code> constructor Assertion:
* constructs KeyException when <code>cause</code> is null
*/
public void testKeyException04() {
Throwable cause = null;
KeyException tE = new KeyException(cause);
assertNull("getMessage() must return null.", tE.getMessage());
assertNull("getCause() must return null", tE.getCause());
}
use of java.security.KeyException in project cxf by apache.
the class RequestParser method parseKeyInfoElement.
/**
* Parse the KeyInfo Element to return a ReceivedKey object containing the found certificate or
* public key.
*/
private static ReceivedKey parseKeyInfoElement(Element keyInfoElement) throws STSException {
KeyInfoFactory keyInfoFactory = null;
try {
keyInfoFactory = KeyInfoFactory.getInstance("DOM", "ApacheXMLDSig");
} catch (NoSuchProviderException ex) {
keyInfoFactory = KeyInfoFactory.getInstance("DOM");
}
try {
KeyInfo keyInfo = keyInfoFactory.unmarshalKeyInfo(new DOMStructure(keyInfoElement));
List<?> list = keyInfo.getContent();
for (int i = 0; i < list.size(); i++) {
if (list.get(i) instanceof KeyValue) {
KeyValue keyValue = (KeyValue) list.get(i);
ReceivedKey receivedKey = new ReceivedKey();
receivedKey.setPublicKey(keyValue.getPublicKey());
return receivedKey;
} else if (list.get(i) instanceof X509Certificate) {
ReceivedKey receivedKey = new ReceivedKey();
receivedKey.setX509Cert((X509Certificate) list.get(i));
return receivedKey;
} else if (list.get(i) instanceof X509Data) {
X509Data x509Data = (X509Data) list.get(i);
for (int j = 0; j < x509Data.getContent().size(); j++) {
if (x509Data.getContent().get(j) instanceof X509Certificate) {
ReceivedKey receivedKey = new ReceivedKey();
receivedKey.setX509Cert((X509Certificate) x509Data.getContent().get(j));
return receivedKey;
}
}
}
}
} catch (MarshalException e) {
LOG.log(Level.WARNING, "", e);
throw new STSException(e.getMessage(), e, STSException.INVALID_REQUEST);
} catch (KeyException e) {
LOG.log(Level.WARNING, "", e);
throw new STSException(e.getMessage(), e, STSException.INVALID_REQUEST);
}
return null;
}
use of java.security.KeyException in project TinyKeePass by sorz.
the class BaseActivity method getKey.
private void getKey() {
int authMethod = preferences.getInt(PREF_KEY_AUTH_METHOD, AUTH_METHOD_UNDEFINED);
switch(authMethod) {
case AUTH_METHOD_UNDEFINED:
onKeyAuthFailed.accept(getString(R.string.broken_keys));
break;
case AUTH_METHOD_NONE:
case AUTH_METHOD_SCREEN_LOCK:
try {
Cipher cipher = secureStringStorage.getDecryptCipher();
decryptKey(cipher);
} catch (UserNotAuthenticatedException e) {
// should do authentication
Intent intent = keyguardManager.createConfirmDeviceCredentialIntent(getString(R.string.auth_key_title), getString(R.string.auth_key_description));
startActivityForResult(intent, REQUEST_CONFIRM_DEVICE_CREDENTIAL);
} catch (KeyException e) {
onKeyException(e);
} catch (SecureStringStorage.SystemException e) {
throw new RuntimeException(e);
}
break;
case DatabaseSetupActivity.AUTH_METHOD_FINGERPRINT:
getFragmentManager().beginTransaction().add(FingerprintDialogFragment.newInstance(Cipher.DECRYPT_MODE), "fingerprint").commit();
break;
}
}
use of java.security.KeyException in project scheduling by ow2-proactive.
the class SchedulerAuthenticationGUIHelper method login.
/**
* This method will log a client to the scheduler by requesting his URL, username and password from a
* graphical interface.
*
* @param schedulerURL The default URL of the scheduler to connect
* @return The connection to the scheduler as a {@link Scheduler} if logging successful.
* If the username is empty or if the user cancel the authentication, this method will return null.
* @throws LoginException If a problem occurs while logging the user.
* @throws SchedulerException If a problem occurs at scheduler level.
*/
public static Scheduler login(String schedulerURL) throws LoginException, SchedulerException {
AuthResultContainer auth = connect(schedulerURL);
if (auth == null) {
return null;
} else {
SchedulerAuthenticationInterface schedAuth = auth.getAuth();
Credentials cred = null;
try {
cred = Credentials.createCredentials(new CredData(CredData.parseLogin(auth.getUsername()), CredData.parseDomain(auth.getUsername()), auth.getPassword()), schedAuth.getPublicKey());
} catch (LoginException e) {
throw new LoginException("Could not retrieve public key from Scheduler " + schedulerURL + ", contact the administrator" + e);
} catch (KeyException e) {
throw new LoginException("Could not encrypt credentials " + e);
}
return schedAuth.login(cred);
}
}
Aggregations