use of org.apache.qpid.server.security.auth.manager.oauth2.OAuth2UserPrincipal in project qpid-broker-j by apache.
the class CloudFoundryDashboardManagementGroupProviderImpl method getGroupPrincipalsForUser.
@Override
public Set<Principal> getGroupPrincipalsForUser(Principal userPrincipal) {
if (!(userPrincipal instanceof OAuth2UserPrincipal)) {
return Collections.emptySet();
}
if (_serviceToManagementGroupMapping == null) {
throw new IllegalConfigurationException("CloudFoundryDashboardManagementGroupProvider serviceToManagementGroupMapping may not be null");
}
OAuth2UserPrincipal oauth2UserPrincipal = (OAuth2UserPrincipal) userPrincipal;
String accessToken = oauth2UserPrincipal.getAccessToken();
Set<Principal> groupPrincipals = new HashSet<>();
for (Map.Entry<String, String> entry : _serviceToManagementGroupMapping.entrySet()) {
String serviceInstanceId = entry.getKey();
String managementGroupName = entry.getValue();
if (mayManageServiceInstance(serviceInstanceId, accessToken)) {
LOGGER.debug("Adding group '{}' to the set of Principals", managementGroupName);
groupPrincipals.add(new GroupPrincipal(managementGroupName, this));
} else {
LOGGER.debug("CloudFoundryDashboardManagementEndpoint denied management permission for service instance '{}'", serviceInstanceId);
}
}
return groupPrincipals;
}
Aggregations