Package org.opencustomer.db.vo.system

Examples of org.opencustomer.db.vo.system.LdapGroupVO


        return LdapGroupVO.class;
    }

    public LdapGroupVO getByName(String name)
    {
        LdapGroupVO group = null;

        try
        {
            StringBuilder hql = new StringBuilder();
            hql.append(" FROM ").append(getEntityClass().getName()).append(" e ");
View Full Code Here


     * @return the LdapGroupVO if a group is found, otherwise null
     * @author fbreske
     */
    public LdapGroupVO getByDN(String name)
    {
        LdapGroupVO group = null;

        try
        {
            StringBuilder hql = new StringBuilder();
            hql.append(" FROM ").append(getEntityClass().getName()).append(" e ");
View Full Code Here

    {
        if(log.isDebugEnabled())
            log.debug("sync user: " + username);
          
        UserVO user = new UserDAO().getByUserName(username);
        LdapGroupVO profile = LdapUtil.getInstance().getProfileForUser(username);
       
        if(user == null && profile == null)
        {
            if(log.isDebugEnabled())
                log.debug("ignoring new user without ldapgroups");
        }
        else if(user == null)
        {
            if(log.isDebugEnabled())
                log.debug("creating new user");
            LdapUtil.getInstance().createUserFromLdap(username);
        }
        else if(user.getProfile().getRole().isAdmin())
        {
            if(log.isDebugEnabled())
                log.debug("user is admin, do nothing");
        }
        else if(user.getProfile().getLdapGroup() != null && !LdapAuthenticator.getInstance().isLdapUser(username))
        {
            new UserDAO().delete(user);
            user = null;
            if(log.isDebugEnabled())
                log.debug("oc user deleted: " + username);
        }
        else if((user.getProfile().getRole().isAdmin() || (user.getProfile().getLdapGroup() == null))&& LdapAuthenticator.getInstance().isLdapUser(username))
        {
            log.error("username conflict: " +  username);
            user = null;
        }
        else if(profile == null)
        {
            if(log.isDebugEnabled())
                log.debug("no ldapgroup for user, deleting user");
            new UserDAO().delete(user);
            user = null;
        }
        else if(user.getProfile().getId() != profile.getProfile().getId())
        {
            if(log.isDebugEnabled())
                log.debug("ldap group change");
            user.setProfile(profile.getProfile());
        }
        else
        {
            if(log.isDebugEnabled())
                log.debug("no changes for user: " + username);
View Full Code Here

                log.debug("no ldap user for username: " + username);
            return null;
        }
        else if(user == null)
        {
            LdapGroupVO profile = getProfileForUser(username);
            if(profile != null)
            {
                if(log.isDebugEnabled())
                    log.debug("creating new user: " + username);
                InitialDirContext ctx = new InitialDirContext(env);
                Attributes attrs = ctx.getAttributes("uid=" + username + "," + SystemConfiguration.getInstance().getStringValue(SystemConfiguration.Key.LDAP_USER_PREFIX));
               
                // Defaultwerte setzen
                user = new UserVO();
                user.setUserName(attrs.get("Uid").get().toString());
                user.setProfile(profile.getProfile());
                user.setLocale(adminUser.getLocale());
                user.setOwnerUser(adminUser.getId());
                user.setOwnerGroup(adminUser.getId());
                user.setAccessUser(Access.WRITE_SYSTEM);
                user.setAccessGroup(Access.READ);
View Full Code Here

    private LdapGroupVO createGroupFromLdap(String groupDN) throws NamingException
    {
        InitialDirContext ctx = new InitialDirContext(env);
        Attributes attrs = ctx.getAttributes(groupDN + "," + SystemConfiguration.getInstance().getStringValue(SystemConfiguration.Key.LDAP_GROUP_PREFIX),new String[]{"cn"});
       
        LdapGroupVO ldapGroup = null;
       
        if(attrs.get("cn") != null)
        {
            String name = (String)attrs.get("cn").get(0); // TODO: what is this name for
            ldapGroup = new LdapGroupDAO().getByName(name);
            if(ldapGroup == null)
            {
                if(log.isDebugEnabled())
                    log.debug("creating new ldapGroup: " + name);
                ldapGroup = new LdapGroupVO();
                ldapGroup.setName(groupDN);
                ldapGroup.setOwnerGroup(adminUser.getProfile().getDefaultUsergroup().getId());
                ldapGroup.setOwnerUser(adminUser.getId());
                ldapGroup.setPriority(new LdapGroupDAO().getAll().size());
                ldapGroup.setAccessUser(Access.WRITE_SYSTEM);
                ldapGroup.setAccessGroup(Access.NONE);
                ldapGroup.setAccessGlobal(Access.NONE);
                ProfileVO profile = new ProfileVO();
                profile.setAccessGlobal(Access.READ);
                profile.setAccessGroup(Access.READ);
                profile.setAccessUser(Access.WRITE_SYSTEM);
                profile.setIpPattern("*");
                profile.setTimeLock(30);
                profile.setRole(new RoleDAO().getByName("User"));
                profile.setDefaultUsergroup(profile.getRole().getDefaultUsergroup());
                profile.setOwnerUser(adminUser.getId());
                profile.setOwnerGroup(adminUser.getProfile().getDefaultUsergroup().getId());
                ldapGroup.setProfile(profile);
                new LdapGroupDAO().insert(ldapGroup,adminUser);
            }
            else
            {
                if(log.isDebugEnabled())
View Full Code Here

        while(enm.hasMore())
        {
            NamingEnumeration<SearchResult> enm2 = ctx.search(SystemConfiguration.getInstance().getStringValue(SystemConfiguration.Key.LDAP_GROUP_PREFIX),filter_groups,new String[]{enm.next().getNameInNamespace()},null);
            while(enm2.hasMore())
            {
                LdapGroupVO tmpGroup = new LdapGroupDAO().getByDN(enm2.next().getName());
                ldapGroups.add(tmpGroup);
                if(log.isDebugEnabled())
                    log.debug("found ldap group " + tmpGroup.getName() + " for user " + username);
            }
        }
       
        LdapGroupVO preferdGroup = null;     
        for(LdapGroupVO tmp : ldapGroups)
        {
            if(preferdGroup == null || preferdGroup.getPriority() > tmp.getPriority())
                preferdGroup = tmp;
        }
       
        if(log.isDebugEnabled()){
            if(preferdGroup == null)
                log.debug("user has no group");
            else
                log.debug("prefered group is: " + preferdGroup.getName());
        }
        return preferdGroup;
    }
View Full Code Here

TOP

Related Classes of org.opencustomer.db.vo.system.LdapGroupVO

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.