public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
for (Callback callback : callbacks) {
// jaspi to server communication
if (callback instanceof CallerPrincipalCallback) {
CallerPrincipalCallback callerPrincipalCallback = (CallerPrincipalCallback) callback;
if (callerPrincipalCallback.getPrincipal() != null) {
Principal callerPrincipal = callerPrincipalCallback.getPrincipal();
callerPrincipalCallback.getSubject().getPrincipals().add(callerPrincipal);
callerPrincipalCallback.getSubject().getPrincipals().add(new WrappingCallerPrincipal(callerPrincipal));
} else if (callerPrincipalCallback.getName() != null) {
Principal callerPrincipal = new GeronimoUserPrincipal(callerPrincipalCallback.getName());
callerPrincipalCallback.getSubject().getPrincipals().add(callerPrincipal);
callerPrincipalCallback.getSubject().getPrincipals().add(new WrappingCallerPrincipal(callerPrincipal));
}
} else if (callback instanceof GroupPrincipalCallback) {
GroupPrincipalCallback groupPrincipalCallback = ( GroupPrincipalCallback ) callback;
if (groupPrincipalCallback.getGroups() != null) {
Set<Principal> principalSet = groupPrincipalCallback.getSubject().getPrincipals();