protected void rolesSearch(InitialLdapContext ctx, SearchControls constraints, String user, int recursionMax, int nesting, RoleGroup roleGroup) throws NamingException { rolesSearch(ctx, constraints, user, null, recursionMax, nesting, roleGroup); }
protected Properties loadRoles() throws IOException { return Util.loadProperties(rolesRsrcName); }
@Override public void init(Map<String, Object> options) { this.options = options; if (options != null) { try { roles = loadRoles(); } catch (IOException ioe) { throw new IllegalStateException(ioe); } } }
Principal principal = getCallerPrincipal(contextMap); ClassLoader currentTCCL = SecurityActions.getContextClassLoader(); try SecurityActions.setContextClassLoader(null); ctx = constructInitialLdapContext(bindDN, bindCredential); constraints.setReturningAttributes(new String[0]); constraints.setTimeLimit(searchTimeLimit); rolesSearch(ctx, constraints, principal.getName(), recursion, 0, mappedObject); SecurityActions.setContextClassLoader(currentTCCL);
ClassLoader loader = SecurityActions.getContextClassLoader(); URL url = null; url = SecurityActions.findResource(ucl, propertiesName); PicketBoxLogger.LOGGER.traceAttemptToLoadResource(propertiesName); try is = SecurityActions.openStream(url); safeClose(is);
String dn = canonicalize(sr.getName()); if (roleAttributeIsDN && parseRoleNameFromDN) parseRole(roleName, roleGroup); addRole(roleName, roleGroup); addRole(roleName, roleGroup); rolesSearch(ctx, constraints, user, dn, recursionMax, nesting + 1, roleGroup);
public void performMapping(Map<String, Object> contextMap, RoleGroup mappedObject) { if (contextMap == null || contextMap.isEmpty()) throw PicketBoxMessages.MESSAGES.invalidNullArgument("contextMap"); //Obtain the principal to roles mapping Principal principal = getCallerPrincipal(contextMap); if (principal != null) { String username = principal.getName(); Util.addRolesToGroup(username, mappedObject, roles); result.setMappedObject(mappedObject); } }
public void performMapping(Map<String, Object> contextMap, RoleGroup mappedObject) { if (contextMap == null || contextMap.isEmpty()) throw PicketBoxMessages.MESSAGES.invalidNullArgument("contextMap"); //Obtain the principal to roles mapping Principal principal = getCallerPrincipal(contextMap); if (principal != null && rolesQuery != null) { String username = principal.getName(); Util.addRolesToGroup(username, mappedObject, dsJndiName, rolesQuery, suspendResume, tm); result.setMappedObject(mappedObject); } }
private void parseRole(String dn, RoleGroup roleGroup) { StringTokenizer st = new StringTokenizer(dn, ","); while (st != null && st.hasMoreTokens()) { String keyVal = st.nextToken(); if (keyVal.indexOf(roleNameAttributeID) > -1) { StringTokenizer kst = new StringTokenizer(keyVal, "="); kst.nextToken(); addRole(kst.nextToken(), roleGroup); } } }
public Class<?> run() throws PrivilegedActionException { try { return getContextClassLoader().loadClass(name); } catch (Exception e) { throw new PrivilegedActionException(e); } } });
/** * Load roles from options map */ @Override protected Properties loadRoles() throws IOException { roles = new Properties(); for (Map.Entry<String, Object> entry : options.entrySet()) { String key = entry.getKey(); if (isValidEntry(key)) roles.put(key, entry.getValue()); } return roles; }
public void init(Map<String, Object> options) { if (options != null) { String option = (String) options.get("rolesProperties"); if (option != null) rolesRsrcName = StringPropertyReplacer.replaceProperties(option); // read properties file try { roles = loadRoles(); } catch (IOException ioe) { throw new IllegalStateException(ioe); } } }
public void init(Map<String, Object> options) { if (options != null) { dsJndiName = (String) options.get("dsJndiName"); if (dsJndiName == null) throw PicketBoxMessages.MESSAGES.invalidNullProperty("dsJndiName"); rolesQuery = (String) options.get("rolesQuery"); if (rolesQuery == null) throw PicketBoxMessages.MESSAGES.invalidNullProperty("rolesQuery"); String option = (String) options.get("suspendResume"); if (option != null) suspendResume = Boolean.valueOf(option.toString()).booleanValue(); // Get the Transaction Manager JNDI Name option = (String) options.get("transactionManagerJndiName"); if (option != null) TX_MGR_JNDI_NAME = option; try { if (suspendResume) tm = getTransactionManager(); } catch (NamingException e) { throw PicketBoxMessages.MESSAGES.failedToGetTransactionManager(e); } } }
if (credential != null) env.put(Context.SECURITY_CREDENTIALS, credential); this.traceLDAPEnv(env); return new InitialLdapContext(env, null);
/** * Create the set of roles the user belongs to by parsing the roles.properties * data for username=role1,role2,... * * @param username - name of user * @param roleGroup - group containing the user's roles * @param roles - the Properties containing the user=roles mappings * @return Group[] containing the sets of roles */ static void addRolesToGroup(String username, RoleGroup roleGroup, Properties roles) { String[] roleNames = null; if (roles.containsKey(username)) { String value = roles.getProperty(username); PicketBoxLogger.LOGGER.traceAdditionOfRoleToGroup(value, roleGroup.getRoleName()); roleNames = parseRoles(value); } if (roleNames != null) { for (int i = 0; i < roleNames.length; i++) { roleGroup.addRole(new SimpleRole(roleNames[i])); } } }