keycloak
公開メンバ関数 | 全メンバ一覧
org.keycloak.common.util.HttpPostRedirect クラス
org.keycloak.common.util.HttpPostRedirect 連携図
Collaboration graph

公開メンバ関数

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>
引数
titlemay be null. Just the title of the HTML document
actionUrlURL to redirect to
paramsmust be encoded so that they can be placed in an HTML form hidden INPUT field value
戻り値
63  {
64  StringBuilder builder = new StringBuilder();
65  builder.append("<HTML>")
66  .append("<HEAD>");
67  if (title != null) {
68  builder.append("<TITLE>SAML HTTP Post Binding</TITLE>");
69  }
70  builder.append("</HEAD>")
71  .append("<BODY Onload=\"document.forms[0].submit()\">")
72 
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("\"/>");
76  }
77 
78 
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>")
83 
84  .append("</FORM></BODY></HTML>");
85 
86  return builder.toString();
87  }

このクラス詳解は次のファイルから抽出されました: