From 140af3ed17461b21a8cc0d5f42ed7bf71b1578a1 Mon Sep 17 00:00:00 2001 From: Christopher Tate Date: Thu, 30 Nov 2023 10:06:41 -0700 Subject: [PATCH] Adding an authClient field in the PageLayout rh-pre-commit.version: 2.0.3 rh-pre-commit.check-secrets: ENABLED --- .../smartvillage/enus/page/PageLayoutGen.java | 75 +++++++++++++++++++ .../smartvillage/enus/config/ConfigKeys.java | 20 +++++ .../smartvillage/enus/page/PageLayout.java | 12 ++- 3 files changed, 105 insertions(+), 2 deletions(-) diff --git a/src/gen/java/org/computate/smartvillage/enus/page/PageLayoutGen.java b/src/gen/java/org/computate/smartvillage/enus/page/PageLayoutGen.java index 9a88b6d5..a49d3d2f 100644 --- a/src/gen/java/org/computate/smartvillage/enus/page/PageLayoutGen.java +++ b/src/gen/java/org/computate/smartvillage/enus/page/PageLayoutGen.java @@ -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; + + /**
The entity authClient + * is defined as null before being initialized. + *
Find the entity authClient in Solr + *
+ * @param w is for wrapping a value to assign to this entity during initialization. + **/ + protected abstract void _authClient(Wrap 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 authClientWrap = new Wrap().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 // /////////////// @@ -4370,6 +4430,7 @@ public Future promisePageLayout(Promise promise) { userFullNameInit(); userNameInit(); userEmailInit(); + authClientInit(); logoutUrlInit(); long0Init(); long1Init(); @@ -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": @@ -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": @@ -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": @@ -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": @@ -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": @@ -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"; @@ -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 = ""; @@ -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: diff --git a/src/main/java/org/computate/smartvillage/enus/config/ConfigKeys.java b/src/main/java/org/computate/smartvillage/enus/config/ConfigKeys.java index f82ef67a..8cff8fce 100644 --- a/src/main/java/org/computate/smartvillage/enus/config/ConfigKeys.java +++ b/src/main/java/org/computate/smartvillage/enus/config/ConfigKeys.java @@ -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"; + /** * **/ diff --git a/src/main/java/org/computate/smartvillage/enus/page/PageLayout.java b/src/main/java/org/computate/smartvillage/enus/page/PageLayout.java index 011fb835..135ae3b2 100644 --- a/src/main/java/org/computate/smartvillage/enus/page/PageLayout.java +++ b/src/main/java/org/computate/smartvillage/enus/page/PageLayout.java @@ -184,13 +184,21 @@ protected void _userEmail(Wrap w) { w.o(siteRequest_.getUserEmail()); } + /** + * Description: The current user's email + */ + protected void _authClient(Wrap 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 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); }