Examples of ILocalAccountPerson


Examples of org.jasig.portal.persondir.ILocalAccountPerson

    this.isauth = true;
    if (this.myPrincipal.UID != null) {
      try {
        String first_name, last_name;
        ILocalAccountDao accountStore = LocalAccountDaoLocator.getLocalAccountDao();
        ILocalAccountPerson account = accountStore.getPerson(this.myPrincipal.UID);
        if (account != null) {
            first_name = (String) account.getAttributeValue("given");
            last_name = (String) account.getAttributeValue("sn");
          this.myPrincipal.FullName = first_name + " " + last_name;
          if (log.isInfoEnabled())
              log.info( "User " + this.myPrincipal.UID + " is authenticated");
          this.isauth = true;
        }
View Full Code Here

Examples of org.jasig.portal.persondir.ILocalAccountPerson

            System.err.println("You did not specify a valid user name.  Please try again.");
            return false;
        }

        // attempt to get the account form the database
        ILocalAccountPerson account = this.localAccountDao.getPerson(user);
        if (account == null) {
            if (!create) {
                System.err.println("No such user: " + user);
                return false;
            }

            account = this.localAccountDao.createPerson(user);
        }

        System.out.print("Enter Password for " + user + ": ");
        System.out.flush(); // Needed for prompt to appear when running from Ant.
        final BufferedReader d = new BufferedReader(new InputStreamReader(System.in));
        final String spass = d.readLine();

        // update the user's password
        final String encryptedPassword = this.portalPasswordService.encryptPassword(spass);
        account.setPassword(encryptedPassword);
       
        this.localAccountDao.updateAccount(account);

        System.out.println("Password Updated...");
        return true;
View Full Code Here

Examples of org.jasig.portal.persondir.ILocalAccountPerson

        if (StringUtils.isBlank(user)) {
            throw new IllegalArgumentException("You did not specify a valid user name.  Please try again.");
        }

        // attempt to get the account form the database
        ILocalAccountPerson account = this.localAccountDao.getPerson(user);
        if (account == null) {
            if (!create) {
                throw new IllegalArgumentException("No such user: " + user);
            }

            account = this.localAccountDao.createPerson(user);
        }

        // update the user's password
        final String encryptedPassword = this.portalPasswordService.encryptPassword(spass);
        account.setPassword(encryptedPassword);
       
        this.localAccountDao.updateAccount(account);

        logger.info("Password Updated for: {}", user);
    }
View Full Code Here

Examples of org.jasig.portal.persondir.ILocalAccountPerson

        return form;
    }

    public PersonForm getForm(String username) {
       
        ILocalAccountPerson person = accountDao.getPerson(username);
       
        PersonForm form = new PersonForm(accountEditAttributes);
        form.setUsername(person.getName());
        form.setId(person.getId());
       
        Set<String> attributeNames = accountDao.getCurrentAttributeNames();
        for (String name : attributeNames) {
            List<String> values = new ArrayList<String>();
            List<Object> attrValues = person.getAttributeValues(name);
            if (attrValues != null) {
                for (Object value : person.getAttributeValues(name)) {
                    values.add((String) value);
                }
            }
            form.getAttributes().put(name, new StringListAttribute(values));
        }
View Full Code Here

Examples of org.jasig.portal.persondir.ILocalAccountPerson

        return form;
    }

    protected boolean isLocalAccount(String username) {
        ILocalAccountPerson person = accountDao.getPerson(username);
        if (person != null) {
            return true;
        } else {
            return false;
        }
View Full Code Here

Examples of org.jasig.portal.persondir.ILocalAccountPerson

        if (!canDeleteUser(currentUser, target)) {
            throw new RuntimeException("Current user " + currentUser.getName()
                    + " does not have permissions to update person " + target);
        }
       
        ILocalAccountPerson person = accountDao.getPerson(target);
       
        accountDao.deleteAccount(person);
        log.info("Account " + person.getName() + " successfully deleted");
       
    }
View Full Code Here

