Search in sources :

Example 26 with LinkedMultiValueMap

use of org.springframework.util.LinkedMultiValueMap in project portal by ixinportal.

the class outTest method test.

@Test
public void test() throws IOException {
    // String csr = getImgBase64();
    String url = "http://124.205.224.179:9018/portal/evidence/generate";
    // String url = "http://localhost:8080/portal/evidence/generate";
    String appId = "6726df2211aa4d";
    String serviceCode = "idd0001.1";
    String businessSn = null;
    String evidenceSns = "csfwicz201709281922442165307";
    String name = "小明";
    String code = "123456789";
    LinkedMultiValueMap<String, Object> map = new LinkedMultiValueMap<String, Object>();
    map.add("appId", appId);
    map.add("serviceCode", serviceCode);
    map.add("businessSn", businessSn);
    map.add("name", name);
    map.add("code", code);
    map.add("evidenceSns", evidenceSns);
    try {
        HttpHeaders headers = new HttpHeaders();
        headers.add("Content-Signature", "HMAC-SHA1 " + Base64.encode(HMACSHA1.getHmacSHA1(appId + serviceCode + evidenceSns + businessSn + name + code, "5119e22fe26c4da1acf25a512c702a5f"), false));
        System.out.println(Base64.encode(HMACSHA1.getHmacSHA1(appId + serviceCode + evidenceSns + businessSn + name + code, "5119e22fe26c4da1acf25a512c702a5f"), false));
        HttpEntity httpEntity = new HttpEntity(map, headers);
        ResponseEntity<String> resStr = restTemplate.exchange(url, HttpMethod.POST, httpEntity, String.class);
        System.out.println("statusCode:" + resStr.getStatusCode());
        System.out.println("body:" + resStr.getBody());
    } catch (Exception e) {
        e.printStackTrace();
    }
/*	File file = new File("D://eventBase64.txt");
		File filePdf = new File("D://123.pdf");
		
		try {
			writeTxtFile(getEvidenceBase64(), file);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}*/
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) HttpEntity(org.springframework.http.HttpEntity) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Test(org.junit.Test) UserInfoWebControllerTest(com.itrus.portal.controller.web.test.UserInfoWebControllerTest)

Example 27 with LinkedMultiValueMap

use of org.springframework.util.LinkedMultiValueMap in project portal by ixinportal.

the class ClientWebControllerTest method testgetAllInfo3.

