没有回调URL的Steam OpenID身份验证

时间:2015-03-14 18:22:53

标签: java openid easymock google-openid steam

我正在尝试如何在我的java应用程序中添加一个蒸汽记录。我在http://openid.net/developers/libraries中尝试了几个OpenID库,这是针对JOpenID的,

例如 - >

    OpenIdManager manager = new OpenIdManager();

    manager.setTimeOut(10000);
    Endpoint endpoint = manager.lookupEndpoint("http://steamcommunity.com/openid");
    System.out.println(endpoint);
    Association association = manager.lookupAssociation(endpoint);
    System.out.println(association);
    String url = manager.getAuthenticationUrl(endpoint, association);
    System.out.println("Copy the authentication URL in browser:\n" + url);
    System.out.println("After successfully sign on in browser, enter the URL of address bar in browser:");

    String ret = url;
    HttpServletRequest request = createRequest(ret);
    Authentication authentication = manager.getAuthentication(request, association.getRawMacKey(), endpoint.getAlias());
    System.out.println(authentication);

因为我没有尝试使用这个网络应用程序而且我没有使用回调网址,所以我使用" easymock"

public HttpServletRequest createRequest(String url) throws UnsupportedEncodingException {
    int pos = url.indexOf('?');
    if (pos==(-1))
        throw new IllegalArgumentException("Bad url.");
    String query = url.substring(pos + 1);
    String[] params = query.split("[\\&]+");
    final Map<String, String> map = new HashMap<String, String>();
    for (String param : params) {
        pos = param.indexOf('=');
        if (pos==(-1))
            throw new IllegalArgumentException("Bad url.");
        String key = param.substring(0, pos);
        String value = param.substring(pos + 1);
        map.put(key, URLDecoder.decode(value, "UTF-8"));
    }
    return (HttpServletRequest) Proxy.newProxyInstance(
            Main.class.getClassLoader(),
            new Class[] { HttpServletRequest.class },
            new InvocationHandler() {
                public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                    if (method.getName().equals("getParameter"))
                        return map.get((String)args[0]);
                    throw new UnsupportedOperationException(method.getName());
                }


            }
    );
}  

但是我收到了一个错误,

java.lang.IllegalArgumentException: interface javax.servlet.http.HttpServletRequest is not visible from class loader
at java.lang.reflect.Proxy.getProxyClass0(Proxy.java:487)
at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:722)

我也尝试使用

中的代码

https://gist.github.com/FernFerret/7692878(对于Openid4java和spark)但在链接中创建Route时出错,说没有&#39; Route(String)&#39;

get(new Route("/") {

那么如何使用重定向URL进行OpenID身份验证呢?

任何人都可以使用&#34;任何&#34; OpenID代码指导我进行Steam的Java OpenID身份验证吗?

我只需要在

中提供的返回值(如 - &gt; http // steamcommunity.com / openid / id / 76561197960435530&#34;)

http://steamcommunity.com/dev/

返回的唯一值。

非常感谢任何投入!!

0 个答案:

没有答案