Java Code Examples for org.apache.directory.shared.ldap.entry.ServerEntry#put()
The following examples show how to use
org.apache.directory.shared.ldap.entry.ServerEntry#put() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EmbeddedLdapServer.java From codenvy with Eclipse Public License 1.0 | 6 votes |
/** * Adds a new user which matches the default schema pattern, which is: * * <ul> * <li>objectClass=inetOrgPerson * <li>rdn - uid={id} * <li>cn={name} * <li>mail={mail} * <li>sn={@literal <none>} * <li>other.foreach(pair -> {pair.first}={pair.second}) * </ul> * * @return newly created and added entry instance * @throws Exception when any error occurs */ public ServerEntry addDefaultLdapUser(String id, String name, String mail, Pair... other) throws Exception { final ServerEntry entry = newEntry("uid", id); entry.put("objectClass", "inetOrgPerson"); entry.put("uid", id); entry.put("cn", name); entry.put("mail", mail); entry.put("sn", "<none>"); for (Pair pair : other) { if (pair.second instanceof byte[]) { entry.put(pair.first.toString(), (byte[]) pair.second); } else { entry.put(pair.first.toString(), pair.second.toString()); } } addEntry(entry); return entry; }
Example 2
Source File: ApacheDirectoryPartitionManager.java From carbon-identity with Apache License 2.0 | 5 votes |
private void addAdminPassword(ServerEntry adminEntry, String password, PasswordAlgorithm algorithm, final boolean kdcEnabled) throws DirectoryServerException { try { String passwordToStore = "{" + algorithm.getAlgorithmName() + "}"; if (algorithm != PasswordAlgorithm.PLAIN_TEXT && !kdcEnabled) { MessageDigest md = MessageDigest.getInstance(algorithm.getAlgorithmName()); md.update(password.getBytes()); byte[] bytes = md.digest(); String hash = Base64.encode(bytes); passwordToStore = passwordToStore + hash; } else { if (kdcEnabled) { logger.warn( "KDC enabled. Enforcing passwords to be plain text. Cause - KDC " + "cannot operate with hashed passwords."); } passwordToStore = password; } adminEntry.put("userPassword", passwordToStore.getBytes()); } catch (NoSuchAlgorithmException e) { throwDirectoryServerException("Could not find matching hash algorithm - " + algorithm.getAlgorithmName(), e); } }
Example 3
Source File: EmbeddedLdapServer.java From codenvy with Eclipse Public License 1.0 | 3 votes |
/** * Creates a new group which matches default schema pattern, which is: * * <ul> * <li>objectClass=groupOfNames * <li>rdn - ou={name} * <li>cn={name} * <li>members.foreach(m -> member={m}) * </ul> * * @param name a name of a group * @return newly created and added group entry * @throws Exception when any error occurs */ public ServerEntry addDefaultLdapGroup(String name, List<String> members) throws Exception { final ServerEntry group = newEntry("ou", name); group.put("objectClass", "top", "groupOfNames"); group.put("cn", name); group.put("ou", name); for (String member : members) { group.add("member", member); } addEntry(group); return group; }