Package net.webpasswordsafe.common.model

Examples of net.webpasswordsafe.common.model.User


    @Transactional(propagation=Propagation.REQUIRED)
    public void deleteGroup(Group updateGroup)
    {
        Date now = new Date();
        String action = "delete group";
        User loggedInUser = getLoggedInUser();
        if (authorizer.isAuthorized(loggedInUser, Function.DELETE_GROUP.name()))
        {
            Group group = groupDAO.findById(updateGroup.getId());
            if (group != null)
            {
                // remove associated password permissions
                List<Password> passwords = passwordDAO.findPasswordsByPermissionSubject(group);
                for (Password password : passwords)
                {
                    password.removePermissionsBySubject(group);
                    passwordDAO.makePersistent(password);
                }
                // remove associated template details
                List<Template> templates = templateDAO.findTemplatesByDetailSubject(group);
                for (Template template : templates)
                {
                    template.removeDetailsBySubject(group);
                    templateDAO.makePersistent(template);
                }
                // remove associated users
                group.removeUsers();
                // actually remove group
                groupDAO.flush();
                groupDAO.makeTransient(group);
                auditLogger.log(now, loggedInUser.getUsername(), ServerSessionUtil.getIP(), action, groupTarget(group), true, "");
            }
            else
            {
                auditLogger.log(now, ServerSessionUtil.getUsername(), ServerSessionUtil.getIP(), action, groupTarget(updateGroup), false, "invalid id");
            }
View Full Code Here


    @Override
    @Transactional(propagation=Propagation.REQUIRED, readOnly=true)
    public User getUserWithGroups(long userId)
    {
        User user = userDAO.findById(userId);
        // fetch groups
        int numGroups = user.getGroups().size();
        LOG.debug(user.getName()+" has "+numGroups+" groups");
        return user;
    }
View Full Code Here

    @Override
    @Transactional(propagation=Propagation.REQUIRED, readOnly=true)
    public boolean isUserTaken(String username)
    {
        User user = userDAO.findUserByUsername(username);
        return (null != user);
    }
View Full Code Here

    public boolean unblockIP(String ipaddress)
    {
        boolean isUnblocked = false;
        Date now = new Date();
        String action = "unblock ip";
        User loggedInUser = getLoggedInUser();
        if (authorizer.isAuthorized(loggedInUser, Function.UNBLOCK_IP.name()))
        {
            IPLockout ipLockout = ipLockoutDAO.findByIP(ipaddress);
            if ((null != ipLockout) && (null != ipLockout.getLockoutDate()))
            {
View Full Code Here

        return isUnblocked;
    }

    private User getLoggedInUser()
    {
        User loggedInUser = loginService.getLogin();
        if (null == loggedInUser)
        {
            throw new RuntimeException("Not Logged In!");
        }
        return loggedInUser;
View Full Code Here

    }
   
    private boolean isAuthorizedReport(HttpServletRequest req, String reportName)
    {
        boolean isAuthorized = isAuthorized(req, Constants.VIEW_REPORT_PREFIX+reportName);
        User user = new User();
        user.setUsername((String)req.getSession().getAttribute(Constants.SESSION_KEY_USERNAME));
        AuditLogger auditLogger = (AuditLogger)WebApplicationContextUtils.getWebApplicationContext(getServletContext()).getBean("auditLogger");
        auditLogger.log(new Date(), user.getUsername(), req.getRemoteAddr(), "view report", reportName, isAuthorized, (isAuthorized ? "" : "not authorized"));
        return isAuthorized;
    }
View Full Code Here

    @SuppressWarnings("unchecked")
    private boolean isAuthorized(HttpServletRequest req, String action)
    {
        boolean isAuthorized = false;
        Authorizer authorizer = (Authorizer)WebApplicationContextUtils.getWebApplicationContext(getServletContext()).getBean("authorizer");
        User user = new User();
        user.setUsername((String)req.getSession().getAttribute(Constants.SESSION_KEY_USERNAME));
        user.setRoles((Set<Constants.Role>)req.getSession().getAttribute(Constants.SESSION_KEY_ROLES));
        try
        {
            isAuthorized = authorizer.isAuthorized(user, action);
        }
        catch (Exception e)
View Full Code Here

    @Override
    public boolean authenticate(String username, String password)
    {
        boolean isAuthSuccess = false;
        User user = userDAO.findActiveUserByUsername(username);
        if (null != user)
        {
            isAuthSuccess = authenticator.authenticate(username, password);
            if (!isWhitelistUser(username))
            {
                if (!isAuthSuccess)
                {
                    UserLockout lockout = userLockoutDAO.findByUser(user);
                    lockout = (null == lockout) ? new UserLockout(user, 0) : lockout;
                    int failCount = lockout.getFailCount() + 1;
                    if (failCount >= failedLoginThreshold)
                    {
                        lockout.setFailCount(0);
                        user.setActiveFlag(false);
                        LOG.debug("UserLockoutAuthenticator: "+username+" is locked out");
                        auditLogger.log(new Date(), username, ServerSessionUtil.getIP(), "lockout", username, true, "user disabled");
                    }
                    else
                    {
View Full Code Here

TOP

Related Classes of net.webpasswordsafe.common.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.