/** {@inheritDoc} */ public void initialize( final Subject subject, final CallbackHandler callbackHandler, final Map<String, ?> sharedState, final Map<String, ?> options) { this.setLdapPrincipal = true; this.setLdapCredential = true; super.initialize(subject, callbackHandler, sharedState, options); final Iterator<String> i = options.keySet().iterator(); while (i.hasNext()) { final String key = i.next(); final String value = (String) options.get(key); if (key.equalsIgnoreCase("userRoleAttribute")) { if ("*".equals(value)) { this.userRoleAttribute = null; } else { this.userRoleAttribute = value.split(","); } } } if (this.logger.isDebugEnabled()) { this.logger.debug("userRoleAttribute = " + Arrays.toString(this.userRoleAttribute)); } this.auth = createAuthenticator(options); if (this.logger.isDebugEnabled()) { this.logger.debug("Created authenticator: " + this.auth.getAuthenticatorConfig()); } }
@Override public void initialize( final Subject subject, final CallbackHandler callbackHandler, final Map<String, ?> sharedState, final Map<String, ?> options) { setLdapPrincipal = true; setLdapCredential = true; super.initialize(subject, callbackHandler, sharedState, options); for (String key : options.keySet()) { final String value = (String) options.get(key); if ("userRoleAttribute".equalsIgnoreCase(key)) { if ("".equals(value)) { userRoleAttribute = ReturnAttributes.NONE.value(); } else if ("*".equals(value)) { userRoleAttribute = ReturnAttributes.ALL_USER.value(); } else { userRoleAttribute = value.split(","); } } else if ("authenticatorFactory".equalsIgnoreCase(key)) { try { authenticatorFactory = (AuthenticatorFactory) Class.forName(value).newInstance(); } catch (ClassNotFoundException | IllegalAccessException | InstantiationException e) { throw new IllegalArgumentException(e); } } } if (authenticatorFactory == null) { authenticatorFactory = new PropertiesAuthenticatorFactory(); } logger.trace( "authenticatorFactory = {}, userRoleAttribute = {}", authenticatorFactory, Arrays.toString(userRoleAttribute)); auth = authenticatorFactory.createAuthenticator(options); logger.debug("Retrieved authenticator from factory: {}", auth); authRequest = authenticatorFactory.createAuthenticationRequest(options); authRequest.setReturnAttributes(userRoleAttribute); logger.debug("Retrieved authentication request from factory: {}", authRequest); }
public void initialize( Subject subject, CallbackHandler callbackHandler, Map<String, ?> sharedState, Map<String, ?> options) { super.initialize(subject, callbackHandler, sharedState, options); // get the user credential query out of the options dbUserTable = (String) options.get("userTable"); dbUserTableUserField = (String) options.get("userField"); dbUserTableCredentialField = (String) options.get("credentialField"); userQuery = "select " + dbUserTableCredentialField + " from " + dbUserTable + " where " + dbUserTableUserField + "=?"; // get the user roles query out of the options dbUserRoleTable = (String) options.get("userRoleTable"); dbUserRoleTableUserField = (String) options.get("userRoleUserField"); dbUserRoleTableRoleField = (String) options.get("userRoleRoleField"); rolesQuery = "select " + dbUserRoleTableRoleField + " from " + dbUserRoleTable + " where " + dbUserRoleTableUserField + "=?"; if (LOG.isDebugEnabled()) LOG.debug("userQuery = " + userQuery); if (LOG.isDebugEnabled()) LOG.debug("rolesQuery = " + rolesQuery); }