@Test
public void testgetAllInfo3() {
    try {
        String url = "https://ixin.itrus.com.cn/clientWeb/getProductInfo";
        LinkedMultiValueMap<String, Object> map = new LinkedMultiValueMap<String, Object>();
        // 项目id
        map.add("projectName", "宁波CA");
        // 
        map.add("type", 2);
        map.add("certSn", "4A52B8E3B7C7478BEDB2E7732496D699BA627F16");
        map.add("keySn", "TW15031122021634");
        map.add("isregister", 0);
        // enterprise
        map.add("enterprise_enterpriseName", "宁波高新区天威诚信数字证书技术服务有限公司");
        map.add("enterprise_enterpriseSn", "91330201677673485L");
        // map.add("enterprise_orgIndustry", 1);
        map.add("enterprise_enterpriseNature", 1);
        // userInfo
        map.add("userInfo_realName", "张琼艳");
        map.add("userInfo_trustMPhnoe", true);
        map.add("userInfo_trustEmail", true);
        map.add("userInfo_mPhone", "13123801307");
        map.add("userInfo_email", "153312045@qq.com");
        map.add("userInfo_telephone", "0574-87324610");
        // map.add("userInfo_userPosition", "java");
        map.add("userInfo_postalCode", "315000");
        map.add("userInfo_regionCodes", "");
        map.add("userInfo_userAdds", "宁波市海曙区华楼街8号");
        map.add("userInfo_orgIndustry", 9);
        // 营业执照businessLicense_
        // 
        map.add("businessLicense_enterpriseName", "宁波高新区天威诚信数字证书技术服务有限公司");
        // 
        map.add("businessLicense_licenseNo", "330215000008195");
        // 是否三证合一,是否三证合一
        map.add("businessLicense_isDateless", false);
        // 住所
        map.add("businessLicense_abode", "宁波高新区院士路66号创业大厦5-41室");
        // 住所
        map.add("businessLicense_businessScope", null);
        // 
        map.add("businessLicense_regFund", "100万元");
        // 
        map.add("businessLicense_operationStart", "2008-08-18 00:00:00");
        // 
        map.add("businessLicense_operationEnd", "2018-08-17 23:59:59");
        // 
        map.add("businessLicense_imgFile", ImageUtils.getImgBase64("/com/itrus/portal/controller/web/test/businessLicense_imgFile.txt"));
        // 组织机构信息
        // 
        map.add("orgCode_enterpriseName", "宁波高新区天威诚信数字证书技术服务有限公司");
        // 
        map.add("orgCode_orgCode", "677673485");
        // 
        map.add("orgCode_imgFile", ImageUtils.getImgBase64("/com/itrus/portal/controller/web/test/orgCode_imgFile.txt"));
        // 税务登记信息taxregisterCert_
        // 
        map.add("taxregisterCert_enterpriseName", "宁波高新区天威诚信数字证书技术服务有限公司");
        // 
        map.add("taxregisterCert_certNo", "330207677673485");
        // 
        map.add("taxregisterCert_imgFile", ImageUtils.getImgBase64("/com/itrus/portal/controller/web/test/taxregisterCert_imgFile.txt"));
        // 法人信息
        // 
        map.add("identityCard_enterpriseName", "宁波高新区天威诚信数字证书技术服务有限公司");
        // 
        map.add("identityCard_idCode", "330103196504191647");
        // 
        map.add("identityCard_name", "胥琳");
        map.add("identityCard_cardType", 1);
        // 
        map.add("identityCard_frontImg", ImageUtils.getImgBase64("/com/itrus/portal/controller/web/test/identityCard_frontImg.txt"));
        // 
        map.add("identityCard_backImg", ImageUtils.getImgBase64("/com/itrus/portal/controller/web/test/identityCard_backImg.txt"));
        CloseableHttpClient httpClient = RestTemplateUtils.acceptsUntrustedCertsHttpClient();
        HttpComponentsClientHttpRequestFactory clientHttpRequestFactory = new HttpComponentsClientHttpRequestFactory(httpClient);
        RestTemplate restTemplate = new RestTemplate(clientHttpRequestFactory);
        String map2 = restTemplate.postForObject(url, map, String.class);
        System.out.println(map2);
    } catch (Exception e) {
        // TODO: handle exception
        e.printStackTrace();
    }
}
Also used : CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) RestTemplate(org.springframework.web.client.RestTemplate) HttpComponentsClientHttpRequestFactory(org.springframework.http.client.HttpComponentsClientHttpRequestFactory) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) AbstractTest(com.itrus.portal.abstracttest.test.AbstractTest) Test(org.junit.Test)

Example 28 with LinkedMultiValueMap

use of org.springframework.util.LinkedMultiValueMap in project portal by ixinportal.

the class RrdSaveTest method testYace.

