Package org.jboss.aerogear.security.shiro.model

Examples of org.jboss.aerogear.security.shiro.model.User


     * @param username represents a simple user's implementation to hold credentials.
     */
    @Override
    public void to(String username) {

        User user = entityManager.createNamedQuery("User.findByUsername", User.class)
                .setParameter("username", username)
                .getSingleResult();

        user.setRoles(list);
        entityManager.merge(user);

    }
View Full Code Here


    @Override
    protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authToken) throws AuthenticationException {

        UsernamePasswordToken token = (UsernamePasswordToken) authToken;

        User user = (User) identityManagerment.findByUsername(token.getUsername());

        if (user != null) {
            return new SimpleAuthenticationInfo(user.getId(), new Sha512Hash(user.getPassword()), getName());
        } else {
            throw new RuntimeException("Authentication failed");
        }
    }
View Full Code Here

    @Override
    protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {

        try {
            Long userId = (Long) (principals.fromRealm(getName()).iterator().next());
            User user = (User) identityManagerment.findById(userId);
            if (user != null) {
                SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
                for (Role role : user.getRoles()) {
                    info.addRole(role.getName());
                    info.addStringPermissions(role.getPermissions());
                }
                return info;
            } else {
View Full Code Here

        return grantConfiguration.roles(roles);
    }

    @Override
    public User findByUsername(String username) throws RuntimeException {
        User user = entityManager.createNamedQuery("User.findByUsername", User.class)
                .setParameter("username", username)
                .getSingleResult();
        if (user == null) {
            throw new RuntimeException("AeroGearUser do not exist");
        }
View Full Code Here

        return entityManager.find(User.class, id);
    }

    @Override
    public void remove(String username) {
        User user = entityManager.createNamedQuery("User.findByUsername", User.class)
                .setParameter("username", username)
                .getSingleResult();
        if (user == null) {
            throw new RuntimeException("AeroGearUser do not exist");
        }
View Full Code Here

     * @param user
     * @param password
     */
    @Override
    public void create(User user, String password) {
        User newUser = new User(user.getUsername(),
                new Sha512Hash(password).toHex());
        entityManager.persist(newUser);
    }
View Full Code Here

    @Produces
    @Secret
    @Override
    public String getSecret() {
        Long id = (Long) subject.getPrincipal();
        User user = entityManager.find(User.class, id);
        if (user.getSecret() == null) {
            user.setSecret(Base32.random());
            entityManager.merge(user);
        }
        return user.getSecret();
    }
View Full Code Here

    @Produces
    @LoggedUser
    @Override
    public String getLogin() {
        Long id = (Long) subject.getPrincipal();
        User user = entityManager.find(User.class, id);

        return user.getUsername();
    }
View Full Code Here

TOP

Related Classes of org.jboss.aerogear.security.shiro.model.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.