當前位置: 首頁>>代碼示例>>Java>>正文


Java SimpleAuthorizationInfo.setObjectPermissions方法代碼示例

本文整理匯總了Java中org.apache.shiro.authz.SimpleAuthorizationInfo.setObjectPermissions方法的典型用法代碼示例。如果您正苦於以下問題:Java SimpleAuthorizationInfo.setObjectPermissions方法的具體用法?Java SimpleAuthorizationInfo.setObjectPermissions怎麽用?Java SimpleAuthorizationInfo.setObjectPermissions使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.shiro.authz.SimpleAuthorizationInfo的用法示例。


在下文中一共展示了SimpleAuthorizationInfo.setObjectPermissions方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: doGetAuthorizationInfo

import org.apache.shiro.authz.SimpleAuthorizationInfo; //導入方法依賴的package包/類
/**
 * {@inheritDoc}
 * <p>This default implementation handles built-in groups (all, anonymous, registered, etc.), delegating
 * to loadAuthorizationInfo method the actual loading of application-specific groups.</p>
 *
 * @return
 */
public AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
    Object principal = principals.getPrimaryPrincipal();
    Set<String> groups = new HashSet<String>();
    groups.add(SecurityLogic.getAllGroup(portofinoConfiguration));
    if (principal == null) {
        groups.add(SecurityLogic.getAnonymousGroup(portofinoConfiguration));
    } else if (principal instanceof Serializable) {
        groups.add(SecurityLogic.getRegisteredGroup(portofinoConfiguration));
        groups.addAll(loadAuthorizationInfo((Serializable) principal));
    } else {
        throw new AuthorizationException("Invalid principal: " + principal);
    }

    SimpleAuthorizationInfo info = new SimpleAuthorizationInfo(groups);
    if(groups.contains(SecurityLogic.getAdministratorsGroup(portofinoConfiguration))) {
        info.addStringPermission("*");
    }
    Permission permission = new GroupPermission(groups);
    info.setObjectPermissions(Collections.singleton(permission));
    return info;
}
 
開發者ID:ManyDesigns,項目名稱:Portofino,代碼行數:29,代碼來源:AbstractPortofinoRealm.java

示例2: doGetAuthorizationInfo

import org.apache.shiro.authz.SimpleAuthorizationInfo; //導入方法依賴的package包/類
@Override
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals)
{
    Set<String> roles = Sets.newHashSet("user");
    Set<Permission> permissions = Sets.newHashSet();
    Collection<AllowAllUser> principalsCollection = principals.byType(AllowAllUser.class);

    if (principalsCollection.isEmpty()) {
        throw new AuthorizationException("No principals!");
    }

    for (AllowAllUser user : principalsCollection) {
        for (UserGroup userGroup : groups) {
            if (userGroup.representedByGroupStrings(user.getGroups())) {
                permissions.addAll(userGroup.getPermissions());
                break;
            }
        }
    }

    SimpleAuthorizationInfo authorizationInfo = new SimpleAuthorizationInfo(roles);
    authorizationInfo.setObjectPermissions(permissions);

    return authorizationInfo;
}
 
開發者ID:airbnb,項目名稱:airpal,代碼行數:26,代碼來源:AllowAllRealm.java

示例3: doGetAuthorizationInfo

import org.apache.shiro.authz.SimpleAuthorizationInfo; //導入方法依賴的package包/類
@Override
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals)
{
    Set<String> roles = Sets.newHashSet("user");
    Set<Permission> permissions = Sets.newHashSet();

    Collection<AllowAllUser> principalsCollection = principals.byType(AllowAllUser.class);

    if (principalsCollection.isEmpty()) {
        throw new AuthorizationException("No principals!");
    }

    for (AllowAllUser user : principalsCollection) {
        for (UserGroup userGroup : groups) {
            if (userGroup.representedByGroupStrings(user.getGroups())) {
                permissions.addAll(userGroup.getPermissions());
                break;
            }
        }
    }

    SimpleAuthorizationInfo authorizationInfo = new SimpleAuthorizationInfo(roles);
    authorizationInfo.setObjectPermissions(permissions);

    return authorizationInfo;
}
 
開發者ID:airbnb,項目名稱:airpal,代碼行數:27,代碼來源:ExampleLDAPRealm.java


注:本文中的org.apache.shiro.authz.SimpleAuthorizationInfo.setObjectPermissions方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。