|
String | buildHtml (String title, String actionUrl, Map< String, String > params) |
|
Helper class to do a browser redirect via a POST.
- 著者
- Bill Burke
- バージョン
- Revision
- 1
◆ buildHtml()
String org.keycloak.common.util.HttpPostRedirect.buildHtml |
( |
String |
title, |
|
|
String |
actionUrl, |
|
|
Map< String, String > |
params |
|
) |
| |
|
inline |
Generate an HTML page that does a browser redirect via a POST. The HTML document uses Javascript to automatically submit a FORM post when loaded.
This is similar to what the SAML Post Binding does.
Here's an example
<HTML>
<HEAD>
<TITLE>title</TITLE>
</HEAD>
<BODY Onload="document.forms[0].submit()">
<FORM METHOD="POST" ACTION="actionUrl">
<INPUT TYPE="HIDDEN" NAME="param" VALUE="value"/>
<NOSCRIPT>
<P>JavaScript is disabled. We strongly recommend to enable it. Click the button below to continue.</P>
<INPUT TYPE="SUBMIT" VALUE="CONTINUE"/>
</NOSCRIPT>
</FORM>
</BODY>
</HTML>
- 引数
-
title | may be null. Just the title of the HTML document |
actionUrl | URL to redirect to |
params | must be encoded so that they can be placed in an HTML form hidden INPUT field value |
- 戻り値
64 StringBuilder builder =
new StringBuilder();
65 builder.append(
"<HTML>")
68 builder.append(
"<TITLE>SAML HTTP Post Binding</TITLE>");
70 builder.append(
"</HEAD>")
71 .append(
"<BODY Onload=\"document.forms[0].submit()\">")
73 .append(
"<FORM METHOD=\"POST\" ACTION=\"").append(actionUrl).append(
"\">");
74 for (Map.Entry<String, String> param : params.entrySet()) {
75 builder.append(
"<INPUT TYPE=\"HIDDEN\" NAME=\"").append(param.getKey()).append(
"\"").append(
" VALUE=\"").append(param.getValue()).append(
"\"/>");
79 builder.append(
"<NOSCRIPT>")
80 .append(
"<P>JavaScript is disabled. We strongly recommend to enable it. Click the button below to continue.</P>")
81 .append(
"<INPUT TYPE=\"SUBMIT\" VALUE=\"CONTINUE\" />")
82 .append(
"</NOSCRIPT>")
84 .append(
"</FORM></BODY></HTML>");
86 return builder.toString();
このクラス詳解は次のファイルから抽出されました: