Example usage for io.netty.handler.codec.http HttpHeaderNames ACCESS_CONTROL_ALLOW_CREDENTIALS

List of usage examples for io.netty.handler.codec.http HttpHeaderNames ACCESS_CONTROL_ALLOW_CREDENTIALS

Introduction

In this page you can find the example usage for io.netty.handler.codec.http HttpHeaderNames ACCESS_CONTROL_ALLOW_CREDENTIALS.

Prototype

AsciiString ACCESS_CONTROL_ALLOW_CREDENTIALS

To view the source code for io.netty.handler.codec.http HttpHeaderNames ACCESS_CONTROL_ALLOW_CREDENTIALS.

Click Source Link

Document

"access-control-allow-credentials"

Usage

From source file:org.ballerinalang.composer.service.ballerina.parser.service.BallerinaParserService.java

License:Open Source License

@OPTIONS
@Path("/built-in-packages")
@Consumes(MediaType.APPLICATION_JSON)/* ww w. j a  va2 s  . c  om*/
@Produces(MediaType.APPLICATION_JSON)
public Response getBuiltInPackages() {
    return Response.ok().header(HttpHeaderNames.ACCESS_CONTROL_MAX_AGE.toString(), "600 ")
            .header(HttpHeaderNames.ACCESS_CONTROL_ALLOW_ORIGIN.toString(), "*")
            .header(HttpHeaderNames.ACCESS_CONTROL_ALLOW_CREDENTIALS.toString(), "true")
            .header(HttpHeaderNames.ACCESS_CONTROL_ALLOW_METHODS.toString(),
                    "POST, GET, PUT, UPDATE, DELETE, OPTIONS, HEAD")
            .header(HttpHeaderNames.ACCESS_CONTROL_ALLOW_HEADERS.toString(),
                    HttpHeaderNames.CONTENT_TYPE.toString() + ", " + HttpHeaderNames.ACCEPT.toString()
                            + ", X-Requested-With")
            .build();
}

From source file:org.ballerinalang.composer.service.ballerina.parser.service.BallerinaParserService.java

License:Open Source License

@OPTIONS
@Path("/endpoints")
@Consumes(MediaType.APPLICATION_JSON)//from   ww  w . jav a  2 s .  c om
@Produces(MediaType.APPLICATION_JSON)
public Response getEndpointOptions() {
    return Response.ok().header(HttpHeaderNames.ACCESS_CONTROL_MAX_AGE.toString(), "600 ")
            .header(HttpHeaderNames.ACCESS_CONTROL_ALLOW_ORIGIN.toString(), "*")
            .header(HttpHeaderNames.ACCESS_CONTROL_ALLOW_CREDENTIALS.toString(), "true")
            .header(HttpHeaderNames.ACCESS_CONTROL_ALLOW_METHODS.toString(),
                    "POST, GET, PUT, UPDATE, DELETE, OPTIONS, HEAD")
            .header(HttpHeaderNames.ACCESS_CONTROL_ALLOW_HEADERS.toString(),
                    HttpHeaderNames.CONTENT_TYPE.toString() + ", " + HttpHeaderNames.ACCEPT.toString()
                            + ", X-Requested-With")
            .build();
}

From source file:org.ballerinalang.composer.service.ballerina.parser.service.BallerinaParserService.java

License:Open Source License

@OPTIONS
@Path("/actions")
@Consumes(MediaType.APPLICATION_JSON)// ww w . ja  va2  s. c om
@Produces(MediaType.APPLICATION_JSON)
public Response getActionsOptions() {
    return Response.ok().header(HttpHeaderNames.ACCESS_CONTROL_MAX_AGE.toString(), "600 ")
            .header(HttpHeaderNames.ACCESS_CONTROL_ALLOW_ORIGIN.toString(), "*")
            .header(HttpHeaderNames.ACCESS_CONTROL_ALLOW_CREDENTIALS.toString(), "true")
            .header(HttpHeaderNames.ACCESS_CONTROL_ALLOW_METHODS.toString(),
                    "POST, GET, PUT, UPDATE, DELETE, OPTIONS, HEAD")
            .header(HttpHeaderNames.ACCESS_CONTROL_ALLOW_HEADERS.toString(),
                    HttpHeaderNames.CONTENT_TYPE.toString() + ", " + HttpHeaderNames.ACCEPT.toString()
                            + ", X-Requested-With")
            .build();
}

