I'm trying to write my own ServerAuthModule
, to use a custom login system.
If I understood everything right, what happens is that the container calls the validateRequest method for every incoming request, and that my SAM will check for credentials, and tell the container the username and groups of the user (if the credentials are right) via the CallbackHandler.
public class MySAM implements ServerAuthModule {
@Override
public AuthStatus validateRequest(MessageInfo messageInfo, Subject clientSubject, Subject serviceSubject) throws AuthException {
// check user credentials
...
// set username and groups
CallerPrincipalCallback cpCallback = new CallerPrincipalCallback(clientSubject, username);
GroupPrincipalCallback gpCallback = new GroupPrincipalCallback(clientSubject, groups);
callbackHandler.handle(new Callback[]{cpCallback, gpCallback}
return AuthStatus.SUCCESS;
}
...
}
My problem now is, that when a user logs in, I don't know to which groups the user belongs. I can only check whether the user is in a given group. Is it somehow possible to give the container a method with which it can check whether a user is in a given group, instead of giving it an array with groups in the validateRequest
method?
boolean isInGroup(String username, String group) {
// ask backend system
}