org.apache.http.auth.InvalidCredentialsException#com.sun.jersey.core.util.MultivaluedMapImpl源码实例Demo

下面列出了org.apache.http.auth.InvalidCredentialsException#com.sun.jersey.core.util.MultivaluedMapImpl 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: localization_nifi   文件: ClientUtils.java
/**
 * Performs a POST using the specified url and form data.
 *
 * @param uri the uri to post to
 * @param formData the data to post
 * @return the client response of the post
 */
public ClientResponse post(URI uri, Map<String, String> formData) throws ClientHandlerException, UniformInterfaceException {
    // convert the form data
    MultivaluedMapImpl entity = new MultivaluedMapImpl();
    for (String key : formData.keySet()) {
        entity.add(key, formData.get(key));
    }

    // get the resource
    WebResource.Builder resourceBuilder = client.resource(uri).accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_FORM_URLENCODED);

    // add the form data if necessary
    if (!entity.isEmpty()) {
        resourceBuilder = resourceBuilder.entity(entity);
    }

    // perform the request
    return resourceBuilder.post(ClientResponse.class);
}
 
源代码2 项目: ingestion   文件: RestJobTest.java
@Test
public void simpleGetWithMultipleEventsUsingJsonHandler() throws JobExecutionException {
    String goodUrl = "GOOD URL";
    Map<String, Object> properties = new HashMap<String, Object>();
    MultivaluedMap<String, String> responseHeaders = new MultivaluedMapImpl();
    properties.put(RestSource.CONF_URL, goodUrl);
    properties.put(RestSource.CONF_HEADERS, "{}");
    properties.put(RestSource.CONF_METHOD, "GET");
    String jsonResponse = "[{\"field1\":\"value1\"},{\"field2\":\"value2\"}]";

    restSourceHandler = initJsonHandler("");
    urlHandler = new DefaultUrlHandler();
    when(schedulerContext.get("urlHandler")).thenReturn(urlHandler);
    when(client.resource(goodUrl)).thenReturn(webResource);
    when(response.getEntity(String.class)).thenReturn(jsonResponse);
    when(response.getHeaders()).thenReturn(responseHeaders);
    when(schedulerContext.get("properties")).thenReturn(properties);
    when(schedulerContext.get("restSourceHandler")).thenReturn(restSourceHandler);

    job.execute(context);

    assertThat(queue.size()).isEqualTo(2);
    assertThat(new String(queue.poll().getBody())).isEqualTo("{\"field1\":\"value1\"}");
    assertThat(new String(queue.poll().getBody())).isEqualTo("{\"field2\":\"value2\"}");
}
 
源代码3 项目: localization_nifi   文件: ApplicationResource.java
protected MultivaluedMap<String, String> getRequestParameters() {
    final MultivaluedMap<String, String> entity = new MultivaluedMapImpl();

    // get the form that jersey processed and use it if it exists (only exist for requests with a body and application form urlencoded
    final Form form = (Form) httpContext.getProperties().get(FormDispatchProvider.FORM_PROPERTY);
    if (form == null) {
        for (final Map.Entry<String, String[]> entry : httpServletRequest.getParameterMap().entrySet()) {
            if (entry.getValue() == null) {
                entity.add(entry.getKey(), null);
            } else {
                for (final String aValue : entry.getValue()) {
                    entity.add(entry.getKey(), aValue);
                }
            }
        }
    } else {
        entity.putAll(form);
    }

    return entity;
}
 
