protected void throwFault(String error, Exception ex) { LOG.warning(error); Response response = JAXRSUtils.toResponseBuilder(400).entity(error).type("text/plain").build(); throw ExceptionUtils.toBadRequestException(null, response); }
protected void throwFault(String error, Exception ex) { LOG.warning(error); Response response = JAXRSUtils.toResponseBuilder(400).entity(error).build(); throw ExceptionUtils.toBadRequestException(null, response); }
protected void reportInvalidRequestError(OAuthError entity, MediaType mt) { ResponseBuilder rb = JAXRSUtils.toResponseBuilder(400); if (mt != null) { rb.type(mt); } throw ExceptionUtils.toBadRequestException(null, rb.entity(entity).build()); }
private static RuntimeException createParamConversionException(ParameterType pType, Exception ex) { // // For path, query & matrix parameters this is 404, // for others 400... // if (pType == ParameterType.PATH || pType == ParameterType.QUERY || pType == ParameterType.MATRIX) { return ExceptionUtils.toNotFoundException(ex, null); } return ExceptionUtils.toBadRequestException(ex, null); } public static <T> T createFromParameterHandler(String value,
protected void throwFault(String error, Exception ex) { LOG.warning(error); Response response = JAXRSUtils.toResponseBuilder(400).entity(error).build(); throw ExceptionUtils.toBadRequestException(null, response); }
protected void throwFault(String error, Exception ex) { StringBuilder log = new StringBuilder(error); if (ex != null) { log = log.append(" - ").append(ex.getMessage()); } LOG.warning(log.toString()); Response response = JAXRSUtils.toResponseBuilder(400).entity(error).type("text/plain").build(); throw ExceptionUtils.toBadRequestException(null, response); }
protected void throwFault(String error, Exception ex) { LOG.warning(error); Response response = JAXRSUtils.toResponseBuilder(400).entity(error).build(); throw ExceptionUtils.toBadRequestException(null, response); }
protected void throwFault(String error, Exception ex) { LOG.warning(error); Response response = JAXRSUtils.toResponseBuilder(400).entity(error).type("text/plain").build(); throw ExceptionUtils.toBadRequestException(null, response); }
protected void throwFault(String error, Exception ex) { StringBuilder log = new StringBuilder(error); if (ex != null) { log = log.append(" - ").append(ex.getMessage()); } LOG.warning(log.toString()); Response response = JAXRSUtils.toResponseBuilder(400).entity(error).type("text/plain").build(); throw ExceptionUtils.toBadRequestException(null, response); }
protected void throwFault(String error, Exception ex) { LOG.warning(error); Response response = JAXRSUtils.toResponseBuilder(400).entity(error).build(); throw ExceptionUtils.toBadRequestException(null, response); }
protected void reportInvalidRequestError(OAuthError entity, MediaType mt) { ResponseBuilder rb = JAXRSUtils.toResponseBuilder(400); if (mt != null) { rb.type(mt); } throw ExceptionUtils.toBadRequestException(null, rb.entity(entity).build()); }
protected static void handleExceptionEnd(Throwable t, String message, boolean read) { Response.Status status = read ? Response.Status.BAD_REQUEST : Response.Status.INTERNAL_SERVER_ERROR; Response r = JAXRSUtils.toResponseBuilder(status) .type(MediaType.TEXT_PLAIN).entity(message).build(); throw read ? ExceptionUtils.toBadRequestException(t, r) : ExceptionUtils.toInternalServerErrorException(t, r); }
protected static void handleExceptionEnd(Throwable t, String message, boolean read) { Response.Status status = read ? Response.Status.BAD_REQUEST : Response.Status.INTERNAL_SERVER_ERROR; Response r = JAXRSUtils.toResponseBuilder(status) .type(MediaType.TEXT_PLAIN).entity(message).build(); WebApplicationException ex = read ? ExceptionUtils.toBadRequestException(t, r) : ExceptionUtils.toInternalServerErrorException(t, r); throw ex; }
private URI getTargetURI(String targetAddress) { if (targetAddress != null) { try { return URI.create(targetAddress); } catch (IllegalArgumentException ex) { reportError("INVALID_TARGET_URI"); } } else { reportError("MISSING_TARGET_URI"); } throw ExceptionUtils.toBadRequestException(null, null); }
protected void reportEmptyContentLength() { String message = new org.apache.cxf.common.i18n.Message("EMPTY_BODY", BUNDLE).toString(); LOG.warning(message); throw ExceptionUtils.toBadRequestException(null, null); }
/** * HTTPS is the default transport for OAuth 2.0 services. * By default this method will issue a warning for open * endpoints */ protected void checkTransportSecurity() { if (!mc.getSecurityContext().isSecure()) { LOG.warning("Unsecure HTTP, HTTPS is recommended"); if (blockUnsecureRequests) { throw ExceptionUtils.toBadRequestException(null, null); } } }
/** * HTTPS is the default transport for OAuth 2.0 services. * By default this method will issue a warning for open * endpoints */ protected void checkTransportSecurity() { if (!mc.getSecurityContext().isSecure()) { LOG.warning("Unsecure HTTP, HTTPS is recommended"); if (blockUnsecureRequests) { throw ExceptionUtils.toBadRequestException(null, null); } } }
protected Object unmarshalFromReader(Unmarshaller unmarshaller, XMLStreamReader reader, MediaType mt) throws JAXBException { CachedOutputStream out = new CachedOutputStream(); try { XMLStreamWriter writer = StaxUtils.createXMLStreamWriter(out); StaxUtils.copy(new StaxSource(reader), writer); writer.writeEndDocument(); writer.flush(); writer.close(); return unmarshalFromInputStream(unmarshaller, out.getInputStream(), mt); } catch (Exception ex) { throw ExceptionUtils.toBadRequestException(ex, null); } }
public T readFrom(Class<T> clazz, Type genericType, Annotation[] annotations, MediaType type, MultivaluedMap<String, String> headers, InputStream is) throws IOException { XMLStreamReader reader = null; try { reader = createReader(clazz, genericType, is); DataReader<XMLStreamReader> dataReader = binding.createReader(XMLStreamReader.class); Object o = dataReader.read(null, reader, clazz); return o == null ? null : clazz.cast(o); } catch (Exception ex) { throw ExceptionUtils.toBadRequestException(ex, null); } finally { StaxUtils.close(reader); } }
private void doLogout(Cookie context, SecurityContext sc) { if (context == null || sc.getUserPrincipal() == null || sc.getUserPrincipal().getName() == null) { reportError("MISSING_RESPONSE_STATE"); throw ExceptionUtils.toBadRequestException(null, null); } stateProvider.removeResponseState(context.getValue()); }