当前位置: 首页>>代码示例>>Java>>正文


Java Form.param方法代码示例

本文整理汇总了Java中javax.ws.rs.core.Form.param方法的典型用法代码示例。如果您正苦于以下问题:Java Form.param方法的具体用法?Java Form.param怎么用?Java Form.param使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.ws.rs.core.Form的用法示例。


在下文中一共展示了Form.param方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testResetPasswordTooShort

import javax.ws.rs.core.Form; //导入方法依赖的package包/类
@Test
public void testResetPasswordTooShort() throws IOException {
    final User user = new User();
    user.setName("Example 3");
    user.setEmail("[email protected]");
    user.setRoles("user");

    String code = null;

    try (MinijaxRequestContext ctx = createRequestContext()) {
        ctx.get(Dao.class).create(user);
        code = ctx.get(Security.class).forgotPassword(user);
    }

    final Form form = new Form();
    form.param("newPassword", "foo");
    form.param("confirmNewPassword", "foo");

    final Response r = target("/resetpassword/" + code).request().post(Entity.form(form));
    assertNotNull(r);
    assertEquals(400, r.getStatus());
    assertTrue(r.getCookies().isEmpty());
}
 
开发者ID:minijax,项目名称:minijax,代码行数:24,代码来源:ResetPasswordTest.java

示例2: submit

import javax.ws.rs.core.Form; //导入方法依赖的package包/类
public AccessToken submit() throws IOException {
  Form form = new Form();
  form.param("assertion", assertion);
  form.param("grant_type", "urn:ietf:params:oauth:grant-type:jwt-bearer");

  Entity<Form> entity = Entity.form(form);

  Response response = client.target(EINSTEIN_VISION_URL + "/v1/oauth2/token")
      .request()
      .post(entity);

  if (!isSuccessful(response)) {
    throw new IOException("Error occurred while fetching Access Token " + response);
  }
  return readResponseAs(response, AccessToken.class);
}
 
开发者ID:MetaMind,项目名称:quickstart,代码行数:17,代码来源:AccessTokenRequest.java

示例3: testEngineWithInjectedClientPost

import javax.ws.rs.core.Form; //导入方法依赖的package包/类
@Test
public void testEngineWithInjectedClientPost() {

    final HttpClient httpClient = Vertx.vertx().createHttpClient(httpClientOptions);
    final Client client = new ResteasyClientBuilder().httpEngine(new VertxClientEngine(httpClient))
        .register(GsonMessageBodyHandler.class).build();
    final Form xform = new Form();
    xform.param("userName", "ca1\\\\meowmix");
    xform.param("password", "mingnamulan");
    xform.param("state", "authenticate");
    xform.param("style", "xml");
    xform.param("xsl", "none");

    final JsonObject arsString = client.target("https://httpbin.org/post").request()
        .post(Entity.form(xform), JsonObject.class);
    assertEquals("xml", arsString.getAsJsonObject("form").get("style").getAsString());
}
 
开发者ID:trajano,项目名称:app-ms,代码行数:18,代码来源:SpringJaxrsHandlerTest.java

示例4: testEngineWithInjectedClientPost2

import javax.ws.rs.core.Form; //导入方法依赖的package包/类
@Test
public void testEngineWithInjectedClientPost2() {

    final ResteasyDeployment deployment = new ResteasyDeployment();
    deployment.start();
    final ResteasyProviderFactory providerFactory = deployment.getProviderFactory();
    final HttpClient httpClient = Vertx.vertx().createHttpClient(httpClientOptions);
    final Client client = new ResteasyClientBuilder()
        .providerFactory(providerFactory)
        .httpEngine(new VertxClientEngine(httpClient))
        .register(GsonMessageBodyHandler.class)
        .build();
    final Form xform = new Form();
    xform.param("userName", "ca1\\\\meowmix");
    xform.param("password", "mingnamulan");
    xform.param("state", "authenticate");
    xform.param("style", "xml");
    xform.param("xsl", "none");

    final Response response = client.target("https://httpbin.org/post").request(MediaType.APPLICATION_JSON)
        .post(Entity.form(xform), Response.class);
    assertFalse(response.getStringHeaders().isEmpty());
    System.out.println(response.getStringHeaders());
    assertFalse(response.getHeaders().isEmpty());
    assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getMediaType());
    assertTrue(response.hasEntity());
    final JsonObject arsString = response.readEntity(JsonObject.class);
    assertEquals("xml", arsString.getAsJsonObject("form").get("style").getAsString());
}
 
