Search in sources :

Example 1 with AuthenticationErrorRecord

use of dev.hawala.xns.level4.mailing.MailingCommon.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();
    }
}
Also used : AuthenticationErrorRecord(dev.hawala.xns.level4.chs.Clearinghouse3.AuthenticationErrorRecord) EndOfMessageException(dev.hawala.xns.level3.courier.iWireStream.EndOfMessageException) NoMoreWriteSpaceException(dev.hawala.xns.level3.courier.iWireStream.NoMoreWriteSpaceException) EndOfMessageException(dev.hawala.xns.level3.courier.iWireStream.EndOfMessageException)

Example 2 with AuthenticationErrorRecord

use of dev.hawala.xns.level4.mailing.MailingCommon.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;
}
Also used : ThreePartName(dev.hawala.xns.level4.common.AuthChsCommon.ThreePartName) AuthenticationErrorRecord(dev.hawala.xns.level4.mailing.MailingCommon.AuthenticationErrorRecord) EndOfMessageException(dev.hawala.xns.level3.courier.iWireStream.EndOfMessageException) NoMoreWriteSpaceException(dev.hawala.xns.level3.courier.iWireStream.NoMoreWriteSpaceException) EndOfMessageException(dev.hawala.xns.level3.courier.iWireStream.EndOfMessageException) IOException(java.io.IOException)

Example 3 with AuthenticationErrorRecord

use of dev.hawala.xns.level4.mailing.MailingCommon.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;
}
Also used : ThreePartName(dev.hawala.xns.level4.common.AuthChsCommon.ThreePartName) AuthenticationErrorRecord(dev.hawala.xns.level4.filing.FilingCommon.AuthenticationErrorRecord) EndOfMessageException(dev.hawala.xns.level3.courier.iWireStream.EndOfMessageException) EndOfMessageException(dev.hawala.xns.level3.courier.iWireStream.EndOfMessageException)

Aggregations

EndOfMessageException (dev.hawala.xns.level3.courier.iWireStream.EndOfMessageException)3 NoMoreWriteSpaceException (dev.hawala.xns.level3.courier.iWireStream.NoMoreWriteSpaceException)2 ThreePartName (dev.hawala.xns.level4.common.AuthChsCommon.ThreePartName)2 AuthenticationErrorRecord (dev.hawala.xns.level4.chs.Clearinghouse3.AuthenticationErrorRecord)1 AuthenticationErrorRecord (dev.hawala.xns.level4.filing.FilingCommon.AuthenticationErrorRecord)1 AuthenticationErrorRecord (dev.hawala.xns.level4.mailing.MailingCommon.AuthenticationErrorRecord)1 IOException (java.io.IOException)1