Example usage for org.springframework.util LinkedMultiValueMap LinkedMultiValueMap

List of usage examples for org.springframework.util LinkedMultiValueMap LinkedMultiValueMap

Introduction

In this page you can find the example usage for org.springframework.util LinkedMultiValueMap LinkedMultiValueMap.

Prototype

public LinkedMultiValueMap() 

Source Link

Document

Create a new LinkedMultiValueMap that wraps a LinkedHashMap .

Usage

From source file:org.trustedanalytics.h2oscoringengine.publisher.restapi.validation.PasswordValidationRuleTest.java

@Test
public void validate_emptyPasswordKeyInData_exceptionThrown() {
    //given//from   w w  w  . jav  a  2 s . c o m
    MultiValueMap<String, String> requestWithEmptyPasswordKey = new LinkedMultiValueMap<>();
    requestWithEmptyPasswordKey.add(PasswordValidationRule.PASSWORD_KEY, "");
    PasswordValidationRule rule = new PasswordValidationRule(new FormDataValidator());

    //then
    thrown.expect(ValidationException.class);

    //when
    rule.validate(requestWithEmptyPasswordKey);
}

From source file:org.trustedanalytics.h2oscoringengine.publisher.restapi.validation.UsernameValidationRuleTest.java

@Test
public void validate_emptyUsernameKeyInData_exceptionThrown() {
    // given// w  w  w .ja v  a  2  s. co m
    MultiValueMap<String, String> requestWithEmptyUsernameKey = new LinkedMultiValueMap<>();
    requestWithEmptyUsernameKey.add(UsernameValidationRule.USERNAME_KEY, "");
    UsernameValidationRule rule = new UsernameValidationRule(new FormDataValidator());

    // then
    thrown.expect(ValidationException.class);

    // when
    rule.validate(requestWithEmptyUsernameKey);
}

From source file:com.naver.template.social.connect.DaoConnectionRepository.java

public MultiValueMap<String, Connection<?>> findAllConnections() {
    //List<Connection<?>> resultList = jdbcTemplate.query(selectFromUserConnection() + " where userId = ? order by providerId, rank", connectionMapper, userId);
    List<Connection<?>> resultList = userConnectionDAO.selectAllConnections(userId);
    MultiValueMap<String, Connection<?>> connections = new LinkedMultiValueMap<String, Connection<?>>();
    Set<String> registeredProviderIds = connectionFactoryLocator.registeredProviderIds();
    for (String registeredProviderId : registeredProviderIds) {
        connections.put(registeredProviderId, Collections.<Connection<?>>emptyList());
    }//  w w w  .j  a  va 2s.co m
    for (Connection<?> connection : resultList) {
        String providerId = connection.getKey().getProviderId();
        if (connections.get(providerId).size() == 0) {
            connections.put(providerId, new LinkedList<Connection<?>>());
        }
        connections.add(providerId, connection);
    }
    return connections;
}

From source file:org.mitre.openid.connect.client.DefaultUserInfoFetcher.java

@Override
public UserInfo loadUserInfo(OIDCAuthenticationToken token) {

    ServerConfiguration serverConfiguration = token.getServerConfiguration();

    if (serverConfiguration == null) {
        logger.warn("No server configuration found.");
        return null;
    }// ww w . ja v  a 2s.  c o m

    if (Strings.isNullOrEmpty(serverConfiguration.getUserInfoUri())) {
        logger.warn("No userinfo endpoint, not fetching.");
        return null;
    }

    // if we got this far, try to actually get the userinfo
    HttpClient httpClient = new SystemDefaultHttpClient();

    HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory(httpClient);

    RestTemplate restTemplate = new RestTemplate(factory);

    MultiValueMap<String, String> form = new LinkedMultiValueMap<String, String>();
    form.add("access_token", token.getAccessTokenValue());

    try {
        String userInfoString = restTemplate.postForObject(serverConfiguration.getUserInfoUri(), form,
                String.class);

        JsonObject userInfoJson = new JsonParser().parse(userInfoString).getAsJsonObject();

        UserInfo userInfo = DefaultUserInfo.fromJson(userInfoJson);

        return userInfo;
    } catch (Exception e) {
        logger.warn("Error fetching userinfo", e);
        return null;
    }

}

From source file:org.craftercms.profile.services.impl.AbstractProfileRestClientBase.java

