Search in sources :

Example 16 with ThreePartName

use of dev.hawala.xns.level4.common.AuthChsCommon.ThreePartName in project dodo by devhawala.

the class Clearinghouse3Impl method listAliasesOf.

/*
	 * ListAliasesOf: PROCEDURE [pattern: ObjectNamePattern, list: BulkData.Sink,
	 *    agent: Authenticator]
	 *  RETURNS [distinguishedObject: ObjectName]
	 *  REPORTS [ArgumentError, AuthenticationError, CallError, WrongServer] = 9;
	 */
private static void listAliasesOf(ListAliasesParams params, DistinguishedObjectResults results) {
    StringBuilder sb = new StringBuilder();
    String paramsString = params.append(sb, "", "params").toString();
    Log.C.printf("CHS3", "Clearinghouse3Impl.listAliasesOf(), %s \n", paramsString);
    // authentication
    checkCredentials("lookupObject", params.agent, true);
    // lookup the name(pattern) and raise an error if not found
    if (!chsDatabase.findDistinguishedName(params.pattern, results.distinguishedObject)) {
        Clearinghouse3.ArgumentErrorRecord err = new Clearinghouse3.ArgumentErrorRecord(Clearinghouse3.ArgumentProblem.noSuchObject, Clearinghouse3.WhichArgument.first);
        Log.C.printf("CHS3", "Clearinghouse3Impl.listAliasesOf() -> ArgumentErrorRecord[noSuchObject,first], reason: not found in CHS\n");
        err.raise();
    }
    // prepare the stream...
    // but unclear stream of what: Object(=STRING)?, ThreePartName? (seems to be (ThreePart-)Name)
    StreamOf<Name> streamData = new StreamOf<>(0, 1, 2, Name::make);
    List<String> aliases = chsDatabase.getAliasesOf(results.distinguishedObject);
    for (String alias : aliases) {
        Name a = streamData.add();
        a.object.set(alias);
        a.domain.set(chsDatabase.getDomainName());
        a.organization.set(chsDatabase.getOrganizationName());
    }
    // ... and send the bulk data
    sendBulkData("listAliasesOf", params.list, streamData);
    // done
    sb.setLength(0);
    String resultsString = results.append(sb, "", "results").toString();
    Log.C.printf("CHS3", "Clearinghouse3Impl.listAliasesOf(), %s \n", resultsString);
}
Also used : StreamOf(dev.hawala.xns.level3.courier.StreamOf) TwoPartName(dev.hawala.xns.level4.common.AuthChsCommon.TwoPartName) ObjectName(dev.hawala.xns.level4.common.AuthChsCommon.ObjectName) Name(dev.hawala.xns.level4.common.AuthChsCommon.Name) ThreePartName(dev.hawala.xns.level4.common.AuthChsCommon.ThreePartName)

Example 17 with ThreePartName

use of dev.hawala.xns.level4.common.AuthChsCommon.ThreePartName in project dodo by devhawala.

the class Clearinghouse3Impl method retrieveMembers.

/*
	 * RetrieveMembers: PROCEDURE [pattern: ObjectNamePattern, property: Property,
	 *     membership: BulkData.Sink, agent: Authenticator]
	 *  RETURNS [distinguishedObject: ObjectName]
	 *  REPORTS [ArgumentError, AuthenticationError, CallError, PropertyError,
	 *     WrongServer] = 18;
	 */
private static void retrieveMembers(RetrieveMembersParams params, DistinguishedObjectResults results) {
    Log.C.printf("CHS3", "Clearinghouse3Impl.retrieveMembers( pattern = '%s:%s:%s' , property = %d )\n", params.pattern.object.get(), params.pattern.domain.get(), params.pattern.organization.get(), params.property.get());
    // authentication
    checkCredentials("retrieveMembers", params.agent, true);
    // get the members and if available stream them back
    try {
        List<ThreePartName> members = chsDatabase.getEntryGroupMembers(params.pattern, (int) (params.property.get() & 0xFFFFFFFFL), results.distinguishedObject);
        if (members == null) {
            Log.C.printf("CHS3", "Clearinghouse3Impl.retrieveItem(): entry found, but wrong property type (group, not item)\n");
            new Clearinghouse3.PropertyErrorRecord(PropertyProblem.wrongType, results.distinguishedObject).raise();
        }
        StreamOf<ObjectName> membersStream = new StreamOf<>(0, 1, 2, ObjectName::make);
        for (ThreePartName member : members) {
            ThreePartName m = membersStream.add();
            m.object.set(member.object.get());
            m.domain.set(member.domain.get());
            m.organization.set(member.organization.get());
        }
        sendBulkData("retrieveMembers", params.membership, membersStream);
        Log.C.printf("CHS3", "Clearinghouse3Impl.retrieveMembers(): entry and group property found, %d members\n", members.size());
    } catch (IllegalArgumentException e) {
        Log.C.printf("CHS3", "Clearinghouse3Impl.retrieveMembers(): entry not found\n");
        new Clearinghouse3.ArgumentErrorRecord(ArgumentProblem.noSuchObject, WhichArgument.first).raise();
    }
}
Also used : ThreePartName(dev.hawala.xns.level4.common.AuthChsCommon.ThreePartName) StreamOf(dev.hawala.xns.level3.courier.StreamOf) ObjectName(dev.hawala.xns.level4.common.AuthChsCommon.ObjectName)

Example 18 with ThreePartName

use of dev.hawala.xns.level4.common.AuthChsCommon.ThreePartName 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

ThreePartName (dev.hawala.xns.level4.common.AuthChsCommon.ThreePartName)13 EndOfMessageException (dev.hawala.xns.level3.courier.iWireStream.EndOfMessageException)9 NoMoreWriteSpaceException (dev.hawala.xns.level3.courier.iWireStream.NoMoreWriteSpaceException)7 Name (dev.hawala.xns.level4.common.AuthChsCommon.Name)7 IOException (java.io.IOException)7 StrongVerifier (dev.hawala.xns.level4.common.AuthChsCommon.StrongVerifier)6 Credentials (dev.hawala.xns.level4.common.AuthChsCommon.Credentials)5 Verifier (dev.hawala.xns.level4.common.AuthChsCommon.Verifier)5 WireWriter (dev.hawala.xns.level3.courier.WireWriter)4 ChsDatabase (dev.hawala.xns.level4.common.ChsDatabase)4 ThreePartNameWithTagAndDateString (dev.hawala.xns.level4.mailing.MailTransport5.ThreePartNameWithTagAndDateString)3 NameList (dev.hawala.xns.level4.mailing.MailingCommon.NameList)3 StreamOf (dev.hawala.xns.level3.courier.StreamOf)2 CourierException (dev.hawala.xns.level3.courier.exception.CourierException)2 ObjectName (dev.hawala.xns.level4.common.AuthChsCommon.ObjectName)2 Attribute (dev.hawala.xns.level4.filing.FilingCommon.Attribute)2 Volume (dev.hawala.xns.level4.filing.fs.Volume)2 dev.hawala.xns.level4.filing.fs.iContentSource (dev.hawala.xns.level4.filing.fs.iContentSource)2 State (dev.hawala.xns.level4.mailing.Inbasket1.State)2 ServiceErrorRecord (dev.hawala.xns.level4.mailing.MailTransport4.ServiceErrorRecord)2