use of org.apache.shiro.authz.SimpleAuthorizationInfo in project zeppelin by apache.
the class LdapRealm method queryForAuthorizationInfo.
/**
* Get groups from LDAP.
*
* @param principals
* the principals of the Subject whose AuthenticationInfo should
* be queried from the LDAP server.
* @param ldapContextFactory
* factory used to retrieve LDAP connections.
* @return an {@link AuthorizationInfo} instance containing information
* retrieved from the LDAP server.
* @throws NamingException
* if any LDAP errors occur during the search.
*/
@Override
public AuthorizationInfo queryForAuthorizationInfo(final PrincipalCollection principals, final LdapContextFactory ldapContextFactory) throws NamingException {
if (!isAuthorizationEnabled()) {
return null;
}
final Set<String> roleNames = getRoles(principals, ldapContextFactory);
LOGGER.debug("RolesNames Authorization: {}", roleNames);
SimpleAuthorizationInfo simpleAuthorizationInfo = new SimpleAuthorizationInfo(roleNames);
Set<String> stringPermissions = permsFor(roleNames);
simpleAuthorizationInfo.setStringPermissions(stringPermissions);
return simpleAuthorizationInfo;
}
use of org.apache.shiro.authz.SimpleAuthorizationInfo in project zeppelin by apache.
the class LdapGroupRealm method queryForAuthorizationInfo.
@Override
public AuthorizationInfo queryForAuthorizationInfo(PrincipalCollection principals, LdapContextFactory ldapContextFactory) throws NamingException {
String username = (String) getAvailablePrincipal(principals);
LdapContext ldapContext = ldapContextFactory.getSystemLdapContext();
Set<String> roleNames = getRoleNamesForUser(username, ldapContext, getUserDnTemplate());
return new SimpleAuthorizationInfo(roleNames);
}
use of org.apache.shiro.authz.SimpleAuthorizationInfo in project SSM by Intel-bigdata.
the class LdapGroupRealm method queryForAuthorizationInfo.
public AuthorizationInfo queryForAuthorizationInfo(PrincipalCollection principals, LdapContextFactory ldapContextFactory) throws NamingException {
String username = (String) getAvailablePrincipal(principals);
LdapContext ldapContext = ldapContextFactory.getSystemLdapContext();
Set<String> roleNames = getRoleNamesForUser(username, ldapContext, getUserDnTemplate());
return new SimpleAuthorizationInfo(roleNames);
}
use of org.apache.shiro.authz.SimpleAuthorizationInfo in project SSM by Intel-bigdata.
the class LdapRealm method queryForAuthorizationInfo.
/**
* Get groups from LDAP.
*
* @param principals
* the principals of the Subject whose AuthenticationInfo should
* be queried from the LDAP server.
* @param ldapContextFactory
* factory used to retrieve LDAP connections.
* @return an {@link AuthorizationInfo} instance containing information
* retrieved from the LDAP server.
* @throws NamingException
* if any LDAP errors occur during the search.
*/
@Override
protected AuthorizationInfo queryForAuthorizationInfo(final PrincipalCollection principals, final LdapContextFactory ldapContextFactory) throws NamingException {
if (!isAuthorizationEnabled()) {
return null;
}
final Set<String> roleNames = getRoles(principals, ldapContextFactory);
if (log.isDebugEnabled()) {
log.debug("RolesNames Authorization: " + roleNames);
}
SimpleAuthorizationInfo simpleAuthorizationInfo = new SimpleAuthorizationInfo(roleNames);
Set<String> stringPermissions = permsFor(roleNames);
simpleAuthorizationInfo.setStringPermissions(stringPermissions);
return simpleAuthorizationInfo;
}
use of org.apache.shiro.authz.SimpleAuthorizationInfo in project qi4j-sdk by Qi4j.
the class PasswordRealmMixin method doGetAuthorizationInfo.
@Override
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
UnitOfWork uow = module.newUnitOfWork();
try {
String username = getAvailablePrincipal(principals).toString();
RoleAssignee roleAssignee = findRoleAssignee(uow, username);
if (roleAssignee == null) {
LOG.debug("No authorization info for {}", username);
return null;
}
LOG.debug("Found role assignee for {}: {}", username, roleAssignee);
Set<String> roleNames = roleAssignee.roleNames();
Set<String> permissionStrings = roleAssignee.permissionStrings();
LOG.debug("Found role assignee has the following roles: {}", roleNames);
LOG.debug("Found role assignee has the following permissions: {}", permissionStrings);
SimpleAuthorizationInfo atzInfo = new SimpleAuthorizationInfo(roleNames);
atzInfo.setStringPermissions(permissionStrings);
return atzInfo;
} finally {
uow.discard();
}
}
Aggregations