use of com.sequenceiq.cloudbreak.common.model.user.IdentityUser in project cloudbreak by hortonworks.
the class SecurityGroupController method getPublic.
@Override
public SecurityGroupResponse getPublic(String name) {
IdentityUser user = authenticatedUserService.getCbUser();
SecurityGroup securityGroup = securityGroupService.getPublicSecurityGroup(name, user);
return convert(securityGroup);
}
use of com.sequenceiq.cloudbreak.common.model.user.IdentityUser in project cloudbreak by hortonworks.
the class SecurityGroupController method getPublics.
@Override
public Set<SecurityGroupResponse> getPublics() {
IdentityUser user = authenticatedUserService.getCbUser();
Set<SecurityGroup> securityGroups = securityGroupService.retrieveAccountSecurityGroups(user);
return convert(securityGroups);
}
use of com.sequenceiq.cloudbreak.common.model.user.IdentityUser in project cloudbreak by hortonworks.
the class SecurityGroupController method getPrivates.
@Override
public Set<SecurityGroupResponse> getPrivates() {
IdentityUser user = authenticatedUserService.getCbUser();
Set<SecurityGroup> securityGroups = securityGroupService.retrievePrivateSecurityGroups(user);
return convert(securityGroups);
}
use of com.sequenceiq.cloudbreak.common.model.user.IdentityUser in project cloudbreak by hortonworks.
the class OwnerBasedPermissionEvaluator method hasPermission.
@Override
public boolean hasPermission(Authentication authentication, Object target, Object permission) {
Permission p = Permission.valueOf(permission.toString().toUpperCase());
if (target == null) {
return false;
}
OAuth2Authentication oauth = (OAuth2Authentication) authentication;
if (oauth.getUserAuthentication() == null) {
return oauth.getOAuth2Request().getScope().contains(AUTO_SCALE_SCOPE);
}
IdentityUser user = userDetailsService.getDetails((String) authentication.getPrincipal(), UserFilterField.USERNAME);
Collection<?> targets = target instanceof Collection ? (Collection<?>) target : Collections.singleton(target);
return targets.stream().allMatch(t -> {
try {
return hasPermission(user, p, t);
} catch (IllegalAccessException e) {
LOGGER.error("Object doesn't have properties to check permission with class: " + t.getClass().getCanonicalName(), e);
return false;
}
});
}
use of com.sequenceiq.cloudbreak.common.model.user.IdentityUser in project cloudbreak by hortonworks.
the class ScimAccountGroupReaderFilter method doFilterInternal.
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (authentication != null) {
OAuth2Authentication oauth = (OAuth2Authentication) authentication;
if (oauth.getUserAuthentication() != null) {
String username = (String) authentication.getPrincipal();
IdentityUser user = userDetailsService.getDetails(username, UserFilterField.USERNAME);
request.setAttribute("user", user);
}
}
filterChain.doFilter(request, response);
}
Aggregations