Package net.webpasswordsafe.common.model

Examples of net.webpasswordsafe.common.model.Password


    @Override
    @Transactional(propagation=Propagation.REQUIRED, readOnly=true)
    public boolean isPasswordTaken(String passwordName, String username, long ignorePasswordId)
    {
        boolean isPasswordTaken = false;
        Password password = passwordDAO.findPasswordByName(passwordName, username);
        if (password != null)
        {
            if (password.getId() != ignorePasswordId)
            {
                isPasswordTaken = true;
            }
        }
        return isPasswordTaken;
View Full Code Here


    @Override
    @SuppressWarnings("unchecked")
    public Password findAllowedPasswordById(long passwordId, User user, AccessLevel accessLevel)
    {
        Password foundPassword = null;
        String sqlAccessLevelIn = null;
        switch (accessLevel) {
            case GRANT : sqlAccessLevelIn = "(:aclgrant) "; break;
            case WRITE : sqlAccessLevelIn = "(:aclwrite, :aclgrant) "; break;
            case READ : sqlAccessLevelIn = "(:aclread, :aclwrite, :aclgrant) "; break;
        }
        StringBuilder hqlString = new StringBuilder();
        hqlString.append("select distinct pw.id from Password pw join pw.permissions pm where pw.id = :passwordId ");
        if (!authorizer.isAuthorized(user, Function.BYPASS_PASSWORD_PERMISSIONS.name()))
        {
            hqlString.append(" and pm.accessLevel in ");
            hqlString.append(sqlAccessLevelIn);
            hqlString.append("and ((pm.subject = :user) or (pm.subject in (select g from Group g join g.users u where u = :user)))");
        }
        Query hqlQuery = getSession().createQuery(hqlString.toString());
        hqlQuery.setLong("passwordId", passwordId);
        if (!authorizer.isAuthorized(user, Function.BYPASS_PASSWORD_PERMISSIONS.name()))
        {
            hqlQuery.setEntity("user", user);
            if (accessLevel.equals(AccessLevel.GRANT) || accessLevel.equals(AccessLevel.WRITE) || accessLevel.equals(AccessLevel.READ))
            {
                hqlQuery.setString("aclgrant", AccessLevel.GRANT.name());
            }
            if (accessLevel.equals(AccessLevel.WRITE) || accessLevel.equals(AccessLevel.READ))
            {
                hqlQuery.setString("aclwrite", AccessLevel.WRITE.name());
            }
            if (accessLevel.equals(AccessLevel.READ))
            {
                hqlQuery.setString("aclread", AccessLevel.READ.name());
            }
        }
        List<Long> passwordIds = hqlQuery.list();
        if (passwordIds.size() > 0)
        {
            foundPassword = findById(passwordIds.get(0));
            foundPassword.getPermissions().size();
            foundPassword.getTags().size();
        }
        return foundPassword;
    }
View Full Code Here

TOP

Related Classes of net.webpasswordsafe.common.model.Password

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.