⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 openidaxsubmit.jsp

📁 开源的OpenId的一个java实现
💻 JSP
字号:
<%@page import="org.wso2.solutions.identity.relyingparty.TokenVerifierConstants"%>
<%@page import="org.wso2.solutions.identity.relyingparty.HTMLEncoder"%>
<%@page import="org.wso2.solutions.identity.IdentityConstants"%>
<%@page import="org.wso2.solutions.identity.relyingparty.openid.OpenIDAuthenticationRequest"%>
<%@page import="org.wso2.solutions.identity.relyingparty.openid.OpenIDConsumer"%>
<%@page import="org.wso2.solutions.identity.relyingparty.openid.OpenIDRequestType"%>
<%@page import="org.wso2.solutions.identity.relyingparty.RelyingPartyException"%>
<%@page import="org.wso2.utils.ServerConfiguration"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
</head>
<body>

	<%
		try
		{
			OpenIDAuthenticationRequest openIDAuthRequest = null;
      		openIDAuthRequest = new OpenIDAuthenticationRequest(request,response);
      	
      		openIDAuthRequest.setOpenIDUrl((String)request.getParameter("openIdUrl"));

			ServerConfiguration serverConfig = null;
            	String host = null;
            	String httpsPort = null;
                  String useOpenIDSchema = null;

            	serverConfig = ServerConfiguration.getInstance();
            	host = serverConfig.getFirstProperty("HostName");
            	httpsPort = serverConfig.getFirstProperty("Ports.HTTPS");  

                  useOpenIDSchema = (String)request.getParameter("useSchema");


  			openIDAuthRequest
                    .addRequestType(OpenIDRequestType.ATTRIBUTE_EXCHANGE);

                 if (useOpenIDSchema != null && useOpenIDSchema .equalsIgnoreCase("true"))
                 {

            	// Set the required claims - I need these claims from the OpenID
            	// Provider.
            	openIDAuthRequest.addRequiredClaims(
                    IdentityConstants.OpenId.ExchangeAttributes.NICK_NAME,
                    "http://schema.openid.net/namePerson/friendly");
	            openIDAuthRequest.addRequiredClaims(
                    IdentityConstants.OpenId.ExchangeAttributes.FULL_NAME,
                    "http://schema.openid.net/namePerson");
            	openIDAuthRequest.addRequiredClaims(
                    IdentityConstants.OpenId.ExchangeAttributes.EMAIL,
                    "http://schema.openid.net/contact/email");
            	openIDAuthRequest.addRequiredClaims(
                    IdentityConstants.OpenId.ExchangeAttributes.DOB,
                    "http://schema.openid.net/birthDate");
            	openIDAuthRequest.addRequiredClaims(
                    IdentityConstants.OpenId.ExchangeAttributes.GENDER,
                    "http://schema.openid.net/person/gender");
            	openIDAuthRequest.addRequiredClaims(
                    IdentityConstants.OpenId.ExchangeAttributes.POSTAL_CODE,
                    "http://schema.openid.net/contact/postalCode/home");
            	openIDAuthRequest.addRequiredClaims(
                    IdentityConstants.OpenId.ExchangeAttributes.COUNTRY,
                    "http://schema.openid.net/contact/country/home");
            	openIDAuthRequest.addRequiredClaims(
                    IdentityConstants.OpenId.ExchangeAttributes.LANGUAGE,
                    "http://schema.openid.net/pref/language");       	
                  }
                  else
                  { 
                  // Set the required claims - I need these claims from the OpenID
            	// Provider.
            	openIDAuthRequest.addRequiredClaims(
                    IdentityConstants.OpenId.ExchangeAttributes.NICK_NAME,
                    IdentityConstants.OpenId.ExchangeAttributes.NICK_NAME_NS);
            	openIDAuthRequest.addRequiredClaims(
                    IdentityConstants.OpenId.ExchangeAttributes.FULL_NAME,
                    IdentityConstants.OpenId.ExchangeAttributes.FULL_NAME_NS);
            	openIDAuthRequest.addRequiredClaims(
                    IdentityConstants.OpenId.ExchangeAttributes.EMAIL,
                    IdentityConstants.OpenId.ExchangeAttributes.EMAIL_NS);
            	openIDAuthRequest.addRequiredClaims(
                    IdentityConstants.OpenId.ExchangeAttributes.DOB,
                    IdentityConstants.OpenId.ExchangeAttributes.DOB_NS);
            	openIDAuthRequest.addRequiredClaims(
                    IdentityConstants.OpenId.ExchangeAttributes.GENDER,
                    IdentityConstants.OpenId.ExchangeAttributes.GENDER_NS);
            	openIDAuthRequest.addRequiredClaims(
                    IdentityConstants.OpenId.ExchangeAttributes.POSTAL_CODE,
                    IdentityConstants.OpenId.ExchangeAttributes.POSTAL_CODE_NS);
            	openIDAuthRequest.addRequiredClaims(
                    IdentityConstants.OpenId.ExchangeAttributes.COUNTRY,
                    IdentityConstants.OpenId.ExchangeAttributes.COUNTRY_NS);
            	openIDAuthRequest.addRequiredClaims(
                    IdentityConstants.OpenId.ExchangeAttributes.LANGUAGE,
                    IdentityConstants.OpenId.ExchangeAttributes.LANGUAGE_NS);
            	openIDAuthRequest.addRequiredClaims(
                    IdentityConstants.OpenId.ExchangeAttributes.TIMEZONE,
                    IdentityConstants.OpenId.ExchangeAttributes.TIMEZONE_NS);
                  }
                                          
            	openIDAuthRequest.setReturnUrl("https://" + host + ":" + httpsPort + "/" + "javarp/openidloggedin.jsp");

      		OpenIDConsumer.getInstance().doOpenIDAuthentication(openIDAuthRequest);
		}
		catch(RelyingPartyException e)
		{
			out.println(e.getMessage());
		}


	%>

<br/><br/>

<a href="index.html">Back</a>

</body>

</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -