首页 > 解决方案 > 从我的数据库中检索权限始终为空

问题描述

我遇到了一个问题,一切都正常工作,例如角色和身份验证。但是,我的开发已经停止,因为我无法获得帐户的权限。权限总是返回 null,我不知道为什么。

DefaultSecurityManager defaultSecurityManager = new DefaultSecurityManager();
ModularRealmAuthenticator authenticator = new ModularRealmAuthenticator();
authenticator.setAuthenticationStrategy(new AtLeastOneSuccessfulStrategy());
defaultSecurityManager.setAuthenticator(authenticator);
ModularRealmAuthorizer authorizer = new ModularRealmAuthorizer();
authorizer.setPermissionResolver(new WildcardPermissionResolver());
defaultSecurityManager.setAuthorizer(authorizer);
JdbcRealm realm = new JdbcRealm();
realm.setDataSource(DatabaseUtil.DATA_SOURCE);
realm.setAuthenticationQuery("SELECT password FROM account WHERE username = ?");
realm.setUserRolesQuery("SELECT accountRole FROM account WHERE username = ?");
realm.setPermissionsQuery("SELECT permissions FROM account WHERE username = ?");
realm.setPermissionsLookupEnabled(true);
realm.setCredentialsMatcher(new PasswordMatcher());
defaultSecurityManager.setRealm(realm);
SecurityUtils.setSecurityManager(defaultSecurityManager);

标签: javashiro

解决方案


推荐阅读