@Override public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options) { this.subject = subject; this.callbackHandler = callbackHandler; succeeded = false; init(options); users = load(USER_FILE_PROP_NAME, "user", options).getProps(); groups = load(GROUP_FILE_PROP_NAME, "group", options).invertedPropertiesValuesMap(); }
/** * Performs initialization of file paths. A standard JAAS override. */ @Override public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options) { super.initialize(subject, callbackHandler, sharedState, options); usersByDn = load(USER_FILE_PROP_NAME, "", options).invertedPropertiesMap(); groupsByUser = load(GROUP_FILE_PROP_NAME, "", options).invertedPropertiesValuesMap(); }
/** * Overriding to allow for proper initialization. Standard JAAS. */ @Override public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options) { this.subject = subject; this.callbackHandler = callbackHandler; init(options); }
/** * 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 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; }
@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); } }
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 void load(final File source, Properties props) throws IOException { FileInputStream in = new FileInputStream(source); try { props.load(in); if (key.isDecrypt()) { try { EncryptionSupport.decrypt(this.props); } catch (NoClassDefFoundError e) { // this Happens whe jasypt is not on the classpath.. key.setDecrypt(false); LOG.info("jasypt is not on the classpath: password decryption disabled."); } } } finally { in.close(); } }
@Override public Set<Principal> getPrincipals() { Set<Principal> groups = new HashSet<Principal>(); groups.add(new GroupPrincipal(anonymousGroup)); return groups; } };
private String getLDAPPropertyValue (String propertyName){ for (int i=0; i < config.length; i++ ) if (config[i].getPropertyName() == propertyName) return config[i].getPropertyValue(); return null; }
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); }
@Override public boolean abort() throws LoginException { if (debug) { LOG.debug("abort"); } if (!succeeded) { return false; } else if (succeeded && commitSucceeded) { // we succeeded, but another required module failed logout(); } else { // our commit failed clear(); succeeded = false; } return true; }
/** * Standard JAAS override. */ @Override public boolean abort() throws LoginException { if (debug) { LOG.debug("abort"); } if (!succeeded) { return false; } else if (succeeded && commitSucceeded) { // we succeeded, but another required module failed logout(); } else { // our commit failed clear(); succeeded = false; } return true; }
public void init(Map options) { debug = booleanOption("debug", options); if (debug) { LOG.debug("Initialized debug"); } }
/** * Overriding handle method to handle certificates. * * @param callbacks The callbacks requested. * @throws IOException * @throws UnsupportedCallbackException Thrown if an unkown Callback type is * encountered. */ @Override public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { for (int i = 0; i < callbacks.length; i++) { Callback callback = callbacks[i]; if (callback instanceof CertificateCallback) { CertificateCallback certCallback = (CertificateCallback)callback; certCallback.setCertificates(certificates); } else { throw new UnsupportedCallbackException(callback); } } } }
@Override public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options) { this.subject = subject; this.handler = callbackHandler; config = new LDAPLoginProperty [] { new LDAPLoginProperty (INITIAL_CONTEXT_FACTORY, (String)options.get(INITIAL_CONTEXT_FACTORY)), new LDAPLoginProperty (CONNECTION_URL, (String)options.get(CONNECTION_URL)), new LDAPLoginProperty (CONNECTION_USERNAME, (String)options.get(CONNECTION_USERNAME)), new LDAPLoginProperty (CONNECTION_PASSWORD, (String)options.get(CONNECTION_PASSWORD)), new LDAPLoginProperty (CONNECTION_PROTOCOL, (String)options.get(CONNECTION_PROTOCOL)), new LDAPLoginProperty (AUTHENTICATION, (String)options.get(AUTHENTICATION)), new LDAPLoginProperty (USER_BASE, (String)options.get(USER_BASE)), new LDAPLoginProperty (USER_SEARCH_MATCHING, (String)options.get(USER_SEARCH_MATCHING)), new LDAPLoginProperty (USER_SEARCH_SUBTREE, (String)options.get(USER_SEARCH_SUBTREE)), new LDAPLoginProperty (ROLE_BASE, (String)options.get(ROLE_BASE)), new LDAPLoginProperty (ROLE_NAME, (String)options.get(ROLE_NAME)), new LDAPLoginProperty (ROLE_SEARCH_MATCHING, (String)options.get(ROLE_SEARCH_MATCHING)), new LDAPLoginProperty (ROLE_SEARCH_SUBTREE, (String)options.get(ROLE_SEARCH_SUBTREE)), new LDAPLoginProperty (USER_ROLE_NAME, (String)options.get(USER_ROLE_NAME)), new LDAPLoginProperty (EXPAND_ROLES, (String) options.get(EXPAND_ROLES)), new LDAPLoginProperty (EXPAND_ROLES_MATCHING, (String) options.get(EXPAND_ROLES_MATCHING)), }; }
@Override public boolean logout() throws LoginException { subject.getPrincipals().removeAll(principals); clear(); if (debug) { LOG.debug("logout"); } succeeded = false; commitSucceeded = false; return true; }
@Override public boolean abort() throws LoginException { if (!succeeded) { return false; } else if (succeeded && commitSucceeded) { // we succeeded, but another required module failed logout(); } else { // our commit failed user = null; groups.clear(); succeeded = false; } return true; }
@Override public boolean abort() throws LoginException { if (debug) { LOG.debug("abort"); } if (!succeeded) { return false; } else if (succeeded && commitSucceeded) { // we succeeded, but another required module failed logout(); } else { // our commit failed succeeded = false; } return true; }
private boolean isLoginPropertySet(String propertyName) { for (int i=0; i < config.length; i++ ) { if (config[i].getPropertyName() == propertyName && (config[i].getPropertyValue() != null && !"".equals(config[i].getPropertyValue()))) return true; } return false; }