@Override public void initialize(Subject subject, CallbackHandler callbackHandler, Map<String, ?> sharedState, Map<String, ?> options) { this.subject = subject; this.callbackHandler = callbackHandler; loginSucceeded = false; init(options); users = load(USER_FILE_PROP_NAME, "user", options).getProps(); roles = load(ROLE_FILE_PROP_NAME, "role", options).invertedPropertiesValuesMap(); }
/** * Performs initialization of file paths. A standard JAAS override. */ @Override public void initialize(Subject subject, CallbackHandler callbackHandler, Map<String, ?> sharedState, Map<String, ?> options) { super.initialize(subject, callbackHandler, sharedState, options); usersByDn = load(USER_FILE_PROP_NAME, "", options).invertedPropertiesMap(); regexpByUser = load(USER_FILE_PROP_NAME, "", options).regexpPropertiesMap(); rolesByUser = load(ROLE_FILE_PROP_NAME, "", options).invertedPropertiesValuesMap(); }
private void clear() { username = null; userAuthenticated = false; closeContext(); }
private String getLDAPPropertyValue(String propertyName) { for (LDAPLoginProperty conf : config) if (conf.getPropertyName().equals(propertyName)) return conf.getPropertyValue(); return null; }
@Override public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { ((Krb5Callback) callbacks[0]).setPeerPrincipal(new UserPrincipal("A")); } }, null, null);
private void resolveRolesForDN(DirContext context, String dn, String username, List<String> roles) throws NamingException { addRoles(context, dn, username, roles); if (logger.isDebugEnabled()) { logger.debug("Roles " + roles + " for user " + username); } for (String role : roles) { groups.add(new RolePrincipal(role)); } }
public ReloadableProperties load(String nameProperty, String fallbackName, Map options) { ReloadableProperties result; FileNameKey key = new FileNameKey(nameProperty, fallbackName, options); key.setDebug(debug); synchronized (staticCache) { result = staticCache.get(key); if (result == null) { result = new ReloadableProperties(key); staticCache.put(key, result); } } return result.obtained(); }
private Subject doAuthenticate(HashMap<String, ?> options, JaasCallbackHandler callbackHandler) throws LoginException { Subject mySubject = new Subject(); loginModule.initialize(mySubject, callbackHandler, null, options); loginModule.login(); loginModule.commit(); return mySubject; } }
public FileNameKey(String nameProperty, String fallbackName, Map options) { this.file = new File(baseDir(options), stringOption(nameProperty, fallbackName, options)); absPath = file.getAbsolutePath(); reload = booleanOption("reload", options); decrypt = booleanOption("decrypt", options); }
public String getUserFromSubject(Subject subject) { String validatedUser = ""; Set<UserPrincipal> users = subject.getPrincipals(UserPrincipal.class); // should only ever be 1 UserPrincipal for (UserPrincipal userPrincipal : users) { validatedUser = userPrincipal.getName(); } return validatedUser; }
@Override public boolean abort() throws LoginException { clear(); return true; }
/** * Overriding to allow for proper initialization. Standard JAAS. */ @Override public void initialize(Subject subject, CallbackHandler callbackHandler, Map<String, ?> sharedState, Map<String, ?> options) { this.subject = subject; this.callbackHandler = callbackHandler; init(options); }
public void init(Map options) { debug = booleanOption("debug", options); if (debug) { logger.debug("Initialized debug"); } }
@Override public boolean abort() throws LoginException { clear(); logger.debug("abort"); return true; }
@Override public boolean abort() throws LoginException { clear(); logger.debug("abort"); return true; }
/** * Standard JAAS override. */ @Override public boolean abort() throws LoginException { clear(); if (debug) { logger.debug("abort"); } return true; }
@Override public boolean abort() throws LoginException { clear(); if (debug) { logger.debug("abort"); } return true; }
private boolean isLoginPropertySet(String propertyName) { for (LDAPLoginProperty conf : config) { if (conf.getPropertyName().equals(propertyName) && (conf.getPropertyValue() != null && !"".equals(conf.getPropertyValue()))) return true; } return false; }
@Override public boolean logout() throws LoginException { clear(); return true; }
private boolean presentInArray(LDAPLoginProperty[] ldapProps, String propertyName) { for (LDAPLoginProperty conf : ldapProps) { if (conf.getPropertyName().equals(propertyName) && (conf.getPropertyValue() != null && !"".equals(conf.getPropertyValue()))) return true; } return false; }