use of com.hortonworks.streamline.common.exception.service.exception.request.WebserviceAuthorizationException in project streamline by hortonworks.
the class SecurityUtil method checkRole.
public static void checkRole(StreamlineAuthorizer authorizer, SecurityContext securityContext, String... roles) {
Principal principal = securityContext.getUserPrincipal();
AuthenticationContext authenticationCtx = SecurityUtil.getAuthenticationContext(principal);
for (String role : roles) {
if (!authorizer.hasRole(authenticationCtx, role)) {
throw new WebserviceAuthorizationException("Principal: " + principal + " does not have role: " + role);
}
}
}
use of com.hortonworks.streamline.common.exception.service.exception.request.WebserviceAuthorizationException in project streamline by hortonworks.
the class SecurityUtil method checkPermissions.
public static void checkPermissions(StreamlineAuthorizer authorizer, SecurityContext securityContext, String targetEntityNamespace, Long targetEntityId, Permission first, Permission... rest) {
Principal principal = securityContext.getUserPrincipal();
EnumSet<Permission> permissions = EnumSet.of(first, rest);
if (!doCheckPermissions(authorizer, principal, targetEntityNamespace, targetEntityId, permissions)) {
throw new WebserviceAuthorizationException("Principal: " + principal + " does not have permissions: " + permissions + " on namespace: " + targetEntityNamespace + " id: " + targetEntityId);
}
}
use of com.hortonworks.streamline.common.exception.service.exception.request.WebserviceAuthorizationException in project streamline by hortonworks.
the class StreamlineKerberosRequestFilter method filter.
@Override
public void filter(ContainerRequestContext requestContext) throws IOException {
Principal principal = httpRequest.getUserPrincipal();
String scheme = requestContext.getUriInfo().getRequestUri().getScheme();
LOG.debug("Method: {}, AuthType: {}, RemoteUser: {}, UserPrincipal: {}, Scheme: {}", httpRequest.getMethod(), httpRequest.getAuthType(), httpRequest.getRemoteUser(), principal, scheme);
if (principal == null || !httpRequest.getAuthType().equalsIgnoreCase(KERBEROS_AUTH)) {
throw new WebserviceAuthorizationException("Not authorized");
}
SecurityContext securityContext = new StreamlineSecurityContext(principal, scheme, KERBEROS_AUTH);
LOG.debug("SecurityContext {}", securityContext);
requestContext.setSecurityContext(securityContext);
}
use of com.hortonworks.streamline.common.exception.service.exception.request.WebserviceAuthorizationException in project streamline by hortonworks.
the class StreamlineBasicAuthorizationRequestFilter method filter.
@Override
public void filter(ContainerRequestContext requestContext) throws IOException {
Map.Entry<String, String> auth = getAuth(requestContext.getHeaders().getFirst("Authorization"));
if (auth == null) {
throw new WebserviceAuthorizationException("Not authorized");
}
StreamlinePrincipal user = new StreamlinePrincipal(auth.getKey());
LOG.debug("StreamlinePrincipal: {}", user);
String scheme = requestContext.getUriInfo().getRequestUri().getScheme();
requestContext.setSecurityContext(new StreamlineSecurityContext(user, scheme));
}
Aggregations