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);
}
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();
}
}
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;
}
Aggregations