protected MultiValueMap<String, String> createBaseParams() {
    MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
    RestClientUtils.addValue(ProfileConstants.PARAM_ACCESS_TOKEN_ID, accessTokenIdResolver.getAccessTokenId(),
            params);//from   w w  w .j  a v a 2  s .c o m

    return params;
}

From source file:com.fns.grivet.service.NamedQueryServiceSelectTest.java

@Test
public void testCreateThenGetHappyPath() throws IOException {
    Resource r = resolver.getResource("classpath:TestSelectQuery.json");
    String json = IOUtils.toString(r.getInputStream(), Charset.defaultCharset());
    NamedQuery namedQuery = objectMapper.readValue(json, NamedQuery.class);
    namedQueryService.create(namedQuery);

    MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
    params.add("createdTime", LocalDateTime.now().plusDays(1).toString());
    String result = namedQueryService.get("getAttributesCreatedBefore", params);
    String[] expected = { "bigint", "varchar", "decimal", "datetime", "int", "text", "json", "boolean" };
    List<String> actual = JsonPath.given(result).getList("name");
    Assertions.assertTrue(actual.containsAll(Arrays.asList(expected)));
}

From source file:org.unidle.social.ConnectionRepositoryImpl.java

@Override
@Transactional(readOnly = true)//  w ww  .  ja v a 2 s.  c  om
public MultiValueMap<String, Connection<?>> findAllConnections() {

    final MultiValueMap<String, Connection<?>> connections = new LinkedMultiValueMap<>();

    final List<UserConnection> userConnections = userConnectionRepository.findAll(user);
    for (final UserConnection userConnection : userConnections) {

        final Connection<?> connection = Functions.toConnection(connectionFactoryLocator, textEncryptor)
                .apply(userConnection);

        connections.add(userConnection.getProviderId(), connection);
    }

    return connections;
}

From source file:am.ik.categolj2.app.authentication.AuthenticationHelper.java

public HttpEntity<MultiValueMap<String, Object>> createRopRequest(String username, String password) {
    MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
    params.add("username", username);
    params.add("password", password);
    params.add("grant_type", "password");
    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
    byte[] clientInfo = (adminClientProperties.getClientId() + ":" + adminClientProperties.getClientSecret())
            .getBytes(StandardCharsets.UTF_8);
    String basic = new String(Base64.getEncoder().encode(clientInfo), StandardCharsets.UTF_8);
    headers.set(com.google.common.net.HttpHeaders.AUTHORIZATION, "Basic " + basic);
    return new HttpEntity<>(params, headers);
}

From source file:org.apigw.util.OAuthTestHelper.java

public String getAuthorizationCode(String clientId, String redirectUri, String scope) {
    String cookie = loginAndGetConfirmationPage(clientId, redirectUri, scope);
    HttpHeaders headers = new HttpHeaders();
    headers.setAccept(Arrays.asList(MediaType.TEXT_HTML));
    headers.set("Cookie", cookie);
    MultiValueMap<String, String> formData = new LinkedMultiValueMap<String, String>();
    formData.add("user_oauth_approval", "true");
    ResponseEntity<Void> result = serverRunning.postForStatus("/apigw-auth-server-web/oauth/authorize", headers,
            formData);//from w w w .j av a2  s .com
    assertEquals(HttpStatus.FOUND, result.getStatusCode());
    // Get the authorization code using the same session
    return getAuthorizationCode(result);
}

From source file:com.epam.reportportal.auth.OAuthSuccessHandler.java

@Override
protected void handle(HttpServletRequest request, HttpServletResponse response, Authentication authentication)
        throws IOException, ServletException {
    OAuth2Authentication oauth = (OAuth2Authentication) authentication;
    OAuth2AccessToken accessToken = tokenServicesFacade.get().createToken(ReportPortalClient.ui,
            oauth.getName(), oauth.getUserAuthentication(), oauth.getOAuth2Request().getExtensions());

    MultiValueMap<String, String> query = new LinkedMultiValueMap<>();
    query.add("token", accessToken.getValue());
    query.add("token_type", accessToken.getTokenType());
    URI rqUrl = UriComponentsBuilder.fromHttpRequest(new ServletServerHttpRequest(request))
            .replacePath("/ui/authSuccess.html").replaceQueryParams(query).build().toUri();

    eventPublisher.publishEvent(new UiUserSignedInEvent(authentication));

    getRedirectStrategy().sendRedirect(request, response, rqUrl.toString());
}