开发者ID:trajano,项目名称:app-ms,代码行数:30,代码来源:SpringJaxrsHandlerTest.java

示例5: testUserWithoutPassword

import javax.ws.rs.core.Form; //导入方法依赖的package包/类
@Test
public void testUserWithoutPassword() throws IOException {
    final User user = new User();
    user.setName("Example 2");
    user.setEmail("[email protected]");
    user.setRoles("user");

    Cookie cookie = null;

    try (MinijaxRequestContext ctx = createRequestContext()) {
        ctx.get(Dao.class).create(user);
        cookie = ctx.get(Security.class).loginAs(user);
    }

    final Form form = new Form();
    form.param("csrf", cookie.getValue());
    form.param("oldPassword", "my-old-password");
    form.param("newPassword", "my-new-password");
    form.param("confirmNewPassword", "my-new-password");

    final Response r = target("/changepassword").request().cookie(cookie).post(Entity.form(form));
    assertNotNull(r);
    assertEquals(400, r.getStatus());
}
 
开发者ID:minijax,项目名称:minijax,代码行数:25,代码来源:ChangePasswordTest.java

示例6: testIncorrectOldPassword

import javax.ws.rs.core.Form; //导入方法依赖的package包/类
@Test
public void testIncorrectOldPassword() throws IOException {
    final User user = new User();
    user.setName("Example 3");
    user.setEmail("[email protected]");
    user.setRoles("user");
    user.setPassword("my-old-password");

    Cookie cookie = null;

    try (MinijaxRequestContext ctx = createRequestContext()) {
        ctx.get(Dao.class).create(user);
        cookie = ctx.get(Security.class).loginAs(user);
    }

    final Form form = new Form();
    form.param("csrf", cookie.getValue());
    form.param("oldPassword", "wrong-old-password");
    form.param("newPassword", "my-new-password");
    form.param("confirmNewPassword", "my-new-password");

    final Response r = target("/changepassword").request().cookie(cookie).post(Entity.form(form));
    assertNotNull(r);
    assertEquals(400, r.getStatus());
}
 
开发者ID:minijax,项目名称:minijax,代码行数:26,代码来源:ChangePasswordTest.java

示例7: testMismatchedPasswords

import javax.ws.rs.core.Form; //导入方法依赖的package包/类
@Test
public void testMismatchedPasswords() throws IOException {
    final User user = new User();
    user.setName("Example 4");
    user.setEmail("[email protected]");
    user.setRoles("user");
    user.setPassword("my-old-password");

    Cookie cookie = null;

    try (MinijaxRequestContext ctx = createRequestContext()) {
        ctx.get(Dao.class).create(user);
        cookie = ctx.get(Security.class).loginAs(user);
    }

    final Form form = new Form();
    form.param("csrf", cookie.getValue());
    form.param("oldPassword", "my-old-password");
    form.param("newPassword", "my-new-password");
    form.param("confirmNewPassword", "different-password");

    final Response r = target("/changepassword").request().cookie(cookie).post(Entity.form(form));
    assertNotNull(r);
    assertEquals(400, r.getStatus());
}
 
开发者ID:minijax,项目名称:minijax,代码行数:26,代码来源:ChangePasswordTest.java

示例8: testPasswordTooShort

import javax.ws.rs.core.Form; //导入方法依赖的package包/类
@Test
public void testPasswordTooShort() throws IOException {
    final User user = new User();
    user.setName("Example 5");
    user.setEmail("[email protected]");
    user.setRoles("user");
    user.setPassword("my-old-password");

    Cookie cookie = null;

    try (MinijaxRequestContext ctx = createRequestContext()) {
        ctx.get(Dao.class).create(user);
        cookie = ctx.get(Security.class).loginAs(user);
    }

    final Form form = new Form();
    form.param("csrf", cookie.getValue());
    form.param("oldPassword", "my-old-password");
    form.param("newPassword", "foo");
    form.param("confirmNewPassword", "foo");

    final Response r = target("/changepassword").request().cookie(cookie).post(Entity.form(form));
    assertNotNull(r);
    assertEquals(400, r.getStatus());
}
 
