@Post
 public Representation requestToken(Representation input) throws JSONException {
   Form response = new Form();
   response.add(ERROR, OAuthError.invalid_client.name());
   response.add(ERROR_DESC, "Invalid Client");
   return response.getWebRepresentation();
 }
 @Post
 public Representation requestToken(Representation input) throws JSONException {
   Form form = new Form(input);
   assertThat(form.getFirstValue(CLIENT_ID), is(STUB_CLIENT_ID));
   assertThat(form.getFirstValue(CLIENT_SECRET), is(STUB_CLIENT_SECRET));
   Form response = new Form();
   response.add(ACCESS_TOKEN, "foo");
   response.add("expires", "3600");
   return response.getWebRepresentation();
 }
Ejemplo n.º 3
0
 private static Representation getComparisonRepresentation(Comparison comparison) {
   Form form = new Form();
   form.add("id", comparison.getId());
   form.add("dataset1", comparison.getFirstDataset());
   form.add("dataset2", comparison.getSecondDataset());
   form.add("adapter", comparison.getAdapterId());
   form.add("extractor", comparison.getExtractorId());
   form.add("measure", comparison.getMeasureId());
   return form.getWebRepresentation();
 }
Ejemplo n.º 4
0
  public void testPost2() throws Exception {
    String aparam =
        "{'aradon':"
            + "[{'name':'employee','section':'system','path':'/lore/test/ion.dev.floor4/3477','param':{'empno':'3477','ename':'ddd','address':'ddd','sal':'20','dept':'ddd','memo':'222','aradon.result.method':'post', 'aradon.result.format':'json'}}, "
            + " {'name':'indexer','section':'system','path':'/index/ion.dev.floor4/3477','param':{'empno':'3477','ename':'ddd','address':'ddd','sal':'20','dept':'ddd','memo':'222','aradon.result.method':'post', 'aradon.result.format':'json'}}"
            + "]}";
    Request request = new Request(Method.POST, prefixURL);
    Form form = new Form();
    form.add("aradon.parameter", aparam);
    request.setEntity(form.getWebRepresentation());

    handle("resource/config/aradon-config.xml", request);
  }
Ejemplo n.º 5
0
  public void testLetsGet() throws Exception {
    String aparam =
        "{aradon:"
            + "[{name:'abcd',  section:'system', path:'/repository/bulletin.bleujin', param:{p1:'abc', p2:'${sequence.result.nodes[0].currval}', p3:['red','green','white'], modified:'${currdate.result.nodes[0].now}', 'aradon.result.format':'json', 'aradon.result.method':'get'}, page:{pageNo:1, listNum:10, screenCount:1}}, "
            + " {name:'sequence', section:'system', path:'/sequence/myseq', param:{'aradon.result.format':'json', 'aradon.result.method':'put'}}, "
            + " {name:'currdate', section:'system', path:'/utils/datetime', param:{'aradon.result.format':'json', 'aradon.result.method':'get'}}"
            + "]}";
    Request request = new Request(Method.POST, prefixURL);
    Form form = new Form();
    form.add("aradon.parameter", aparam);
    request.setEntity(form.getWebRepresentation());

    handle("resource/config/aradon-config.xml", request);
  }
Ejemplo n.º 6
0
  public void testLetsPost() throws Exception {
    String aparam =
        "{aradon:"
            + "[{name:'board',  	section:'system', path:'/repository/bulletin.bleujin', param:{subject:'HiHi This is Let', content:'11월엔 투피어', boardid:'board1', reguserid:'bleujin', no:'${sequence.result.nodes[0].currval}',  modified:'${currdate.result.nodes[0].now}', 'aradon.result.format':'json', 'aradon.result.method':'post', 'aradon.page.pageNo':1, 'aradon.page.listNum':10, 'aradon.page.screenCount':10}}, "
            + " {name:'sequence', section:'system', path:'/sequence/bulletin.bleujin', param:{'aradon.result.format':'json', 'aradon.result.method':'put'}}, "
            + " {name:'currdate', section:'system', path:'/utils/datetime', param:{'aradon.result.format':'json', 'aradon.result.method':'get'}}"
            + "]}";

    Request request = new Request(Method.POST, prefixURL);
    Form form = new Form();
    form.add("aradon.parameter", aparam);
    request.setEntity(form.getWebRepresentation());

    handle("resource/config/aradon-config.xml", request);
  }
  /**
   * Tries to send a query to the PushEndpoint running on http://localhost:8183/pushendpoint.
   *
   * @throws Exception
   */
  @Test
  public void sendQueryToPushEndpoint() throws Exception {

    // construct workflow
    ClientResource rdfResource = new ClientResource(Resources.MGMT_WORKFLOWS_URL);

    Form form = new Form();
    form.add("workflow", SampleRdfWorkflows.getWorkflowWithPushEndpoint());
    Representation rep = form.getWebRepresentation();
    rep.setMediaType(MediaType.APPLICATION_RDF_XML);
    Representation rdfResponse = rdfResource.post(rep);
    Reference url = rdfResponse.getLocationRef();

    // retrieve endpoint
    ClientResource endpointResource =
        new ClientResource(url + "/endpoint?urn=urn:eu.larkc.endpoint.push.ep1");
    Representation endpointResponse = endpointResource.get();

    Reference pushEndpointUrl = endpointResponse.getLocationRef();
    logger.debug("PushEndpoint URL: {}", pushEndpointUrl);

    // execute query
    ClientResource pushEndpointResource = new ClientResource(pushEndpointUrl);

    Form queryForm = new Form();
    queryForm.add("query", SampleQueries.WHO_KNOWS_FRANK);
    Representation queryRep = queryForm.getWebRepresentation();

    pushEndpointResource.post(queryRep);

    Assert.assertEquals(200, pushEndpointResource.getResponse().getStatus().getCode());

    // delete workflow
    ClientResource workflowResource = new ClientResource(url);
    workflowResource.delete();
  }
