Package javax.ws.rs.core

Examples of javax.ws.rs.core.Form


    public void writeTo(OOBAuthorizationResponse obj, Class<?> c, Type t,
                        Annotation[] anns,
                        MediaType mt, MultivaluedMap<String, Object> headers, OutputStream os)
        throws IOException, WebApplicationException {
       
        Form form = new Form(new MetadataMap<String, String>());
        form.param(OAuth.OAUTH_VERIFIER, obj.getVerifier());
        form.param(OAuth.OAUTH_TOKEN, obj.getRequestToken());
        if (obj.getState() != null) {
            form.param(OAuthConstants.X_OAUTH_STATE, obj.getState());
        }
        formProvider.writeTo(form, Form.class, Form.class, anns, mt, headers, os);
    }
View Full Code Here


       
        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.param("name", "CXF Rocks").param("id", Long.toString(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(new MetadataMap<String, String>());
        f.param("id", "679").param("name", "CXF in Action - ")
            .param("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

    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;
        }
       
        try {
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<String, String>)obj);
            }
        }
        return null;
    }
View Full Code Here

    }
   
    public void filter(ContainerRequestContext context) {
        Message message = JAXRSUtils.getCurrentMessage();
       
        Form form = readFormData(message);   
        MultivaluedMap<String, String> formData = form.asMap();
        String assertion = formData.getFirst(SAML_ELEMENT);
       
        handleToken(message, assertion);        

        // redirect if needed
View Full Code Here

                                                   Map<String, String> extraParams,
                                                   String defaultTokenType,
                                                   boolean setAuthorizationHeader)
        throws OAuthServiceException {   
       
        Form form = new Form(grant.toMap());
        if (extraParams != null) {
            for (Map.Entry<String, String> entry : extraParams.entrySet()) {
                form.param(entry.getKey(), entry.getValue());
            }
        }
        if (consumer != null) {
            if (setAuthorizationHeader) {
                StringBuilder sb = new StringBuilder();
                sb.append("Basic ");
                try {
                    String data = consumer.getKey() + ":" + consumer.getSecret();
                    sb.append(Base64Utility.encode(data.getBytes("UTF-8")));
                } catch (Exception ex) {
                    throw new ProcessingException(ex);
                }
                accessTokenService.header("Authorization", sb.toString());
            } else {
                form.param(OAuthConstants.CLIENT_ID, consumer.getKey());
                if (consumer.getSecret() != null) {
                    form.param(OAuthConstants.CLIENT_SECRET, consumer.getSecret());
                }
            }
        } else {
            // in this case the AccessToken service is expected to find a mapping between
            // the authenticated credentials and the client registration id
View Full Code Here

  }

  private Entity<?> getEntity( Method method, Object[] parameter ) {
    Entity<?> result = null;
    if( hasFormParameter( method ) ) {
      Form form = computeForm( method, parameter );
      result = Entity.form( form );
    } else if( hasMultiPartFormParameter( method ) ) {
      MultiPart mp = computeMultiPart( method, parameter );
      result = Entity.entity( mp, mp.getMediaType() );
    } else {
View Full Code Here

  private boolean hasFormParameter( Method method ) {
    return ClientHelper.hasFormAnnotation( method, FormParam.class );
  }

  private Form computeForm( Method method, Object[] parameter ) {
    Form result = new Form();
    Annotation[][] parameterAnnotations = method.getParameterAnnotations();
    for( int i = 0; i < parameterAnnotations.length; i++ ) {
      Annotation[] annotations = parameterAnnotations[ i ];
      FormParam formParam = extractAnnotation( annotations, FormParam.class );
      if( formParam != null ) {
        result.param( formParam.value(), parameter[ i ].toString() );
      }
    }
    return result.asMap().isEmpty() ? null : result;
  }
View Full Code Here

  }

  private Entity<?> getEntity( Method method, Object[] parameter ) {
    Entity<?> result = null;
    if( hasFormParameter( method ) ) {
      Form form = computeForm( method, parameter );
      result = Entity.form( form );
    } else {
      result = determineBodyParameter( method, parameter );
    }
    return result;
View Full Code Here

TOP

Related Classes of javax.ws.rs.core.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.