源代码4 项目: pxf   文件: HttpRequestParserTest.java
@Before
public void setUp() {
    parameters = new MultivaluedMapImpl();
    parameters.putSingle("X-GP-ALIGNMENT", "all");
    parameters.putSingle("X-GP-SEGMENT-ID", "-44");
    parameters.putSingle("X-GP-SEGMENT-COUNT", "2");
    parameters.putSingle("X-GP-HAS-FILTER", "0");
    parameters.putSingle("X-GP-FORMAT", "TEXT");
    parameters.putSingle("X-GP-URL-HOST", "my://bags");
    parameters.putSingle("X-GP-URL-PORT", "-8020");
    parameters.putSingle("X-GP-ATTRS", "-1");
    parameters.putSingle("X-GP-OPTIONS-ACCESSOR", "are");
    parameters.putSingle("X-GP-OPTIONS-RESOLVER", "packed");
    parameters.putSingle("X-GP-DATA-DIR", "i'm/ready/to/go");
    parameters.putSingle("X-GP-FRAGMENT-METADATA", "U29tZXRoaW5nIGluIHRoZSB3YXk=");
    parameters.putSingle("X-GP-OPTIONS-I'M-STANDING-HERE", "outside-your-door");
    parameters.putSingle("X-GP-USER", "alex");
    parameters.putSingle("X-GP-OPTIONS-SERVER", "custom_server");
    parameters.putSingle("X-GP-XID", "transaction:id");

    when(mockRequestHeaders.getRequestHeaders()).thenReturn(parameters);
    when(mockRequestHeaders.getPath()).thenReturn("foo");

    parser = new HttpRequestParser(mockPluginConf);
}
 
源代码5 项目: pxf   文件: HttpRequestParserTest.java
@Test
public void testConvertToCaseInsensitiveMapUtf8() throws Exception {
    byte[] bytes = {
            (byte) 0x61, (byte) 0x32, (byte) 0x63, (byte) 0x5c, (byte) 0x22,
            (byte) 0x55, (byte) 0x54, (byte) 0x46, (byte) 0x38, (byte) 0x5f,
            (byte) 0xe8, (byte) 0xa8, (byte) 0x88, (byte) 0xe7, (byte) 0xae,
            (byte) 0x97, (byte) 0xe6, (byte) 0xa9, (byte) 0x9f, (byte) 0xe7,
            (byte) 0x94, (byte) 0xa8, (byte) 0xe8, (byte) 0xaa, (byte) 0x9e,
            (byte) 0x5f, (byte) 0x30, (byte) 0x30, (byte) 0x30, (byte) 0x30,
            (byte) 0x30, (byte) 0x30, (byte) 0x30, (byte) 0x30, (byte) 0x5c,
            (byte) 0x22, (byte) 0x6f, (byte) 0x35
    };
    String value = new String(bytes, CharEncoding.ISO_8859_1);

    MultivaluedMap<String, String> multivaluedMap = new MultivaluedMapImpl();
    multivaluedMap.put("one", Collections.singletonList(value));

    Map<String, String> caseInsensitiveMap = new HttpRequestParser.RequestMap(multivaluedMap);

    assertEquals("Only one key should have exist", caseInsensitiveMap.keySet().size(), 1);

    assertEquals("Value should be converted to UTF-8",
            caseInsensitiveMap.get("one"), "a2c\"UTF8_計算機用語_00000000\"o5");
}
 
源代码6 项目: atlas   文件: TypesJerseyResourceIT.java
@Test
public void testGetTraitNames() throws Exception {
    String[] traitsAdded = addTraits();

    MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
    queryParams.add("type", DataTypes.TypeCategory.TRAIT.name());

    ObjectNode response = atlasClientV1.callAPIWithQueryParams(AtlasClient.API_V1.LIST_TYPES, queryParams);
    Assert.assertNotNull(response);

    Assert.assertNotNull(response.get(AtlasClient.REQUEST_ID));

    final ArrayNode list = (ArrayNode) response.get(AtlasClient.RESULTS);
    Assert.assertNotNull(list);
    Assert.assertTrue(list.size() >= traitsAdded.length);
}
 
源代码7 项目: docker-java   文件: DockerClient.java
public List<Container> listContainers(boolean allContainers, boolean latest, int limit, boolean showSize, String since, String before) {

		MultivaluedMap<String, String> params = new MultivaluedMapImpl();
		params.add("limit", latest ? "1" : String.valueOf(limit));
		params.add("all", allContainers ? "1" : "0");
		params.add("since", since);
		params.add("before", before);
		params.add("size", showSize ? "1" : "0");

		WebResource webResource = client.resource(restEndpointUrl + "/containers/json").queryParams(params);
		LOGGER.trace("GET: {}", webResource);
		List<Container> containers = webResource.accept(MediaType.APPLICATION_JSON).get(new GenericType<List<Container>>() {
		});
		LOGGER.trace("Response: {}", containers);

		return containers;
	}
 
