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


Java SimpleAuthorizationInfo.addObjectPermission方法代碼示例

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


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

示例1: doGetAuthorizationInfo

import org.apache.shiro.authz.SimpleAuthorizationInfo; //導入方法依賴的package包/類
@Override
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
	
	final User user = principals.byType(User.class).iterator().next();
	final List<Role> roles = user.getRoles();
	SimpleAuthorizationInfo sai = new SimpleAuthorizationInfo();
	
	for (Role role : roles) {
		sai.addRole(role.name());
	}
	
	if (roles.contains(Role.ADMIN)) {
		sai.addObjectPermission(ALL_PERMISSION);
	}
	else {
		sai.addObjectPermission(new ObjectPermission(principals.oneByType(User.class), objectPermissionChecker));
	}
	
	return sai;
	
}
 
開發者ID:thiagohp,項目名稱:eloquentia,代碼行數:22,代碼來源:EloquentiaRealm.java

示例2: doGetAuthorizationInfo

import org.apache.shiro.authz.SimpleAuthorizationInfo; //導入方法依賴的package包/類
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection) {
    SimpleAuthorizationInfo authorizationInfo = new SimpleAuthorizationInfo();
    authorizationInfo.addRole("role1");
    authorizationInfo.addRole("role2");
    authorizationInfo.addObjectPermission(new BitPermission("+user1+10"));
    authorizationInfo.addObjectPermission(new WildcardPermission("user1:*"));
    authorizationInfo.addStringPermission("+user2+10");
    authorizationInfo.addStringPermission("user2:*");
    return authorizationInfo;
}
 
開發者ID:l81893521,項目名稱:shiro-demo,代碼行數:11,代碼來源:MyRealm.java

示例3: testIsPermitted_true

import org.apache.shiro.authz.SimpleAuthorizationInfo; //導入方法依賴的package包/類
@Test
public void testIsPermitted_true() {
  final ShiroPermissionResolver resolver = new ShiroPermissionResolver();
  UserSourceRealm realm = new UserSourceRealm(_userSource) {
    @Override
    protected AuthorizationInfo getAuthorizationInfo(PrincipalCollection principals) {
      SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
      info.addObjectPermission(resolver.resolvePermission("Master:view"));
      return info;
    }
  };
  realm.setPermissionResolver(resolver);
  assertEquals(true, realm.isPermitted(PRINCIPALS, "Master:view"));
}
 
開發者ID:DevStreet,項目名稱:FinanceAnalytics,代碼行數:15,代碼來源:UserSourceRealmTest.java

示例4: testIsPermitted_false

import org.apache.shiro.authz.SimpleAuthorizationInfo; //導入方法依賴的package包/類
@Test
public void testIsPermitted_false() {
  final ShiroPermissionResolver resolver = new ShiroPermissionResolver();
  UserSourceRealm realm = new UserSourceRealm(_userSource) {
    @Override
    protected AuthorizationInfo getAuthorizationInfo(PrincipalCollection principals) {
      SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
      info.addObjectPermission(resolver.resolvePermission("Master:view"));
      return info;
    }
  };
  realm.setPermissionResolver(resolver);
  assertEquals(false, realm.isPermitted(PRINCIPALS, "Master:edit"));
}
 
開發者ID:DevStreet,項目名稱:FinanceAnalytics,代碼行數:15,代碼來源:UserSourceRealmTest.java

示例5: testIsPermitted_otherType

import org.apache.shiro.authz.SimpleAuthorizationInfo; //導入方法依賴的package包/類
@Test
public void testIsPermitted_otherType() {
  final ShiroPermissionResolver resolver = new ShiroPermissionResolver();
  UserSourceRealm realm = new UserSourceRealm(_userSource) {
    @Override
    protected AuthorizationInfo getAuthorizationInfo(PrincipalCollection principals) {
      SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
      info.addObjectPermission(resolver.resolvePermission("Master:view"));
      return info;
    }
  };
  realm.setPermissionResolver(resolver);
  assertEquals(false, realm.isPermitted(PRINCIPALS, PERMISSION_OTHER_TYPE));
}
 
