keycloak
クラス | 公開メンバ関数 | 静的公開メンバ関数 | 限定公開メンバ関数 | 限定公開変数類 | 関数 | 全メンバ一覧
org.keycloak.authentication.ConsoleDisplayMode クラス
org.keycloak.authentication.ConsoleDisplayMode 連携図
Collaboration graph

クラス

class  HeaderBuilder
 

公開メンバ関数

LoginFormsProvider form ()
 
Response message (String msg, String... params)
 
Response text (String text)
 
Response response ()
 
HeaderBuilder header ()
 

静的公開メンバ関数

static Response browserRequired (KeycloakSession session)
 
static Response browserContinue (KeycloakSession session, String callback)
 
static ConsoleDisplayMode challenge (RequiredActionContext context)
 
static ConsoleDisplayMode challenge (AuthenticationFlowContext context)
 
static HeaderBuilder header (RequiredActionContext context)
 
static HeaderBuilder header (AuthenticationFlowContext context)
 

限定公開メンバ関数

LoginFormsProvider formInternal ()
 

限定公開変数類

RequiredActionContext requiredActionContext
 
AuthenticationFlowContext flowContext
 
HeaderBuilder header
 

関数

 ConsoleDisplayMode (RequiredActionContext requiredActionContext)
 
 ConsoleDisplayMode (AuthenticationFlowContext flowContext)
 

詳解

This class encapsulates a proprietary HTTP challenge protocol designed by keycloak team which is used by text-based console clients to dynamically render and prompt for information in a textual manner. The class is a builder which can build the challenge response (the header and response body).

When doing code to token flow in OAuth, server could respond with

401 WWW-Authenticate: X-Text-Form-Challenge callback="http://localhost/..." param="username" label="Username: " mask=false param="password" label="Password: " mask=true Content-Type: text/plain

Please login with your username and password

The client receives this challenge. It first outputs whatever the text body of the message contains. It will then prompt for username and password using the label values as prompt messages for each parameter.

After the input has been entered by the user, the client does a form POST to the callback url with the values of the input parameters entered.

The server can challenge with 401 as many times as it wants. The client will look for 302 responses. It will will follow all redirects unless the Location url has an OAuth "code" parameter. If there is a code parameter, then the client will stop and finish the OAuth flow to obtain a token. Any other response code other than 401 or 302 the client should abort with an error message.

構築子と解体子

◆ ConsoleDisplayMode() [1/2]

org.keycloak.authentication.ConsoleDisplayMode.ConsoleDisplayMode ( RequiredActionContext  requiredActionContext)
inlinepackage
117  {
119  }
RequiredActionContext requiredActionContext
Definition: ConsoleDisplayMode.java:126

◆ ConsoleDisplayMode() [2/2]

org.keycloak.authentication.ConsoleDisplayMode.ConsoleDisplayMode ( AuthenticationFlowContext  flowContext)
inlinepackage
121  {
122  this.flowContext = flowContext;
123  }
AuthenticationFlowContext flowContext
Definition: ConsoleDisplayMode.java:127

関数詳解

◆ browserContinue()

static Response org.keycloak.authentication.ConsoleDisplayMode.browserContinue ( KeycloakSession  session,
String  callback 
)
inlinestatic

Browser is required to continue login. This will prompt client on whether to continue with a browser or abort.

引数
session
callback
戻り値
60  {
61  String browserContinueMsg = session.getProvider(LoginFormsProvider.class).getMessage("browserContinue");
62  String browserPrompt = session.getProvider(LoginFormsProvider.class).getMessage("browserContinuePrompt");
63  String answer = session.getProvider(LoginFormsProvider.class).getMessage("browserContinueAnswer");
64 
65  String header = "X-Text-Form-Challenge callback=\"" + callback + "\"";
66  header += " browserContinue=\"" + browserPrompt + "\" answer=\"" + answer + "\"";
67  return Response.status(Response.Status.UNAUTHORIZED)
68  .header("WWW-Authenticate", header)
69  .type(MediaType.TEXT_PLAIN)
70  .entity("\n" + browserContinueMsg + "\n").build();
71  }
HeaderBuilder header()
Definition: ConsoleDisplayMode.java:208
String build()
Definition: ConsoleDisplayMode.java:241

◆ browserRequired()

static Response org.keycloak.authentication.ConsoleDisplayMode.browserRequired ( KeycloakSession  session)
inlinestatic

Browser is required to login. This will abort client from doing a console login.

引数
session
戻り値
46  {
47  return Response.status(Response.Status.UNAUTHORIZED)
48  .header("WWW-Authenticate", "X-Text-Form-Challenge browserRequired")
49  .type(MediaType.TEXT_PLAIN)
50  .entity("\n" + session.getProvider(LoginFormsProvider.class).getMessage("browserRequired") + "\n").build();
51  }

◆ challenge() [1/2]

static ConsoleDisplayMode org.keycloak.authentication.ConsoleDisplayMode.challenge ( RequiredActionContext  context)
inlinestatic

Build challenge response for required actions

引数
context
戻り値
81  {
82  return new ConsoleDisplayMode(context);
83 
84  }
ConsoleDisplayMode(RequiredActionContext requiredActionContext)
Definition: ConsoleDisplayMode.java:117

◆ challenge() [2/2]

static ConsoleDisplayMode org.keycloak.authentication.ConsoleDisplayMode.challenge ( AuthenticationFlowContext  context)
inlinestatic

Build challenge response for authentication flows

引数
context
戻り値
92  {
93  return new ConsoleDisplayMode(context);
94 
95  }
ConsoleDisplayMode(RequiredActionContext requiredActionContext)
Definition: ConsoleDisplayMode.java:117

