keycloak-service
公開メンバ関数 | 静的公開変数類 | 静的非公開変数類 | 全メンバ一覧
org.keycloak.authentication.forms.RegistrationUserCreation クラス
org.keycloak.authentication.forms.RegistrationUserCreation の継承関係図
Inheritance graph
org.keycloak.authentication.forms.RegistrationUserCreation 連携図
Collaboration graph

公開メンバ関数

String getHelpText ()
 
List< ProviderConfigProperty > getConfigProperties ()
 
void validate (ValidationContext context)
 
void buildPage (FormContext context, LoginFormsProvider form)
 
void success (FormContext context)
 
boolean requiresUser ()
 
boolean configuredFor (KeycloakSession session, RealmModel realm, UserModel user)
 
void setRequiredActions (KeycloakSession session, RealmModel realm, UserModel user)
 
boolean isUserSetupAllowed ()
 
void close ()
 
String getDisplayType ()
 
String getReferenceCategory ()
 
boolean isConfigurable ()
 
AuthenticationExecutionModel.Requirement [] getRequirementChoices ()
 
FormAction create (KeycloakSession session)
 
void init (Config.Scope config)
 
void postInit (KeycloakSessionFactory factory)
 
String getId ()
 

静的公開変数類

static final String PROVIDER_ID = "registration-user-creation"
 

静的非公開変数類

static AuthenticationExecutionModel.Requirement [] REQUIREMENT_CHOICES
 

詳解

著者
Bill Burke
バージョン
Revision
1

関数詳解

◆ buildPage()

void org.keycloak.authentication.forms.RegistrationUserCreation.buildPage ( FormContext  context,
LoginFormsProvider  form 
)
inline
117  {
118 
119  }

◆ close()

void org.keycloak.authentication.forms.RegistrationUserCreation.close ( )
inline
174  {
175 
176  }

◆ configuredFor()

boolean org.keycloak.authentication.forms.RegistrationUserCreation.configuredFor ( KeycloakSession  session,
RealmModel  realm,
UserModel  user 
)
inline
158  {
159  return true;
160  }

◆ create()

FormAction org.keycloak.authentication.forms.RegistrationUserCreation.create ( KeycloakSession  session)
inline
202  {
203  return this;
204  }

◆ getConfigProperties()

List<ProviderConfigProperty> org.keycloak.authentication.forms.RegistrationUserCreation.getConfigProperties ( )
inline
59  {
60  return null;
61  }

◆ getDisplayType()

String org.keycloak.authentication.forms.RegistrationUserCreation.getDisplayType ( )
inline
179  {
180  return "Registration User Creation";
181  }

◆ getHelpText()

String org.keycloak.authentication.forms.RegistrationUserCreation.getHelpText ( )
inline
54  {
55  return "This action must always be first! Validates the username of the user in validation phase. In success phase, this will create the user in the database.";
56  }

◆ getId()

String org.keycloak.authentication.forms.RegistrationUserCreation.getId ( )
inline
217  {
218  return PROVIDER_ID;
219  }
static final String PROVIDER_ID
Definition: RegistrationUserCreation.java:51

◆ getReferenceCategory()

String org.keycloak.authentication.forms.RegistrationUserCreation.getReferenceCategory ( )
inline
184  {
185  return null;
186  }

◆ getRequirementChoices()

AuthenticationExecutionModel.Requirement [] org.keycloak.authentication.forms.RegistrationUserCreation.getRequirementChoices ( )
inline
198  {
199  return REQUIREMENT_CHOICES;
200  }
static AuthenticationExecutionModel.Requirement [] REQUIREMENT_CHOICES
Definition: RegistrationUserCreation.java:193

◆ init()

void org.keycloak.authentication.forms.RegistrationUserCreation.init ( Config.Scope  config)
inline
207  {
208 
209  }

◆ isConfigurable()

boolean org.keycloak.authentication.forms.RegistrationUserCreation.isConfigurable ( )
inline
189  {
190  return false;
191  }

◆ isUserSetupAllowed()

boolean org.keycloak.authentication.forms.RegistrationUserCreation.isUserSetupAllowed ( )
inline
168  {
169  return false;
170  }

◆ postInit()

void org.keycloak.authentication.forms.RegistrationUserCreation.postInit ( KeycloakSessionFactory  factory)
inline
212  {
213 
214  }

◆ requiresUser()

boolean org.keycloak.authentication.forms.RegistrationUserCreation.requiresUser ( )
inline
153  {
154  return false;
155  }

◆ setRequiredActions()

void org.keycloak.authentication.forms.RegistrationUserCreation.setRequiredActions ( KeycloakSession  session,
RealmModel  realm,
UserModel  user 
)
inline
163  {
164 
165  }

◆ success()

