开发者

Open ID End point forward is not working

I am new to Open Id development.I have downloaded openid4java sample application from the internet and trying to implement the same in mine.Till now i have written the code to hit to open id end point after discover.its working till discovering.But after that when trying to hit the end point URI I am getting 404 error because its appending my project URL path also. Ex:

/Openid/http:/www.myopenid.com/server.(here Openid is my project name).

This is my servlet :

package com.openid.registration;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.openid4java.discovery.DiscoveryInformation;
import org.openid4java.message.AuthRequest;

public class OpenIdRegistrationServlet extends HttpServlet
{
private static final long serialVersionUID = 1L;
private Stri开发者_JAVA技巧ng returnToUrl;
RequestDispatcher rd = null;

protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException 
{
    HttpSession session=request.getSession(false);
    String OpenID=request.getParameter("openid");
    System.out.println("Open ID entered by the user"+OpenID);
    // Delegate to Open ID code
    DiscoveryInformation discoveryInformation = RegistrationService.performDiscoveryOnUserSuppliedIdentifier(OpenID);
    // Store the disovery results in session.
    System.out.println("OPEnd Point"+discoveryInformation.getOPEndpoint());
    session.setAttribute("discoveryInformation", discoveryInformation);
     // Create the AuthRequest
    returnToUrl=RegistrationService.getReturnToUrl();
    AuthRequest authRequest = RegistrationService.createOpenIdAuthRequest(discoveryInformation, returnToUrl);
    rd = request.getRequestDispatcher(authRequest.getDestinationUrl(true));
    System.out.println("Destination URL:"+authRequest.getDestinationUrl(true));
    rd.forward(request, response);

}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    processRequest(request,response);
    // TODO Auto-generated method stub
}

/**
 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
 */
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    processRequest(request,response);
    // TODO Auto-generated method stub
}

}

I have deployed my application in tomcat 5.Is there any way to remove my project name from the URL or do i need to redirect from apache webserver ? Any help is appreciated


Its my mistake.I have changed forward(request, response) to sendRedirect(authRequest.getDestinationUrl(true)).Its started working fine.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