◆ form()

LoginFormsProvider org.keycloak.authentication.ConsoleDisplayMode.form ( )
inline

Create a theme form pre-populated with challenge

戻り値
135  {
136  if (header == null) throw new RuntimeException("Header Not Set");
137  return formInternal()
138  .setStatus(Response.Status.UNAUTHORIZED)
139  .setMediaType(MediaType.TEXT_PLAIN_TYPE)
140  .setResponseHeader(HttpHeaders.WWW_AUTHENTICATE, header.build());
141  }
LoginFormsProvider setResponseHeader(String headerName, String headerValue)
LoginFormsProvider setMediaType(javax.ws.rs.core.MediaType type)
HeaderBuilder header()
Definition: ConsoleDisplayMode.java:208
LoginFormsProvider formInternal()
Definition: ConsoleDisplayMode.java:194
LoginFormsProvider setStatus(Response.Status status)
String build()
Definition: ConsoleDisplayMode.java:241

◆ formInternal()

LoginFormsProvider org.keycloak.authentication.ConsoleDisplayMode.formInternal ( )
inlineprotected
194  {
195  if (requiredActionContext != null) {
196  return requiredActionContext.form();
197  } else {
198  return flowContext.form();
199 
200  }
201  }
AuthenticationFlowContext flowContext
Definition: ConsoleDisplayMode.java:127
RequiredActionContext requiredActionContext
Definition: ConsoleDisplayMode.java:126

◆ header() [1/3]

static HeaderBuilder org.keycloak.authentication.ConsoleDisplayMode.header ( RequiredActionContext  context)
inlinestatic

Build challenge response header only for required actions

引数
context
戻り値
102  {
103  return new ConsoleDisplayMode(context).header();
104 
105  }
ConsoleDisplayMode(RequiredActionContext requiredActionContext)
Definition: ConsoleDisplayMode.java:117

◆ header() [2/3]

static HeaderBuilder org.keycloak.authentication.ConsoleDisplayMode.header ( AuthenticationFlowContext  context)
inlinestatic

Build challenge response header only for authentication flows

引数
context
戻り値
113  {
114  return new ConsoleDisplayMode(context).header();
115 
116  }
ConsoleDisplayMode(RequiredActionContext requiredActionContext)
Definition: ConsoleDisplayMode.java:117

◆ header() [3/3]

HeaderBuilder org.keycloak.authentication.ConsoleDisplayMode.header ( )
inline

Start building the header

戻り値
208  {
209  String callback;
210  if (requiredActionContext != null) {
211  callback = requiredActionContext.getActionUrl(true).toString();
212  } else {
213  callback = flowContext.getActionUrl(flowContext.generateAccessCode(), true).toString();
214 
215  }
216  header = new HeaderBuilder(callback);
217  return header;
218  }
HeaderBuilder header()
Definition: ConsoleDisplayMode.java:208
AuthenticationFlowContext flowContext
Definition: ConsoleDisplayMode.java:127
RequiredActionContext requiredActionContext
Definition: ConsoleDisplayMode.java:126

◆ message()

Response org.keycloak.authentication.ConsoleDisplayMode.message ( String  msg,
String...  params 
)
inline

Create challenge response with a body generated from localized message.properties of your theme

引数
msgmessage id
paramsparameters to use to format the message
戻り値
152  {
153  if (header == null) throw new RuntimeException("Header Not Set");
154  Response response = Response.status(401)
155  .header(HttpHeaders.WWW_AUTHENTICATE, header.build())
156  .type(MediaType.TEXT_PLAIN)
157  .entity("\n" + formInternal().getMessage(msg, params) + "\n").build();
158  return response;
159  }
HeaderBuilder header()
Definition: ConsoleDisplayMode.java:208
Response response()
Definition: ConsoleDisplayMode.java:184
LoginFormsProvider formInternal()
Definition: ConsoleDisplayMode.java:194
String build()
Definition: ConsoleDisplayMode.java:241

◆ response()

Response org.keycloak.authentication.ConsoleDisplayMode.response ( )
inline

Generate response with empty http response body

戻り値
184  {
185  if (header == null) throw new RuntimeException("Header Not Set");
186  Response response = Response.status(401)
187  .header(HttpHeaders.WWW_AUTHENTICATE, header.build()).build();
188  return response;
189 
190  }
HeaderBuilder header()
Definition: ConsoleDisplayMode.java:208
Response response()
Definition: ConsoleDisplayMode.java:184
String build()
Definition: ConsoleDisplayMode.java:241

◆ text()

Response org.keycloak.authentication.ConsoleDisplayMode.text ( String  text)
inline

Create challenge response with a text message body

引数
textplain text of http response body
戻り値
168  {
169  if (header == null) throw new RuntimeException("Header Not Set");
170  Response response = Response.status(401)
171  .header(HttpHeaders.WWW_AUTHENTICATE, header.build())
172  .type(MediaType.TEXT_PLAIN)
173  .entity("\n" + text + "\n").build();
174  return response;
175 
176  }
HeaderBuilder header()
Definition: ConsoleDisplayMode.java:208
Response response()
Definition: ConsoleDisplayMode.java:184
Response text(String text)
Definition: ConsoleDisplayMode.java:168
String build()
Definition: ConsoleDisplayMode.java:241

メンバ詳解

◆ flowContext

AuthenticationFlowContext org.keycloak.authentication.ConsoleDisplayMode.flowContext
protected

◆ header

HeaderBuilder org.keycloak.authentication.ConsoleDisplayMode.header
protected

◆ requiredActionContext

RequiredActionContext org.keycloak.authentication.ConsoleDisplayMode.requiredActionContext
protected

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