Skip to content

Commit

Permalink
Adding an authClient field in the PageLayout
Browse files Browse the repository at this point in the history
rh-pre-commit.version: 2.0.3
rh-pre-commit.check-secrets: ENABLED
  • Loading branch information
computate committed Nov 30, 2023
1 parent 2c50a20 commit 140af3e
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1172,6 +1172,66 @@ public static String staticSearchFqUserEmail(SiteRequestEnUS siteRequest_, Strin
return PageLayout.staticSearchStrUserEmail(siteRequest_, PageLayout.staticSearchUserEmail(siteRequest_, PageLayout.staticSetUserEmail(siteRequest_, o)));
}

////////////////
// authClient //
////////////////


/** The entity authClient
* is defined as null before being initialized.
*/
@JsonProperty
@JsonInclude(Include.NON_NULL)
protected JsonObject authClient;

/** <br> The entity authClient
* is defined as null before being initialized.
* <br><a href="https://solr-solr.apps-crc.testing/solr/computate/select?q=*:*&fq=partEstEntite_indexed_boolean:true&fq=classeNomCanonique_enUS_indexed_string:org.computate.smartvillage.enus.page.PageLayout&fq=entiteVar_enUS_indexed_string:authClient">Find the entity authClient in Solr</a>
* <br>
* @param w is for wrapping a value to assign to this entity during initialization.
**/
protected abstract void _authClient(Wrap<JsonObject> w);

public JsonObject getAuthClient() {
return authClient;
}

public void setAuthClient(JsonObject authClient) {
this.authClient = authClient;
}
@JsonIgnore
public void setAuthClient(String o) {
this.authClient = PageLayout.staticSetAuthClient(siteRequest_, o);
}
public static JsonObject staticSetAuthClient(SiteRequestEnUS siteRequest_, String o) {
if(o != null) {
return new JsonObject(o);
}
return null;
}
protected PageLayout authClientInit() {
Wrap<JsonObject> authClientWrap = new Wrap<JsonObject>().var("authClient");
if(authClient == null) {
_authClient(authClientWrap);
Optional.ofNullable(authClientWrap.getO()).ifPresent(o -> {
setAuthClient(o);
});
}
return (PageLayout)this;
}

public static String staticSearchAuthClient(SiteRequestEnUS siteRequest_, JsonObject o) {
return o.toString();
}

public static String staticSearchStrAuthClient(SiteRequestEnUS siteRequest_, String o) {
return o == null ? null : o.toString();
}

public static String staticSearchFqAuthClient(SiteRequestEnUS siteRequest_, String o) {
return PageLayout.staticSearchStrAuthClient(siteRequest_, PageLayout.staticSearchAuthClient(siteRequest_, PageLayout.staticSetAuthClient(siteRequest_, o)));
}

