use of dev.hawala.xns.level4.chs.Clearinghouse3.AuthenticationErrorRecord in project dodo by devhawala.
the class Clearinghouse3Impl method checkCredentials.
/* internal functionality */
private static void checkCredentials(String procName, Authenticator agent, boolean allowEmptyCredentials) {
boolean credentialsOk = false;
try {
if (agent.credentials.value.size() == 0) {
credentialsOk = allowEmptyCredentials;
} else if (agent.credentials.type.get() == CredentialsType.simple) {
credentialsOk = AuthChsCommon.simpleCheckPasswordForSimpleCredentials(chsDatabase, agent.credentials, agent.verifier) != null;
} else {
credentialsOk = AuthChsCommon.checkStrongCredentials(chsDatabase, agent.credentials, agent.verifier, chsDatabase.getChsQueryName(), machineId, null, null) != null;
}
} catch (IllegalArgumentException iac) {
AuthenticationErrorRecord err = new AuthenticationErrorRecord(Problem.credentialsInvalid);
Log.C.printf("CHS3", "Clearinghouse3Impl.%s() IllegalArgumentException (name not existing) -> rejecting with AuthenticationError[credentialsInvalid]\n", procName);
err.raise();
} catch (EndOfMessageException e) {
AuthenticationErrorRecord err = new AuthenticationErrorRecord(Problem.inappropriateCredentials);
Log.C.printf("CHS3", "Clearinghouse3Impl.%s() EndOfMessageException when deserializing credsObject -> rejecting with AuthenticationError[inappropriateCredentials]\n", procName);
err.raise();
} catch (Exception e) {
AuthenticationErrorRecord err = new AuthenticationErrorRecord(Problem.otherProblem);
Log.C.printf("CHS3", "Clearinghouse3Impl.%s() Exception when checking credentials -> rejecting with AuthenticationError[otherProblem]: %s\n", procName, e.getMessage());
err.raise();
}
if (!credentialsOk) {
AuthenticationErrorRecord err = new AuthenticationErrorRecord(Problem.credentialsInvalid);
Log.C.printf("CHS3", "Clearinghouse3Impl.%s() -> rejecting with AuthenticationError[credentialsInvalid]\n", procName);
err.raise();
}
}
use of dev.hawala.xns.level4.chs.Clearinghouse3.AuthenticationErrorRecord in project dodo by devhawala.
the class MailService method checkCredentials.
/**
* Check the credentials for validity to this mail service and return
* the user name from the credentials, raising an {@code AuthenticationError}
* if the credentials are invalid.
*
* @param forRecipient recipient of the credentials
* @param credentials the credentials to check
* @param verifier the accompanying encoded verifier
* @param decodedConversationKey the extracted conversion key from the credentials
* @param decodedVerifier the decoded verifier
* @return the user name
*/
public ThreePartName checkCredentials(Name forRecipient, long forMachineId, Credentials credentials, Verifier verifier, int[] decodedConversationKey, StrongVerifier decodedVerifier) {
ThreePartName username = null;
try {
if (credentials.type.get() == CredentialsType.simple) {
if (credentials.value.size() == 0) {
// anonymous access resp. secondary credentials currently not supported
new AuthenticationErrorRecord(AuthenticationProblem.other).raise();
}
username = AuthChsCommon.simpleCheckPasswordForSimpleCredentials(this.chsDatabase, credentials, verifier);
} else {
username = AuthChsCommon.checkStrongCredentials(this.chsDatabase, credentials, verifier, forRecipient, forMachineId, decodedConversationKey, decodedVerifier);
}
} catch (IllegalArgumentException iac) {
AuthenticationErrorRecord err = new AuthenticationErrorRecord(AuthenticationProblem.badNamelnldentity);
Log.C.printf("MS", "checkCredentials() IllegalArgumentException (name not existing) -> rejecting with AuthenticationError[badNamelnldentity]\n");
err.raise();
} catch (EndOfMessageException e) {
AuthenticationErrorRecord err = new AuthenticationErrorRecord(AuthenticationProblem.badPwdlnldentity);
Log.C.printf("MS", "checkCredentials() EndOfMessageException when deserializing credsObject -> rejecting with AuthenticationError[badPwdlnldentity]\n");
err.raise();
} catch (Exception e) {
AuthenticationErrorRecord err = new AuthenticationErrorRecord(AuthenticationProblem.other);
Log.C.printf("MS", "checkCredentials() Exception when checking credentials -> rejecting with AuthenticationError[other]: %s\n", e.getMessage());
err.raise();
}
if (username == null) {
AuthenticationErrorRecord err = new AuthenticationErrorRecord(AuthenticationProblem.badNamelnldentity);
Log.C.printf("MS", "checkCredentials() -> rejecting with AuthenticationError[badNamelnldentity]\n");
err.raise();
}
return username;
}
use of dev.hawala.xns.level4.chs.Clearinghouse3.AuthenticationErrorRecord in project dodo by devhawala.
the class Service method checkCredentials.
private ThreePartName checkCredentials(Credentials credentials, Verifier verifier, int[] decodedConversationKey, StrongVerifier decodedVerifier) {
ThreePartName username = null;
try {
if (credentials.type.get() == CredentialsType.simple) {
if (credentials.value.size() == 0) {
// anonymous access resp. secondary credentials currently not supported
new AuthenticationErrorRecord(Problem.credentialsInvalid).raise();
}
username = AuthChsCommon.simpleCheckPasswordForSimpleCredentials(chsDatabase, credentials, verifier);
} else {
username = AuthChsCommon.checkStrongCredentials(chsDatabase, credentials, verifier, // chsDatabase.getChsQueryName(),
this.serviceName, machineId, decodedConversationKey, decodedVerifier);
}
} catch (IllegalArgumentException iac) {
AuthenticationErrorRecord err = new AuthenticationErrorRecord(Problem.credentialsInvalid);
Log.C.printf("FS", "checkCredentials() IllegalArgumentException (name not existing) -> rejecting with AuthenticationError[credentialsInvalid]\n");
err.raise();
} catch (EndOfMessageException e) {
AuthenticationErrorRecord err = new AuthenticationErrorRecord(Problem.inappropriateCredentials);
Log.C.printf("FS", "checkCredentials() EndOfMessageException when deserializing credsObject -> rejecting with AuthenticationError[inappropriateCredentials]\n");
err.raise();
} catch (Exception e) {
AuthenticationErrorRecord err = new AuthenticationErrorRecord(Problem.otherProblem);
Log.C.printf("FS", "checkCredentials() Exception when checking credentials -> rejecting with AuthenticationError[otherProblem]: %s\n", e.getMessage());
err.raise();
}
if (username == null) {
AuthenticationErrorRecord err = new AuthenticationErrorRecord(Problem.credentialsInvalid);
Log.C.printf("FS", "checkCredentials() -> rejecting with AuthenticationError[credentialsInvalid]\n");
err.raise();
}
return username;
}
Aggregations