源代码8 项目: docker-java   文件: DockerClient.java
public List<Image> getImages(String name, boolean allImages) throws DockerException {

		MultivaluedMap<String, String> params = new MultivaluedMapImpl();
		params.add("filter", name);
		params.add("all", allImages ? "1" : "0");

		WebResource webResource = client.resource(restEndpointUrl + "/images/json").queryParams(params);

		try {
			LOGGER.trace("GET: {}", webResource);
			List<Image> images = webResource.accept(MediaType.APPLICATION_JSON).get(new GenericType<List<Image>>() {
			});
			LOGGER.trace("Response: {}", images);
			return images;
		} catch (UniformInterfaceException exception) {
			if (exception.getResponse().getStatus() == 400) {
				throw new DockerException("bad parameter");
			} else if (exception.getResponse().getStatus() == 500) {
				throw new DockerException("Server error", exception);
			} else {
				throw new DockerException();
			}
		}

	}
 
private ContainerRequest createRequest(String requestPath, String schoolYearsQuery) {
    ContainerRequest request = Mockito.mock(ContainerRequest.class);
    String[] pathParts = requestPath.split("/");
    List<PathSegment> segments = new ArrayList<PathSegment>();
    for (String pathPart : pathParts) {
        segments.add(segmentFor(pathPart));
    }
    
    MultivaluedMap queryParameters = new MultivaluedMapImpl();
    
    String[] schoolYearParts = schoolYearsQuery.split("=");
    if (schoolYearParts.length == 2) {
        queryParameters.add(schoolYearParts[0], schoolYearParts[1]);
    }
    
    Mockito.when(request.getQueryParameters()).thenReturn(queryParameters);
    Mockito.when(request.getPathSegments()).thenReturn(segments);
    Mockito.when(request.getPath()).thenReturn(requestPath);
    return request;
}
 
@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    injector.setDeveloperContext();
    resource.isSandboxEnabled = true;
    List<String> acceptRequestHeaders = new ArrayList<String>();
    acceptRequestHeaders.add(HypermediaType.VENDOR_SLC_JSON);
    headers = mock(HttpHeaders.class);
    when(headers.getRequestHeader("accept")).thenReturn(acceptRequestHeaders);
    when(headers.getRequestHeaders()).thenReturn(new MultivaluedMapImpl());

    // mockTenantResource = mock(TenantResource.class);

    // clear all related collections
    repo.deleteAll("educationOrganization", null);

}
 
源代码11 项目: secure-data-service   文件: OptionalViewTest.java
@Test
@SuppressWarnings({ "unchecked", "rawtypes" })
public void testAppendOptionalFieldsNoOptionsGiven() {
    MultivaluedMap map = new MultivaluedMapImpl();

    EntityBody body = new EntityBody();
    body.put("student", "{\"somekey\":\"somevalue\"}");

    List<EntityBody> entities = new ArrayList<EntityBody>();
    entities.add(body);

    entities = optionalView.add(entities, ResourceNames.SECTIONS, map);

    assertEquals("Should only have one", 1, entities.size());
    assertEquals("Should match", body, entities.get(0));
}
 
源代码12 项目: Processor   文件: TemplateCallTest.java
public void testArg()
{
    String param1Value = "1", param2Value = "with space";
    Resource param3Value = ResourceFactory.createResource("http://whateverest/");
    MultivaluedMap queryParams = new MultivaluedMapImpl();
    queryParams.add(PREDICATE1_LOCAL_NAME, param1Value);
    queryParams.add(PREDICATE2_LOCAL_NAME, param2Value);
    queryParams.add(UNUSED_PREDICATE_LOCAL_NAME, param3Value);

    TemplateCall otherCall = TemplateCall.fromResource(resource, template).
        arg(param1, ResourceFactory.createPlainLiteral(param1Value)).
        arg(param2, ResourceFactory.createPlainLiteral(param2Value)).
        arg(param3, param3Value);
    
    assertEquals(call.applyArguments(queryParams).build(), otherCall.build());
}
 