开发者ID:minijax,项目名称:minijax,代码行数:26,代码来源:ChangePasswordTest.java

示例9: testResetPasswordMismatch

import javax.ws.rs.core.Form; //导入方法依赖的package包/类
@Test
public void testResetPasswordMismatch() throws IOException {
    final User user = new User();
    user.setName("Example 2");
    user.setEmail("[email protected]");
    user.setRoles("user");

    String code = null;

    try (MinijaxRequestContext ctx = createRequestContext()) {
        ctx.get(Dao.class).create(user);
        code = ctx.get(Security.class).forgotPassword(user);
    }

    final Form form = new Form();
    form.param("newPassword", "my-new-password");
    form.param("confirmNewPassword", "different-password");

    final Response r = target("/resetpassword/" + code).request().post(Entity.form(form));
    assertNotNull(r);
    assertEquals(400, r.getStatus());
    assertTrue(r.getCookies().isEmpty());
}
 
开发者ID:minijax,项目名称:minijax,代码行数:24,代码来源:ResetPasswordTest.java

示例10: doPost

import javax.ws.rs.core.Form; //导入方法依赖的package包/类
String doPost(String api, Prameters prams) {
    WebClient wc = WebClient.create(api);
    Form form = new Form();
    form.param(ACCESS_TOKEN, access_token());
    String[] keys = prams.keys;
    for(int i = 0 ; i < keys.length ; i ++){
        form.param(keys[i], prams.value(i).toString());
    }
    Response resp = wc.form(form);
    String result = "";
    try {
        result = IOUtils.toString((InputStream) resp.getEntity());
    } catch (IOException e) {
        throw new ParseResultException(e);
    }
    handleResponse(resp, wc);
    return result;
}
 
开发者ID:kylinsoong,项目名称:weibo4j,代码行数:19,代码来源:Weibo.java

示例11: grantsAccessToResourcesForm

import javax.ws.rs.core.Form; //导入方法依赖的package包/类
@Test
public void grantsAccessToResourcesForm() throws Exception {
    setup(ConfigOverride.config("pac4j.servlet.security[0].clients",
            DirectFormClient.class.getSimpleName()));

    // username == password
    Form form = new Form();
    form.param("username", "rosebud");
    form.param("password", "rosebud");
    final String dogName = client.target(getUrlPrefix() + "/dogs/pierre")
            .request(MediaType.APPLICATION_JSON)
            .post(Entity.entity(form,
                    MediaType.APPLICATION_FORM_URLENCODED_TYPE),
                    String.class);

    assertThat(dogName).isEqualTo("pierre");
}
 
开发者ID:pac4j,项目名称:dropwizard-pac4j,代码行数:18,代码来源:EndToEndServletTest.java

示例12: registerMessagingServiceCallback

import javax.ws.rs.core.Form; //导入方法依赖的package包/类
public void registerMessagingServiceCallback(String consumerKey, String consumerSecret, String callback) 
    throws Exception
{
   WebTarget target = ClientBuilder.newClient().target(MessagingServiceCallbackRegistrationURL);
   String base64Credentials = new String(Base64.encodeBytes("admin:admin".getBytes()));
   Invocation.Builder builder = target.request();
   builder.header("Authorization", "Basic " + base64Credentials);
   Form form = new Form("consumer_id", consumerKey);
   form.param("consumer_secret", consumerSecret);
   form.param("callback_uri", callback);
   Response response = null;
   try {
      response = builder.post(Entity.form(form));
      if (HttpResponseCodes.SC_OK != response.getStatus()) {
         throw new RuntimeException("Callback Registration failed");
     }
   } finally {
      response.close();
   }
}
 
开发者ID:resteasy,项目名称:resteasy-examples,代码行数:21,代码来源:Subscriber.java

示例13: registerMessagingServiceCallback

