Search in sources :

Example 21 with Cookie

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();
    }
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) Cookie(javax.ws.rs.core.Cookie) SimbaRoleR(org.simbasecurity.dwclient.gateway.representations.SimbaRoleR)

Example 22 with Cookie

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);
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) Cookie(javax.ws.rs.core.Cookie) RemoveRoleFromUserR(org.simbasecurity.dwclient.gateway.representations.RemoveRoleFromUserR)

Example 23 with Cookie

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();
    }
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) Cookie(javax.ws.rs.core.Cookie) SimbaUserR(org.simbasecurity.dwclient.gateway.representations.SimbaUserR)

Example 24 with Cookie

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());
}
Also used : Cookie(javax.ws.rs.core.Cookie)

Example 25 with Cookie

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());
}
Also used : Cookie(javax.ws.rs.core.Cookie) ContainerResponse(org.glassfish.jersey.server.ContainerResponse) Test(org.junit.Test)

Aggregations

Cookie (javax.ws.rs.core.Cookie)49 Test (org.junit.Test)28 HashMap (java.util.HashMap)7 ContainerResponse (org.glassfish.jersey.server.ContainerResponse)7 NewCookie (javax.ws.rs.core.NewCookie)6 Entitlement (com.sun.identity.entitlement.Entitlement)4 EntitlementSubject (com.sun.identity.entitlement.EntitlementSubject)4 Privilege (com.sun.identity.entitlement.Privilege)4 PrivilegeManager (com.sun.identity.entitlement.PrivilegeManager)4 ClientResponse (com.sun.jersey.api.client.ClientResponse)4 BeforeClass (org.testng.annotations.BeforeClass)4 SSOToken (com.iplanet.sso.SSOToken)3 Form (javax.ws.rs.core.Form)3 AuthenticatedUsers (org.forgerock.openam.entitlement.conditions.subject.AuthenticatedUsers)3 JSONEntitlement (com.sun.identity.entitlement.JSONEntitlement)2 UniformInterfaceException (com.sun.jersey.api.client.UniformInterfaceException)2 MalformedURLException (java.net.MalformedURLException)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Consumes (javax.ws.rs.Consumes)2