源代码13 项目: incubator-atlas   文件: TypesJerseyResourceIT.java
@Test
public void testGetTraitNames() throws Exception {
    String[] traitsAdded = addTraits();

    MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
    queryParams.add("type", DataTypes.TypeCategory.TRAIT.name());

    JSONObject response = atlasClientV1.callAPIWithQueryParams(AtlasClient.API.LIST_TYPES, queryParams);
    Assert.assertNotNull(response);

    Assert.assertNotNull(response.get(AtlasClient.REQUEST_ID));

    final JSONArray list = response.getJSONArray(AtlasClient.RESULTS);
    Assert.assertNotNull(list);
    Assert.assertTrue(list.length() >= traitsAdded.length);
}
 
源代码14 项目: docker-java   文件: DockerClient.java
/**
 * Create an image by importing the given stream of a tar file.
 *
 * @param repository  the repository to import to
 * @param tag         any tag for this image
 * @param imageStream the InputStream of the tar file
 * @return an {@link ImageCreateResponse} containing the id of the imported image
 * @throws DockerException if the import fails for some reason.
 */
public ImageCreateResponse importImage(String repository, String tag, InputStream imageStream) throws DockerException {
	Preconditions.checkNotNull(repository, "Repository was not specified");
	Preconditions.checkNotNull(imageStream, "imageStream was not provided");

	MultivaluedMap<String, String> params = new MultivaluedMapImpl();
	params.add("repo", repository);
	params.add("tag", tag);
	params.add("fromSrc", "-");

	WebResource webResource = client.resource(restEndpointUrl + "/images/create").queryParams(params);

	try {
		LOGGER.trace("POST: {}", webResource);
		return webResource.accept(MediaType.APPLICATION_OCTET_STREAM_TYPE).post(ImageCreateResponse.class, imageStream);

	} catch (UniformInterfaceException exception) {
		if (exception.getResponse().getStatus() == 500) {
			throw new DockerException("Server error.", exception);
		} else {
			throw new DockerException(exception);
		}
	}
}
 
源代码15 项目: hop   文件: RestTest.java
@Test
public void testCreateMultivalueMap() {
  TransformMeta transformMeta = new TransformMeta();
  transformMeta.setName( "TestRest" );
  PipelineMeta pipelineMeta = new PipelineMeta();
  pipelineMeta.setName( "TestRest" );
  pipelineMeta.addTransform( transformMeta );
  Rest rest = new Rest( transformMeta, mock(RestMeta.class),  mock( RestData.class ),
    1, pipelineMeta, mock( Pipeline.class ) );
  MultivaluedMapImpl map = rest.createMultivalueMap( "param1", "{a:{[val1]}}" );
  String val1 = map.getFirst( "param1" );
  assertTrue( val1.contains( "%7D" ) );
}
 
源代码16 项目: java-docs-samples   文件: MailgunServlet.java
@SuppressWarnings("VariableDeclarationUsageDistance")
private ClientResponse sendSimpleMessage(String recipient) {
  Client client = Client.create();
  client.addFilter(new HTTPBasicAuthFilter("api", MAILGUN_API_KEY));
  MultivaluedMapImpl formData = new MultivaluedMapImpl();
  formData.add("from", "Mailgun User <[email protected]" + MAILGUN_DOMAIN_NAME + ">");
  formData.add("to", recipient);
  formData.add("subject", "Simple Mailgun Example");
  formData.add("text", "Plaintext content");
  WebResource webResource =
      client.resource("https://api.mailgun.net/v3/" + MAILGUN_DOMAIN_NAME + "/messages");
  return webResource
      .type(MediaType.APPLICATION_FORM_URLENCODED)
      .post(ClientResponse.class, formData);
}
 
源代码17 项目: localization_nifi   文件: NiFiTestUser.java
/**
 * Attempts to create a token with the specified username and password.
 *
 * @param url the url
 * @param username the username
 * @param password the password
 * @return response
 * @throws Exception ex
 */
