📄 userinfoservlet.java
字号:
/*
* Copyright 2005-2008 WSO2, Inc. (http://wso2.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wso2.solutions.identity.openid;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class UserInfoServlet extends HttpServlet {
private static final long serialVersionUID = -2306630174647697559L;
/**
*
*/
protected void service(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
String serverUrl = null;
String caller = null;
String back = "";
serverUrl = OpenIDProvider.getOpAddress();
caller = req.getRequestURI().substring(req.getServletPath().length());
if (!OpenIDUtil.isUserExist(caller.substring(1))) {
resp.setContentType("text/html");
back = "<html><head>\n"
+ "</head><body><h1>You are trying to do something fishy !!!</h1></body></html>";
} else {
// if ("html".equals(req.getParameter("format"))) {
resp.setContentType("text/html");
back = "<html><head>\n" + "<link rel='openid2.provider' href='"
+ serverUrl + "'/>\n" + "<link rel='openid.server' href='"
+ serverUrl + "'/>\n" + "</head><body>"
+ "<h2>This is the OpenID Url of user, "
+ caller.substring(1) + "</h2>" + "</body></html>";
/*
* } else { resp.setContentType("application/xrds+xml"); back = "<?xml
* version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<xrds:XRDS\n" + "
* xmlns:xrds=\"xri://$xrds\"\n" + "
* xmlns:openid=\"http://openid.net/xmlns/1.0\"\n" + "
* xmlns=\"xri://$xrd*($v*2.0)\">\n" + " <XRD>\n" + " <Service
* priority=\"0\">\n" + " <Type>http://openid.net/signon/1.0</Type>\n" + "
* <URI>" + serverUrl + "</URI>\n" + " </Service>\n" + " <Service
* priority=\"1\">\n" + "
* <Type>http://specs.openid.net/auth/2.0/signon</Type>\n" + "
* <URI>" + serverUrl + "</URI>\n" + " </Service>\n" + " </XRD>\n" + "</xrds:XRDS>"; }
*/
}
PrintWriter out = resp.getWriter();
out.write(back);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -