Package org.apache.cxf.jaxrs.ext.form

Examples of org.apache.cxf.jaxrs.ext.form.Form


       
        WebClient client = WebClient.create("http://localhost:" + PORT + "/test/services/rest");
        client.type(MediaType.TEXT_PLAIN_TYPE).accept(MediaType.APPLICATION_XML_TYPE);
        client.path("/bookstore/books/139/subresource4/139/CXF Rocks");
        Book bean = new Book("CXF Rocks", 139L);
        Form form = new Form();
        form.set("name", "CXF Rocks").set("id", Long.valueOf(139L));
        Book b = readBook((InputStream)client.matrix("", bean).query("", bean).form(form).getEntity());
        assertEquals(139, b.getId());
        assertEquals("CXF Rocks", b.getName());
    }
View Full Code Here


    public void testGetBookWebClientForm2() throws Exception {
       
        String baseAddress = "http://localhost:" + PORT
            + "/test/services/rest/bookstore/books/679/subresource3";
        WebClient wc = WebClient.create(baseAddress);
        Form f = new Form();
        f.set("id", "679").set("name", "CXF in Action - ")
            .set("name", "679");
        Book b = readBook((InputStream)wc.accept("application/xml")
                          .form(f).getEntity());
        assertEquals(679, b.getId());
        assertEquals("CXF in Action - 679", b.getName());
View Full Code Here

        WebClient wc = createWebClient(address, new SamlFormOutInterceptor(),
                                       formProvider, true);
       
        wc.type(MediaType.APPLICATION_FORM_URLENCODED).accept(MediaType.APPLICATION_XML);
        try {
            Book book = wc.post(new Form().set("name", "CXF").set("id", 125),
                                Book.class);               
            assertEquals(125L, book.getId());
        } catch (ServerWebApplicationException ex) {
            fail(ex.getMessage());
        } catch (ClientWebApplicationException ex) {
View Full Code Here

    private static final Logger LOG =
        LogUtils.getL7dLogger(SamlFormOutInterceptor.class);
    private static final String SAML_ELEMENT = "SAMLToken";
   
    public void handleMessage(Message message) throws Fault {
        Form form = getRequestForm(message);
        if (form == null) {
            return;
        }
        AssertionWrapper assertionWrapper = createAssertion(message);
        try {
           
            String encodedToken = encodeToken(assertionWrapper.assertionToString());
               
            form.set(SAML_ELEMENT, encodedToken);
        } catch (Exception ex) {
            StringWriter sw = new StringWriter();
            ex.printStackTrace(new PrintWriter(sw));
            LOG.warning(sw.toString());
            throw new Fault(new RuntimeException(ex.getMessage() + ", stacktrace: " + sw.toString()));
View Full Code Here

        if (objs != null && objs.size() == 1) {
            Object obj = objs.get(0);
            if (obj instanceof Form) {
                return (Form)obj;
            } else if (obj instanceof MultivaluedMap) {
                return new Form((MultivaluedMap)obj);
            }
        }
        return null;
    }
View Full Code Here

        provider.setExpectedEncoded(true);
    }
   
    public Response handleRequest(Message message, ClassResourceInfo resourceClass) {
       
        Form form = readFormData(message);   
        String assertion = form.getData().getFirst(SAML_ELEMENT);
       
        handleToken(message, assertion);        

        // redirect if needed
        String samlRequestURI = form.getData().getFirst(SAML_RELAY_STATE);
        if (samlRequestURI != null) {
            // RelayState may actually represent a reference to a transient local state
            // containing the actual REQUEST URI client was using before being redirected
            // back to IDP - at the moment assume it's URI
            UriInfoImpl ui = new UriInfoImpl(message);
            if (!samlRequestURI.startsWith(ui.getBaseUri().toString())) {
                return Response.status(302).location(URI.create(samlRequestURI)).build();
            }
        }
        // restore input stream
        CachedOutputStream os = new CachedOutputStream();
        form.getData().remove(SAML_ELEMENT);
        form.getData().remove(SAML_RELAY_STATE);
        try {
            provider.writeTo(form, Form.class, Form.class, new Annotation[]{},
                MediaType.APPLICATION_FORM_URLENCODED_TYPE, new MetadataMap<String, Object>(), os);
            message.setContent(InputStream.class, os.getInputStream());
        } catch (Exception ex) {
View Full Code Here

    @Test
    public void testTooManyFormParams() throws Exception {
        String endpointAddress =
            "http://localhost:" + PORT + "/the/thebooks9/depth-form";
        WebClient wc = WebClient.create(endpointAddress);
        Response r = wc.form(new Form().set("a", "b"));
        assertEquals(204, r.getStatus());
        r = wc.form(new Form().set("a", "b").set("c", "b"));
        assertEquals(413, r.getStatus());
    }
View Full Code Here

        return (MultivaluedMap<String, String>)clazz.newInstance();
    }
   
    @SuppressWarnings("unchecked")
    private Object getFormObject(Class<?> clazz, MultivaluedMap<String, String> params) {
        return Form.class.isAssignableFrom(clazz) ? new Form((MultivaluedMap)params) : params;
    }
View Full Code Here

    @Test
    public void testTooManyFormParams() throws Exception {
        String endpointAddress =
            "http://localhost:" + PORT + "/the/thebooks9/depth-form";
        WebClient wc = WebClient.create(endpointAddress);
        Response r = wc.form(new Form().set("a", "b"));
        assertEquals(204, r.getStatus());
        r = wc.form(new Form().set("a", "b").set("c", "b"));
        assertEquals(413, r.getStatus());
    }
View Full Code Here

        WebClient wc = createWebClient(address, new SamlFormOutInterceptor(),
                                       formProvider, true);
       
        wc.type(MediaType.APPLICATION_FORM_URLENCODED).accept(MediaType.APPLICATION_XML);
        try {
            Book book = wc.post(new Form().set("name", "CXF").set("id", 125),
                                Book.class);               
            assertEquals(125L, book.getId());
        } catch (WebApplicationException ex) {
            fail(ex.getMessage());
        } catch (ClientException ex) {
View Full Code Here

TOP

Related Classes of org.apache.cxf.jaxrs.ext.form.Form

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.