public ClientResponse testCreateToken(String url, String username, String password) throws Exception {
    // convert the form data
    MultivaluedMapImpl entity = new MultivaluedMapImpl();
    entity.add("username", username);
    entity.add("password", password);

    // get the resource
    WebResource.Builder resourceBuilder = addProxiedEntities(client.resource(url).accept(MediaType.TEXT_PLAIN).type(MediaType.APPLICATION_FORM_URLENCODED)).entity(entity);

    // perform the request
    return resourceBuilder.post(ClientResponse.class);
}
 
源代码18 项目: localization_nifi   文件: RemoteNiFiUtils.java
/**
 * Issues a registration request for this NiFi instance for the instance at the baseApiUri.
 *
 * @param baseApiUri uri to register with
 * @return response
 */
public ClientResponse issueRegistrationRequest(String baseApiUri) {
    final URI uri = URI.create(String.format("%s/controller/users", baseApiUri));

    // set up the query params
    MultivaluedMapImpl entity = new MultivaluedMapImpl();
    entity.add("justification", "A Remote instance of NiFi has attempted to create a reference to this NiFi. This action must be approved first.");

    // create the web resource
    WebResource webResource = client.resource(uri);

    // get the client utils and make the request
    return webResource.type(MediaType.APPLICATION_FORM_URLENCODED).entity(entity).post(ClientResponse.class);
}
 
源代码19 项目: atlas   文件: QuickStartV2.java
private void verifyTypesCreated() throws Exception {
    MultivaluedMap<String, String> searchParams = new MultivaluedMapImpl();

    for (String typeName : TYPES) {
        searchParams.clear();
        searchParams.add(SearchFilter.PARAM_NAME, typeName);

        SearchFilter  searchFilter = new SearchFilter(searchParams);
        AtlasTypesDef searchDefs   = atlasClientV2.getAllTypeDefs(searchFilter);

        assert (!searchDefs.isEmpty());

        System.out.println("Created type [" + typeName + "]");
    }
}
 
源代码20 项目: atlas   文件: EntityLineageJerseyResourceIT.java
@Test
public void testInputLineageInfo() throws Exception {
    String tableId = atlasClientV1.getEntity(HIVE_TABLE_TYPE,
            AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, salesMonthlyTable).getId()._getId();

    MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
    queryParams.add(DIRECTION_PARAM, INPUT_DIRECTION);
    queryParams.add(DEPTH_PARAM, "5");
    ObjectNode response = atlasClientV1.callAPI(LINEAGE_V2_API, ObjectNode.class, queryParams, tableId);
    Assert.assertNotNull(response);
    System.out.println("input lineage info = " + response
    );

    AtlasLineageInfo inputLineageInfo = AtlasType.fromJson(response.toString(), AtlasLineageInfo.class);

    Map<String, AtlasEntityHeader> entities = inputLineageInfo.getGuidEntityMap();
    Assert.assertNotNull(entities);

    Set<AtlasLineageInfo.LineageRelation> relations = inputLineageInfo.getRelations();
    Assert.assertNotNull(relations);

    Assert.assertEquals(entities.size(), 6);
    Assert.assertEquals(relations.size(), 5);
    Assert.assertEquals(inputLineageInfo.getLineageDirection(), AtlasLineageInfo.LineageDirection.INPUT);
    Assert.assertEquals(inputLineageInfo.getLineageDepth(), 5);
    Assert.assertEquals(inputLineageInfo.getBaseEntityGuid(), tableId);
}
 
源代码21 项目: atlas   文件: EntityLineageJerseyResourceIT.java
@Test
public void testOutputLineageInfo() throws Exception {
    String tableId = atlasClientV1.getEntity(HIVE_TABLE_TYPE,
            AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, salesFactTable).getId()._getId();

    MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
    queryParams.add(DIRECTION_PARAM, OUTPUT_DIRECTION);
    queryParams.add(DEPTH_PARAM, "5");
    ObjectNode response = atlasClientV1.callAPI(LINEAGE_V2_API, ObjectNode.class, queryParams, tableId);

    Assert.assertNotNull(response);
    System.out.println("output lineage info = " + response);

    AtlasLineageInfo outputLineageInfo = AtlasType.fromJson(response.toString(), AtlasLineageInfo.class);

    Map<String, AtlasEntityHeader> entities = outputLineageInfo.getGuidEntityMap();
    Assert.assertNotNull(entities);

    Set<AtlasLineageInfo.LineageRelation> relations = outputLineageInfo.getRelations();
    Assert.assertNotNull(relations);

    Assert.assertEquals(entities.size(), 5);
    Assert.assertEquals(relations.size(), 4);
    Assert.assertEquals(outputLineageInfo.getLineageDirection(), AtlasLineageInfo.LineageDirection.OUTPUT);
    Assert.assertEquals(outputLineageInfo.getLineageDepth(), 5);
    Assert.assertEquals(outputLineageInfo.getBaseEntityGuid(), tableId);
}
 
