Examples of CoreOAuthProviderSupport


Examples of org.springframework.security.oauth.provider.filter.CoreOAuthProviderSupport

   * tests compatibility of calculating the signature base string.
   */
  @Test
  public void testCalculateSignatureBaseString() throws Exception {
    final String baseUrl = "http://www.springframework.org/schema/security/";
    CoreOAuthProviderSupport support = new CoreOAuthProviderSupport() {
      @Override
      protected String getBaseUrl(HttpServletRequest request) {
        return baseUrl;
      }
    };

    Map<String, String[]> parameterMap = new HashMap<String, String[]>();
    parameterMap.put("a", new String[] { "value-a" });
    parameterMap.put("b", new String[] { "value-b" });
    parameterMap.put("c", new String[] { "value-c" });
    parameterMap.put("param[1]", new String[] { "aaa", "bbb" });

    when(request.getParameterNames()).thenReturn(Collections.enumeration(parameterMap.keySet()));
    for (Map.Entry<String, String[]> param : parameterMap.entrySet()) {
      when(request.getParameterValues(param.getKey())).thenReturn(param.getValue());
    }

    String header = "OAuth realm=\"http://sp.example.com/\","
        + "                oauth_consumer_key=\"0685bd9184jfhq22\","
        + "                oauth_token=\"ad180jjd733klru7\","
        + "                oauth_signature_method=\"HMAC-SHA1\","
        + "                oauth_signature=\"wOJIO9A2W5mFwDgiDvZbTSMK%2FPY%3D\","
        + "                oauth_timestamp=\"137131200\"," + "                oauth_callback=\""
        + OAuthCodec.oauthEncode("http://myhost.com/callback") + "\","
        + "                oauth_nonce=\"4572616e48616d6d65724c61686176\","
        + "                oauth_version=\"1.0\"";
    when(request.getHeaders("Authorization")).thenReturn(Collections.enumeration(Arrays.asList(header)));
    when(request.getMethod()).thenReturn("GET");
    String ours = support.getSignatureBaseString(request);

    when(request.getHeaders("Authorization")).thenReturn(Collections.enumeration(Arrays.asList(header)));
    when(request.getParameterMap()).thenReturn(parameterMap);
    when(request.getHeaderNames()).thenReturn(null);
    OAuthMessage message = OAuthServlet.getMessage(request, baseUrl);
View Full Code Here

Examples of org.springframework.security.oauth.provider.filter.CoreOAuthProviderSupport

  /**
   * tests parsing parameters.
   */
  @Test
  public void testParseParameters() throws Exception {
    CoreOAuthProviderSupport support = new CoreOAuthProviderSupport();
    when(request.getHeaders("Authorization")).thenReturn(
        Collections.enumeration(Arrays.asList("OAuth realm=\"http://sp.example.com/\",\n"
            + "                oauth_consumer_key=\"0685bd9184jfhq22\",\n"
            + "                oauth_token=\"ad180jjd733klru7\",\n"
            + "                oauth_signature_method=\"HMAC-SHA1\",\n"
            + "                oauth_signature=\"wOJIO9A2W5mFwDgiDvZbTSMK%2FPY%3D\",\n"
            + "                oauth_timestamp=\"137131200\",\n"
            + "                oauth_nonce=\"4572616e48616d6d65724c61686176\",\n"
            + "                oauth_version=\"1.0\"")));
    Map<String, String> params = support.parseParameters(request);
    assertEquals("http://sp.example.com/", params.get("realm"));
    assertEquals("0685bd9184jfhq22", params.get(OAuthConsumerParameter.oauth_consumer_key.toString()));
    assertEquals("ad180jjd733klru7", params.get(OAuthConsumerParameter.oauth_token.toString()));
    assertEquals("HMAC-SHA1", params.get(OAuthConsumerParameter.oauth_signature_method.toString()));
    assertEquals("wOJIO9A2W5mFwDgiDvZbTSMK/PY=", params.get(OAuthConsumerParameter.oauth_signature.toString()));
View Full Code Here

Examples of org.springframework.security.oauth.provider.filter.CoreOAuthProviderSupport

            + "                oauth_timestamp=\"1191242096\",\n"
            + "                oauth_nonce=\"kllo9940pd9333jh\",\n"
            + "                oauth_version=\"1.0\"")));

    when(request.getMethod()).thenReturn("gEt");
    CoreOAuthProviderSupport support = new CoreOAuthProviderSupport();
    support.setBaseUrl("http://photos.example.net");
    when(request.getRequestURI()).thenReturn("photos");

    String baseString = support.getSignatureBaseString(request);
    assertEquals(
        "GET&http%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26oauth_consumer_key%3Ddpf43f3p2l4k3l03%26oauth_nonce%3Dkllo9940pd9333jh%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26oauth_version%3D1.0%26size%3Doriginal",
        baseString);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.