@Override public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options) { this.subject = subject; this.callbackHandler = callbackHandler; debug = "true".equalsIgnoreCase((String)options.get("debug")); credentialsInvalidate = "true".equalsIgnoreCase((String)options.get("credentialsInvalidate")); if (options.get(GUEST_USER) != null) { userName = (String)options.get(GUEST_USER); } if (options.get(GUEST_GROUP) != null) { groupName = (String)options.get(GUEST_GROUP); } principals.add(new UserPrincipal(userName)); principals.add(new GroupPrincipal(groupName)); if (debug) { LOG.debug("Initialized debug=" + debug + " guestUser=" + userName + " guestGroup=" + groupName); } }
@Override public boolean commit() throws LoginException { if (!succeeded) { clear(); if (debug) { LOG.debug("commit, result: false"); } return false; } principals.add(new UserPrincipal(user)); Set<String> matchedGroups = groups.get(user); if (matchedGroups != null) { for (String entry : matchedGroups) { principals.add(new GroupPrincipal(entry)); } } subject.getPrincipals().addAll(principals); if (debug) { LOG.debug("commit, result: true"); } commitSucceeded = true; return true; }
/** * Overriding to complete login process. Standard JAAS. */ @Override public boolean commit() throws LoginException { if (debug) { LOG.debug("commit"); } if (!succeeded) { clear(); return false; } principals.add(new UserPrincipal(username)); for (String group : getUserGroups(username)) { principals.add(new GroupPrincipal(group)); } subject.getPrincipals().addAll(principals); username = null; commitSucceeded = true; return true; }
@Override public boolean login() throws LoginException { Callback[] callbacks = new Callback[2]; callbacks[0] = new NameCallback("User name"); callbacks[1] = new PasswordCallback("Password", false); try { handler.handle(callbacks); } catch (IOException ioe) { throw (LoginException)new LoginException().initCause(ioe); } catch (UnsupportedCallbackException uce) { throw (LoginException)new LoginException().initCause(uce); } String password; String username = ((NameCallback)callbacks[0]).getName(); if (username == null) return false; if (((PasswordCallback)callbacks[1]).getPassword() != null) password = new String(((PasswordCallback)callbacks[1]).getPassword()); else password=""; // authenticate will throw LoginException // in case of failed authentication authenticate(username, password); user = new UserPrincipal(username); succeeded = true; return true; }
members.add(new UserPrincipal(principalName));
@Override public boolean commit() throws LoginException { Set<Principal> principals = subject.getPrincipals(); principals.add(new UserPrincipal(username)); for (GroupPrincipal gp : groups) { principals.add(gp); } return true; }
@Override public boolean commit() throws LoginException { Set<Principal> principals = subject.getPrincipals(); principals.add(new UserPrincipal(username)); for (GroupPrincipal gp : groups) { principals.add(gp); } return true; }
@Override public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options) { this.subject = subject; this.callbackHandler = callbackHandler; debug = "true".equalsIgnoreCase((String)options.get("debug")); credentialsInvalidate = "true".equalsIgnoreCase((String)options.get("credentialsInvalidate")); if (options.get(GUEST_USER) != null) { userName = (String)options.get(GUEST_USER); } if (options.get(GUEST_GROUP) != null) { groupName = (String)options.get(GUEST_GROUP); } principals.add(new UserPrincipal(userName)); principals.add(new GroupPrincipal(groupName)); if (debug) { LOG.debug("Initialized debug=" + debug + " guestUser=" + userName + " guestGroup=" + groupName); } }
@Override public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options) { this.subject = subject; this.callbackHandler = callbackHandler; debug = "true".equalsIgnoreCase((String)options.get("debug")); credentialsInvalidate = "true".equalsIgnoreCase((String)options.get("credentialsInvalidate")); if (options.get(GUEST_USER) != null) { userName = (String)options.get(GUEST_USER); } if (options.get(GUEST_GROUP) != null) { groupName = (String)options.get(GUEST_GROUP); } principals.add(new UserPrincipal(userName)); principals.add(new GroupPrincipal(groupName)); if (debug) { LOG.debug("Initialized debug=" + debug + " guestUser=" + userName + " guestGroup=" + groupName); } }
@Override public boolean commit() throws LoginException { boolean result = loginSucceeded; if (result) { principals.add(new UserPrincipal(user)); Set<String> matchedGroups = groups.get(user); if (matchedGroups != null) { for (String entry : matchedGroups) { principals.add(new GroupPrincipal(entry)); } } subject.getPrincipals().addAll(principals); } // will whack loginSucceeded clear(); if (debug) { LOG.debug("commit, result: " + result); } return result; }
@Override public boolean commit() throws LoginException { boolean result = loginSucceeded; if (result) { principals.add(new UserPrincipal(user)); Set<String> matchedGroups = groups.get(user); if (matchedGroups != null) { for (String entry : matchedGroups) { principals.add(new GroupPrincipal(entry)); } } subject.getPrincipals().addAll(principals); } // will whack loginSucceeded clear(); if (debug) { LOG.debug("commit, result: " + result); } return result; }
/** * Overriding to complete login process. Standard JAAS. */ @Override public boolean commit() throws LoginException { principals.add(new UserPrincipal(username)); for (String group : getUserGroups(username)) { principals.add(new GroupPrincipal(group)); } subject.getPrincipals().addAll(principals); clear(); if (debug) { LOG.debug("commit"); } return true; }
/** * Overriding to complete login process. Standard JAAS. */ @Override public boolean commit() throws LoginException { principals.add(new UserPrincipal(username)); for (String group : getUserGroups(username)) { principals.add(new GroupPrincipal(group)); } subject.getPrincipals().addAll(principals); clear(); if (debug) { LOG.debug("commit"); } return true; }
members.add(new UserPrincipal(principalName));
members.add(new UserPrincipal(principalName));
members.add(new UserPrincipal(principalName));