use of javax.ws.rs.core.Cookie in project simba-os by cegeka.
the class SimbaRoleService method findRoleByName.
public SimbaRoleR findRoleByName(String ssoToken, String rolename) {
ClientResponse clientResponse = getSimbaResource().path("role").path("findAll").accept(MediaType.APPLICATION_JSON).header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).cookie(new Cookie(AuthenticationConstants.SIMBA_SSO_TOKEN, ssoToken)).get(ClientResponse.class);
handleError("findRole", rolename, null, clientResponse, logger);
List<SimbaRoleR> roles = Lists.newArrayList(clientResponse.getEntity(SimbaRoleR[].class));
Optional<SimbaRoleR> result = FluentIterable.from(roles).firstMatch(withRoleName(rolename));
if (!result.isPresent()) {
throw new IllegalArgumentException(String.format("No role found for name %s.", rolename));
} else {
return result.get();
}
}
use of javax.ws.rs.core.Cookie in project simba-os by cegeka.
the class SimbaRoleService method removeRoleFromUser.
public void removeRoleFromUser(String ssoToken, SimbaRoleR simbaRole, SimbaUserR simbaUser) {
checkRoleNotNull(simbaRole);
checkUserNotNull(simbaUser);
RemoveRoleFromUserR postEntity = new RemoveRoleFromUserR(simbaRole, simbaUser);
ClientResponse clientResponse = getSimbaResource().path("role").path("removeUser").header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).cookie(new Cookie(AuthenticationConstants.SIMBA_SSO_TOKEN, ssoToken)).post(ClientResponse.class, postEntity);
handleError("removeRole", simbaRole.getName(), simbaUser.getUserName(), clientResponse, logger);
}
use of javax.ws.rs.core.Cookie in project simba-os by cegeka.
the class SimbaUserService method findUserByName.
public SimbaUserR findUserByName(String ssoToken, String username) {
ClientResponse clientResponse = getSimbaResource().path("user").path("findAll").header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).cookie(new Cookie(AuthenticationConstants.SIMBA_SSO_TOKEN, ssoToken)).get(ClientResponse.class);
handleError("findUser", username, clientResponse, logger);
List<SimbaUserR> users = Lists.newArrayList(clientResponse.getEntity(SimbaUserR[].class));
Optional<SimbaUserR> result = FluentIterable.from(users).firstMatch(withName(username));
if (!result.isPresent()) {
throw new IllegalArgumentException(String.format("No user found for name %s.", username));
} else {
return result.get();
}
}
use of javax.ws.rs.core.Cookie in project jersey by jersey.
the class CookieParamAsPrimitiveTest method _testDefault.
void _testDefault(String base, String type, String value) throws ExecutionException, InterruptedException {
assertEquals("content", apply(RequestContextBuilder.from(base + "default/null", "GET").accept("application/" + type).build()).getEntity());
assertEquals("content", apply(RequestContextBuilder.from(base + "default", "GET").accept("application/" + type).build()).getEntity());
assertEquals("content", apply(RequestContextBuilder.from(base + "default/override", "GET").accept("application/" + type).cookie(new Cookie(type, value)).build()).getEntity());
}
use of javax.ws.rs.core.Cookie in project jersey by jersey.
the class CookieParamAsPrimitiveTest method testBadPrimitiveValue.
@Test
public void testBadPrimitiveValue() throws ExecutionException, InterruptedException {
final ContainerResponse responseContext = apply(RequestContextBuilder.from("/", "GET").accept("application/int").cookie(new Cookie("int", "abcdef")).build());
assertEquals(400, responseContext.getStatus());
}
Aggregations