Package org.apache.roller.weblogger.pojos

Examples of org.apache.roller.weblogger.pojos.User


        try {
            // Let's see if there's any user-authentication available from Acegi
            // and retrieve custom user data to pre-populate form.
            boolean usingSSO = WebloggerConfig.getBooleanProperty("users.sso.enabled");
            if(usingSSO) {
                User fromSSO = CustomUserRegistry.getUserDetailsFromAuthentication();
                if(fromSSO != null) {
                    getBean().copyFrom(fromSSO);
                    setFromSS0(true);
                }
            }
View Full Code Here


        if (!hasActionErrors()) try {
           
            UserManager mgr = WebloggerFactory.getWeblogger().getUserManager();
           
            // copy form data into new user pojo
            User ud = new User();
            getBean().copyTo(ud); // doesn't copy password
            ud.setUserName(getBean().getUserName());
            ud.setDateCreated(new java.util.Date());
            ud.setEnabled(Boolean.TRUE);
           
            // If user set both password and passwordConfirm then reset password
            if (!StringUtils.isEmpty(getBean().getPasswordText()) &&
                    !StringUtils.isEmpty(getBean().getPasswordConfirm())) {
                ud.resetPassword(getBean().getPasswordText());
            }
           
            // are we using email activation?
            boolean activationEnabled = WebloggerRuntimeConfig.getBooleanProperty(
                    "user.account.activation.enabled");
            if (activationEnabled) {
                // User account will be enabled after the activation process
                ud.setEnabled(Boolean.FALSE);
               
                // Create & save the activation data
                String activationCode = UUID.randomUUID().toString();
               
                if (mgr.getUserByActivationCode(activationCode) != null) {
                    // In the *extremely* unlikely event that we generate an
                    // activation code that is already use, we'll retry 3 times.
                    int numOfRetries = 3;
                    if (numOfRetries < 1) numOfRetries = 1;
                    for (int i = 0; i < numOfRetries; i++) {
                        activationCode = UUID.randomUUID().toString();
                        if (mgr.getUserByActivationCode(activationCode) == null) {
                            break;
                        } else {
                            activationCode = null;
                        }
                    }
                    // In more unlikely event that three retries isn't enough
                    if (activationCode == null){
                        throw new WebloggerException("error.add.user.activationCodeInUse");
                    }
                }
                ud.setActivationCode(activationCode);
            }
           
            // save new user
            mgr.addUser(ud);
            WebloggerFactory.getWeblogger().flush();
           
            // now send activation email if necessary
            if (activationEnabled && ud.getActivationCode() != null) {
                try {
                    // send activation mail to the user
                    MailUtil.sendUserActivationEmail(ud);
                } catch (WebloggerException ex) {
                    log.error("Error sending activation email to - "+ud.getEmailAddress(), ex);
                }
               
                setActivationStatus("pending");
            }
            
View Full Code Here

            UserManager mgr = WebloggerFactory.getWeblogger().getUserManager();
           
            if (getActivationCode() == null) {
                addError("error.activate.user.missingActivationCode");
            } else {
                User user = mgr.getUserByActivationCode(getActivationCode());
               
                if (user != null) {
                    // enable user account
                    user.setEnabled(Boolean.TRUE);
                    user.setActivationCode(null);
                    mgr.saveUser(user);
                    WebloggerFactory.getWeblogger().flush();
                   
                    setActivationStatus("active");
                   
View Full Code Here

        // if usingSSO, we don't want to error on empty password/username from HTML form.
        setFromSS0(false);
        boolean usingSSO = WebloggerConfig.getBooleanProperty("users.sso.enabled");
        if(usingSSO) {
            boolean storePassword = WebloggerConfig.getBooleanProperty("users.sso.passwords.saveInRollerDb");
            User fromSSO = CustomUserRegistry.getUserDetailsFromAuthentication();
            if(fromSSO != null) {
                String password = WebloggerConfig.getProperty("users.sso.passwords.defaultValue", "<unknown>");
                if(storePassword) {
                    password = fromSSO.getPassword();
                }
                getBean().setPasswordText(password);
                getBean().setPasswordConfirm(password);
                getBean().setUserName(fromSSO.getUserName());
                setFromSS0(true);
            }
        }
       
        String allowed = WebloggerConfig.getProperty("username.allowedChars");
View Full Code Here

        boolean userEnabled = false;
        boolean weblogEnabled = false;
        boolean apiEnabled = false;
        boolean weblogFound = false;
        Weblog website = null;
        User user = null;
        try {
            UserManager userMgr = WebloggerFactory.getWeblogger().getUserManager();
            user = userMgr.getUserByUserName(username);
            userEnabled = user.getEnabled().booleanValue();
           
            website = userMgr.getWebsiteByHandle(blogid);
            if (website != null) {
                weblogFound = true;
                weblogEnabled = website.getEnabled().booleanValue();
                apiEnabled = website.getEnableBloggerApi().booleanValue();
            }
           
            if (user != null) {
                // are passwords encrypted
                String encrypted =
                        WebloggerConfig.getProperty("passwds.encryption.enabled");
                //System.out.print("password was [" + password + "] ");
                if ("true".equalsIgnoreCase(encrypted)) {
                    password = Utilities.encodePassword(password,
                            WebloggerConfig.getProperty("passwds.encryption.algorithm"));
                }
                authenticated = password.equals(user.getPassword());
            }
        } catch (Exception e) {
            mLogger.error("ERROR internal error validating user", e);
        }
       
View Full Code Here

     */
    protected boolean validateUser(String username, String password)
    throws Exception {
        boolean authenticated = false;
        boolean enabled = false;
        User user = null;
        try {
           
            UserManager userMgr = WebloggerFactory.getWeblogger().getUserManager();
            user = userMgr.getUserByUserName(username);
           
            enabled = user.getEnabled().booleanValue();
            if (enabled) {
                // are passwords encrypted?
                String encrypted =
                        WebloggerConfig.getProperty("passwds.encryption.enabled");
                //System.out.print("password was [" + password + "] ");
                if ("true".equalsIgnoreCase(encrypted)) {
                    password = Utilities.encodePassword(password,
                            WebloggerConfig.getProperty("passwds.encryption.algorithm"));
                }
                //System.out.println("is now [" + password + "]");
                authenticated = user.getPassword().equals(password);
                if (authenticated) {
                    //WebloggerFactory.getWeblogger().setUser(user);
                }
            }
        } catch (Exception e) {
View Full Code Here

        // get all permissions: for all users, for all websites
        try {
            List users = getRoller().getUserManager().getUsers(null, null, null, null, 0, -1);
            List perms = new ArrayList();
            for (Iterator i = users.iterator(); i.hasNext(); ) {
                User user = (User)i.next();
                List permissions = getRoller().getUserManager().getAllPermissions(user);
                for (Iterator j = permissions.iterator(); j.hasNext(); ) {
                    WeblogPermission pd = (WeblogPermission)j.next();
                    perms.add(pd);
                }
View Full Code Here

                //get all entries for the given website handle & username
                Weblog wd = getWebsiteData(handle);
                if (wd == null) {
                    throw new NotFoundException("ERROR: Unknown weblog handle: " + handle);
                }
                User ud = getUserData(username);
                if (ud == null) {
                    throw new NotFoundException("ERROR: Unknown user name: " + username);
                }
                WeblogPermission pd = getRoller().getUserManager().getPermissions(wd, ud);
                if (pd == null) {
View Full Code Here

            throw new InternalException("ERROR: Could not create members", re);
        }
    }
   
    private WeblogPermission toPermissionsData(MemberEntry entry) throws HandlerException {
        User ud = getUserData(entry.getName());
        Weblog wd = getWebsiteData(entry.getHandle());
        WeblogPermission pd = new WeblogPermission();
        pd.setUser(ud);
        pd.setWebsite(wd);
        pd.setPermissionMask(stringToMask(entry.getPermission()));
View Full Code Here

        return getPermissionsData(entry.getHandle(), entry.getName());
    }
   
    private WeblogPermission getPermissionsData(String handle, String username) throws HandlerException {
        try {
            User ud = getUserData(username);
            Weblog wd = getWebsiteData(handle);
            WeblogPermission pd = getRoller().getUserManager().getPermissions(wd, ud);
           
            return pd;
        } catch (WebloggerException re) {
View Full Code Here

TOP

Related Classes of org.apache.roller.weblogger.pojos.User

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.