Package org.springframework.ldap.core

Examples of org.springframework.ldap.core.DirContextAdapter


                            if (base.length() > 0) {
                                dn.append(",");
                                dn.append(base);
                            }

                            results.add(new DirContextAdapter(searchResult.getAttributes(),
                                    new DistinguishedName(dn.toString()), ctxBaseDn));
                        }
                    } catch (PartialResultException e) {
                        logger.info("Ignoring PartialResultException");
                    }
View Full Code Here


            // Check for password policy control
            PasswordPolicyControl ppolicy = PasswordPolicyControlExtractor.extractControl(ctx);

            Attributes attrs = ctx.getAttributes(userDn, getUserAttributes());

            DirContextAdapter result = new DirContextAdapter(attrs, new DistinguishedName(userDn),
                    ctxSource.getBaseLdapPath());

            if (ppolicy != null) {
                result.setAttributeValue(ppolicy.getID(), ppolicy);
            }

            return result;
        } catch (NamingException e) {
            // This will be thrown if an invalid user name is used and the method may
View Full Code Here

    }

    @Test
    public void testMapUserToContext() throws Exception {
        User user = new UserImpl();
        DirContextAdapter adapter = new DirContextAdapter();

        contextMapper.mapUserToContext(user, adapter);

        assertTrue("Nothing happened", true);
    }
View Full Code Here

    }

    @Test
    public void testMapUserToContext() throws Exception {
        User user = new User();
        DirContextAdapter adapter = new DirContextAdapter();

        contextMapper.mapUserToContext(user, adapter);

        assertTrue("Nothing happened", true);
    }
View Full Code Here

     * {@inheritDoc}
     */
    @Override
    public Object mapFromContext(final Object inCtx)
    {
        DirContextAdapter dir = (DirContextAdapter) inCtx;
       
        //This is the callback for the PagedLdapSearch, getNameInNamespace returns the fully qualified
        //dn for the result.  This is preferred over getDn which just returns the relative dn without
        //the base path if it was supplied by the ldaptemplate during search.
        return new LdapGroup(new DistinguishedName(dir.getNameInNamespace()));
    }
View Full Code Here

    }
   
    public void internalAdd(Entity entity, DistinguishedName dn) throws SecurityException
    {
        if (entityExists(entity)) { throw new SecurityException(SecurityException.PRINCIPAL_ALREADY_EXISTS.createScoped(entity.getType(), entity.getId())); }
        DirContextAdapter context = new DirContextAdapter();
        if (dn != null)
        {
            dn.add(configuration.getLdapIdAttribute(), entity.getId());
            for (AttributeDef attrDef : configuration.getAttributeDefinitions())
            {
                Attribute entityAttr = entity.getAttribute(attrDef.getName());
                BasicAttribute basicAttr = null;
                if (entityAttr != null)
                {
                    if (attrDef.isMultiValue())
                    {
                        Collection<String> entityAttrValues = entityAttr.getValues();
                        if (entityAttrValues != null && entityAttrValues.size() > 0)
                        {
                            basicAttr = new BasicAttribute(attrDef.getName());
                            for (String val : entityAttrValues)
                            {
                                basicAttr.add(val);
                            }
                        }
                    } else
                    {
                        basicAttr = new BasicAttribute(attrDef.getName());
                        basicAttr.add(entityAttr.getValue());
                    }
                } else
                {
                    if (attrDef.isIdAttribute())
                    {
                        basicAttr = new BasicAttribute(attrDef.getName());
                        basicAttr.add(entity.getId());
                    } else if (attrDef.isRequired())
                    {
                        String requiredValue = attrDef.getRequiredDefaultValue();
                        if (requiredValue != null && requiredValue.length() > 0)
                        {
                            basicAttr = new BasicAttribute(attrDef.getName());
                            basicAttr.add(attrDef.getRequiredDefaultValue());
                        }
                    } else
                    {
                        // TODO missing required attribute value, throw
                        // exception
                        // return;
                    }
                }
                if (basicAttr != null)
                {
                    context.setAttribute(basicAttr);
                }
            }
            BasicAttribute attr = new BasicAttribute("objectClass");
            for (String objClass : configuration.getObjectClassesArray())
            {
                attr.add(objClass);
            }
            context.setAttribute(attr);
            ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader();
            try
            {
                Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
View Full Code Here

TOP

Related Classes of org.springframework.ldap.core.DirContextAdapter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.