use of javax.ws.rs.core.Cookie in project OpenAM by OpenRock.
the class ListenerRestTest method getListener.
private String getListener(String url) throws UnsupportedEncodingException, EncodingException {
String adminTokenId = adminToken.getTokenID().toString();
String adminHashedTokenId = Hash.hash(adminTokenId);
String adminTokenIdHeader = RestServiceManager.SSOTOKEN_SUBJECT_PREFIX + RestServiceManager.SUBJECT_DELIMITER + adminTokenId;
String cookieValue = adminTokenId;
if (Boolean.parseBoolean(SystemProperties.get(Constants.AM_COOKIE_ENCODE, "false"))) {
cookieValue = URLEncoder.encode(adminTokenId, "UTF-8");
}
cookie = new Cookie(SystemProperties.get(Constants.AM_COOKIE_NAME), cookieValue);
String encodedURL = ESAPI.encoder().encodeForURL(url);
String result = listenerClient.path(encodedURL).queryParam("subject", adminHashedTokenId).header(RestServiceManager.SUBJECT_HEADER_NAME, adminTokenIdHeader).cookie(cookie).get(String.class);
return result;
}
use of javax.ws.rs.core.Cookie in project OpenAM by OpenRock.
the class PrivilegeRestTest method setup.
@BeforeClass
public void setup() throws Exception {
PrivilegeManager pm = PrivilegeManager.getInstance("/", adminSubject);
Privilege privilege = Privilege.getNewInstance();
privilege.setName(PRIVILEGE_NAME);
privilege.setDescription("desciption");
Map<String, Boolean> actions = new HashMap<String, Boolean>();
actions.put("GET", true);
Entitlement entitlement = new Entitlement(RESOURCE_NAME + "/*", actions);
privilege.setEntitlement(entitlement);
EntitlementSubject sbj = new AuthenticatedUsers();
privilege.setSubject(sbj);
pm.add(privilege);
String tokenId = adminToken.getTokenID().toString();
hashedTokenId = Hash.hash(tokenId);
tokenIdHeader = RestServiceManager.SSOTOKEN_SUBJECT_PREFIX + RestServiceManager.SUBJECT_DELIMITER + tokenId;
String cookieValue = tokenId;
if (Boolean.parseBoolean(SystemProperties.get(Constants.AM_COOKIE_ENCODE, "false"))) {
cookieValue = URLEncoder.encode(tokenId, "UTF-8");
}
cookie = new Cookie(SystemProperties.get(Constants.AM_COOKIE_NAME), cookieValue);
webClient = Client.create().resource(SystemProperties.getServerInstanceName() + "/ws/1/entitlement/privilege");
}
use of javax.ws.rs.core.Cookie in project OpenAM by OpenRock.
the class RestNoSubjectHeaderTest method setup.
@BeforeClass
public void setup() throws Exception {
String tokenId = adminToken.getTokenID().toString();
hashedTokenId = Hash.hash(tokenId);
String cookieValue = tokenId;
if (Boolean.parseBoolean(SystemProperties.get(Constants.AM_COOKIE_ENCODE, "false"))) {
cookieValue = URLEncoder.encode(tokenId, "UTF-8");
}
cookie = new Cookie(SystemProperties.get(Constants.AM_COOKIE_NAME), cookieValue);
webClient = Client.create().resource(SystemProperties.getServerInstanceName() + "/ws/1/entitlement/privilege");
}
use of javax.ws.rs.core.Cookie in project simba-os by cegeka.
the class SimbaRoleService method addRoleToUser.
public void addRoleToUser(String ssoToken, SimbaRoleR simbaRole, SimbaUserR simbaUser) {
checkRoleNotNull(simbaRole);
checkUserNotNull(simbaUser);
AddRoleToUsersR postEntity = new AddRoleToUsersR(simbaRole, simbaUser);
ClientResponse clientResponse = getSimbaResource().path("role").path("addUsers").header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).cookie(new Cookie(AuthenticationConstants.SIMBA_SSO_TOKEN, ssoToken)).post(ClientResponse.class, postEntity);
handleError("addRole", simbaRole.getName(), simbaUser.getUserName(), clientResponse, logger);
}
Aggregations