本文整理汇总了Java中org.apache.shiro.authz.permission.RolePermissionResolver类的典型用法代码示例。如果您正苦于以下问题:Java RolePermissionResolver类的具体用法?Java RolePermissionResolver怎么用?Java RolePermissionResolver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RolePermissionResolver类属于org.apache.shiro.authz.permission包,在下文中一共展示了RolePermissionResolver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ClothoRealm
import org.apache.shiro.authz.permission.RolePermissionResolver; //导入依赖的package包/类
@Inject
public ClothoRealm(CredentialStore store, RolePermissionResolver roleResolver) {
super();
//XXX: up number of iterations
HashedCredentialsMatcher matcher = new HashedCredentialsMatcher(Sha256Hash.ALGORITHM_NAME);
matcher.setStoredCredentialsHexEncoded(false);
this.store = store;
setAuthenticationTokenClass(UsernamePasswordToken.class);
setCredentialsMatcher(matcher);
setRolePermissionResolver(roleResolver);
setUpRealm();
}
示例2: resolveRolePermissions
import org.apache.shiro.authz.permission.RolePermissionResolver; //导入依赖的package包/类
private Collection<Permission> resolveRolePermissions(
Collection<String> roleNames) {
Collection<Permission> perms = Collections.emptySet();
RolePermissionResolver resolver = getRolePermissionResolver();
if (resolver != null && !CollectionUtils.isEmpty(roleNames)) {
perms = new LinkedHashSet<Permission>(roleNames.size());
for (String roleName : roleNames) {
Collection<Permission> resolved = resolver
.resolvePermissionsInRole(roleName);
if (!CollectionUtils.isEmpty(resolved)) {
perms.addAll(resolved);
}
}
}
return perms;
}
示例3: start
import org.apache.shiro.authz.permission.RolePermissionResolver; //导入依赖的package包/类
@BeforeClass
public static void start() throws Exception {
securityManager = new DefaultSecurityManager();
SecurityUtils.setSecurityManager(securityManager);
realm = new SimpleAccountRealm("test-realm");
realm.addRole("role");
realm.addAccount("foo", "bar", "role");
realm.addAccount("bilbo", "precious", "hobbit");
realm.setRolePermissionResolver(new RolePermissionResolver() {
public Collection<Permission> resolvePermissionsInRole(String roleString) {
if ("role".equals(roleString)) {
final Permission dp = new WildcardPermission("permission");
return Arrays.asList(dp);
}
return Collections.emptyList();
}
});
securityManager.setRealm(realm);
}
示例4: createRolePermissionResolver
import org.apache.shiro.authz.permission.RolePermissionResolver; //导入依赖的package包/类
private RolePermissionResolver createRolePermissionResolver() {
return new RolePermissionResolver () {
@Override
public Collection<Permission> resolvePermissionsInRole(String role) {
return getRolePermissions(role);
}
};
}
示例5: resolveRolePermissions
import org.apache.shiro.authz.permission.RolePermissionResolver; //导入依赖的package包/类
/**
* 此方法 Copy 自父类,没有改变任何代码
* @param roleNames
* @return
*/
private Collection<Permission> resolveRolePermissions(Collection<String> roleNames) {
Collection<Permission> perms = Collections.emptySet();
RolePermissionResolver resolver = getRolePermissionResolver();
if (resolver != null && !CollectionUtils.isEmpty(roleNames)) {
perms = new LinkedHashSet<>(roleNames.size());
for (String roleName : roleNames) {
Collection<Permission> resolved = resolver.resolvePermissionsInRole(roleName);
if (!CollectionUtils.isEmpty(resolved)) {
perms.addAll(resolved);
}
}
}
return perms;
}
示例6: ExceptionCatchingModularRealmAuthorizer
import org.apache.shiro.authz.permission.RolePermissionResolver; //导入依赖的package包/类
@Inject
public ExceptionCatchingModularRealmAuthorizer(final Collection<Realm> realms,
final Provider<RolePermissionResolver> rolePermissionResolverProvider)
{
this.rolePermissionResolverProvider = rolePermissionResolverProvider;
setRealms(realms);
}
示例7: setUp
import org.apache.shiro.authz.permission.RolePermissionResolver; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
realm = (AuthorizingRealmImpl) lookup(Realm.class, AuthorizingRealmImpl.NAME);
realm.setRolePermissionResolver(this.lookup(RolePermissionResolver.class));
configurationManager = lookup(SecurityConfigurationManagerImpl.class);
}
示例8: getRolePermissionResolver
import org.apache.shiro.authz.permission.RolePermissionResolver; //导入依赖的package包/类
@Override
public RolePermissionResolver getRolePermissionResolver() {
return rolePermissionResolverProvider != null ? rolePermissionResolverProvider.get() : null;
}
示例9: setRolePermissionResolver
import org.apache.shiro.authz.permission.RolePermissionResolver; //导入依赖的package包/类
@Override
public void setRolePermissionResolver(RolePermissionResolver rpr) {
// TODO Auto-generated method stub
}
示例10: configure
import org.apache.shiro.authz.permission.RolePermissionResolver; //导入依赖的package包/类
@Override
protected void configure() {
bind(ClothoConnection.class).to(JongoConnection.class);
bind(CredentialStore.class).to(JongoConnection.class);
bind(RolePermissionResolver.class).to(JongoConnection.class);
}
示例11: onInit
import org.apache.shiro.authz.permission.RolePermissionResolver; //导入依赖的package包/类
@Override
public void onInit() {
if (LOG.isTraceEnabled()) {
LOG.trace("Initializing the '"
+ MapDbAuthorizingRealm.class.getSimpleName() + "'.");
}
super.onInit();
// create the maker of the database and create it
final DBMaker<?> maker = DBMaker.newFileDB(location);
maker.cacheHardRefEnable();
maker.cacheLRUEnable();
maker.cacheSize(1000);
maker.closeOnJvmShutdown();
db = maker.make();
// create the maker for the specific maps of users and roles
final HTreeMapMaker usersMapMaker = db.createHashMap("users");
final HTreeMapMaker rolesMapMaker = db.createHashMap("roles");
this.users = usersMapMaker.makeOrGet();
this.roles = rolesMapMaker.makeOrGet();
// disable any caching
setCachingEnabled(false);
setCacheManager(null);
// add a role resolver
setRolePermissionResolver(new RolePermissionResolver() {
@Override
public Collection<Permission> resolvePermissionsInRole(
final String role) {
final SimpleRole r = roles.get(role);
if (r == null) {
return null;
} else {
return r.getPermissions();
}
}
});
checkAdministrator();
}
示例12: applyRolePermissionResolverToRealms
import org.apache.shiro.authz.permission.RolePermissionResolver; //导入依赖的package包/类
/**
* Sets the internal {@link #getRolePermissionResolver} on any internal configured
* {@link #getRealms Realms} that implement the {@link org.apache.shiro.authz.permission.RolePermissionResolverAware RolePermissionResolverAware} interface.
* <p/>
* This method is called after setting a rolePermissionResolver on this ModularRealmAuthorizer via the
* {@link #setRolePermissionResolver(org.apache.shiro.authz.permission.RolePermissionResolver) setRolePermissionResolver} method.
* <p/>
* It is also called after setting one or more realms via the {@link #setRealms setRealms} method to allow these
* newly available realms to be given the <code>RolePermissionResolver</code> already in use.
*
* @since 1.0
*/
protected void applyRolePermissionResolverToRealms() {
RolePermissionResolver resolver = getRolePermissionResolver();
Collection<Realm> realms = getRealms();
if (resolver != null && realms != null && !realms.isEmpty()) {
for (Realm realm : realms) {
if (realm instanceof RolePermissionResolverAware) {
((RolePermissionResolverAware) realm).setRolePermissionResolver(resolver);
}
}
}
}
示例13: getRolePermissionResolver
import org.apache.shiro.authz.permission.RolePermissionResolver; //导入依赖的package包/类
/**
* Returns the RolePermissionResolver to be used on <em>all</em> configured realms, or <code>null</code (the default)
* if all realm instances will each configure their own permission resolver.
*
* @return the RolePermissionResolver to be used on <em>all</em> configured realms, or <code>null</code (the default)
* if realm instances will each configure their own role permission resolver.
* @since 1.0
*/
public RolePermissionResolver getRolePermissionResolver() {
return this.rolePermissionResolver;
}
示例14: setRolePermissionResolver
import org.apache.shiro.authz.permission.RolePermissionResolver; //导入依赖的package包/类
/**
* Sets the specified {@link RolePermissionResolver RolePermissionResolver} on <em>all</em> of the wrapped realms that
* implement the {@link org.apache.shiro.authz.permission.RolePermissionResolverAware PermissionResolverAware} interface.
* <p/>
* Only call this method if you want the permission resolver to be passed to all realms that implement the
* <code>RolePermissionResolver</code> interface. If you do not want this to occur, the realms must
* configure themselves individually (or be configured individually).
*
* @param rolePermissionResolver the rolePermissionResolver to set on all of the wrapped realms that implement the
* {@link org.apache.shiro.authz.permission.RolePermissionResolverAware RolePermissionResolverAware} interface.
*/
public void setRolePermissionResolver(RolePermissionResolver rolePermissionResolver) {
this.rolePermissionResolver = rolePermissionResolver;
applyRolePermissionResolverToRealms();
}
示例15: getRolePermissionResolver
import org.apache.shiro.authz.permission.RolePermissionResolver; //导入依赖的package包/类
/**
* Overridden because the OpalSecurityManager sets {@code this} as the {@code RolePermissionResolver} on all configured
* realms. This results the following object graph:
* <p/>
* <pre>
* AuthorizingReam.rolePermissionResolver -> MicaAuthorizingRealm (this)
* ^
* |
* MicaAuthorizingRealm.rolePermissionResolver -> GroupPermissionResolver
*
* <pre>
* By overriding this method, we prevent an infinite loop from occurring when
* {@code getRolePermissionResolver().resolvePermissionsInRole()} is called.
*/
@Override
public RolePermissionResolver getRolePermissionResolver() {
return rolePermissionResolver;
}