開發者ID:DevStreet,項目名稱:FinanceAnalytics,代碼行數:15,代碼來源:UserSourceRealmTest.java

示例6: testIsPermittedAll_none

import org.apache.shiro.authz.SimpleAuthorizationInfo; //導入方法依賴的package包/類
@Test
public void testIsPermittedAll_none() {
  final ShiroPermissionResolver resolver = new ShiroPermissionResolver();
  UserSourceRealm realm = new UserSourceRealm(_userSource) {
    @Override
    protected AuthorizationInfo getAuthorizationInfo(PrincipalCollection principals) {
      SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
      info.addObjectPermission(resolver.resolvePermission("Master:view"));
      info.addObjectPermission(resolver.resolvePermission("Source:view"));
      return info;
    }
  };
  realm.setPermissionResolver(resolver);
  assertEquals(true, realm.isPermittedAll(PRINCIPALS));
}
 
開發者ID:DevStreet,項目名稱:FinanceAnalytics,代碼行數:16,代碼來源:UserSourceRealmTest.java

示例7: testIsPermittedAll_true

import org.apache.shiro.authz.SimpleAuthorizationInfo; //導入方法依賴的package包/類
@Test
public void testIsPermittedAll_true() {
  final ShiroPermissionResolver resolver = new ShiroPermissionResolver();
  UserSourceRealm realm = new UserSourceRealm(_userSource) {
    @Override
    protected AuthorizationInfo getAuthorizationInfo(PrincipalCollection principals) {
      SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
      info.addObjectPermission(resolver.resolvePermission("Master:view"));
      info.addObjectPermission(resolver.resolvePermission("Source:view"));
      return info;
    }
  };
  realm.setPermissionResolver(resolver);
  assertEquals(true, realm.isPermittedAll(PRINCIPALS, "Master:view", "Source:view"));
}
 
開發者ID:DevStreet,項目名稱:FinanceAnalytics,代碼行數:16,代碼來源:UserSourceRealmTest.java

示例8: testIsPermittedAll_false

import org.apache.shiro.authz.SimpleAuthorizationInfo; //導入方法依賴的package包/類
@Test
public void testIsPermittedAll_false() {
  final ShiroPermissionResolver resolver = new ShiroPermissionResolver();
  UserSourceRealm realm = new UserSourceRealm(_userSource) {
    @Override
    protected AuthorizationInfo getAuthorizationInfo(PrincipalCollection principals) {
      SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
      info.addObjectPermission(resolver.resolvePermission("Master:view"));
      info.addObjectPermission(resolver.resolvePermission("Source:view"));
      return info;
    }
  };
  realm.setPermissionResolver(resolver);
  assertEquals(false, realm.isPermittedAll(PRINCIPALS, "Master:view", "Source:edit"));
}
 
開發者ID:DevStreet,項目名稱:FinanceAnalytics,代碼行數:16,代碼來源:UserSourceRealmTest.java

示例9: testCheckPermission_true

import org.apache.shiro.authz.SimpleAuthorizationInfo; //導入方法依賴的package包/類
@Test
public void testCheckPermission_true() {
  final ShiroPermissionResolver resolver = new ShiroPermissionResolver();
  UserSourceRealm realm = new UserSourceRealm(_userSource) {
    @Override
    protected AuthorizationInfo getAuthorizationInfo(PrincipalCollection principals) {
      SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
      info.addObjectPermission(resolver.resolvePermission("Master:view"));
      return info;
    }
  };
  realm.setPermissionResolver(resolver);
  realm.checkPermission(PRINCIPALS, "Master:view");
}
 
開發者ID:DevStreet,項目名稱:FinanceAnalytics,代碼行數:15,代碼來源:UserSourceRealmTest.java

示例10: testCheckPermission_false