From source file:org.ballerinalang.composer.service.ballerina.parser.service.BallerinaParserService.java

License:Open Source License

@OPTIONS
@Path("/built-in-types")
@Consumes(MediaType.APPLICATION_JSON)/*from www  .j a va 2 s.  co m*/
@Produces(MediaType.APPLICATION_JSON)
public Response getBuiltInTypesOptions() {
    return Response.ok().header(HttpHeaderNames.ACCESS_CONTROL_MAX_AGE.toString(), "600 ")
            .header(HttpHeaderNames.ACCESS_CONTROL_ALLOW_ORIGIN.toString(), "*")
            .header(HttpHeaderNames.ACCESS_CONTROL_ALLOW_CREDENTIALS.toString(), "true")
            .header(HttpHeaderNames.ACCESS_CONTROL_ALLOW_METHODS.toString(),
                    "POST, GET, PUT, UPDATE, DELETE, OPTIONS, HEAD")
            .header(HttpHeaderNames.ACCESS_CONTROL_ALLOW_HEADERS.toString(),
                    HttpHeaderNames.CONTENT_TYPE.toString() + ", " + HttpHeaderNames.ACCEPT.toString()
                            + ", X-Requested-With")
            .build();
}

From source file:org.ballerinalang.composer.service.ballerina.parser.service.BallerinaParserService.java

License:Open Source License

@OPTIONS
@Path("/file/validate-and-parse")
@Consumes(MediaType.APPLICATION_JSON)//from w  w w.j a  v  a2  s  .  co  m
@Produces(MediaType.APPLICATION_JSON)
public Response validateAndParseOptions() {
    return Response.ok().header("Access-Control-Max-Age", "600 ")
            .header(HttpHeaderNames.ACCESS_CONTROL_ALLOW_ORIGIN.toString(), "*")
            .header(HttpHeaderNames.ACCESS_CONTROL_ALLOW_CREDENTIALS.toString(), "true")
            .header(HttpHeaderNames.ACCESS_CONTROL_ALLOW_METHODS.toString(),
                    "POST, GET, PUT, UPDATE, DELETE, OPTIONS, HEAD")
            .header(HttpHeaderNames.ACCESS_CONTROL_ALLOW_HEADERS.toString(),
                    HttpHeaderNames.CONTENT_TYPE.toString() + ", " + HttpHeaderNames.ACCEPT.toString()
                            + ", X-Requested-With")
            .build();
}

From source file:org.ballerinalang.composer.service.ballerina.parser.service.BallerinaParserService.java

License:Open Source License

@OPTIONS
@Path("/model/parse-fragment")
@Consumes(MediaType.APPLICATION_JSON)/*from  ww w.  ja  v a2  s. c  o m*/
@Produces(MediaType.APPLICATION_JSON)
public Response optionsParseFragment() {
    return Response.ok().header("Access-Control-Max-Age", "600 ")
            .header(HttpHeaderNames.ACCESS_CONTROL_ALLOW_ORIGIN.toString(), "*")
            .header(HttpHeaderNames.ACCESS_CONTROL_ALLOW_CREDENTIALS.toString(), "true")
            .header(HttpHeaderNames.ACCESS_CONTROL_ALLOW_METHODS.toString(), "POST, GET, OPTIONS")
            .header(HttpHeaderNames.ACCESS_CONTROL_ALLOW_HEADERS.toString(),
                    HttpHeaderNames.CONTENT_TYPE.toString() + ", " + HttpHeaderNames.ACCEPT.toString()
                            + ", X-Requested-With")
            .build();
}

From source file:org.ballerinalang.composer.service.fs.service.FileSystemService.java

License:Open Source License