// @Test
public void testYace() throws Exception {
    // 调用url
    String url = "https://47.104.188.51/evidence/save";
    String appId = "e2e9623ef6c64f";
    String serviceCode = "cz0002";
    String evidenceSn = null;
    String hashAlg = "SHA-1";
    String evidencePackage = "{\"authEvent\":{\"eventSn\":\"TWS0001\",\"eventType\":\"2\",\"eventHapPlatform\":{\"hapPlatformName\":\"北京天威诚信\",\"hapPlatformDomain\":\"www.beijing.com\"},\"principalId\":[{\"name\":\"测试人人贷\",\"dataId\":\"000000000000000000\",\"type\":\"1\"},{\"name\":\"测试人人贷1\",\"dataId\":\"000000000000000001\",\"type\":\"1\"},{\"name\":\"测试人人贷2\",\"dataId\":\"000000000000000002\",\"type\":\"1\"},{\"name\":\"测试人人贷4\",\"dataId\":\"000000000000000003\",\"type\":\"1\"},{\"name\":\"测试人人贷3\",\"dataId\":\"000000000000000003\",\"type\":\"1\"},{\"name\":\"测试人人贷5\",\"dataId\":\"000000000000000005\",\"type\":\"1\"},{\"name\":\"测试人人贷2\",\"dataId\":\"000000000000000002\",\"type\":\"1\"},{\"name\":\"测试人人贷3\",\"dataId\":\"000000000000000003\",\"type\":\"1\"}],\"eventContent\":{\"title\":\"存证合同\",\"validStartTime\":\"1511921076793\",\"validEndTime\":\"1511921076793\",\"dataFormat\":\"1\",\"contCode\":\"000000001\"}}}";
    String signedBase64 = testSign(evidencePackage);
    System.out.println(signedBase64);
    LinkedMultiValueMap<String, Object> map = new LinkedMultiValueMap<String, Object>();
    map.add("appId", appId);
    map.add("serviceCode", serviceCode);
    map.add("hashAlg", hashAlg);
    map.add("evidencePackage", evidencePackage);
    map.add("signedBase64", signedBase64);
    HttpHeaders headers = new HttpHeaders();
    headers.add("Content-Signature", "HMAC-SHA1 " + Base64.encode(HMACSHA1.getHmacSHA1(appId + serviceCode + evidenceSn + hashAlg + signedBase64 + evidencePackage, "3d4988ea60174912aad197757a4e1b95"), false));
    System.out.println(Base64.encode(HMACSHA1.getHmacSHA1(appId + serviceCode + evidenceSn + hashAlg + signedBase64 + evidencePackage, "3d4988ea60174912aad197757a4e1b95"), false));
    HttpEntity httpEntity = new HttpEntity(map, headers);
    ResponseEntity<String> resStr = restTemplate.exchange(url, HttpMethod.POST, httpEntity, String.class);
    System.out.println("statusCode:" + resStr.getStatusCode());
    System.out.println("body:" + resStr.getBody());
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) HttpEntity(org.springframework.http.HttpEntity) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap)

Example 29 with LinkedMultiValueMap

use of org.springframework.util.LinkedMultiValueMap in project portal by ixinportal.

the class RrdSaveTest method test.

