Examples of UserManager


Examples of org.apache.felix.jmood.compendium.UserManager

                LogManagerMBean lm = new LogManager(ac);
                server.registerMBean(lm,
                        new ObjectName(ObjectNames.LOG_SERVICE));
            }
            if (ac.getUserAdmin() != null) {
                UserManagerMBean um = new UserManager(ac);
                server
                        .registerMBean(um, new ObjectName(
                                ObjectNames.UA_SERVICE));
            }
        } catch (InstanceAlreadyExistsException e) {
View Full Code Here

Examples of org.apache.ftpserver.ftplet.UserManager

        // reset state variables
        session.resetState();

        // only administrator can execute this
        UserManager userManager = context.getUserManager();
        boolean isAdmin = userManager.isAdmin(session.getUser().getName());
        if (!isAdmin) {
            session.write(LocalizedFtpReply.translate(session, request, context,
                    FtpReply.REPLY_530_NOT_LOGGED_IN, "SITE", null));
            return;
        }

        // get the user name
        String argument = request.getArgument();
        int spIndex = argument.indexOf(' ');
        if (spIndex == -1) {
            session.write(LocalizedFtpReply.translate(session, request, context,
                    FtpReply.REPLY_503_BAD_SEQUENCE_OF_COMMANDS,
                    "SITE.DESCUSER", null));
            return;
        }
        String userName = argument.substring(spIndex + 1);

        // check the user existance
        UserManager usrManager = context.getUserManager();
        User user = null;
        try {
            if (usrManager.doesExist(userName)) {
                user = usrManager.getUserByName(userName);
            }
        } catch (FtpException ex) {
            LOG.debug("Exception trying to get user from user manager", ex);
        }
        if (user == null) {
View Full Code Here

Examples of org.apache.ftpserver.ftplet.UserManager

                                        "PASS.login", null));
                return;
            }

            // authenticate user
            UserManager userManager = context.getUserManager();
            User authenticatedUser = null;
            try {
                UserMetadata userMetadata = new UserMetadata();

                if (session.getRemoteAddress() instanceof InetSocketAddress) {
                    userMetadata.setInetAddress(((InetSocketAddress) session
                            .getRemoteAddress()).getAddress());
                }
                userMetadata.setCertificateChain(session
                        .getClientCertificates());

                Authentication auth;
                if (anonymous) {
                    auth = new AnonymousAuthentication(userMetadata);
                } else {
                    auth = new UsernamePasswordAuthentication(userName,
                            password, userMetadata);
                }

                authenticatedUser = userManager.authenticate(auth);
            } catch (AuthenticationFailedException e) {
                LOG.warn("User failed to log in");
            } catch (Exception e) {
                authenticatedUser = null;
                LOG.warn("PASS.execute()", e);
View Full Code Here

Examples of org.apache.ftpserver.ftplet.UserManager

    public static void main(String[] args) throws Exception {
        PropertiesUserManagerFactory userManagerFactory = new PropertiesUserManagerFactory();
        userManagerFactory.setFile(new File("myusers.properties"));
        userManagerFactory.setPasswordEncryptor(new SaltedPasswordEncryptor());
        UserManager um = userManagerFactory.createUserManager();

        UserFactory userFact = new UserFactory();
        userFact.setName("myNewUser");
        userFact.setPassword("secret");
        userFact.setHomeDirectory("ftproot");
        User user = userFact.createUser();
        um.save(user);
    }
View Full Code Here

Examples of org.apache.ftpserver.ftplet.UserManager

                return;
            }
           
            BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
           
            UserManager um = ((DefaultFtpServer)server).getUserManager();
           
            BaseUser user = new BaseUser();

            System.out.println("Asking for details of the new user");
           
            System.out.println();
            String userName = askForString(in, "User name:", "User name is mandatory");
            if(userName == null) {
                return;
            }
            user.setName(userName);
           
            user.setPassword(askForString(in, "Password:"));
           
            String home = askForString(in, "Home directory:", "Home directory is mandatory");
            if(home == null) {
                return;           
            }
            user.setHomeDirectory(home);
           
            user.setEnabled(askForBoolean(in, "Enabled (Y/N):"));

            user.setMaxIdleTime(askForInt(in, "Max idle time in seconds (0 for none):"));
           
            List<Authority> authorities = new ArrayList<Authority>();
           
            if(askForBoolean(in, "Write permission (Y/N):")) {
                authorities.add(new WritePermission());
            }

            int maxLogins = askForInt(in, "Maximum number of concurrent logins (0 for no restriction)");
            int maxLoginsPerIp = askForInt(in, "Maximum number of concurrent logins per IP (0 for no restriction)");
           
            authorities.add(new ConcurrentLoginPermission(maxLogins, maxLoginsPerIp));
           
            int downloadRate = askForInt(in, "Maximum download rate (0 for no restriction)");
            int uploadRate = askForInt(in, "Maximum upload rate (0 for no restriction)");
           
            authorities.add(new TransferRatePermission(downloadRate, uploadRate));
           
            user.setAuthorities(authorities);
           
            um.save(user);
           
            if(um instanceof PropertiesUserManager) {
                File file = ((PropertiesUserManager) um).getFile();
               
                if(file != null) {
View Full Code Here

Examples of org.apache.ftpserver.ftplet.UserManager

        authorities.add(new TransferRatePermission(1, 5));
        user.setAuthorities(authorities);

        userManager.save(user);

        UserManager newUserManager = createUserManagerFactory().createUserManager();

        User actualUser = newUserManager.getUserByName("newuser");

        assertEquals(user.getName(), actualUser.getName());
        assertNull(actualUser.getPassword());
        assertEquals(user.getHomeDirectory(), actualUser.getHomeDirectory());
        assertEquals(user.getEnabled(), actualUser.getEnabled());
        assertNotNull(user.authorize(new WriteRequest()));
        assertEquals(getMaxDownloadRate(user), getMaxDownloadRate(actualUser));
        assertEquals(user.getMaxIdleTime(), actualUser.getMaxIdleTime());
        assertEquals(getMaxLoginNumber(user), getMaxLoginNumber(actualUser));
        assertEquals(getMaxLoginPerIP(user), getMaxLoginPerIP(actualUser));
        assertEquals(getMaxUploadRate(user), getMaxUploadRate(actualUser));
       
        // verify the password
        assertNotNull(newUserManager.authenticate(new UsernamePasswordAuthentication("newuser", "newpw")));

        try {
            newUserManager.authenticate(new UsernamePasswordAuthentication("newuser", "dummy"));
            fail("Must throw AuthenticationFailedException");
        } catch(AuthenticationFailedException e) {
            // ok
        }

        // save without updating the users password (password==null)
        userManager.save(user);

        newUserManager = createUserManagerFactory().createUserManager();
        assertNotNull(newUserManager.authenticate(new UsernamePasswordAuthentication("newuser", "newpw")));
        try {
            newUserManager.authenticate(new UsernamePasswordAuthentication("newuser", "dummy"));
            fail("Must throw AuthenticationFailedException");
        } catch(AuthenticationFailedException e) {
            // ok
        }

              
        // save and update the users password
        user.setPassword("newerpw");
        userManager.save(user);
       
        newUserManager = createUserManagerFactory().createUserManager();
        assertNotNull(newUserManager.authenticate(new UsernamePasswordAuthentication("newuser", "newerpw")));

        try {
            newUserManager.authenticate(new UsernamePasswordAuthentication("newuser", "newpw"));
            fail("Must throw AuthenticationFailedException");
        } catch(AuthenticationFailedException e) {
            // ok
        }
View Full Code Here

Examples of org.apache.isis.viewer.scimpi.dispatcher.UserManager

            dispatcher.addParameter(name, value);
        }
        final String dir = getServletContext().getRealPath("/WEB-INF");
        dispatcher.init(dir, debugUsers);

        new UserManager(IsisContext.getAuthenticationManager());
    }
