Java Code Examples for javax.security.auth.callback.NameCallback#getDefaultName()

The following examples show how to use javax.security.auth.callback.NameCallback#getDefaultName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SaslNettyServer.java    From herddb with Apache License 2.0 5 votes vote down vote up
private void handleNameCallback(NameCallback nc) {
    // check to see if this user is in the user password database.
    if (credentials.get(nc.getDefaultName()) == null) {
        LOG.severe("User '" + nc.getDefaultName() + "' not found in list of JAAS DIGEST-MD5 users.");
        return;
    }
    nc.setName(nc.getDefaultName());
    userName = nc.getDefaultName();
}
 
Example 2
Source File: SaslNettyServer.java    From blazingcache with Apache License 2.0 5 votes vote down vote up
private void handleNameCallback(NameCallback nc) {
    // check to see if this user is in the user password database.
    if (credentials.get(nc.getDefaultName()) == null) {
        LOG.severe("User '" + nc.getDefaultName() + "' not found in list of JAAS DIGEST-MD5 users.");
        return;
    }
    nc.setName(nc.getDefaultName());
    userName = nc.getDefaultName();
}
 
Example 3
Source File: LocalCallbackHandlerService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * @see javax.security.auth.callback.CallbackHandler#handle(javax.security.auth.callback.Callback[])
 */
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
    for (Callback current : callbacks) {
        if (current instanceof NameCallback) {
            NameCallback ncb = (NameCallback) current;
            String userName = ncb.getDefaultName();
            if ((allowAll || allowedUsersSet.contains(userName)) == false) {
                SECURITY_LOGGER.tracef("Username '%s' is not permitted for local authentication.", userName);
                throw DomainManagementLogger.ROOT_LOGGER.invalidLocalUser(userName);
            }
        } else if (current instanceof AuthorizeCallback) {
            AuthorizeCallback acb = (AuthorizeCallback) current;
            boolean authorized = acb.getAuthenticationID().equals(acb.getAuthorizationID());
            if (authorized == false) {
                SECURITY_LOGGER.tracef(
                        "Checking 'AuthorizeCallback', authorized=false, authenticationID=%s, authorizationID=%s.",
                        acb.getAuthenticationID(), acb.getAuthorizationID());
            }
            acb.setAuthorized(authorized);

            if (authorized && skipGroupLoading) {
                sharedState.put(SKIP_GROUP_LOADING_KEY, Boolean.TRUE);
            }
        } else {
            throw new UnsupportedCallbackException(current);
        }
    }
}
 
Example 4
Source File: ServerCallbackHandler.java    From jstorm with Apache License 2.0 4 votes vote down vote up
private void handleNameCallback(NameCallback nc) {
    LOG.debug("handleNameCallback");
    userName = nc.getDefaultName();
    nc.setName(nc.getDefaultName());
}