///////////////
// logoutUrl //
///////////////
Expand Down Expand Up @@ -4370,6 +4430,7 @@ public Future<Void> promisePageLayout(Promise<Void> promise) {
userFullNameInit();
userNameInit();
userEmailInit();
authClientInit();
logoutUrlInit();
long0Init();
long1Init();
Expand Down Expand Up @@ -4546,6 +4607,8 @@ public Object obtainPageLayout(String var) {
return oPageLayout.userName;
case "userEmail":
return oPageLayout.userEmail;
case "authClient":
return oPageLayout.authClient;
case "logoutUrl":
return oPageLayout.logoutUrl;
case "long0":
Expand Down Expand Up @@ -4727,6 +4790,8 @@ public static Object staticSetPageLayout(String entityVar, SiteRequestEnUS siteR
return PageLayout.staticSetUserName(siteRequest_, o);
case "userEmail":
return PageLayout.staticSetUserEmail(siteRequest_, o);
case "authClient":
return PageLayout.staticSetAuthClient(siteRequest_, o);
case "logoutUrl":
return PageLayout.staticSetLogoutUrl(siteRequest_, o);
case "long0":
Expand Down Expand Up @@ -4871,6 +4936,8 @@ public static Object staticSearchPageLayout(String entityVar, SiteRequestEnUS si
return PageLayout.staticSearchUserName(siteRequest_, (String)o);
case "userEmail":
return PageLayout.staticSearchUserEmail(siteRequest_, (String)o);
case "authClient":
return PageLayout.staticSearchAuthClient(siteRequest_, (JsonObject)o);
case "logoutUrl":
return PageLayout.staticSearchLogoutUrl(siteRequest_, (String)o);
case "long0":
Expand Down Expand Up @@ -5015,6 +5082,8 @@ public static String staticSearchStrPageLayout(String entityVar, SiteRequestEnUS
return PageLayout.staticSearchStrUserName(siteRequest_, (String)o);
case "userEmail":
return PageLayout.staticSearchStrUserEmail(siteRequest_, (String)o);
case "authClient":
return PageLayout.staticSearchStrAuthClient(siteRequest_, (String)o);
case "logoutUrl":
return PageLayout.staticSearchStrLogoutUrl(siteRequest_, (String)o);
case "long0":
Expand Down Expand Up @@ -5159,6 +5228,8 @@ public static String staticSearchFqPageLayout(String entityVar, SiteRequestEnUS
return PageLayout.staticSearchFqUserName(siteRequest_, o);
case "userEmail":
return PageLayout.staticSearchFqUserEmail(siteRequest_, o);
case "authClient":
return PageLayout.staticSearchFqAuthClient(siteRequest_, o);
case "logoutUrl":
return PageLayout.staticSearchFqLogoutUrl(siteRequest_, o);
case "long0":
Expand Down Expand Up @@ -5291,6 +5362,7 @@ public static String staticSearchFqPageLayout(String entityVar, SiteRequestEnUS
public static final String VAR_userFullName = "userFullName";
public static final String VAR_userName = "userName";
public static final String VAR_userEmail = "userEmail";
public static final String VAR_authClient = "authClient";
public static final String VAR_logoutUrl = "logoutUrl";
public static final String VAR_long0 = "long0";
public static final String VAR_long1 = "long1";
Expand Down Expand Up @@ -5366,6 +5438,7 @@ public static String staticSearchFqPageLayout(String entityVar, SiteRequestEnUS
public static final String DISPLAY_NAME_userFullName = "";
public static final String DISPLAY_NAME_userName = "";
public static final String DISPLAY_NAME_userEmail = "";
public static final String DISPLAY_NAME_authClient = "";
public static final String DISPLAY_NAME_logoutUrl = "";
public static final String DISPLAY_NAME_long0 = "";
public static final String DISPLAY_NAME_long1 = "";
Expand Down Expand Up @@ -5466,6 +5539,8 @@ public static String displayNamePageLayout(String var) {
return DISPLAY_NAME_userName;
case VAR_userEmail:
return DISPLAY_NAME_userEmail;
case VAR_authClient:
return DISPLAY_NAME_authClient;
case VAR_logoutUrl:
return DISPLAY_NAME_logoutUrl;
case VAR_long0:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,26 @@
*/
public class ConfigKeys extends ComputateConfigKeys {

/**
* The Auth clients of the site.
**/
public static final String AUTH_CLIENTS = "AUTH_CLIENTS";

/**
* The Auth Client callback URI
**/
public static final String AUTH_CALLBACK_URI = "AUTH_CALLBACK_URI";

/**
* The Auth Client logout URI
**/
public static final String AUTH_LOGOUT_URI = "AUTH_LOGOUT_URI";

/**
* The Auth Client OpenAPI ID
**/
public static final String AUTH_OPEN_API_ID = "AUTH_OPEN_API_ID";

/**
*
**/
Expand Down
12 changes: 10 additions & 2 deletions src/main/java/org/computate/smartvillage/enus/page/PageLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,21 @@ protected void _userEmail(Wrap<String> w) {
w.o(siteRequest_.getUserEmail());
}

/**
* Description: The current user's email
*/
protected void _authClient(Wrap<JsonObject> w) {
JsonObject config = siteRequest_.getConfig();
w.o(config.getJsonObject(ConfigKeys.AUTH_CLIENTS).getJsonObject(config.getJsonObject(ConfigKeys.AUTH_CLIENTS).fieldNames().stream().findFirst().orElse(null)));
}

/**
* Description: The logout URL
*/
protected void _logoutUrl(Wrap<String> w) {
JsonObject config = siteRequest_.getConfig();
try {
w.o(config.getString(ConfigKeys.AUTH_URL) + "/realms/" + config.getString(ConfigKeys.AUTH_REALM) + "/protocol/openid-connect/logout?redirect_uri=" + URLEncoder.encode(config.getString(ConfigKeys.SITE_BASE_URL) + "/logout", "UTF-8"));
JsonObject config = siteRequest_.getConfig();
w.o(authClient.getString(ConfigKeys.AUTH_URL) + "/realms/" + authClient.getString(ConfigKeys.AUTH_REALM) + "/protocol/openid-connect/logout?redirect_uri=" + URLEncoder.encode(config.getString(ConfigKeys.SITE_BASE_URL) + authClient.getString(ConfigKeys.AUTH_LOGOUT_URI), "UTF-8"));
} catch (UnsupportedEncodingException ex) {
ExceptionUtils.rethrow(ex);
}
Expand Down

0 comments on commit 140af3e

Please sign in to comment.