@Test public void testAccessGrantedToNotAPIAdmin() throws Exception { VitamThreadUtils.getVitamSession().setTenantId(0); VitamConfiguration.setAdminTenant(1); ContainerRequestContext containerRequestContext = spy(ContainerRequestContext.class); EndpointAdminOnlyAuthorizationFilter instance = new EndpointAdminOnlyAuthorizationFilter(false); instance.filter(containerRequestContext); verify(containerRequestContext, never()).abortWith(any()); }
@Override public void filter(ContainerRequestContext requestContext) throws IOException { int tenantId = VitamThreadUtils.getVitamSession().getTenantId(); if (isAdminOnly && tenantId != VitamConfiguration.getAdminTenant()) { final VitamError vitamError = generateVitamError(); requestContext.abortWith( Response.status(vitamError.getHttpCode()).entity(vitamError).type(MediaType.APPLICATION_JSON_TYPE) .build()); } }
EndpointAdminOnlyAuthorizationFilter implements ContainerRequestFilter { @Override public void filter(ContainerRequestContext requestContext) throws IOException { int tenantId = VitamThreadUtils.getVitamSession().getTenantId(); if (isAdminOnly && tenantId != VitamConfiguration.getAdminTenant()) { final VitamError vitamError = generateVitamError(); requestContext.abortWith( Response.status(vitamError.getHttpCode()).entity(vitamError).type(MediaType.APPLICATION_JSON_TYPE) .build()); } } }
EndpointAdminOnlyAuthorizationFilter implements ContainerRequestFilter { @Override public void filter(ContainerRequestContext requestContext) throws IOException { int tenantId = VitamThreadUtils.getVitamSession().getTenantId(); if (isAdminOnly && tenantId != VitamConfiguration.getAdminTenant()) { final VitamError vitamError = generateVitamError(); requestContext.abortWith( Response.status(vitamError.getHttpCode()).entity(vitamError).type(MediaType.APPLICATION_JSON_TYPE) .build()); } } EndpointAdminOnlyAuthorizationFilter(boolean isAdminOnly); }
EndpointAdminOnlyAuthorizationFilter implements ContainerRequestFilter { @Override public void filter(ContainerRequestContext requestContext) throws IOException { int tenantId = VitamThreadUtils.getVitamSession().getTenantId(); if (isAdminOnly && tenantId != VitamConfiguration.getAdminTenant()) { final VitamError vitamError = generateVitamError(); requestContext.abortWith( Response.status(vitamError.getHttpCode()).entity(vitamError).type(MediaType.APPLICATION_JSON_TYPE) .build()); } } EndpointAdminOnlyAuthorizationFilter(boolean isAdminOnly); @Override void filter(ContainerRequestContext requestContext); }
EndpointAdminOnlyAuthorizationFilter implements ContainerRequestFilter { @Override public void filter(ContainerRequestContext requestContext) throws IOException { int tenantId = VitamThreadUtils.getVitamSession().getTenantId(); if (isAdminOnly && tenantId != VitamConfiguration.getAdminTenant()) { final VitamError vitamError = generateVitamError(); requestContext.abortWith( Response.status(vitamError.getHttpCode()).entity(vitamError).type(MediaType.APPLICATION_JSON_TYPE) .build()); } } EndpointAdminOnlyAuthorizationFilter(boolean isAdminOnly); @Override void filter(ContainerRequestContext requestContext);  }