Package javax.ws.rs

Examples of javax.ws.rs.BadRequestException


        // Make sure the end user has authenticated, check if HTTPS is used
        SecurityContext securityContext = getAndValidateSecurityContext();
       
        // Make sure the session is valid
        if (!compareRequestAndSessionTokens(params.getFirst(OAuthConstants.SESSION_AUTHENTICITY_TOKEN))) {
            throw new BadRequestException();    
        }
        //TODO: additionally we can check that the Principal that got authenticated
        // in startAuthorization is the same that got authenticated in completeAuthorization
       
        Client client = getClient(params);
View Full Code Here


                handleXMLStreamException(e, true);
            }
        } catch (WebApplicationException e) {
            throw e;
        } catch (Exception e) {
            throw new BadRequestException(e);
        } finally {
            StaxUtils.close(reader);
        }
        // unreachable
        return null;
View Full Code Here

    }
   
    protected void reportEmptyContentLength() {
        String message = new org.apache.cxf.common.i18n.Message("EMPTY_BODY", BUNDLE).toString();
        LOG.warning(message);
        throw new BadRequestException();
    }
View Full Code Here

    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 = Response.status(status)
            .type(MediaType.TEXT_PLAIN).entity(message).build();
        throw read ? new BadRequestException(r, t) : new InternalServerErrorException(r, t);
    }
View Full Code Here

            }
            String cdName = cd == null ? null : cd.getParameter("name");
            String contentId = a.getContentId();
            String name = StringUtils.isEmpty(cdName) ? contentId : cdName.replace("\"", "").replace("'", "");
            if (StringUtils.isEmpty(name)) {
                throw new BadRequestException();
            }
            if (CONTENT_DISPOSITION_FILES_PARAM.equals(name)) {
                // this is a reserved name in Content-Disposition for parts containing files
                continue;
            }
            try {
                String value = IOUtils.toString(a.getDataHandler().getInputStream());
                params.add(HttpUtils.urlDecode(name),
                           decode ? HttpUtils.urlDecode(value) : value);
            } catch (IllegalArgumentException ex) {
                LOG.warning("Illegal URL-encoded characters, make sure that no "
                    + "@FormParam and @Multipart annotations are mixed up");
                throw new InternalServerErrorException();
            } catch (IOException ex) {
                throw new BadRequestException();
            }
        }
    }
View Full Code Here

                        XmlSchemaConstants.XSD_NAMESPACE_URI, "include"), "schemaLocation", loc, href, m, ui);
                    return Response.ok().type(MediaType.APPLICATION_XML_TYPE).entity(
                        new DOMSource(docEl)).build();
                }
            } catch (Exception ex) {
                throw new BadRequestException();
            }
           
        }
        return null;
    }
View Full Code Here

           
            return getFormObject(clazz, params);
        } catch (WebApplicationException e) {
            throw e;
        } catch (Exception e) {
            throw new BadRequestException(e);
        }
    }
View Full Code Here

                //
                if (pType == ParameterType.PATH || pType == ParameterType.QUERY
                    || pType == ParameterType.MATRIX) {
                    throw new NotFoundException(nfe);
                }
                throw new BadRequestException(nfe);
            }
        }
       
        boolean adapterHasToBeUsed = false;
        Class<?> cls = pClass;       
View Full Code Here

    }
   
    private RequestState processRelayState(String relayState) {
        if (relayState == null) {
            reportError("MISSING_RELAY_STATE");
            throw new BadRequestException();
        }
        if (relayState.getBytes().length < 0 || relayState.getBytes().length > 80) {
            reportError("INVALID_RELAY_STATE");
            throw new BadRequestException();
        }
        RequestState requestState = getStateProvider().removeRequestState(relayState);
        if (requestState == null) {
            reportError("MISSING_REQUEST_STATE");
            throw new WebApplicationException(400);
        }
        if (isStateExpired(requestState.getCreatedAt(), 0)) {
            reportError("EXPIRED_REQUEST_STATE");
            throw new BadRequestException();
        }
        return requestState;
    }
View Full Code Here

        boolean postBinding,
        String samlResponse
    ) {
        if (StringUtils.isEmpty(samlResponse)) {
            reportError("MISSING_SAML_RESPONSE");
            throw new BadRequestException();
        }
       
        String samlResponseDecoded = samlResponse;
        /*
        // URL Decoding only applies for the re-direct binding
        if (!postBinding) {
            try {
                samlResponseDecoded = URLDecoder.decode(samlResponse, "UTF-8");
            } catch (UnsupportedEncodingException e) {
                throw new BadRequestException();
            }
        }
        */
        InputStream tokenStream = null;
        if (isSupportBase64Encoding()) {
            try {
                byte[] deflatedToken = Base64Utility.decode(samlResponseDecoded);
                tokenStream = !postBinding && isSupportDeflateEncoding()
                    ? new DeflateEncoderDecoder().inflateToken(deflatedToken)
                    : new ByteArrayInputStream(deflatedToken);
            } catch (Base64Exception ex) {
                throw new BadRequestException(ex);
            } catch (DataFormatException ex) {
                throw new BadRequestException(ex);
            }
        } else {
            try {
                tokenStream = new ByteArrayInputStream(samlResponseDecoded.getBytes("UTF-8"));
            } catch (UnsupportedEncodingException ex) {
                throw new BadRequestException(ex);
            }
        }
       
        Document responseDoc = null;
        try {
            responseDoc = StaxUtils.read(new InputStreamReader(tokenStream, "UTF-8"));
        } catch (Exception ex) {
            throw new WebApplicationException(400);
        }
       
        LOG.fine("Received response: " + DOM2Writer.nodeToString(responseDoc.getDocumentElement()));
       
        XMLObject responseObject = null;
        try {
            responseObject = OpenSAMLUtil.fromDom(responseDoc.getDocumentElement());
        } catch (WSSecurityException ex) {
            throw new BadRequestException(ex);
        }
        if (!(responseObject instanceof org.opensaml.saml2.core.Response)) {
            throw new BadRequestException();
        }
        return (org.opensaml.saml2.core.Response)responseObject;
    }
View Full Code Here

TOP

Related Classes of javax.ws.rs.BadRequestException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.