@Test public void testMissingAuthToken() throws URISyntaxException { try { subject.filter(buildRequest("", new MultivaluedHashMap<>())); fail("Exception expected"); } catch (WebApplicationException e) { assertThat(Response.Status.UNAUTHORIZED.getStatusCode(), is(e.getResponse().getStatus())); assertThat(ErrorCode.MISSING_AUTH_TOKEN.getCode(), is(((ApiError) e.getResponse().getEntity()).getCode())); } }
@Override public void filter(ContainerRequestContext requestContext) { ContainerRequest request = (ContainerRequest) requestContext; try { checkCallAuthorization(request); String requestPath = request.getPath(true); if (!AvailableRoutes.API_PATH.equals(requestPath)) { logger.info("Allow: API call: {}", requestPath); } } catch (ExternalException e) { logger.warn("Deny: API call: {}", request.getPath(true), e); throw new WebApplicationException(e.getCause(), Responses.externalException(e)); } }
AuthFilter implements ContainerRequestFilter { @Override public void filter(ContainerRequestContext requestContext) { ContainerRequest request = (ContainerRequest) requestContext; try { checkCallAuthorization(request); String requestPath = request.getPath(true); if (!AvailableRoutes.API_PATH.equals(requestPath)) { logger.info("Allow: API call: {}", requestPath); } } catch (ExternalException e) { logger.warn("Deny: API call: {}", request.getPath(true), e); throw new WebApplicationException(e.getCause(), Responses.externalException(e)); } } }
AuthFilter implements ContainerRequestFilter { @Override public void filter(ContainerRequestContext requestContext) { ContainerRequest request = (ContainerRequest) requestContext; try { checkCallAuthorization(request); String requestPath = request.getPath(true); if (!AvailableRoutes.API_PATH.equals(requestPath)) { logger.info("Allow: API call: {}", requestPath); } } catch (ExternalException e) { logger.warn("Deny: API call: {}", request.getPath(true), e); throw new WebApplicationException(e.getCause(), Responses.externalException(e)); } } @Inject  AuthFilter(AuthConfig config, com.vmware.photon.controller.api.frontend.auth.AuthPolicyProvider provider); }
AuthFilter implements ContainerRequestFilter { @Override public void filter(ContainerRequestContext requestContext) { ContainerRequest request = (ContainerRequest) requestContext; try { checkCallAuthorization(request); String requestPath = request.getPath(true); if (!AvailableRoutes.API_PATH.equals(requestPath)) { logger.info("Allow: API call: {}", requestPath); } } catch (ExternalException e) { logger.warn("Deny: API call: {}", request.getPath(true), e); throw new WebApplicationException(e.getCause(), Responses.externalException(e)); } } @Inject  AuthFilter(AuthConfig config, com.vmware.photon.controller.api.frontend.auth.AuthPolicyProvider provider); @Override void filter(ContainerRequestContext requestContext); }
AuthFilter implements ContainerRequestFilter { @Override public void filter(ContainerRequestContext requestContext) { ContainerRequest request = (ContainerRequest) requestContext; try { checkCallAuthorization(request); String requestPath = request.getPath(true); if (!AvailableRoutes.API_PATH.equals(requestPath)) { logger.info("Allow: API call: {}", requestPath); } } catch (ExternalException e) { logger.warn("Deny: API call: {}", request.getPath(true), e); throw new WebApplicationException(e.getCause(), Responses.externalException(e)); } } @Inject  AuthFilter(AuthConfig config, com.vmware.photon.controller.api.frontend.auth.AuthPolicyProvider provider); @Override void filter(ContainerRequestContext requestContext); static final String AUTHORIZATION_HEADER; static final String AUTHORIZATION_METHOD; static final String REQUEST_TOKENGROUPS_PROPERTY_NAME; static final String DEFAULT_ADMIN_GROUP_PROPERTY_NAME; }