当前位置: 首页>>代码示例>>Java>>正文


Java UserDao类代码示例

本文整理汇总了Java中org.bubblecloud.ilves.security.UserDao的典型用法代码示例。如果您正苦于以下问题:Java UserDao类的具体用法?Java UserDao怎么用?Java UserDao使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


UserDao类属于org.bubblecloud.ilves.security包,在下文中一共展示了UserDao类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: enter

import org.bubblecloud.ilves.security.UserDao; //导入依赖的package包/类
@Override
public final void enter(final String parameters) {
    final String userId = parameters;
    final EntityManager entityManager = getSite().getSiteContext().getObject(EntityManager.class);

    final User user = UserDao.getUser(entityManager, userId);

    if (user != null) {
        user.setEmailAddressValidated(true);
        SecurityService.updateUser(getSite().getSiteContext(), user);
        Notification.show(getSite().localize("message-email-verification.success"),
                Notification.Type.HUMANIZED_MESSAGE);
    } else {
        Notification.show(getSite().localize("message-email-verification.error"),
                Notification.Type.WARNING_MESSAGE);
    }

}
 
开发者ID:bubblecloud,项目名称:ilves,代码行数:19,代码来源:EmailValidationViewlet.java

示例2: saveGroupMatrix

import org.bubblecloud.ilves.security.UserDao; //导入依赖的package包/类
private void saveGroupMatrix() {
    final EntityManager entityManager = Site.getCurrent().getSiteContext().getObject(EntityManager.class);
    final Company company = Site.getCurrent().getSiteContext().getObject(Company.class);

    final List<Group> groups = UserDao.getGroups(entityManager, company);

    for (int i = 0; i < privilegeKeys.length; i++) {
        for (int j = 0; j < groups.size(); j++) {
            final int checkBoxIndex = i + j * privilegeKeys.length;
            final boolean privileged = groupCheckBoxes[checkBoxIndex].getValue();
            final boolean privilegedInDatabase =
                    UserDao.hasGroupPrivilege(entityManager, groups.get(j), privilegeKeys[i], dataId);
            if (privileged && !privilegedInDatabase) {
                SecurityService.addGroupPrivilege(getSite().getSiteContext(), groups.get(j), privilegeKeys[i], null, dataId, null);
            } else if (!privileged && privilegedInDatabase) {
                SecurityService.removeGroupPrivilege(getSite().getSiteContext(), groups.get(j), privilegeKeys[i],  null, dataId, null);
            }
        }
    }

    refreshGroupMatrix();
}
 
开发者ID:bubblecloud,项目名称:ilves,代码行数:23,代码来源:PrivilegesFlowlet.java

示例3: saveUserMatrix

import org.bubblecloud.ilves.security.UserDao; //导入依赖的package包/类
private void saveUserMatrix() {
    if ("true".equals(PropertiesUtil.getProperty("site", "disable-user-asset-permissions"))) {
        return;
    }
    final EntityManager entityManager = Site.getCurrent().getSiteContext().getObject(EntityManager.class);
    final Company company = Site.getCurrent().getSiteContext().getObject(Company.class);

    final List<User> users = UserDao.getUsers(entityManager, company);

    for (int i = 0; i < privilegeKeys.length; i++) {
        for (int j = 0; j < users.size(); j++) {
            final int checkBoxIndex = i + j * privilegeKeys.length;
            final boolean privileged = userCheckBoxes[checkBoxIndex].getValue();
            final boolean privilegedInDatabase =
                    UserDao.hasUserPrivilege(entityManager, users.get(j), privilegeKeys[i], dataId);
            if (privileged && !privilegedInDatabase) {
                SecurityService.addUserPrivilege(getSite().getSiteContext(), users.get(j), privilegeKeys[i], null, dataId, null);
            } else if (!privileged && privilegedInDatabase) {
                SecurityService.removeUserPrivilege(getSite().getSiteContext(), users.get(j), privilegeKeys[i], null, dataId, null);
            }
        }
    }

    refreshUserMatrix();
}
 
开发者ID:bubblecloud,项目名称:ilves,代码行数:26,代码来源:PrivilegesFlowlet.java

示例4: load

import org.bubblecloud.ilves.security.UserDao; //导入依赖的package包/类
public static synchronized void load(final EntityManager entityManager, final Company company, final Group group) {
    if (!groupPrivileges.get(company).containsKey(group)) {
        groupPrivileges.get(company).put(group, new HashMap<String, Set<String>>());
    }
    final List<Privilege> privileges = UserDao.getGroupPrivileges(entityManager, group);
    for (final Privilege privilege : privileges) {
        if (!groupPrivileges.get(company).get(group).containsKey(privilege.getKey())) {
            groupPrivileges.get(company).get(group).put(privilege.getKey(), new HashSet<String>());
        }
        groupPrivileges.get(company).get(group).get(privilege.getKey()).add(privilege.getDataId());
    }
}
 
开发者ID:bubblecloud,项目名称:ilves,代码行数:13,代码来源:PrivilegeCache.java

