Created
April 25, 2019 01:49
-
-
Save tsuchm/14efc8f0e08c6720040cdc49cfef4746 to your computer and use it in GitHub Desktop.
Sample code to use Shibboleth authentication information on Java servelet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.*; | |
| import java.net.URLDecoder; | |
| import javax.servlet.*; | |
| import javax.servlet.http.*; | |
| public class GetHeaders extends HttpServlet { | |
| public void doGet(HttpServletRequest request, | |
| HttpServletResponse response) | |
| throws IOException, ServletException { | |
| response.setContentType("text/html; charset=UTF-8"); | |
| PrintWriter out = response.getWriter(); | |
| // ヘッダ情報の変数名一覧を取得する | |
| java.util.Enumeration envnam = request.getHeaderNames(); | |
| // ヘッダ情報一覧表用のHTMLを格納する文字列 | |
| String rows = ""; | |
| // 各ヘッダ情報についての処理 | |
| while(envnam.hasMoreElements()){ | |
| // ヘッダ情報の変数名を取得 | |
| String name = (String)envnam.nextElement(); | |
| // ヘッダ情報の値を取得 | |
| String rawvalue = request.getHeader(name); | |
| String value = null; | |
| try { | |
| value = new String(rawvalue.getBytes("iso-8859-1"), "utf-8"); | |
| } catch( Exception e ){ | |
| value = rawvalue; | |
| } | |
| // 一覧表用のHTMLを作成する | |
| rows += "<tr><td>" + name + "</td><td>" + value + "</td></tr>"; | |
| } | |
| out.println("<html>"); | |
| out.println("<title>ヘッダ情報の取得</title>"); | |
| out.println("<body><h1>ヘッダ情報の取得</h1><p><table border=\"1\">"); | |
| out.println("<thead><tr><td>ヘッダ名</td><td>値</td></tr></thead>"); | |
| out.println("<tbody>"); | |
| out.println(rows); | |
| out.println("</tbody></table><a href=\"GetHeaders.java\">サンプルコード</a></body>"); | |
| out.println("</html>"); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| RedirectMatch ^/sandbox$ /sandbox/ | |
| ProxyPass /sandbox/ ajp://localhost:8009/sandbox/ | |
| <Location /sandbox/> | |
| AuthType shibboleth | |
| ShibRequestSetting requireSession 1 | |
| ShibUseHeaders on | |
| Require organizationalStatus enabled | |
| </Location> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment