use of javax.ws.rs.core.Cookie in project cxf by apache.
the class AbstractServiceProviderFilter method checkSecurityContext.
protected boolean checkSecurityContext(Message m) {
HttpHeaders headers = new HttpHeadersImpl(m);
Map<String, Cookie> cookies = headers.getCookies();
Cookie securityContextCookie = cookies.get(SSOConstants.SECURITY_CONTEXT_TOKEN);
ResponseState responseState = getValidResponseState(securityContextCookie, m);
if (responseState == null) {
return false;
}
if (!isSupportUnsolicited()) {
Cookie relayStateCookie = cookies.get(SSOConstants.RELAY_STATE);
if (relayStateCookie == null) {
reportError("MISSING_RELAY_COOKIE");
return false;
}
String originalRelayState = responseState.getRelayState();
if (!originalRelayState.equals(relayStateCookie.getValue())) {
// perhaps the response state should also be removed
reportError("INVALID_RELAY_STATE");
return false;
}
}
try {
String assertion = responseState.getAssertion();
SamlAssertionWrapper assertionWrapper = new SamlAssertionWrapper(StaxUtils.read(new StringReader(assertion)).getDocumentElement());
setSecurityContext(m, assertionWrapper);
} catch (Exception ex) {
reportError("INVALID_RESPONSE_STATE");
return false;
}
return true;
}
use of javax.ws.rs.core.Cookie in project carbon-apimgt by wso2.
the class AuthUtilTestCase method testGetHttpOnlyCookieHeader.
@Test
public void testGetHttpOnlyCookieHeader() {
Cookie cookie = new Cookie("WSO2_AM_REFRESH_TOKEN_1_Development", "xxx-refresh-token-1-xxx");
String httpOnlyCookieHeader = AuthUtil.getHttpOnlyCookieHeader(cookie);
Assert.assertEquals("WSO2_AM_REFRESH_TOKEN_1_Development=xxx-refresh-token-1-xxx; HttpOnly", httpOnlyCookieHeader);
}
use of javax.ws.rs.core.Cookie in project Payara by payara.
the class RestUtil2 method sendRequestToCollectionResource.
@Handler(id = "rest.list", input = { @HandlerInput(name = "endpoint", type = String.class, required = true), @HandlerInput(name = "attrs", type = Map.class, required = false) }, output = { @HandlerOutput(name = "result", type = List.class) })
public static void sendRequestToCollectionResource(HandlerContext handlerCtx) {
// Map<String, Object> attrs = (Map<String, Object>) handlerCtx.getInputValue("attrs");
String endpoint = fixEndpoint((String) handlerCtx.getInputValue("endpoint"));
Response resp = RestUtil.getJerseyClient().target(endpoint).request(RestUtil.RESPONSE_TYPE).cookie(new Cookie(RestUtil.REST_TOKEN_COOKIE, RestUtil.getRestToken())).get(Response.class);
if (!isSuccess(resp.getStatus())) {
throw new RuntimeException(resp.readEntity(String.class));
}
List list = resp.readEntity(List.class);
handlerCtx.setOutputValue("result", list);
}
use of javax.ws.rs.core.Cookie in project Payara by payara.
the class RestUtil method post.
public static RestResponse post(String address, Map<String, Object> payload) {
WebTarget target = getJerseyClient().target(address);
MultivaluedMap formData = buildMultivalueMap(payload);
Response cr = target.request(RESPONSE_TYPE).cookie(new Cookie(REST_TOKEN_COOKIE, getRestToken())).post(Entity.entity(formData, MediaType.APPLICATION_FORM_URLENCODED), Response.class);
RestResponse rr = RestResponse.getRestResponse(cr);
return rr;
}
use of javax.ws.rs.core.Cookie in project Payara by payara.
the class RestUtil method put.
public static RestResponse put(String address, Map<String, Object> payload) {
WebTarget target = getJerseyClient().target(address);
MultivaluedMap formData = buildMultivalueMap(payload);
Response cr = target.request(RESPONSE_TYPE).cookie(new Cookie(REST_TOKEN_COOKIE, getRestToken())).put(Entity.entity(formData, MediaType.APPLICATION_FORM_URLENCODED), Response.class);
RestResponse rr = RestResponse.getRestResponse(cr);
return rr;
}
Aggregations