import org.apache.shiro.authz.SimpleAuthorizationInfo; //導入方法依賴的package包/類
@Test(expectedExceptions = UnauthorizedException.class)
public void testCheckPermission_false() {
  final ShiroPermissionResolver resolver = new ShiroPermissionResolver();
  UserSourceRealm realm = new UserSourceRealm(_userSource) {
    @Override
    protected AuthorizationInfo getAuthorizationInfo(PrincipalCollection principals) {
      SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
      info.addObjectPermission(resolver.resolvePermission("Master:view"));
      return info;
    }
  };
  realm.setPermissionResolver(resolver);
  realm.checkPermission(PRINCIPALS, "Master:edit");
}
 
開發者ID:DevStreet,項目名稱:FinanceAnalytics,代碼行數:15,代碼來源:UserSourceRealmTest.java

示例11: testCheckPermission_otherType

import org.apache.shiro.authz.SimpleAuthorizationInfo; //導入方法依賴的package包/類
@Test(expectedExceptions = UnauthorizedException.class)
public void testCheckPermission_otherType() {
  final ShiroPermissionResolver resolver = new ShiroPermissionResolver();
  UserSourceRealm realm = new UserSourceRealm(_userSource) {
    @Override
    protected AuthorizationInfo getAuthorizationInfo(PrincipalCollection principals) {
      SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
      info.addObjectPermission(resolver.resolvePermission("Master:view"));
      return info;
    }
  };
  realm.setPermissionResolver(resolver);
  realm.checkPermission(PRINCIPALS, PERMISSION_OTHER_TYPE);
}
 
開發者ID:DevStreet,項目名稱:FinanceAnalytics,代碼行數:15,代碼來源:UserSourceRealmTest.java

示例12: testCheckPermissions_true

import org.apache.shiro.authz.SimpleAuthorizationInfo; //導入方法依賴的package包/類
@Test
public void testCheckPermissions_true() {
  final ShiroPermissionResolver resolver = new ShiroPermissionResolver();
  UserSourceRealm realm = new UserSourceRealm(_userSource) {
    @Override
    protected AuthorizationInfo getAuthorizationInfo(PrincipalCollection principals) {
      SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
      info.addObjectPermission(resolver.resolvePermission("Master:view"));
      info.addObjectPermission(resolver.resolvePermission("Source:view"));
      return info;
    }
  };
  realm.setPermissionResolver(resolver);
  realm.checkPermissions(PRINCIPALS, "Master:view", "Source:view");
}
 
開發者ID:DevStreet,項目名稱:FinanceAnalytics,代碼行數:16,代碼來源:UserSourceRealmTest.java

示例13: testCheckPermissions_false

import org.apache.shiro.authz.SimpleAuthorizationInfo; //導入方法依賴的package包/類
@Test(expectedExceptions = UnauthorizedException.class)
public void testCheckPermissions_false() {
  final ShiroPermissionResolver resolver = new ShiroPermissionResolver();
  UserSourceRealm realm = new UserSourceRealm(_userSource) {
    @Override
    protected AuthorizationInfo getAuthorizationInfo(PrincipalCollection principals) {
      SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
      info.addObjectPermission(resolver.resolvePermission("Master:view"));
      info.addObjectPermission(resolver.resolvePermission("Source:view"));
      return info;
    }
  };
  realm.setPermissionResolver(resolver);
  realm.checkPermissions(PRINCIPALS, "Master:view", "Source:edit");
}
 
開發者ID:DevStreet,項目名稱:FinanceAnalytics,代碼行數:16,代碼來源:UserSourceRealmTest.java

示例14: doGetAuthorizationInfo

import org.apache.shiro.authz.SimpleAuthorizationInfo; //導入方法依賴的package包/類
@Override
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
  SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
  info.addObjectPermission(new AllPermission());
  return info;
}
 
開發者ID:DevStreet,項目名稱:FinanceAnalytics,代碼行數:7,代碼來源:PermissiveSecurityManager.java


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