源代码22 项目: atlas   文件: EntityLineageJerseyResourceIT.java
@Test
public void testLineageInfo() throws Exception {
    String tableId = atlasClientV1.getEntity(HIVE_TABLE_TYPE,
            AtlasClient.REFERENCEABLE_ATTRIBUTE_NAME, salesMonthlyTable).getId()._getId();

    MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
    queryParams.add(DIRECTION_PARAM, BOTH_DIRECTION);
    queryParams.add(DEPTH_PARAM, "5");
    ObjectNode response = atlasClientV1.callAPI(LINEAGE_V2_API, ObjectNode.class, queryParams, tableId);

    Assert.assertNotNull(response);
    System.out.println("both lineage info = " + response);

    AtlasLineageInfo bothLineageInfo = AtlasType.fromJson(response.toString(), AtlasLineageInfo.class);

    Map<String, AtlasEntityHeader> entities = bothLineageInfo.getGuidEntityMap();
    Assert.assertNotNull(entities);

    Set<AtlasLineageInfo.LineageRelation> relations = bothLineageInfo.getRelations();
    Assert.assertNotNull(relations);

    Assert.assertEquals(entities.size(), 6);
    Assert.assertEquals(relations.size(), 5);
    Assert.assertEquals(bothLineageInfo.getLineageDirection(), AtlasLineageInfo.LineageDirection.BOTH);
    Assert.assertEquals(bothLineageInfo.getLineageDepth(), 5);
    Assert.assertEquals(bothLineageInfo.getBaseEntityGuid(), tableId);
}
 
源代码23 项目: atlas   文件: EntityJerseyResourceIT.java
@Test(expectedExceptions = AtlasServiceException.class)
public void testGetEntityListForBadEntityType() throws Exception {
    MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
    queryParams.add("type", "blah");

    ObjectNode response = atlasClientV1.callAPIWithQueryParams(AtlasClient.API_V1.GET_ENTITY, queryParams);
    assertNotNull(response);
    Assert.assertNotNull(response.get(AtlasClient.ERROR));
}
 
源代码24 项目: docker-java   文件: DockerClient.java
public ClientResponse pull(String repository, String tag, String registry) throws DockerException {
	Preconditions.checkNotNull(repository, "Repository was not specified");

	if (StringUtils.countMatches(repository, ":") == 1) {
		String repositoryTag[] = StringUtils.split(repository, ':');
		repository = repositoryTag[0];
		tag = repositoryTag[1];

	}

	MultivaluedMap<String, String> params = new MultivaluedMapImpl();
	params.add("tag", tag);
	params.add("fromImage", repository);
	params.add("registry", registry);

	WebResource webResource = client.resource(restEndpointUrl + "/images/create").queryParams(params);

	try {
		LOGGER.trace("POST: {}", webResource);
		return webResource.accept(MediaType.APPLICATION_OCTET_STREAM_TYPE).post(ClientResponse.class);
	} catch (UniformInterfaceException exception) {
		if (exception.getResponse().getStatus() == 500) {
			throw new DockerException("Server error.", exception);
		} else {
			throw new DockerException(exception);
		}
	}
}
 
