use of org.apache.hadoop.security.Groups in project atlas by apache.
the class AtlasAbstractAuthenticationProvider method getAuthoritiesFromUGI.
public static List<GrantedAuthority> getAuthoritiesFromUGI(String userName) {
List<GrantedAuthority> grantedAuths = new ArrayList<GrantedAuthority>();
UserGroupInformation ugi = UserGroupInformation.createRemoteUser(userName);
if (ugi != null) {
String[] userGroups = ugi.getGroupNames();
if (userGroups != null) {
for (String group : userGroups) {
grantedAuths.add(new SimpleGrantedAuthority(group));
}
}
}
// if group empty take groups from UGI LDAP-based group mapping
if (grantedAuths != null && grantedAuths.isEmpty()) {
try {
Configuration config = new Configuration();
Groups gp = new Groups(config);
List<String> userGroups = gp.getGroups(userName);
if (userGroups != null) {
for (String group : userGroups) {
grantedAuths.add(new SimpleGrantedAuthority(group));
}
}
} catch (java.io.IOException e) {
LOG.error("Exception while fetching groups ", e);
}
}
return grantedAuths;
}
use of org.apache.hadoop.security.Groups in project knox by apache.
the class HadoopGroupProviderFilter method init.
@Override
public void init(final FilterConfig filterConfig) throws ServletException {
super.init(filterConfig);
try {
hadoopConfig = new Configuration(false);
if (filterConfig.getInitParameterNames() != null) {
for (final Enumeration<String> keys = filterConfig.getInitParameterNames(); keys.hasMoreElements(); ) {
final String key = keys.nextElement();
hadoopConfig.set(key, filterConfig.getInitParameter(key));
}
}
hadoopGroups = new Groups(hadoopConfig);
} catch (final Exception e) {
throw new ServletException(e);
}
}
use of org.apache.hadoop.security.Groups in project zeppelin by apache.
the class KnoxJwtRealm method onInit.
@Override
protected void onInit() {
super.onInit();
try {
Configuration hadoopConfig = new Configuration();
hadoopGroups = new Groups(hadoopConfig);
} catch (final Exception e) {
LOGGER.error("Exception in onInit", e);
}
}
use of org.apache.hadoop.security.Groups in project incubator-atlas by apache.
the class AtlasAbstractAuthenticationProvider method getAuthoritiesFromUGI.
public static List<GrantedAuthority> getAuthoritiesFromUGI(String userName) {
List<GrantedAuthority> grantedAuths = new ArrayList<GrantedAuthority>();
UserGroupInformation ugi = UserGroupInformation.createRemoteUser(userName);
if (ugi != null) {
String[] userGroups = ugi.getGroupNames();
if (userGroups != null) {
for (String group : userGroups) {
grantedAuths.add(new SimpleGrantedAuthority(group));
}
}
}
// if group empty take groups from UGI LDAP-based group mapping
if (grantedAuths != null && grantedAuths.isEmpty()) {
try {
Configuration config = new Configuration();
Groups gp = new Groups(config);
List<String> userGroups = gp.getGroups(userName);
if (userGroups != null) {
for (String group : userGroups) {
grantedAuths.add(new SimpleGrantedAuthority(group));
}
}
} catch (java.io.IOException e) {
LOG.error("Exception while fetching groups ", e);
}
}
return grantedAuths;
}
Aggregations