context = open(); principal = getPrincipal(context, username); close(context); context = open(); principal = getPrincipal(context, username); release(context); close(context);
/** * Create a new JNDI Realm. * * @param parent MBean Name of the associated parent component * * @exception Exception if an MBean cannot be created or registered */ public String createJNDIRealm(String parent) throws Exception { // Create a new JNDIRealm instance JNDIRealm realm = new JNDIRealm(); // Add the new instance to its parent component ObjectName pname = new ObjectName(parent); Container container = getParentContainerFromParent(pname); // Add the new instance to its parent component container.setRealm(realm); // Return the corresponding MBean name ObjectName oname = realm.getObjectName(); if (oname != null) { return (oname.toString()); } else { return null; } }
password = getAttributeValue(userPassword, attrs); roles = addAttributeValues(userRoleName, attrs, roles);
JNDIRealm realm = new JNDIRealm(); realm.setConnectionURL(connectionURL); realm.setConnectionName(connectionName); realm.setConnectionPassword(connectionPassword); ObjectName oname = realm.getObjectName();
context = open(); principal = authenticate(context, username, credentials); close(context); context = open(); principal = authenticate(context, username, credentials); release(context); close(context);
curUserPattern++) { User user = getUser(context, username); if (user != null) { try { if (checkCredentials(context, user, credentials)) { List roles = getRoles(context, user); return (new GenericPrincipal(this, username, } else { User user = getUser(context, username); if (user == null) return (null); if (!checkCredentials(context, user, credentials)) return (null); List roles = getRoles(context, user);
String filter = roleFormat.format(new String[] { doRFC2254Encoding(dn), username, userRoleId }); SearchControls controls = new SearchControls(); if (roleSubtree) try { if (roleSearchAsUser) { userCredentialsAdd(context, dn, user.getPassword()); userCredentialsRemove(context); if (attrs == null) continue; String dname = getDistinguishedName(context, roleBase, result); String name = getAttributeValue(roleName, attrs); if (name != null && dname != null) { groupMap.put(dname, name); if (getRoleNested()) { if (attrs == null) continue; String dname = getDistinguishedName(context, roleBase, result); String name = getAttributeValue(roleName, attrs); if (name != null && dname != null && !groupMap.keySet().contains(dname)) { groupMap.put(dname, name);
String dn = getDistinguishedName(context, userBase, result); password = getAttributeValue(userPassword, attrs); userRoleAttrValue = getAttributeValue(userRoleAttribute, attrs); roles = addAttributeValues(userRoleName, attrs, roles);
String filter = roleFormat.format(new String[] { doRFC2254Encoding(dn), username }); SearchControls controls = new SearchControls(); if (roleSubtree) if (attrs == null) continue; String dname = getDistinguishedName(context, roleBase, result); String name = getAttributeValue(roleName, attrs); if (name != null && dname != null) { groupMap.put(dname, name); if (getRoleNested()) { if (attrs == null) continue; String dname = getDistinguishedName(context, roleBase, result); String name = getAttributeValue(roleName, attrs); if (name != null && dname != null && !groupMap.keySet().contains(dname)) { groupMap.put(dname, name);
validated = bindAsUser(context, user, credentials); } else { validated = compareCredentials(context, user, credentials);
String filter = roleFormat.format(new String[] { doRFC2254Encoding(dn), username, userRoleId }); SearchControls controls = new SearchControls(); if (roleSubtree) NamingEnumeration<SearchResult> results = searchAsUser(context, user, base, filter, controls, isRoleSearchAsUser()); if (attrs == null) continue; String dname = getDistinguishedName(context, roleBase, result); String name = getAttributeValue(roleName, attrs); if (name != null && dname != null) { groupMap.put(dname, name); if (getRoleNested()) { results = searchAsUser(context, user, roleBase, filter, controls, isRoleSearchAsUser()); if (attrs == null) continue; String dname = getDistinguishedName(context, roleBase, result); String name = getAttributeValue(roleName, attrs); if (name != null && dname != null && !groupMap.keySet().contains(dname)) { groupMap.put(dname, name);
/** * Gracefully shut down active use of the public methods of this Component. * * @exception LifecycleException if this component detects a fatal error * that needs to be reported */ public void stop() throws LifecycleException { // Perform normal superclass finalization super.stop(); // Close any open directory server connection close(this.context); }
/** * Get the principal associated with the specified certificate. * @param username The user name * @return the Principal associated with the given certificate. */ @Override protected Principal getPrincipal(String username) { return getPrincipal(username, null); }
String filter = roleFormat.format(new String[] { doRFC2254Encoding(dn), username }); SearchControls controls = new SearchControls(); if (roleSubtree) if (attrs == null) continue; list = addAttributeValues(roleName, attrs, list);
/** * Create a new JNDI Realm. * * @param parent MBean Name of the associated parent component * @return the object name of the created realm * * @exception Exception if an MBean cannot be created or registered */ public String createJNDIRealm(String parent) throws Exception { // Create a new JNDIRealm instance JNDIRealm realm = new JNDIRealm(); // Add the new instance to its parent component return addRealmToParent(parent, realm); }
/** * Check whether the credentials presented by the user match those * retrieved from the directory. * * @param context The directory context * @param info The User to be authenticated * @param credentials Authentication credentials * * @exception NamingException if a directory server error occurs */ protected boolean compareCredentials(DirContext context, User info, String credentials) throws NamingException { // Validate the credentials specified by the user if (containerLog.isTraceEnabled()) containerLog.trace(" validating credentials"); if (info == null || credentials == null) return (false); String password = info.getPassword(); return compareCredentials(credentials, password); }
context = open(); principal = authenticate(context, username, credentials); close(context); context = open(); principal = authenticate(context, username, credentials); release(context); close(context);
curUserPattern++) { User user = getUser(context, username, credentials, curUserPattern); if (user != null) { try { if (checkCredentials(context, user, credentials)) { List<String> roles = getRoles(context, user); if (containerLog.isDebugEnabled()) { containerLog.debug("Found roles: " + roles.toString()); } else { User user = getUser(context, username, credentials); if (user == null) return null; if (!checkCredentials(context, user, credentials)) return null; List<String> roles = getRoles(context, user); if (containerLog.isDebugEnabled()) { containerLog.debug("Found roles: " + roles.toString());
String filter = roleFormat.format(new String[] { doRFC2254Encoding(dn), username }); SearchControls controls = new SearchControls(); if (roleSubtree) try { if (roleSearchAsUser) { userCredentialsAdd(context, dn, user.getPassword()); userCredentialsRemove(context); if (attrs == null) continue; String dname = getDistinguishedName(context, roleBase, result); String name = getAttributeValue(roleName, attrs); if (name != null && dname != null) { groupMap.put(dname, name); if (getRoleNested()) { if (attrs == null) continue; String dname = getDistinguishedName(context, roleBase, result); String name = getAttributeValue(roleName, attrs); if (name != null && dname != null && !groupMap.keySet().contains(dname)) { groupMap.put(dname, name);
String dn = getDistinguishedName(context, userBase, result); password = getAttributeValue(userPassword, attrs); userRoleAttrValue = getAttributeValue(userRoleAttribute, attrs); roles = addAttributeValues(userRoleName, attrs, roles);