void org.keycloak.authentication.forms.RegistrationUserCreation.success ( FormContext  context)
inline
122  {
123  MultivaluedMap<String, String> formData = context.getHttpRequest().getDecodedFormParameters();
124  String email = formData.getFirst(Validation.FIELD_EMAIL);
125  String username = formData.getFirst(RegistrationPage.FIELD_USERNAME);
126  if (context.getRealm().isRegistrationEmailAsUsername()) {
127  username = formData.getFirst(RegistrationPage.FIELD_EMAIL);
128  }
129  context.getEvent().detail(Details.USERNAME, username)
130  .detail(Details.REGISTER_METHOD, "form")
131  .detail(Details.EMAIL, email)
132  ;
133  UserModel user = context.getSession().users().addUser(context.getRealm(), username);
134  user.setEnabled(true);
135 
136  user.setEmail(email);
137  context.getAuthenticationSession().setClientNote(OIDCLoginProtocol.LOGIN_HINT_PARAM, username);
138  AttributeFormDataProcessor.process(formData, context.getRealm(), user);
139  context.setUser(user);
140  context.getEvent().user(user);
141  context.getEvent().success();
142  context.newEvent().event(EventType.LOGIN);
143  context.getEvent().client(context.getAuthenticationSession().getClient().getClientId())
144  .detail(Details.REDIRECT_URI, context.getAuthenticationSession().getRedirectUri())
145  .detail(Details.AUTH_METHOD, context.getAuthenticationSession().getProtocol());
146  String authType = context.getAuthenticationSession().getAuthNote(Details.AUTH_TYPE);
147  if (authType != null) {
148  context.getEvent().detail(Details.AUTH_TYPE, authType);
149  }
150  }

◆ validate()

void org.keycloak.authentication.forms.RegistrationUserCreation.validate ( ValidationContext  context)
inline
64  {
65  MultivaluedMap<String, String> formData = context.getHttpRequest().getDecodedFormParameters();
66  List<FormMessage> errors = new ArrayList<>();
67  context.getEvent().detail(Details.REGISTER_METHOD, "form");
68 
69  String email = formData.getFirst(Validation.FIELD_EMAIL);
70  String username = formData.getFirst(RegistrationPage.FIELD_USERNAME);
71  context.getEvent().detail(Details.USERNAME, username);
72  context.getEvent().detail(Details.EMAIL, email);
73 
74  String usernameField = RegistrationPage.FIELD_USERNAME;
75  if (context.getRealm().isRegistrationEmailAsUsername()) {
76  context.getEvent().detail(Details.USERNAME, email);
77 
78  if (Validation.isBlank(email)) {
79  errors.add(new FormMessage(RegistrationPage.FIELD_EMAIL, Messages.MISSING_EMAIL));
80  } else if (!Validation.isEmailValid(email)) {
81  errors.add(new FormMessage(RegistrationPage.FIELD_EMAIL, Messages.INVALID_EMAIL));
82  formData.remove(Validation.FIELD_EMAIL);
83  }
84  if (errors.size() > 0) {
85  context.error(Errors.INVALID_REGISTRATION);
86  context.validationError(formData, errors);
87  return;
88  }
89  if (email != null && !context.getRealm().isDuplicateEmailsAllowed() && context.getSession().users().getUserByEmail(email, context.getRealm()) != null) {
90  context.error(Errors.EMAIL_IN_USE);
91  formData.remove(Validation.FIELD_EMAIL);
92  errors.add(new FormMessage(RegistrationPage.FIELD_EMAIL, Messages.EMAIL_EXISTS));
93  context.validationError(formData, errors);
94  return;
95  }
96  } else {
97  if (Validation.isBlank(username)) {
98  context.error(Errors.INVALID_REGISTRATION);
99  errors.add(new FormMessage(RegistrationPage.FIELD_USERNAME, Messages.MISSING_USERNAME));
100  context.validationError(formData, errors);
101  return;
102  }
103 
104  if (context.getSession().users().getUserByUsername(username, context.getRealm()) != null) {
105  context.error(Errors.USERNAME_IN_USE);
106  errors.add(new FormMessage(usernameField, Messages.USERNAME_EXISTS));
107  formData.remove(Validation.FIELD_USERNAME);
108  context.validationError(formData, errors);
109  return;
110  }
111 
112  }
113  context.success();
114  }

メンバ詳解

◆ PROVIDER_ID

final String org.keycloak.authentication.forms.RegistrationUserCreation.PROVIDER_ID = "registration-user-creation"
static

◆ REQUIREMENT_CHOICES

AuthenticationExecutionModel.Requirement [] org.keycloak.authentication.forms.RegistrationUserCreation.REQUIREMENT_CHOICES
staticprivate
初期値:
= {
AuthenticationExecutionModel.Requirement.REQUIRED,
AuthenticationExecutionModel.Requirement.DISABLED
}

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