/**
 * Create CORS Response allowing all origins.
 *
 * TODO: Find a better solution to handle CORS in a global manner
 * and to avoid redundant logic for CORS in each service.
 *
 * @return CORS Response//from   w  ww.j  ava  2  s  . com
 */
public Response createCORSResponse() {
    return Response.ok().header(HttpHeaderNames.ACCESS_CONTROL_ALLOW_ORIGIN.toString(), "*")
            .header(HttpHeaderNames.ACCESS_CONTROL_ALLOW_CREDENTIALS.toString(), "true")
            .header(HttpHeaderNames.ACCESS_CONTROL_ALLOW_METHODS.toString(), "POST, GET, OPTIONS ")
            .header(HttpHeaderNames.ACCESS_CONTROL_ALLOW_HEADERS.toString(),
                    HttpHeaderNames.CONTENT_TYPE.toString() + ", " + HttpHeaderNames.ACCEPT.toString()
                            + ", X-Requested-With")
            .build();
}

From source file:org.ballerinalang.composer.service.tryit.service.TryItService.java

License:Open Source License

/**
 * The options in requests./*from  ww w. j a  v  a  2 s.  c om*/
 * @return The options in responses.
 */
@OPTIONS
@Path("/{protocol}")
@Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.APPLICATION_JSON)
public Response options() {
    return Response.ok().header("Access-Control-Max-Age", "600 ")
            .header(HttpHeaderNames.ACCESS_CONTROL_ALLOW_ORIGIN.toString(), "*")
            .header(HttpHeaderNames.ACCESS_CONTROL_ALLOW_CREDENTIALS.toString(), "true")
            .header(HttpHeaderNames.ACCESS_CONTROL_ALLOW_METHODS.toString(),
                    "POST, GET, PUT, UPDATE, DELETE, OPTIONS, HEAD")
            .header(HttpHeaderNames.ACCESS_CONTROL_ALLOW_HEADERS.toString(),
                    HttpHeaderNames.CONTENT_TYPE.toString() + ", " + HttpHeaderNames.ACCEPT.toString()
                            + ", X-Requested-With")
            .build();

}

From source file:org.ballerinalang.net.http.CorsHeaderGenerator.java

License:Open Source License

private static void setAllowOriginAndCredentials(List<String> effectiveOrigins, CorsHeaders resCors,
        Map<String, String> responseHeaders) {
    int allowCreds = resCors.getAllowCredentials();
    if (allowCreds == 1) {
        responseHeaders.put(HttpHeaderNames.ACCESS_CONTROL_ALLOW_CREDENTIALS.toString(), String.valueOf(true));
    }//from   w  w w  . j a  v  a  2s.  c o m
    responseHeaders.put(HttpHeaderNames.ACCESS_CONTROL_ALLOW_ORIGIN.toString(),
            DispatcherUtil.concatValues(effectiveOrigins, true));
}

From source file:org.ballerinalang.stdlib.services.cors.HTTPCorsTest.java

License:Open Source License

public void assertEqualsCorsResponse(HttpCarbonMessage response, int statusCode, String origin,
        String credentials, String headers, String methods, String maxAge) {
    Assert.assertEquals(response.getProperty(HttpConstants.HTTP_STATUS_CODE), statusCode);
    Assert.assertEquals(response.getHeader(HttpHeaderNames.ACCESS_CONTROL_ALLOW_ORIGIN.toString()), origin);
    Assert.assertEquals(response.getHeader(HttpHeaderNames.ACCESS_CONTROL_ALLOW_CREDENTIALS.toString()),
            credentials);/*from   w  ww.j  a va2s .  c o m*/
    Assert.assertEquals(response.getHeader(HttpHeaderNames.ACCESS_CONTROL_ALLOW_HEADERS.toString()), headers);
    Assert.assertEquals(response.getHeader(HttpHeaderNames.ACCESS_CONTROL_ALLOW_METHODS.toString()), methods);
    Assert.assertEquals(response.getHeader(HttpHeaderNames.ACCESS_CONTROL_MAX_AGE.toString()), maxAge);
}