@Override public void create() throws RealmUnavailableException { if (identityMapping.newIdentityParent == null || identityMapping.newIdentityAttributes == null) { throw log.ldapRealmNotConfiguredToSupportCreatingIdentities(); } DirContext context = obtainContext(); try { LdapName distinguishName = (LdapName) identityMapping.newIdentityParent.clone(); distinguishName.add(new Rdn(identityMapping.rdnIdentifier, name)); log.debugf("Creating identity [%s] with DN [%s] in LDAP", name, distinguishName.toString()); context.createSubcontext(distinguishName, identityMapping.newIdentityAttributes); } catch (NamingException e) { throw log.ldapRealmFailedCreateIdentityOnServer(e); } finally { closeContext(context); } }
private void storeAttributes(String alias, List<ModificationItem> items) throws KeyStoreException { DirContext context = obtainDirContext(); try { SearchResult result = searchAlias(context, alias, null, new String[]{}); LdapName distinguishName; if (result == null) { // alias not exists yet - create if (createPath == null || createAttributes == null || createRdn == null) throw log.creationNotConfigured(alias); distinguishName = (LdapName) createPath.clone(); distinguishName.add(new Rdn(createRdn, alias)); log.debugf("Creating keystore alias [%s] with DN [%s] in LDAP", alias, distinguishName.toString()); context.createSubcontext(distinguishName, createAttributes); items.add(new ModificationItem(DirContext.REPLACE_ATTRIBUTE, new BasicAttribute(aliasAttribute, alias))); } else { distinguishName = new LdapName(result.getNameInNamespace()); } context.modifyAttributes(distinguishName, items.toArray(new ModificationItem[items.size()])); } catch (NamingException e) { throw log.ldapKeyStoreFailedToStore(alias, e); } finally { returnDirContext(context); } }
newLdapName.add(new Rdn(identityMapping.rdnIdentifier, renameTo)); identity.getDirContext().rename(identityLdapName, newLdapName);
/** * Extract rdn value from username * @param dn distinguished name or username * @return username */ private String extractRdnValue(String dn) throws IOException { if (userName.startsWith("uid=") && userName.contains(",")) { try { return (String) new Rdn(dn.substring(0, dn.indexOf(','))).getValue(); } catch (InvalidNameException e) { throw new IOException(e); } } else { return dn; } }
/** * Add a Rdn to the built LdapName. * @param key the rdn attribute key. * @param value the rdn value. * * @return this builder. */ public LdapNameBuilder add(String key, Object value) { Assert.hasText(key, "key must not be blank"); Assert.notNull(key, "value must not be null"); try { ldapName.add(new Rdn(key, value)); return this; } catch (InvalidNameException e) { throw new org.springframework.ldap.InvalidNameException(e); } }
/** * Add a Rdn to the built LdapName. * @param key the rdn attribute key. * @param value the rdn value. * * @return this builder. */ public LdapNameBuilder add(String key, Object value) { Assert.hasText(key, "key must not be blank"); Assert.notNull(key, "value must not be null"); try { ldapName.add(new Rdn(key, value)); return this; } catch (InvalidNameException e) { throw new org.springframework.ldap.InvalidNameException(e); } }
public void createLdapNameById(LdapName name, Object id) throws InvalidNameException { Rdn rdn = new Rdn(idProperty.getDbColumn(), id); name.add(rdn); }
public void createLdapNameById(LdapName name, Object id) throws InvalidNameException { Rdn rdn = new Rdn(idProperty.getDbColumn(), id); name.add(rdn); }
public void createLdapNameById(LdapName name, Object id) throws InvalidNameException { if (id instanceof Map<?,?> == false){ throw new RuntimeException("Expecting a Map for concatinated key"); } Map<?,?> mapId = (Map<?,?>)id; for (int i = 0; i < props.length; i++) { Object v = mapId.get(props[i].getName()); if (v == null){ throw new RuntimeException("No value in Map for key "+props[i].getName()); } Rdn rdn = new Rdn(props[i].getDbColumn(), v); name.add(rdn); } }
public void createLdapNameById(LdapName name, Object id) throws InvalidNameException { if (id instanceof Map<?,?> == false){ throw new RuntimeException("Expecting a Map for concatinated key"); } Map<?,?> mapId = (Map<?,?>)id; for (int i = 0; i < props.length; i++) { Object v = mapId.get(props[i].getName()); if (v == null){ throw new RuntimeException("No value in Map for key "+props[i].getName()); } Rdn rdn = new Rdn(props[i].getDbColumn(), v); name.add(rdn); } }
public void createLdapNameById(LdapName name, Object id) throws InvalidNameException { for (int i = 0; i < props.length; i++) { Object v = props[i].getValue(id); Rdn rdn = new Rdn(props[i].getDbColumn(), v); name.add(rdn); } }
public void createLdapNameByBean(LdapName name, Object bean) throws InvalidNameException { for (int i = 0; i < props.length; i++) { Object v = props[i].getValue(bean); Rdn rdn = new Rdn(props[i].getDbColumn(), v); name.add(rdn); } }
public void createLdapNameById(LdapName name, Object id) throws InvalidNameException { for (int i = 0; i < props.length; i++) { Object v = props[i].getValue(id); Rdn rdn = new Rdn(props[i].getDbColumn(), v); name.add(rdn); } }
public void createLdapNameByBean(LdapName name, Object bean) throws InvalidNameException { for (int i = 0; i < props.length; i++) { Object v = props[i].getValue(bean); Rdn rdn = new Rdn(props[i].getDbColumn(), v); name.add(rdn); } }
public Name getTemporaryName(Name originalName) { LdapName temporaryName = LdapUtils.newLdapName(originalName); // Add tempSuffix to the leaf node name. try { String leafNode = (String) temporaryName.remove(temporaryName.size() - 1); temporaryName.add(new Rdn(leafNode + tempSuffix)); } catch (InvalidNameException e) { throw new org.springframework.ldap.InvalidNameException(e); } return temporaryName; }
public Name getTemporaryName(Name originalName) { LdapName temporaryName = LdapUtils.newLdapName(originalName); // Add tempSuffix to the leaf node name. try { String leafNode = (String) temporaryName.remove(temporaryName.size() - 1); temporaryName.add(new Rdn(leafNode + tempSuffix)); } catch (InvalidNameException e) { throw new org.springframework.ldap.InvalidNameException(e); } return temporaryName; }
public Name getTemporaryName(Name originalName) { LdapName temporaryName = LdapUtils.newLdapName(originalName); // Add tempSuffix to the leaf node name. try { String leafNode = (String) temporaryName.remove(temporaryName.size() - 1); temporaryName.add(new Rdn(leafNode + tempSuffix)); } catch (InvalidNameException e) { throw new org.springframework.ldap.InvalidNameException(e); } return temporaryName; }
public Name getTemporaryName(Name originalName) { LdapName temporaryName = LdapUtils.newLdapName(originalName); // Add tempSuffix to the leaf node name. try { String leafNode = (String) temporaryName.remove(temporaryName.size() - 1); temporaryName.add(new Rdn(leafNode + tempSuffix)); } catch (InvalidNameException e) { throw new org.springframework.ldap.InvalidNameException(e); } return temporaryName; }
@Override public void create() throws RealmUnavailableException { if (identityMapping.newIdentityParent == null || identityMapping.newIdentityAttributes == null) { throw log.ldapRealmNotConfiguredToSupportCreatingIdentities(); } DirContext context = obtainContext(); try { LdapName distinguishName = (LdapName) identityMapping.newIdentityParent.clone(); distinguishName.add(new Rdn(identityMapping.rdnIdentifier, name)); log.debugf("Creating identity [%s] with DN [%s] in LDAP", name, distinguishName.toString()); context.createSubcontext(distinguishName, identityMapping.newIdentityAttributes); } catch (NamingException e) { throw log.ldapRealmFailedCreateIdentityOnServer(e); } finally { closeContext(context); } }
@Override public void create() throws RealmUnavailableException { if (identityMapping.newIdentityParent == null || identityMapping.newIdentityAttributes == null) { throw log.ldapRealmNotConfiguredToSupportCreatingIdentities(); } DirContext context = obtainContext(); try { LdapName distinguishName = (LdapName) identityMapping.newIdentityParent.clone(); distinguishName.add(new Rdn(identityMapping.rdnIdentifier, name)); log.debugf("Creating identity [%s] with DN [%s] in LDAP", name, distinguishName.toString()); context.createSubcontext(distinguishName, identityMapping.newIdentityAttributes); } catch (NamingException e) { throw log.ldapRealmFailedCreateIdentityOnServer(e); } finally { closeContext(context); } }