Search in sources :

Example 21 with LinkedMultiValueMap

use of org.springframework.util.LinkedMultiValueMap in project cas by apereo.

the class GoogleAuthenticatorRestHttpRequestCredentialFactoryTests method verifyNoCredentials.

@Test
public void verifyNoCredentials() {
    final GoogleAuthenticatorRestHttpRequestCredentialFactory f = new GoogleAuthenticatorRestHttpRequestCredentialFactory();
    final LinkedMultiValueMap body = new LinkedMultiValueMap<>();
    final List<Credential> results = f.fromRequestBody(body);
    assertTrue(results.isEmpty());
}
Also used : Credential(org.apereo.cas.authentication.Credential) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) Test(org.junit.Test)

Example 22 with LinkedMultiValueMap

use of org.springframework.util.LinkedMultiValueMap in project perry by ca-cwds.

the class LoginServiceImpl method invalidate.

@Override
public void invalidate(String perryToken) {
    OAuth2AccessToken accessToken = tokenService.deleteToken(perryToken);
    try {
        HttpHeaders headers = new HttpHeaders();
        MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
        params.add("token", accessToken.getValue());
        params.add("token_type_hint", "access_token");
        headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
        HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(params, headers);
        restClientService.clientRestTemplate().postForEntity(revokeTokenUri, request, String.class).getBody();
    } catch (Exception e) {
        throw new PerryException("Token Revocation problem for revokeTokenUri = " + revokeTokenUri, e);
    }
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) HttpEntity(org.springframework.http.HttpEntity) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) OAuth2AccessToken(org.springframework.security.oauth2.common.OAuth2AccessToken) PerryException(gov.ca.cwds.rest.api.domain.PerryException) MultiValueMap(org.springframework.util.MultiValueMap) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) PerryException(gov.ca.cwds.rest.api.domain.PerryException)

Example 23 with LinkedMultiValueMap

use of org.springframework.util.LinkedMultiValueMap in project CzechIdMng by bcvsolutions.

the class DefaultAuditServiceTest method createAndEditOneTransaction.

@Test
public void createAndEditOneTransaction() {
    String username = "test_user_" + System.currentTimeMillis();
    IdmIdentityDto newIdentity = getTransactionTemplate().execute(new TransactionCallback<IdmIdentityDto>() {

        public IdmIdentityDto doInTransaction(TransactionStatus transactionStatus) {
            IdmIdentityDto identity = new IdmIdentityDto();
            identity.setUsername(username);
            identity.setFirstName(username);
            identity.setLastName(username);
            identity = identityService.save(identity);
            // 
            identity.setEmail("example@example.tld");
            identity.setLastName(username + "edit");
            return identityService.save(identity);
        }
    });
    assertEquals(newIdentity.getUsername(), username);
    MultiValueMap<String, Object> parameters = new LinkedMultiValueMap<>();
    parameters.put("username", ImmutableList.of(username));
    List<IdmAuditDto> audits = auditService.findEntityWithRelation(IdmIdentity.class, parameters, null).getContent();
    assertEquals(2, audits.size());
    // 
    String contractChangedAttribute = audits.get(0).getChangedAttributes();
    assertTrue(contractChangedAttribute.contains("externe"));
    assertTrue(contractChangedAttribute.contains("position"));
    assertTrue(contractChangedAttribute.contains("identity"));
    assertTrue(contractChangedAttribute.contains("disabled"));
    assertTrue(contractChangedAttribute.contains("main"));
    // 
    String identityChangedAttribute = audits.get(1).getChangedAttributes();
    assertTrue(identityChangedAttribute.contains("state"));
    assertTrue(identityChangedAttribute.contains("email"));
    assertTrue(identityChangedAttribute.contains("lastName"));
}
Also used : LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) IdmAuditDto(eu.bcvsolutions.idm.core.api.audit.dto.IdmAuditDto) TransactionStatus(org.springframework.transaction.TransactionStatus) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentity(eu.bcvsolutions.idm.core.model.entity.IdmIdentity) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 24 with LinkedMultiValueMap

use of org.springframework.util.LinkedMultiValueMap in project CzechIdMng by bcvsolutions.

the class DefaultAuditServiceTest method editAndDeleteOneTrasaction.

@Test
public void editAndDeleteOneTrasaction() {
    String username = "test_user_" + System.currentTimeMillis();
    IdmIdentityDto identity = new IdmIdentityDto();
    identity.setUsername(username);
    identity.setFirstName(username);
    identity.setLastName(username);
    identityService.save(identity);
    IdmIdentityDto newIdentity = getTransactionTemplate().execute(new TransactionCallback<IdmIdentityDto>() {

        public IdmIdentityDto doInTransaction(TransactionStatus transactionStatus) {
            IdmIdentityDto identity = identityService.getByCode(username);
            identity.setFirstName(username + "--edit");
            identity = identityService.save(identity);
            // hibernate send this as one query
            // 
            identityService.delete(identity);
            return null;
        }
    });
    assertEquals(newIdentity, null);
    MultiValueMap<String, Object> parameters = new LinkedMultiValueMap<>();
    parameters.put("username", ImmutableList.of(username));
    List<IdmAuditDto> audits = auditService.findEntityWithRelation(IdmIdentity.class, parameters, null).getContent();
    // add idenity + contract -- delete identity + contract
    assertEquals(4, audits.size());
}
Also used : LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) IdmAuditDto(eu.bcvsolutions.idm.core.api.audit.dto.IdmAuditDto) TransactionStatus(org.springframework.transaction.TransactionStatus) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentity(eu.bcvsolutions.idm.core.model.entity.IdmIdentity) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 25 with LinkedMultiValueMap

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

the class SelectSaveTest method test.

@Test
public void test() throws Exception {
    String url = "http://124.205.224.179:9018/portal1/evidence/searchStored";
    url = "https://ixin.itrus.com.cn/evidence/searchStored";
    String appId = "561eef791b474f";
    String evidenceSn = "yycsicz201710160947163906505";
    LinkedMultiValueMap<String, Object> map = new LinkedMultiValueMap<String, Object>();
    map.add("appId", appId);
    map.add("evidenceSn", evidenceSn);
    try {
        HttpHeaders headers = new HttpHeaders();
        headers.add("Content-Signature", "HMAC-SHA1 " + Base64.encode(HMACSHA1.getHmacSHA1(appId + evidenceSn, "d283620085e04f868c72f21997b70234"), false));
        System.out.println(Base64.encode(HMACSHA1.getHmacSHA1(appId + evidenceSn, "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());
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) HttpEntity(org.springframework.http.HttpEntity) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) JSONObject(com.alibaba.fastjson.JSONObject) Test(org.junit.Test)

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