源代码25 项目: ribbon   文件: SecureGetTest.java
@Test
public void testFailsWithHostNameValidationOn() throws Exception {

	AbstractConfiguration cm = ConfigurationManager.getConfigInstance();

	String name = "GetPostSecureTest" + ".testFailsWithHostNameValidationOn";

	String configPrefix = name + "." + "ribbon";

	cm.setProperty(configPrefix + "." + CommonClientConfigKey.IsSecure, "true");
	cm.setProperty(configPrefix + "." + CommonClientConfigKey.SecurePort, Integer.toString(testServer2.getPort()));
	cm.setProperty(configPrefix + "." + CommonClientConfigKey.IsHostnameValidationRequired, "true"); // <--
	cm.setProperty(configPrefix + "." + CommonClientConfigKey.IsClientAuthRequired, "true");
	cm.setProperty(configPrefix + "." + CommonClientConfigKey.KeyStore, FILE_KS1.getAbsolutePath());
	cm.setProperty(configPrefix + "." + CommonClientConfigKey.KeyStorePassword, PASSWORD);
	cm.setProperty(configPrefix + "." + CommonClientConfigKey.TrustStore, FILE_TS1.getAbsolutePath());
	cm.setProperty(configPrefix + "." + CommonClientConfigKey.TrustStorePassword, PASSWORD);

	RestClient rc = (RestClient) ClientFactory.getNamedClient(name);

	testServer1.accept();

	URI getUri = new URI(SERVICE_URI1 + "test/");
	MultivaluedMapImpl params = new MultivaluedMapImpl();
	params.add("name", "test");
       HttpRequest request = HttpRequest.newBuilder().uri(getUri).queryParams("name", "test").build();

	try{
		rc.execute(request);

		fail("expecting ssl hostname validation error");
	}catch(ClientHandlerException che){
		assertTrue(che.getMessage().indexOf("hostname in certificate didn't match") > -1);
	}
}
 
源代码26 项目: atlas   文件: AtlasClientV2.java
public AtlasLineageInfo getLineageInfo(final String guid, final LineageDirection direction, final int depth) throws AtlasServiceException {
    MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
    queryParams.add("direction", direction.toString());
    queryParams.add("depth", String.valueOf(depth));

    return callAPI(API_V2.LINEAGE_INFO, AtlasLineageInfo.class, queryParams, guid);
}
 
源代码27 项目: atlas   文件: AtlasClientV2.java
public AtlasEntityWithExtInfo getEntityByGuid(String guid, boolean minExtInfo, boolean ignoreRelationships) throws AtlasServiceException {
    MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();

    queryParams.add("minExtInfo", String.valueOf(minExtInfo));
    queryParams.add("ignoreRelationships", String.valueOf(ignoreRelationships));

    return callAPI(API_V2.GET_ENTITY_BY_GUID, AtlasEntityWithExtInfo.class, queryParams, guid);
}
 
源代码28 项目: atlas   文件: AtlasClientV2.java
public AtlasEntitiesWithExtInfo getEntitiesByGuids(List<String> guids, boolean minExtInfo, boolean ignoreRelationships) throws AtlasServiceException {
    MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();

    queryParams.put("guid", guids);
    queryParams.add("minExtInfo", String.valueOf(minExtInfo));
    queryParams.add("ignoreRelationships", String.valueOf(ignoreRelationships));

    return callAPI(API_V2.GET_ENTITIES_BY_GUIDS, AtlasEntitiesWithExtInfo.class, queryParams);
}
 
源代码29 项目: atlas   文件: AtlasClientV2.java
public AtlasSearchResult fullTextSearchWithParams(final String query, final int limit, final int offset) throws AtlasServiceException {
    MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
    queryParams.add(QUERY, query);
    queryParams.add(LIMIT, String.valueOf(limit));
    queryParams.add(OFFSET, String.valueOf(offset));

    return callAPI(API_V2.FULL_TEXT_SEARCH, AtlasSearchResult.class, queryParams);
}
 
源代码30 项目: ribbon   文件: GetPostTest.java
@Test
public void testGet() throws Exception {
	URI getUri = new URI(SERVICE_URI + "test/getObject");
	MultivaluedMapImpl params = new MultivaluedMapImpl();
	params.add("name", "test");
	HttpRequest request = HttpRequest.newBuilder().uri(getUri).queryParams("name", "test").build();
	HttpResponse response = client.execute(request);
	assertEquals(200, response.getStatus());
	assertTrue(response.getEntity(TestObject.class).name.equals("test"));
}