private static Response checkResponse(Response r, int status) { if (r == null) { return JAXRSUtils.toResponse(status); } return r; } }
private static Response checkResponse(Response r, int status) { if (r == null) { return JAXRSUtils.toResponse(status); } else { return r; } } }
public static Response toResponse(Response.Status status) { return toResponse(status.getStatusCode()); }
public static Response toResponse(Response.Status status) { return toResponse(status.getStatusCode()); }
protected void handleJAXBException(JAXBException e, boolean read) { StringBuilder sb = handleExceptionStart(e); Throwable linked = e.getLinkedException(); if (linked != null && linked.getMessage() != null) { if (read && linked instanceof XMLStreamException && linked.getMessage().startsWith("Maximum Number")) { throw ExceptionUtils.toWebApplicationException(null, JAXRSUtils.toResponse(413)); } sb.append(linked.getMessage()).append(". "); } Throwable t = linked != null ? linked : e.getCause() != null ? e.getCause() : e; String message = new org.apache.cxf.common.i18n.Message("JAXB_EXCEPTION", BUNDLE, sb.toString()).toString(); handleExceptionEnd(t, message, read); }
protected void handleJAXBException(JAXBException e, boolean read) { StringBuilder sb = handleExceptionStart(e); Throwable linked = e.getLinkedException(); if (linked != null && linked.getMessage() != null) { Throwable cause = linked; while (read && cause != null) { if (cause instanceof XMLStreamException && cause.getMessage().startsWith("Maximum Number")) { throw ExceptionUtils.toWebApplicationException(null, JAXRSUtils.toResponse(413)); } if (cause instanceof DepthExceededStaxException) { throw ExceptionUtils.toWebApplicationException(null, JAXRSUtils.toResponse(413)); } cause = cause.getCause(); } String msg = linked.getMessage(); if (sb.lastIndexOf(msg) == -1) { sb.append(msg).append(". "); } } Throwable t = linked != null ? linked : e.getCause() != null ? e.getCause() : e; String message = new org.apache.cxf.common.i18n.Message("JAXB_EXCEPTION", BUNDLE, sb.toString()).toString(); handleExceptionEnd(t, message, read); }
return source.cast(docRequired ? doc : new DOMSource(doc)); } catch (DepthExceededStaxException e) { throw ExceptionUtils.toWebApplicationException(null, JAXRSUtils.toResponse(413)); } catch (XMLStreamException e) { if (e.getMessage() != null && e.getMessage().startsWith("Maximum Number")) { throw ExceptionUtils.toWebApplicationException(null, JAXRSUtils.toResponse(413));
return source.cast(docRequired ? doc : new DOMSource(doc)); } catch (DepthExceededStaxException e) { throw ExceptionUtils.toWebApplicationException(null, JAXRSUtils.toResponse(413)); } catch (XMLStreamException e) { if (e.getMessage() != null && e.getMessage().startsWith("Maximum Number")) { throw ExceptionUtils.toWebApplicationException(null, JAXRSUtils.toResponse(413)); } else { throw ExceptionUtils.toBadRequestException(e, null);
BUNDLE, pClass.getName()).toString()); Response r = JAXRSUtils.toResponse(HttpUtils.getParameterFailureStatus(pType)); throw ExceptionUtils.toHttpException(t, r);
handleJAXBException(e, true); } catch (DepthExceededStaxException e) { throw ExceptionUtils.toWebApplicationException(null, JAXRSUtils.toResponse(413)); } catch (WebApplicationException e) { throw e;
handleJAXBException(e, true); } catch (DepthExceededStaxException e) { throw ExceptionUtils.toWebApplicationException(null, JAXRSUtils.toResponse(413)); } catch (WebApplicationException e) { throw e;
BUNDLE, pClass.getName()).toString()); Response r = JAXRSUtils.toResponse(HttpUtils.getParameterFailureStatus(pType)); throw ExceptionUtils.toHttpException(ex, r);
@Override public void filter(ContainerRequestContext context) throws IOException { if (isMethodWithNoContent(context.getMethod()) || isCheckEmptyStream() && !context.hasEntity()) { return; } try { JweDecryptionOutput out = decrypt(context.getEntityStream()); byte[] bytes = out.getContent(); context.setEntityStream(new ByteArrayInputStream(bytes)); context.getHeaders().putSingle("Content-Length", Integer.toString(bytes.length)); String ct = JoseUtils.checkContentType(out.getHeaders().getContentType(), getDefaultMediaType()); if (ct != null) { context.getHeaders().putSingle("Content-Type", ct); } if (super.isValidateHttpHeaders()) { super.validateHttpHeadersIfNeeded(context.getHeaders(), out.getHeaders()); } } catch (JweException ex) { context.abortWith(JAXRSUtils.toResponse(400)); return; } }
@Override public void filter(ContainerRequestContext context) throws IOException { if (isMethodWithNoContent(context.getMethod()) || isCheckEmptyStream() && !context.hasEntity()) { return; } JwsSignatureVerifier theSigVerifier = getInitializedSigVerifier(); JwsJsonConsumer c = new JwsJsonConsumer(IOUtils.readStringFromStream(context.getEntityStream())); try { validate(c, theSigVerifier); } catch (JwsException ex) { context.abortWith(JAXRSUtils.toResponse(400)); return; } byte[] bytes = c.getDecodedJwsPayloadBytes(); context.setEntityStream(new ByteArrayInputStream(bytes)); context.getHeaders().putSingle("Content-Length", Integer.toString(bytes.length)); // the list is guaranteed to be non-empty JwsJsonSignatureEntry sigEntry = c.getSignatureEntries().get(0); String ct = JoseUtils.checkContentType(sigEntry.getUnionHeader().getContentType(), getDefaultMediaType()); if (ct != null) { context.getHeaders().putSingle("Content-Type", ct); } if (super.isValidateHttpHeaders()) { super.validateHttpHeadersIfNeeded(context.getHeaders(), sigEntry.getProtectedHeader()); } }
JwsSignatureVerifier theSigVerifier = getInitializedSigVerifier(p.getJwsHeaders()); if (!p.verifySignatureWith(theSigVerifier)) { context.abortWith(JAXRSUtils.toResponse(400)); return;