@Test
public void test() throws Exception {
    /**
     * 参数配置根据实际为准
     */
    // 调用url
    String url = "http://127.0.0.1:8080/portal/evidence/osstest";
    // String appId = "de0fd604774749";
    // String serviceCode = "cz0004";
    // String evidenceSn = null;
    // String hashAlg = "SHA-1";
    // String evidencePackage = "{\"authEvent\":{\"eventSn\":\"TWS0001\",\"eventType\":\"2\",\"eventHapPlatform\":{\"hapPlatformName\":\"北京天威诚信\",\"hapPlatformDomain\":\"www.beijing.com\"},\"principalId\":[{\"name\":\"测试人人贷\",\"dataId\":\"000000000000000000\",\"type\":\"1\"},{\"name\":\"测试人人贷1\",\"dataId\":\"000000000000000001\",\"type\":\"1\"},{\"name\":\"测试人人贷2\",\"dataId\":\"000000000000000002\",\"type\":\"1\"},{\"name\":\"测试人人贷3\",\"dataId\":\"000000000000000003\",\"type\":\"1\"},{\"name\":\"测试人人贷3\",\"dataId\":\"000000000000000003\",\"type\":\"1\"},{\"name\":\"测试人人贷3\",\"dataId\":\"000000000000000003\",\"type\":\"1\"}],\"eventContent\":{\"title\":\"存证合同\",\"validStartTime\":\"1511921076793\",\"validEndTime\":\"1511921076793\",\"dataFormat\":\"1\",\"contCode\":\"000000001\"}}}";
    // String signedBase64 = testSign(evidencePackage);
    // System.out.println(signedBase64);
    LinkedMultiValueMap<String, Object> map = new LinkedMultiValueMap<String, Object>();
    map.add("type", 1);
    // map.add("serviceCode", serviceCode);
    // map.add("hashAlg", hashAlg);
    // map.add("evidencePackage", evidencePackage);1
    // map.add("signedBase64", signedBase64);
    // HttpHeaders headers = new HttpHeaders();
    // headers.add("Content-Signature", "HMAC-SHA1 " + Base64.encode(HMACSHA1.getHmacSHA1(appId+serviceCode+evidenceSn+
    // hashAlg+signedBase64+evidencePackage, "3806693ee9674d469e0a73d56ec34a83"), false));
    // System.out.println(Base64.encode(HMACSHA1.getHmacSHA1("828a4ceddb6a42cz0002nullSHA1MIIF8AYJKoZIhvcNAQcCoIIF4TCCBd0CAQExCzAJBgUrDgMCGgUAMAsGCSqGSIb3DQEHAaCCA/0wggP5MIIC4aADAgECAhQeTaNwnOTXTduNA54N/nWQ34SzQjANBgkqhkiG9w0BAQsFADB7MQswCQYD VQQGEwJDTjETMBEGA1UECgwKaVRydXNDaGluYTEcMBoGA1UECwwTQ2hpbmEgVHJ1c3QgTmV0d29y azE5MDcGA1UEAwwwaVRydXNDaGluYSBDbGFzcyAyIEVudGVycHJpc2UgU3Vic2NyaWJlciBDQSAt IEczMB4XDTE3MTIxMjA2NTY1M1oXDTE4MTIxMjA2NTY1M1owbDEYMBYGA1UEAwwP5Lq65Lq66LS3 5rWL6K+VMRUwEwYDVQQLDAzor4Hmja7mnI3liqExOTA3BgNVBAoMMOWMl+S6rOWkqeWogeivmuS/ oeeUteWtkOWVhuWKoeacjeWKoeaciemZkOWFrOWPuDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC AQoCggEBAN7Kd2e/j7dqSUul/cghicjNbVuF790l2j26KmTq10vMccAQjmBoIBuD399GzycnYTbd 0D2mI5JxopRr3iKtSW59fuZxXxhxLa7hgm9xC9Rf599iuOH8lDKIdwK3eNi61x3DyaQYAOikkiVq SjrP+vHoHUexylcxjkDVCiSy/a9nKCR2UMQIYdYw7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drCNOBR5Id3PMPuJB4cWxvsSkUlH7w5mTk8ZecO 7h8tzbnhH8uXPcyAZ/ffugdQ+dYz6RwEr6wF9aCiMLaiffsPOC8Xat0CCS3aoOJZgnR07ezOpMPW l00+ANynYIaEPmC/WKf51kcl24ni+xhmsAfbxbM/HKzB3OCTmribypFqfvvrNHuEtRadXxXGX2R7 x13bqkZtCcEbT8IofjfoiFWmZABXtlLBsBgdwJ9R7BylBpwizowZHaKQ{\"authEvent\":{\"eventContent\":{\"contCode\":\"56F64D2511B596B350E47C91BC4114D8762513A6\",\"dataFormat\":\"1\"},\"eventHapPlatform\":{\"hapPlatformDomain\":\"www.renrendai.com\",\"hapPlatformName\":\"人人贷商务顾问(北京)有限公司\"},\"eventSn\":\"BORROW9713\",\"eventType\":\"2\",\"principalId\":[{\"dataId\":\"1001110010101010\",\"name\":\"周杰伦\",\"type\":\"2\"},{\"dataId\":\"yingyeNumber\",\"name\":\"人人贷\",\"type\":\"1\"}]}}", "0bf02da952444c1f97a33095922bc9af"), false));
    HttpEntity httpEntity = new HttpEntity(map, null);
    ResponseEntity<String> resStr = restTemplate.exchange(url, HttpMethod.POST, httpEntity, String.class);
    System.out.println("statusCode:" + resStr.getStatusCode());
    System.out.println("body:" + resStr.getBody());
}
Also used : HttpEntity(org.springframework.http.HttpEntity) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) Test(org.junit.Test)

