@Override
    public Authentication authenticate(Authentication authentication) throws AuthenticationException {
        ModelUser oUser = new ModelUser();

        oUser.setUser(authentication.getName());
        oUser.setPassword(authentication.getCredentials().toString());

        ModelUser oUserLogged = oService.login(oUser);

        if (oUserLogged != null) {
            List<GrantedAuthority> grantedAuths = new ArrayList();

            switch (oUserLogged.getProfile()) {
                case 1:
                    grantedAuths.add(new SimpleGrantedAuthority(oProfile.getSuperAdmin()));
                    break;
                case 2:
                    grantedAuths.add(new SimpleGrantedAuthority(oProfile.getAdmin()));
                    break;
                case 3:
                    grantedAuths.add(new SimpleGrantedAuthority(oProfile.getClient()));
                    break;
            }

            Authentication auth = new UsernamePasswordAuthenticationToken(oUserLogged.getUser(),
                    oUserLogged.getPassword(), grantedAuths);

            return auth;
        } else {
            return null;
        }
    }