Ejemplo n.º 8
0
 public void doPost(String path, String fileToPost) {
   ClientResource cr = new ClientResource(testContext, BASE_URI + path);
   Form form = new Form();
   InputStream in = getClass().getClassLoader().getResourceAsStream(fileToPost);
   try {
     Properties prop = new Properties();
     prop.load(in);
     for (Entry<Object, Object> entry : prop.entrySet()) {
       form.add((String) entry.getKey(), (String) entry.getValue());
     }
     cr.post(form.getWebRepresentation());
   } catch (Exception e) {
     e.printStackTrace();
     Assert.fail();
   }
 }
Ejemplo n.º 9
0
 /**
  * Handles the HTTP <code>POST</code> method.
  *
  * @param request servlet request
  * @param response servlet response
  * @throws ServletException if a servlet-specific error occurs
  * @throws IOException if an I/O error occurs
  */
 @Override
 protected void doPost(HttpServletRequest request, HttpServletResponse response)
     throws ServletException, IOException {
   response.setContentType("text/html;charset=UTF-8");
   PrintWriter out = response.getWriter();
   String nom2 = request.getParameter("nom");
   String prenom2 = request.getParameter("prenom");
   String tel2 = request.getParameter("telephone");
   String mail2 = request.getParameter("mail");
   String adresse2 = request.getParameter("adresse");
   String diplome2 = request.getParameter("diplome");
   String competence2 = request.getParameter("competence");
   String situationPro2 = request.getParameter("situationPro");
   String url6 = CANDIDAT;
   ClientResource resource6 = new ClientResource(url6);
   Form form2 =
       new Form(
           "nom="
               + nom2
               + "&prenom="
               + prenom2
               + "&tel="
               + tel2
               + "&mail="
               + mail2
               + "&adresse="
               + adresse2
               + "&diplome="
               + diplome2
               + "&competence="
               + competence2
               + "&situationPro="
               + situationPro2);
   form2.encode(CharacterSet.UTF_8);
   Representation rep2 = form2.getWebRepresentation();
   resource6.post(rep2);
 }
  private Representation handle(ParameterList request) {
    Logger log = getLogger();
    log.info("Handle on OP");
    ConcurrentMap<String, Object> attribs = getContext().getAttributes();
    ServerManager manager = (ServerManager) attribs.get("openid_manager");
    log.info("OP endpoint = " + manager.getOPEndpointUrl());

    String mode =
        request.hasParameter("openid.mode") ? request.getParameterValue("openid.mode") : null;

    Message response;
    String responseText;

    if ("associate".equals(mode)) {
      // --- process an association request ---
      response = manager.associationResponse(request);
      responseText = response.keyValueFormEncoding();
    } else if ("checkid_setup".equals(mode) || "checkid_immediate".equals(mode)) {
      // interact with the user and obtain data needed to continue
      List<?> userData = userInteraction(request, manager.getOPEndpointUrl());

      String userSelectedId = (String) userData.get(0);
      String userSelectedClaimedId = (String) userData.get(1);
      Boolean authenticatedAndApproved = (Boolean) userData.get(2);

      // --- process an authentication request ---
      response =
          manager.authResponse(
              request,
              userSelectedId,
              userSelectedClaimedId,
              authenticatedAndApproved.booleanValue());

      if (response instanceof DirectError) {
        Form f = new Form();
        @SuppressWarnings("unchecked")
        Map<String, String> m = (Map<String, String>) response.getParameterMap();
        for (String key : m.keySet()) {
          f.add(key, m.get(key));
        }
        return f.getWebRepresentation();
      } else {
        // caller will need to decide which of the following to use:

        // option1: GET HTTP-redirect to the return_to URL
        // return new
        // StringRepresentation(response.getDestinationUrl(true));
        redirectSeeOther(response.getDestinationUrl(true));
        return new EmptyRepresentation();

        // option2: HTML FORM Redirection
        // RequestDispatcher dispatcher =
        // getServletContext().getRequestDispatcher("formredirection.jsp");
        // httpReq.setAttribute("prameterMap",
        // response.getParameterMap());
        // httpReq.setAttribute("destinationUrl",
        // response.getDestinationUrl(false));
        // dispatcher.forward(request, response);
        // return null;
      }
    } else if ("check_authentication".equals(mode)) {
      // --- processing a verification request ---
      response = manager.verify(request);
      log.info("OpenID : " + response.keyValueFormEncoding());
      responseText = response.keyValueFormEncoding();
    } else if (Method.GET.equals(getMethod())) {
      // Could be a discovery request
      sendXRDSLocation();
      return new StringRepresentation("XRDS Discovery Information");
    } else {
      // --- error response ---
      response = DirectError.createDirectError("Unknown request");
      responseText = response.keyValueFormEncoding();
    }

    // return the result to the user
    return new StringRepresentation(responseText);
  }