Example 30 with LinkedMultiValueMap

use of org.springframework.util.LinkedMultiValueMap in project portal by ixinportal.

the class RrdSaveTest method test118.

// @Test
public void test118() throws Exception {
    // 调用url
    String url = "http://10.157.103.143/portal/evidence/save";
    String appId = "561eef791b474f";
    String serviceCode = "idd0001";
    String evidenceSn = null;
    String hashAlg = "SHA-1";
    String evidencePackage = "{\"authEvent\":{\"eventContent\":{\"contCode\":\"56F64D2511B596B350E47C91BC4114D8762513A6\",\"dataFormat\":\"1\"},\"eventHapPlatform\":{\"hapPlatformDomain\":\"www.ceshi.com\",\"hapPlatformName\":\"测试(北京)有限公司\"},\"eventSn\":\"BORROW9713\",\"eventType\":\"2\",\"principalId\":[{\"dataId\":\"1001110010101010\",\"name\":\"周杰伦\",\"type\":\"2\"},{\"dataId\":\"yingyeNumber\",\"name\":\"周润发\",\"type\":\"1\"}]}}";
    String signedBase64 = testSign(evidencePackage);
    // System.out.println(evidencePackage);
    LinkedMultiValueMap<String, Object> map = new LinkedMultiValueMap<String, Object>();
    map.add("appId", appId);
    map.add("serviceCode", serviceCode);
    map.add("hashAlg", hashAlg);
    map.add("evidencePackage", evidencePackage);
    map.add("signedBase64", signedBase64);
    HttpHeaders headers = new HttpHeaders();
    headers.add("Content-Signature", "HMAC-SHA1 " + Base64.encode(HMACSHA1.getHmacSHA1(appId + serviceCode + evidenceSn + hashAlg + signedBase64 + evidencePackage, "d283620085e04f868c72f21997b70234"), false));
    System.out.println(Base64.encode(HMACSHA1.getHmacSHA1(appId + serviceCode + evidenceSn + hashAlg + signedBase64 + evidencePackage, "d283620085e04f868c72f21997b70234"), false));
    HttpEntity httpEntity = new HttpEntity(map, headers);
    ResponseEntity<String> resStr = restTemplate.exchange(url, HttpMethod.POST, httpEntity, String.class);
    System.out.println("statusCode:" + resStr.getStatusCode());
    System.out.println("body:" + resStr.getBody());
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) HttpEntity(org.springframework.http.HttpEntity) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap)

Aggregations

LinkedMultiValueMap (org.springframework.util.LinkedMultiValueMap)413 Test (org.junit.Test)153 HttpHeaders (org.springframework.http.HttpHeaders)126 MultiValueMap (org.springframework.util.MultiValueMap)94 Test (org.junit.jupiter.api.Test)88 HttpEntity (org.springframework.http.HttpEntity)60 List (java.util.List)42 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)40 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)37 HashMap (java.util.HashMap)36 MediaType (org.springframework.http.MediaType)34 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)33 URI (java.net.URI)33 Map (java.util.Map)31 AbstractReadWriteDtoControllerRestTest (eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoControllerRestTest)30 ArrayList (java.util.ArrayList)27 UUID (java.util.UUID)27 lombok.val (lombok.val)27 IOException (java.io.IOException)26 Assert (org.junit.Assert)25