本文整理了Java中org.apache.cxf.jaxrs.ext.MessageContext.getHttpHeaders()
方法的一些代码示例,展示了MessageContext.getHttpHeaders()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MessageContext.getHttpHeaders()
方法的具体详情如下:
包路径:org.apache.cxf.jaxrs.ext.MessageContext
类名称:MessageContext
方法名:getHttpHeaders
暂无
代码示例来源:origin: apache/cxf
public HttpHeaders getHttpHeaders() {
MessageContext mc = getCurrentMessageContext();
return mc != null ? mc.getHttpHeaders() : null;
}
代码示例来源:origin: org.apache.cxf/cxf-bundle-jaxrs
public HttpHeaders getHttpHeaders() {
MessageContext mc = getCurrentMessageContext();
return mc != null ? mc.getHttpHeaders() : null;
}
代码示例来源:origin: apache/cxf
public static String[] getAuthorizationParts(MessageContext mc,
Set<String> challenges,
String realm) {
List<String> headers = mc.getHttpHeaders().getRequestHeader("Authorization");
if (headers != null && headers.size() == 1) {
String[] parts = headers.get(0).split(" ");
if (parts.length > 0
&& (challenges == null || challenges.isEmpty()
|| challenges.contains(parts[0])
|| challenges.size() == 1 && challenges.contains("*"))) {
return parts;
}
}
throwAuthorizationFailure(challenges, realm);
return null;
}
代码示例来源:origin: org.apache.cxf/cxf-rt-rs-security-oauth2
public static String[] getAuthorizationParts(MessageContext mc,
Set<String> challenges,
String realm) {
List<String> headers = mc.getHttpHeaders().getRequestHeader("Authorization");
if (headers != null && headers.size() == 1) {
String[] parts = headers.get(0).split(" ");
if (parts.length > 0
&& (challenges == null || challenges.isEmpty()
|| challenges.contains(parts[0])
|| challenges.size() == 1 && challenges.contains("*"))) {
return parts;
}
}
throwAuthorizationFailure(challenges, realm);
return null;
}
代码示例来源:origin: Talend/tesb-rt-se
@Override
public Response checkAlive() {
for (MediaType acceptedType : messageContext.getHttpHeaders().getAcceptableMediaTypes()) {
if (!acceptedType.isWildcardType() && !acceptedType.isWildcardSubtype()
&& MediaType.TEXT_HTML_TYPE.isCompatible(acceptedType)) {
return Response.ok(getClass().getResourceAsStream("/index.html"),
MediaType.TEXT_HTML_TYPE).build();
}
}
URI baseUri = messageContext.getUriInfo().getBaseUriBuilder().build();
StringBuffer response = new StringBuffer("Talend Auxiliary Storage REST Service:\n")
.append(" - wsdl - ").append(baseUri).append("/auxstorage/{key}.\n");
return Response.ok(response.toString()).type(MediaType.TEXT_PLAIN).build();
}
代码示例来源:origin: org.talend.esb.auxiliary.storage/auxiliary-storage-service-rest
@Override
public Response checkAlive() {
for (MediaType acceptedType : messageContext.getHttpHeaders().getAcceptableMediaTypes()) {
if (!acceptedType.isWildcardType() && !acceptedType.isWildcardSubtype()
&& MediaType.TEXT_HTML_TYPE.isCompatible(acceptedType)) {
return Response.ok(getClass().getResourceAsStream("/index.html"),
MediaType.TEXT_HTML_TYPE).build();
}
}
URI baseUri = messageContext.getUriInfo().getBaseUriBuilder().build();
StringBuffer response = new StringBuffer("Talend Auxiliary Storage REST Service:\n")
.append(" - wsdl - ").append(baseUri).append("/auxstorage/{key}.\n");
return Response.ok(response.toString()).type(MediaType.TEXT_PLAIN).build();
}
代码示例来源:origin: apache/cxf
protected void checkContentLength() {
if (mc != null && isPayloadEmpty(mc.getHttpHeaders())) {
String message = new org.apache.cxf.common.i18n.Message("EMPTY_BODY", BUNDLE).toString();
LOG.warning(message);
throw new WebApplicationException(400);
}
}
代码示例来源:origin: org.apache.cxf/cxf-bundle-jaxrs
protected void checkContentLength() {
if (mc != null && isPayloadEmpty(mc.getHttpHeaders())) {
String message = new org.apache.cxf.common.i18n.Message("EMPTY_BODY", BUNDLE).toString();
LOG.warning(message);
throw new WebApplicationException(400);
}
}
代码示例来源:origin: fabric8io/jube
/**
* Using HTTP POST, we can add a new customer to the system by uploading the XML representation for the customer.
* This operation will be mapped to the method below and the XML representation will get unmarshaled into a real
* Customer object.
* <p/>
* After the method has added the customer to the local data map, it will use the Response class to build the HTTP reponse,
* sending back the inserted customer object together with a HTTP Status 200/OK. This allows us to send back the
* new id for the customer object to the client application along with any other data that might have been updated in
* the process.
* <p/>
* Note how this method is using the same @Path value as our previous method - the HTTP method used will determine which
* method is being invoked.
*/
@POST
@Path("/customers/")
@Consumes({"application/xml", "application/json"})
@ApiOperation(value = "Add a new Customer")
@ApiResponses(value = {@ApiResponse(code = 500, message = "Invalid ID supplied")})
public Response addCustomer(@ApiParam(value = "Customer object that needs to be updated", required = true)
Customer customer) {
LOG.info("Invoking addCustomer, Customer name is: {}", customer.getName());
customer.setId(++currentId);
customers.put(customer.getId(), customer);
if (jaxrsContext.getHttpHeaders().getMediaType().getSubtype().equals("json")) {
return Response.ok().type("application/json").entity(customer).build();
} else {
return Response.ok().type("application/xml").entity(customer).build();
}
}
代码示例来源:origin: apache/meecrowave
@Override // don't fail without a client
protected Client getClientFromBasicAuthScheme(final MultivaluedMap<String, String> params) {
final List<String> authorization = getMessageContext().getHttpHeaders().getRequestHeader("Authorization");
if (authorization == null || authorization.isEmpty()) {
if (!configurer.getConfiguration().isForceClient()) {
return DEFAULT_CLIENT;
}
}
return super.getClientFromBasicAuthScheme(params);
}
}
代码示例来源:origin: apache/meecrowave
@Override // don't fail without a client
protected Client getClientFromBasicAuthScheme(final MultivaluedMap<String, String> params) {
final List<String> authorization = getMessageContext().getHttpHeaders().getRequestHeader("Authorization");
if (authorization == null || authorization.isEmpty()) {
if (!configurer.getConfiguration().isForceClient()) {
return DEFAULT_CLIENT;
}
}
return super.getClientFromBasicAuthScheme(params);
}
}
代码示例来源:origin: apache/cxf
@Override
public void filter(ContainerRequestContext requestContext) throws IOException {
UriInfo ui = mc.getUriInfo();
Response response = null;
if (ui.getPath().endsWith(APIDOCS_LISTING_PATH_JSON)) {
response = getListingJsonResponse(
app, mc.getServletContext(), mc.getServletConfig(), mc.getHttpHeaders(), ui);
} else if (ui.getPath().endsWith(APIDOCS_LISTING_PATH_YAML)) {
response = getListingYamlResponse(
app, mc.getServletContext(), mc.getServletConfig(), mc.getHttpHeaders(), ui);
}
if (response != null) {
requestContext.abortWith(response);
}
}
}
代码示例来源:origin: apache/cxf
@Override
public void writeTo(Object obj, Class<?> cls, Type genericType, Annotation[] anns,
MediaType m, MultivaluedMap<String, Object> headers, OutputStream os) throws IOException {
List<String> failHeaders = getContext().getHttpHeaders().getRequestHeader("fail-write");
if (failHeaders != null && !failHeaders.isEmpty()) {
os.write("fail".getBytes());
throw new IOException();
}
super.writeTo(obj, cls, genericType, anns, m, headers, os);
}
}
代码示例来源:origin: apache/cxf
@Override
public Object invoke(Exchange exchange, Object request, Object resourceObject) {
MessageContext mc = new MessageContextImpl(exchange.getInMessage());
List<Object> params = CastUtils.cast((List<?>)request);
String path = mc.getUriInfo().getPath();
if ("default/books/999".equals(path)) {
Long bookId = (Long)params.get(0);
Book book = new Book("CXF in Action", bookId);
Response r = Response.ok(book,
mc.getHttpHeaders().getAcceptableMediaTypes().get(0)).build();
return new MessageContentsList(r);
} else if ("default/echobookdefault".equals(path)) {
Source source = (Source)params.get(0);
Response r = Response.ok(source, MediaType.APPLICATION_ATOM_XML_TYPE).build();
return new MessageContentsList(r);
} else {
return super.invoke(exchange, request, resourceObject);
}
}
}
代码示例来源:origin: apache/cxf
@Override
public void filter(ContainerRequestContext context) {
List<String> authHeaders = messageContext.getHttpHeaders()
.getRequestHeader(HttpHeaders.AUTHORIZATION);
if (authHeaders == null || authHeaders.size() != 1) {
代码示例来源:origin: apache/cxf
MediaType mt = mc.getHttpHeaders().getMediaType();
代码示例来源:origin: org.apache.cxf/cxf-bundle-jaxrs
public Response handleRequest(Message m, ClassResourceInfo resourceClass) {
List<String> authHeaders = messageContext.getHttpHeaders()
.getRequestHeader(HttpHeaders.AUTHORIZATION);
if (authHeaders.size() != 1) {
代码示例来源:origin: org.apache.cxf/cxf-bundle-jaxrs
MediaType mt = mc.getHttpHeaders().getMediaType();
内容来源于网络,如有侵权,请联系作者删除!