@Override public void modifyAttributes(Name name, ModificationItem[] mods) throws NamingException { delegating.modifyAttributes(name, mods); }
@Override public void modifyAttributes(String name, int mod_op, Attributes attrs) throws NamingException { delegating.modifyAttributes(name, mod_op, attrs); }
@Override public void modifyAttributes(String name, ModificationItem[] mods) throws NamingException { delegating.modifyAttributes(name, mods); }
@Override public void modifyAttributes(Name name, int mod_op, Attributes attrs) throws NamingException { delegating.modifyAttributes(name, mod_op, attrs); }
@Override public void modifyAttributes(Name name, int mod_op, Attributes attrs) throws NamingException { Assert.checkNotNullParam("name", name); final ReparsedName reparsedName = reparse(name); ContextResult result = getProviderContext(reparsedName.getUrlScheme()); if(result.oldStyle) { ((DirContext)result.context).modifyAttributes(name, mod_op, attrs); } else { ((DirContext)result.context).modifyAttributes(reparsedName.getName(), mod_op, attrs); } }
@Override public void modifyAttributes(Name name, ModificationItem[] mods) throws NamingException { Assert.checkNotNullParam("name", name); final ReparsedName reparsedName = reparse(name); ContextResult result = getProviderContext(reparsedName.getUrlScheme()); if(result.oldStyle) { ((DirContext)result.context).modifyAttributes(name, mods); } else { ((DirContext)result.context).modifyAttributes(reparsedName.getName(), mods); } }
@Override public void modifyAttributes(String name, int mod_op, Attributes attrs) throws NamingException { Assert.checkNotNullParam("name", name); final ReparsedName reparsedName = reparse(getNameParser().parse(name)); ContextResult result = getProviderContext(reparsedName.getUrlScheme()); if(result.oldStyle) { ((DirContext)result.context).modifyAttributes(name, mod_op, attrs); } else { ((DirContext)result.context).modifyAttributes(reparsedName.getName(), mod_op, attrs); } }
@Override public void modifyAttributes(String name, ModificationItem[] mods) throws NamingException { Assert.checkNotNullParam("name", name); final ReparsedName reparsedName = reparse(getNameParser().parse(name)); ContextResult result = getProviderContext(reparsedName.getUrlScheme()); if(result.oldStyle) { ((DirContext)result.context).modifyAttributes(name, mods); } else { ((DirContext)result.context).modifyAttributes(reparsedName.getName(), mods); } }
@Override public void clearCredentials() throws RealmUnavailableException { try { Attributes attributes = new BasicAttributes(); attributes.put(new BasicAttribute(userPasswordAttributeName)); context.modifyAttributes(distinguishedName, DirContext.REMOVE_ATTRIBUTE, attributes); } catch (NoSuchAttributeException e) { // ignore if already clear } catch (NamingException e) { throw log.ldapRealmCredentialClearingFailed(distinguishedName, e); } } }
@Override public void persistCredential(final Credential credential) throws RealmUnavailableException { // TODO - We probably need some better resolution here of the existing attributes - i.e. different types we would want to add, same type we would want to replace. try { byte[] composedPassword = UserPasswordPasswordUtil.composeUserPassword(credential.castAndApply(PasswordCredential.class, PasswordCredential::getPassword)); Assert.assertNotNull(composedPassword); Attributes attributes = new BasicAttributes(); attributes.put(userPasswordAttributeName, composedPassword); context.modifyAttributes(distinguishedName, DirContext.REPLACE_ATTRIBUTE, attributes); } catch (NamingException | IOException e) { throw log.ldapRealmCredentialPersistingFailed(credential.toString(), distinguishedName, e); } }
public Object executeWithContext(DirContext ctx) throws NamingException { for (GrantedAuthority authority : authorities) { String group = convertAuthorityToGroup(authority); DistinguishedName fullDn = LdapUtils.getFullDn(userDn, ctx); ModificationItem addGroup = new ModificationItem(modType, new BasicAttribute(groupMemberAttributeName, fullDn.toUrl())); ctx.modifyAttributes(buildGroupDn(group), new ModificationItem[] { addGroup }); } return null; } });
@Override public void persistCredential(final Credential credential) throws RealmUnavailableException { OneTimePassword password = credential.castAndApply(PasswordCredential.class, c -> c.getPassword(OneTimePassword.class)); try { Attributes attributes = new BasicAttributes(); attributes.put(algorithmAttributeName, password.getAlgorithm()); attributes.put(hashAttributeName, ByteIterator.ofBytes(password.getHash()).base64Encode().drainToString()); attributes.put(seedAttributeName, password.getSeed()); attributes.put(sequenceAttributeName, Integer.toString(password.getSequenceNumber())); context.modifyAttributes(distinguishedName, DirContext.REPLACE_ATTRIBUTE, attributes); } catch (NamingException e) { throw log.ldapRealmCredentialPersistingFailed(credential.toString(), distinguishedName, e); } }
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); } }
@Override public void clearCredentials() throws RealmUnavailableException { try { Attributes attributes = new BasicAttributes(); attributes.put(new BasicAttribute(algorithmAttributeName)); attributes.put(new BasicAttribute(hashAttributeName)); attributes.put(new BasicAttribute(seedAttributeName)); attributes.put(new BasicAttribute(sequenceAttributeName)); context.modifyAttributes(distinguishedName, DirContext.REMOVE_ATTRIBUTE, attributes); } catch (NoSuchAttributeException e) { // ignore if already clear } catch (NamingException e) { throw log.ldapRealmCredentialClearingFailed(distinguishedName, e); } } }
identity.getDirContext().modifyAttributes(identityLdapName, modItemsArray);
public void modifyAttributes(String name, int mod_op, Attributes attrs) throws NamingException { try { ctx.modifyAttributes(name, mod_op, attrs); } catch (CommunicationException e) { reconnect(); ctx.modifyAttributes(name, mod_op, attrs); } } }
public void modifyAttributes(String name, ModificationItem... mods) throws NamingException { try { ctx.modifyAttributes(name, mods); } catch (CommunicationException e) { reconnect(); ctx.modifyAttributes(name, mods); } }
@Override public Object operation() throws NamingException { ((DirContext) getDelegate()).modifyAttributes(name, modOp, attrs); return null; } }.perform();
/** * @see DirContext#modifyAttributes(Name, int, Attributes) */ public void modifyAttributes(Name name, int modOp, Attributes attrs) throws NamingException { this.assertOpen(); this.getDelegateDirContext().modifyAttributes(name, modOp, attrs); }
public void removeUser(String username, String groupName) throws NamingException { try { ModificationItem[] mods = new ModificationItem[1]; Attribute mod = new BasicAttribute("member", getUserDN(username)); mods[0] = new ModificationItem(DirContext.REMOVE_ATTRIBUTE, mod); context.modifyAttributes(getGroupDN(groupName), mods); } catch (NoSuchAttributeException e) { // If user is not assigned, ignore the error } }