Examples of org.jasig.portal.persondir.ILocalAccountPerson

       
    }
   
    public void updateAccount(IPerson currentUser, PersonForm form) {
       
        ILocalAccountPerson account;
       
        // if this is a new user, create an account object with the specified
        // username
        if (form.getId() < 0) {
            account = accountDao.getPerson(form.getUsername());
            if (account == null) {
                /*
                 * Should there be a permissions check to verify
                 * the user is allowed to create new users?
                 */
                account = accountDao.createPerson(form.getUsername());
            }
        }
       
        // otherwise, get the existing account from the database
        else {
            account = accountDao.getPerson(form.getId());
        }
       
        /*
         * SANITY CHECK #1:  Is the user permitted to modify this account? 
         * (Presumably this check was already made when the page was rendered,
         * but re-checking alleviates danger from cleverly-crafted HTTP
         * requests.)
         */
        if (!canEditUser(currentUser, account.getName())) {
            throw new RuntimeException("Current user " + currentUser.getName()
                    + " does not have permissions to update person "
                    + account.getName());
        }

        // Used w/ check #2
        EntityIdentifier ei = currentUser.getEntityIdentifier();
        IAuthorizationPrincipal ap = AuthorizationService.instance().newPrincipal(ei.getKey(), ei.getType());
       
        // update the account attributes to match those specified in the form
        List<Preference> editableAttributes = getEditableUserAttributes(currentUser);
        for (Preference editableAttribute : editableAttributes) {
            String attributeName = editableAttribute.getName();

            /*
             * SANITY CHECK #2:  Should never fail since getEditableUserAttributes should return only
             * editable attribute names, but do this anyway just in case.
             */
            if (!ap.hasPermission("UP_USERS", "EDIT_USER_ATTRIBUTE", attributeName)) {
                throw new RuntimeException("Current user " + currentUser.getName()
                        + " does not have permissions to edit attribute " + attributeName);
            }

            if (form.getAttributes().get(attributeName) == null || form.getAttributes().get(attributeName).isBlank()) {
                account.removeAttribute(attributeName);
            } else {
                account.setAttribute(attributeName, form.getAttributes().get(attributeName).getValue());
            }
        }

        // if a new password has been specified, update the account password
        if (StringUtils.isNotBlank(form.getPassword())) {
            account.setPassword(passwordService.encryptPassword(form.getPassword()));
            account.setLastPasswordChange(new Date());
            account.removeAttribute("loginToken");
        }
       
        accountDao.updateAccount(account);
        log.info("Account " + account.getName() + " successfully updated");
    }
View Full Code Here

Examples of org.jasig.portal.persondir.ILocalAccountPerson

        String token = RandomStringUtils.randomAlphanumeric(20);
        return token;
    }
   
    public boolean validateLoginToken(String username, String token) {
        ILocalAccountPerson person = accountDao.getPerson(username);
        if (person != null) {
            Object recordedToken = person.getAttributeValue("loginToken");
            if (recordedToken != null && recordedToken.equals(token)) {
                if (log.isInfoEnabled()) {
                    log.info("Successfully validated security token for user:  " + username);
                }
                return true;
View Full Code Here

Examples of org.jasig.portal.persondir.ILocalAccountPerson

        if (StringUtils.isNotBlank(password)) {
            if (!password.equals(form.getConfirmPassword())) {
                throw new RuntimeException("Passwords don't match");
            }

            ILocalAccountPerson account = accountDao.getPerson(username);
            account.setPassword(passwordService.encryptPassword(password));
            account.setLastPasswordChange(new Date());
            account.removeAttribute("loginToken");
            accountDao.updateAccount(account);
            if (log.isInfoEnabled()) {
                log.info("Password created for account:  " + account);
            }
        } else {
View Full Code Here

Examples of org.jasig.portal.persondir.ILocalAccountPerson

                        .getLocalAccountDao();
                IPortalPasswordService passwordService = PortalPasswordServiceLocator
                        .getPortalPasswordService();

                // retrieve the account from the local user store
                ILocalAccountPerson account = accountStore.getPerson(this.myPrincipal.UID);
               
                if (account != null) {

                    // get the account password as an ASCII string
                    String loginPassword = new String(this.myOpaqueCredentials.credentialstring);
                   
                    // if the password provided at login matches the hashed
                    // account password, authenticate the user
                    if (passwordService.validatePassword(loginPassword, account.getPassword())) {
                       
                        // set the full name for this user
                        String fullName = (String) account.getAttributeValue("displayName");
                        this.myPrincipal.FullName = fullName;
                        if (log.isInfoEnabled())
                            log.info("User " + this.myPrincipal.UID
                                    + " is authenticated");
                        this.isauth = true;
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.