示例5: enter

import org.bubblecloud.ilves.security.UserDao; //导入依赖的package包/类
/**
 * SiteView constructSite occurred.
 */
@Override
public void enter(final String parameterString) {
    final EntityManager entityManager = getSite().getSiteContext().getObject(EntityManager.class);
    final Company company = getSite().getSiteContext().getObject(Company.class);

    try {
        final VerificationResult verification = OpenIdUtil.getVerificationResult(company.getUrl(), "openidlink");
        final Identifier identifier = verification.getVerifiedId();
        if (identifier != null) {
            final String userEmailAddress = getSite().getSecurityProvider().getUser();
            final User user = UserDao.getUser(entityManager, company, userEmailAddress);
            user.setOpenIdIdentifier(identifier.getIdentifier());
            SecurityService.updateUser(getSite().getSiteContext(), user);
            ((AbstractSiteUI) UI.getCurrent()).redirectTo(company.getUrl(), "account",
                    "OpenID authenticated user as: " + identifier.getIdentifier(),
                    Notification.Type.HUMANIZED_MESSAGE);
        }else {
            ((AbstractSiteUI) UI.getCurrent()).redirectTo(company.getUrl(), "account",
                    "OpenID authentication failed:" + verification.getStatusMsg(),
                    Notification.Type.ERROR_MESSAGE);
        }
    } catch (final Exception exception) {
        LOGGER.error("Error linking OpenID account.", exception);
        ((AbstractSiteUI) UI.getCurrent()).redirectTo(company.getUrl(), "account",
                "Error linking OpenID account.",
                Notification.Type.ERROR_MESSAGE);
    }
}
 
开发者ID:bubblecloud,项目名称:ilves,代码行数:32,代码来源:OpenIdLinkViewlet.java

示例6: enter

import org.bubblecloud.ilves.security.UserDao; //导入依赖的package包/类
/**
 * SiteView constructSite occurred.
 */
@Override
public void enter(final String parameterString) {

    final EntityManager entityManager = getSite().getSiteContext().getObject(EntityManager.class);
    final Company company = getSite().getSiteContext().getObject(Company.class);
    final HttpServletRequest request = ((VaadinServletRequest) VaadinService.getCurrentRequest())
            .getHttpServletRequest();

    try {
        final VerificationResult verification = OpenIdUtil.getVerificationResult(company.getUrl(), "openidlogin");
        final Identifier identifier = verification.getVerifiedId();

        if (identifier == null) {
            ((AbstractSiteUI) UI.getCurrent()).redirectTo(company.getUrl(), "login",
                    getSite().localize("message-login-failed")
                            + ":" + verification.getStatusMsg(),
                    Notification.Type.ERROR_MESSAGE
            );
        }

        final User user = UserDao.getUserByOpenIdIdentifier(entityManager, company, identifier.getIdentifier());

        if (user == null) {
            LOGGER.warn("User OpenID login failed due to not registered Open ID identifier: "
                    + identifier.getIdentifier()
                    + " (IP: " + request.getRemoteHost() + ":" + request.getRemotePort() + ")");
            ((AbstractSiteUI) UI.getCurrent()).redirectTo(company.getUrl(), "login",
                    getSite().localize("message-login-failed"),
                    Notification.Type.WARNING_MESSAGE);
            return;
        }

        if (user.isLockedOut()) {
            LOGGER.warn("User login failed due to user being locked out: " + user.getEmailAddress()
                    + " (IP: " + request.getRemoteHost() + ":" + request.getRemotePort() + ")");
            ((AbstractSiteUI) UI.getCurrent()).redirectTo(company.getUrl(), "login",
                    getSite().localize("message-login-failed"),
                    Notification.Type.WARNING_MESSAGE);
            return;
        }

        LOGGER.info("User login: " + user.getEmailAddress()
                + " (IP: " + request.getRemoteHost() + ":" + request.getRemotePort() + ")");
        AuditService.log(getSite().getSiteContext(), "openid password login");

        final List<Group> groups = UserDao.getUserGroups(entityManager, company, user);

        SecurityService.updateUser(getSite().getSiteContext(), user);

        ((SecurityProviderSessionImpl) getSite().getSecurityProvider()).setUser(user, groups);

        ((AbstractSiteUI) UI.getCurrent()).redirectTo(company.getUrl(),
                getSite().getCurrentNavigationVersion().getDefaultPageName(),
                getSite().localize("message-login-success") + " (" + user.getEmailAddress() + ")",
                Notification.Type.HUMANIZED_MESSAGE);

    } catch (final Exception exception) {
        LOGGER.error("Error logging in OpenID user.", exception);
        ((AbstractSiteUI) UI.getCurrent()).redirectTo(company.getUrl(), "login",
                getSite().localize("message-login-error"),
                Notification.Type.ERROR_MESSAGE);
    }
}
 
开发者ID:bubblecloud,项目名称:ilves,代码行数:67,代码来源:OpenIdLoginViewlet.java


注:本文中的org.bubblecloud.ilves.security.UserDao类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。