import javax.ws.rs.core.Form; //导入方法依赖的package包/类
public void registerMessagingServiceCallback(String consumerKey, String callback)
{
   WebTarget target = ClientBuilder.newClient().target(MessagingServiceCallbackRegistrationURL);
   Invocation.Builder builder = target.request();
   String base64Credentials = new String(Base64.encodeBytes("admin:admin".getBytes()));
   builder.header("Authorization", "Basic " + base64Credentials);
   Form form = new Form("consumer_id", consumerKey);
   form.param("callback_uri", callback);
   Response response = null;
   try {
      response = builder.post(Entity.form(form));
      if (HttpResponseCodes.SC_OK != response.getStatus()) {
         throw new RuntimeException("Callback Registration failed");
      }
   }
   catch (Exception ex) {
      throw new RuntimeException("Callback Registration failed");
   }
   finally {
      response.close();
   }
}
 
开发者ID:resteasy,项目名称:resteasy-examples,代码行数:23,代码来源:SubscriberReceiver.java

示例14: delete

import javax.ws.rs.core.Form; //导入方法依赖的package包/类
/**
 * deletes a StrategyDayPart entity.
 * 
 * @param strategyDayPart
 *            expects a StrategyDayPart entity.
 * @return JsonResponse<? extends T1Entity> returns a JsonResponse of type T
 *         entity.
 * @throws ClientException
 *             a client exception is thrown if any error occurs.
 * 
 * @throws ParseException
 *             a parse exception is thrown when the response cannot be
 *             parsed.
 */
public JsonResponse<? extends T1Entity> delete(StrategyDayPart strategyDayPart)
		throws ClientException, ParseException {
	StringBuilder path = new StringBuilder();

	if (strategyDayPart.getId() > 0) {
		path.append(Constants.entityPaths.get("StrategyDayPart"));
		path.append("/");
		path.append(strategyDayPart.getId());
		path.append(DELETE);
	}

	String finalPath = t1Service.constructUrl(path, Constants.entityPaths.get("StrategyDayPart"));

	Form strategyConceptForm = new Form();
	if (strategyDayPart.getVersion() >= 0) {
		strategyConceptForm.param(VERSION, String.valueOf(strategyDayPart.getVersion()));
	}

	Response responseObj = connection.post(finalPath, strategyConceptForm, this.user);
	String response = responseObj.readEntity(String.class);

	T1JsonToObjParser parser = new T1JsonToObjParser();

	return parser.parseJsonToObj(response, Constants.getEntityType.get("strategy_day_parts"));
}
 
开发者ID:MediaMath,项目名称:t1-java,代码行数:40,代码来源:PostService.java

示例15: obtainAccessToken

import javax.ws.rs.core.Form; //导入方法依赖的package包/类
public String obtainAccessToken(String username, String password) {
    Form form = new Form();
    form.param("grant_type", "password");
    form.param("username", username);
    form.param("password", password);
    form.param("client_id", deployment.getClientId());
    String secret = deployment.getClientCredentials().get("secret").toString();
    form.param("client_secret", secret);
    Client client = null;
    try {
        ClientBuilder clientBuilder = ClientBuilder.newBuilder();
        SSLContext sslcontext = deployment.getSSLContext();
        if(sslcontext != null) {
            client = clientBuilder.sslContext(sslcontext).hostnameVerifier(new AnyHostnameVerifier()).build();
        } else {
            client = clientBuilder.build();
        }

        String tokenURL = String.format("%s/auth/realms/%s/protocol/openid-connect/token",
                deployment.getAuthServerUrl(), deployment.getRealm());
        WebTarget target = client.target(tokenURL);
        if(deployment.getDebug() > 0)
            target.register(new LoggingFilter());
        String json = target.request(MediaType.APPLICATION_JSON_TYPE)
                .post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE), String.class);
        AccessToken accessToken = JsonSerialization.readValue(json, AccessToken.class);
        return accessToken.getToken();
    } catch (Exception e) {
        throw new RuntimeException("Failed to request token", e);
    } finally {
        if (client != null) {
            client.close();
        }
    }
}
 
开发者ID:obsidian-toaster-quickstarts,项目名称:redhat-sso,代码行数:36,代码来源:AuthzClient.java


注:本文中的javax.ws.rs.core.Form.param方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。