Package javax.ws.rs.core

Examples of javax.ws.rs.core.Form.asMap()


    }

    private void testSubResource(final String path, final boolean omitEmail) throws Exception {
        final Form form = new Form();
        form.asMap().put("firstName", Arrays.asList("Jersey"));
        form.asMap().put("lastName", Arrays.asList("JAX-RS"));
        if (!omitEmail) {
            form.asMap().put("email", Arrays.asList("jersey@example.com"));
        }

        final ContactBean contactBean = new ContactBean();
View Full Code Here


    private void testSubResource(final String path, final boolean omitEmail) throws Exception {
        final Form form = new Form();
        form.asMap().put("firstName", Arrays.asList("Jersey"));
        form.asMap().put("lastName", Arrays.asList("JAX-RS"));
        if (!omitEmail) {
            form.asMap().put("email", Arrays.asList("jersey@example.com"));
        }

        final ContactBean contactBean = new ContactBean();
        contactBean.setName("Jersey JAX-RS");
        contactBean.setEmail("jersey@example.com");
View Full Code Here

        }
    }

    private void testSubResourceNegative(final String path) throws Exception {
        final Form form = new Form();
        form.asMap().put("foo", Arrays.asList("bar"));

        final Response response = testSubResource(path, form);

        assertEquals(400, response.getStatus());
View Full Code Here

    }

    @Test
    public void testSubResourceEmptyNames() throws Exception {
        final Form form = new Form();
        form.asMap().put("firstName", Arrays.asList(""));
        form.asMap().put("lastName", Arrays.asList(""));

        final Response response = testSubResource("nullResourceContextInstance", form);

        assertEquals(400, response.getStatus());
View Full Code Here

    @Test
    public void testSubResourceEmptyNames() throws Exception {
        final Form form = new Form();
        form.asMap().put("firstName", Arrays.asList(""));
        form.asMap().put("lastName", Arrays.asList(""));

        final Response response = testSubResource("nullResourceContextInstance", form);

        assertEquals(400, response.getStatus());
View Full Code Here

    }


    private Response doRequest(FullBean bean, String path) {
        final Form form = new Form();
        form.asMap().put("form", Arrays.asList(new String[]{bean.getFormParam()}));

        return target().path(path).path(bean.getPathParam()).matrixParam("matrix",
                bean.getMatrixParam()).queryParam("query",
                bean.getQueryParam()).request().header("header", bean.getHeaderParam()).cookie("cookie",
                bean.getCookie()).post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE));
View Full Code Here

        fp.param("source", "Gulp-CalGul-1.05");

        final WebTarget target = target("FormResource");
        final Form response = target.request().post(Entity.entity(fp, MediaType.APPLICATION_FORM_URLENCODED_TYPE), Form.class);

        assertEquals(fp.asMap().size(), response.asMap().size());
        for (final Map.Entry<String, List<String>> entry : fp.asMap().entrySet()) {
            final List<String> s = response.asMap().get(entry.getKey());
            assertEquals(entry.getValue().size(), s.size());
            for (Iterator<String> it1 = entry.getValue().listIterator(), it2 = s.listIterator(); it1.hasNext(); ) {
                assertEquals(it1.next(), it2.next());
View Full Code Here

        final WebTarget target = target("FormResource");
        final Form response = target.request().post(Entity.entity(fp, MediaType.APPLICATION_FORM_URLENCODED_TYPE), Form.class);

        assertEquals(fp.asMap().size(), response.asMap().size());
        for (final Map.Entry<String, List<String>> entry : fp.asMap().entrySet()) {
            final List<String> s = response.asMap().get(entry.getKey());
            assertEquals(entry.getValue().size(), s.size());
            for (Iterator<String> it1 = entry.getValue().listIterator(), it2 = s.listIterator(); it1.hasNext(); ) {
                assertEquals(it1.next(), it2.next());
            }
        }
View Full Code Here

        if (type != null && MediaType.APPLICATION_FORM_URLENCODED.startsWith(type)
            && method != null && (method.equals(HttpMethod.POST) || method.equals(HttpMethod.PUT))) {
            try {
                FormEncodingProvider<Form> provider = new FormEncodingProvider<Form>(true);
                Form form = FormUtils.readForm(provider, message);
                MultivaluedMap<String, String> formData = form.asMap();
                String token = formData.getFirst(OAuthConstants.ACCESS_TOKEN);
                if (token != null) {
                    FormUtils.restoreForm(provider, form, message);
                    return token;
                }
View Full Code Here

    }
   
    public void filter(ContainerRequestContext context) {
        Message message = JAXRSUtils.getCurrentMessage();
        Form form = readFormData(message);
        MultivaluedMap<String, String> formData = form.asMap();
        String assertionType = formData.getFirst(Constants.CLIENT_AUTH_ASSERTION_TYPE);
        String decodedAssertionType = assertionType != null ? HttpUtils.urlDecode(assertionType) : null;
        if (decodedAssertionType == null || !Constants.CLIENT_AUTH_SAML2_BEARER.equals(decodedAssertionType)) {
            throw ExceptionUtils.toNotAuthorizedException(null, null);
        }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.