View Full Code Here

Examples of org.apache.jackrabbit.api.security.user.UserManager

    public void testMultipleGroupPermissionsOnNode() throws NotExecutableException, RepositoryException {
        Group testGroup = getTestGroup();

        /* create a second group the test user is member of */
        Principal principal = new TestPrincipal("testGroup" + UUID.randomUUID());
        UserManager umgr = getUserManager(superuser);
        Group group2 = umgr.createGroup(principal);
        try {
            group2.addMember(testUser);
            if (!umgr.isAutoSave() && superuser.hasPendingChanges()) {
                superuser.save();
            }

            /* add privileges for the Group the test-user is member of */
            Privilege[] privileges = privilegesFromName(Privilege.JCR_MODIFY_PROPERTIES);
View Full Code Here

Examples of org.apache.jetspeed.security.UserManager

            {

                @Override
                public void onSubmit()
                {
                    UserManager userManager = (UserManager)getManager();
                    JetspeedPrincipal principal = getManager().newPrincipal(
                            getUserName(), false);
                    RoleManager roleManager = ((AbstractAdminWebApplication)getApplication()).getServiceLocator().getRoleManager();
                    PageManager pageManager = ((AbstractAdminWebApplication) getApplication()).getServiceLocator().getPageManager();
                    try
                    {
                        getManager().addPrincipal(principal, null);
                        User user = userManager.getUser(getUserName());

                        if(!StringUtils.isEmpty(defaultRole))
                        {
                            roleManager.addRoleToUser(getUserName(), defaultRole);
                        }
                        if(!StringUtils.isEmpty(requiredRole))
                        {
                            roleManager.addRoleToUser(getUserName(), requiredRole);
                        }
                       
                        Profiler profiler = getServiceLocator().getProfiler();
                       
                        if (!StringUtils.isEmpty(getProfilingRule()))
                        {
                            ProfilingRule profilingRule = profiler.getRule(getProfilingRule());
                           
                            if (profilingRule != null)
                            {
                                profiler.setRuleForPrincipal(principal, profilingRule, "default");
                            }
                            else
                            {
                                log.error("Failed to set profiling rule for principal. Invalid profiling rule: " + getProfilingRule());
                            }
                        }
                        else if (!StringUtils.isEmpty(defaultProfile))
                        {
                            ProfilingRule defaultProfilingRule = profiler.getRule(defaultProfile);
                           
                            if (defaultProfilingRule != null)
                            {
                                profiler.setRuleForPrincipal(principal, defaultProfilingRule, "default");
                            }
                            else
                            {
                                if (log.isDebugEnabled())
                                {
                                    log.debug("Default profiling rule is not applied to the principal because the default profiling rule is not found: " + defaultProfile);
                                }
                            }
                        }
                       
                        String subSite;
                        if (!StringUtils.isEmpty(defaultSubsite))
                        {
                            user.getSecurityAttributes().getAttribute(User.JETSPEED_USER_SUBSITE_ATTRIBUTE,true).setStringValue(defaultSubsite);
                            user.getSecurityAttributes().getAttribute(User.JETSPEED_USER_SUBSITE_ATTRIBUTE, true).setStringValue(defaultSubsite);
                            subSite = subsiteRoot + defaultSubsite + Folder.USER_FOLDER + user.getName();
                        }
                       
                        else
                        {
                            subSite = Folder.USER_FOLDER + user.getName();;
                        }
                       
                        if (!StringUtils.isEmpty(templateFolder))
                        {
                            try
                            {
                                Folder source = pageManager.getFolder(templateFolder);
                                pageManager.deepCopyFolder(source, subSite, user.getName());
                            }
                            catch (FolderNotFoundException e)
                            {
                                error(e.getMessage());
                            }
                            catch (NodeException e)
                            {
                                error(e.getMessage());
                            }
                        }
                        userManager.updateUser(user);
                                               
                        PasswordCredential credential = userManager
                                .getPasswordCredential(user);
                        if (!StringUtils.isEmpty(getPassword()))
                        {
                            credential.setPassword(getPassword(), false);
                        }
                        credential.setUpdateRequired(isCheckpass());
                        userManager.storePasswordCredential(credential);
                        setPrincipal(user);
                        controlPannels(true);
                    }
                    catch (SecurityException jSx)
                    {
View Full Code Here

Examples of org.apache.lenya.ac.UserManager

    public User[] getUsersWithRole(String roleId) throws ProcessingException {
        List users = new ArrayList();
        try {
            Policy policy =
                policyManager.getPolicy(accessController.getAccreditableManager(), getUrl());
            UserManager userManager = accessController.getAccreditableManager().getUserManager();
            User[] userArray = userManager.getUsers();
            for (int i = 0; i < userArray.length; i++) {
                Identity identity = new Identity();
                identity.addIdentifiable(userArray[i]);
                Role[] roles = policy.getRoles(identity);
                for (int roleIndex = 0; roleIndex < roles.length; roleIndex++) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.