From e6e7164e7aea5dbb7ecb90b76be439a0892e5786 Mon Sep 17 00:00:00 2001 From: melloware Date: Tue, 30 Dec 2025 08:06:54 -0500 Subject: [PATCH 1/6] OmniFaces 5.0 (adds new Security Tags) --- deployment/pom.xml | 2 +- .../deployment/OmnifacesProcessor.java | 21 ++++++++++++++++++- pom.xml | 2 +- .../runtime/FacesInfoContributor.java | 3 ++- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/deployment/pom.xml b/deployment/pom.xml index 00dfe3e..342de70 100644 --- a/deployment/pom.xml +++ b/deployment/pom.xml @@ -56,7 +56,7 @@ io.quarkus - quarkus-vertx-http-dev-ui-spi + quarkus-devui-deployment-spi io.quarkus diff --git a/deployment/src/main/java/io/quarkiverse/omnifaces/deployment/OmnifacesProcessor.java b/deployment/src/main/java/io/quarkiverse/omnifaces/deployment/OmnifacesProcessor.java index 4af341c..1346e4d 100644 --- a/deployment/src/main/java/io/quarkiverse/omnifaces/deployment/OmnifacesProcessor.java +++ b/deployment/src/main/java/io/quarkiverse/omnifaces/deployment/OmnifacesProcessor.java @@ -36,6 +36,9 @@ import org.omnifaces.config.WebXml; import org.omnifaces.resourcehandler.CombinedResourceHandler; import org.omnifaces.resourcehandler.WebAppManifest; +import org.omnifaces.security.AnonymousTagHandler; +import org.omnifaces.security.AuthenticatedTagHandler; +import org.omnifaces.security.AuthorizeTagHandler; import io.quarkus.arc.deployment.AdditionalBeanBuildItem; import io.quarkus.arc.deployment.AnnotationsTransformerBuildItem; @@ -185,9 +188,25 @@ void registerForReflection(BuildProducer reflectiveCla ReflectiveClassBuildItem.builder(classNames.toArray(new String[0])).methods(true).serialization(true).build()); } + @BuildStep + void registerSecurityTaglibForReflection(BuildProducer reflectiveClass) { + final List classes = new ArrayList<>(); + + classes.add(AnonymousTagHandler.class.getName()); + classes.add(AuthenticatedTagHandler.class.getName()); + classes.add(AuthorizeTagHandler.class.getName()); + + reflectiveClass.produce(ReflectiveClassBuildItem.builder(classes.toArray(new String[0])) + .constructors() + .methods() + .fields() + .serialization() + .build()); + } + @Record(ExecutionTime.STATIC_INIT) @BuildStep - void registerWebManifests(OmniFacesRecorder recorder, BuildProducer unremovableBeans) { + void registerUnremovableBeans(OmniFacesRecorder recorder, BuildProducer unremovableBeans) { // make WebManifest beans un-removable, users still have to make them beans // https://github.com/quarkiverse/quarkus-omnifaces/issues/72 unremovableBeans.produce(UnremovableBeanBuildItem.beanTypes(WebAppManifest.class)); diff --git a/pom.xml b/pom.xml index f62cba1..ebbc941 100644 --- a/pom.xml +++ b/pom.xml @@ -26,7 +26,7 @@ 17 3.27.0 4.1.2 - 5.0-M6 + 5.0 diff --git a/runtime/src/main/java/io/quarkus/omnifaces/runtime/FacesInfoContributor.java b/runtime/src/main/java/io/quarkus/omnifaces/runtime/FacesInfoContributor.java index f00eea7..9d39e55 100644 --- a/runtime/src/main/java/io/quarkus/omnifaces/runtime/FacesInfoContributor.java +++ b/runtime/src/main/java/io/quarkus/omnifaces/runtime/FacesInfoContributor.java @@ -4,6 +4,7 @@ import java.util.Map; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.Strings; import org.omnifaces.util.Faces; import io.quarkus.info.runtime.spi.InfoContributor; @@ -18,7 +19,7 @@ public String name() { @Override public Map data() { - String facesImpl = StringUtils.removeIgnoreCase(StringUtils.removeIgnoreCase(Faces.getImplInfo(), "Core"), "Impl"); + String facesImpl = Strings.CI.remove(Strings.CI.remove(Faces.getImplInfo(), "Core"), "Impl"); String server = "Undertow " + Undertow.class.getPackage().getImplementationVersion(); String omniFaces = "OmniFaces: " + StringUtils.defaultIfEmpty( org.omnifaces.util.Faces.class.getPackage().getImplementationVersion(), "???"); From da8792ba26a24763ddf564c94844d34ebdf948ff Mon Sep 17 00:00:00 2001 From: melloware Date: Tue, 30 Dec 2025 08:21:34 -0500 Subject: [PATCH 2/6] OmniFaces 5.0 (adds new Security Tags) --- .../omnifaces/deployment/OmnifacesProcessor.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/deployment/src/main/java/io/quarkiverse/omnifaces/deployment/OmnifacesProcessor.java b/deployment/src/main/java/io/quarkiverse/omnifaces/deployment/OmnifacesProcessor.java index 1346e4d..15a7f7d 100644 --- a/deployment/src/main/java/io/quarkiverse/omnifaces/deployment/OmnifacesProcessor.java +++ b/deployment/src/main/java/io/quarkiverse/omnifaces/deployment/OmnifacesProcessor.java @@ -64,6 +64,7 @@ import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem; import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBundleBuildItem; import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; +import io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedPackageBuildItem; import io.quarkus.deployment.pkg.steps.NativeOrNativeSourcesBuild; import io.quarkus.info.deployment.spi.InfoBuildTimeContributorBuildItem; import io.quarkus.omnifaces.runtime.FacesInfoContributor; @@ -189,19 +190,17 @@ void registerForReflection(BuildProducer reflectiveCla } @BuildStep - void registerSecurityTaglibForReflection(BuildProducer reflectiveClass) { + void runtimeInitializedSecurityTaglib(CombinedIndexBuildItem combinedIndex, + BuildProducer runtimeInitializedPackages) { final List classes = new ArrayList<>(); classes.add(AnonymousTagHandler.class.getName()); classes.add(AuthenticatedTagHandler.class.getName()); classes.add(AuthorizeTagHandler.class.getName()); - reflectiveClass.produce(ReflectiveClassBuildItem.builder(classes.toArray(new String[0])) - .constructors() - .methods() - .fields() - .serialization() - .build()); + classes.stream() + .map(RuntimeInitializedPackageBuildItem::new) + .forEach(runtimeInitializedPackages::produce); } @Record(ExecutionTime.STATIC_INIT) From 1190d07922a85cd1bc6996e26e444f8088d9b34e Mon Sep 17 00:00:00 2001 From: melloware Date: Tue, 30 Dec 2025 08:31:52 -0500 Subject: [PATCH 3/6] OmniFaces 5.0 (adds new Security Tags) --- deployment/pom.xml | 4 ++++ .../omnifaces/deployment/OmnifacesProcessor.java | 13 +++++++------ runtime/pom.xml | 4 ++++ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/deployment/pom.xml b/deployment/pom.xml index 342de70..7052130 100644 --- a/deployment/pom.xml +++ b/deployment/pom.xml @@ -46,6 +46,10 @@ io.quarkus quarkus-websockets-client-deployment + + io.quarkus + quarkus-security-deployment + io.quarkus quarkus-jsonp-deployment diff --git a/deployment/src/main/java/io/quarkiverse/omnifaces/deployment/OmnifacesProcessor.java b/deployment/src/main/java/io/quarkiverse/omnifaces/deployment/OmnifacesProcessor.java index 15a7f7d..1346e4d 100644 --- a/deployment/src/main/java/io/quarkiverse/omnifaces/deployment/OmnifacesProcessor.java +++ b/deployment/src/main/java/io/quarkiverse/omnifaces/deployment/OmnifacesProcessor.java @@ -64,7 +64,6 @@ import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem; import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBundleBuildItem; import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; -import io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedPackageBuildItem; import io.quarkus.deployment.pkg.steps.NativeOrNativeSourcesBuild; import io.quarkus.info.deployment.spi.InfoBuildTimeContributorBuildItem; import io.quarkus.omnifaces.runtime.FacesInfoContributor; @@ -190,17 +189,19 @@ void registerForReflection(BuildProducer reflectiveCla } @BuildStep - void runtimeInitializedSecurityTaglib(CombinedIndexBuildItem combinedIndex, - BuildProducer runtimeInitializedPackages) { + void registerSecurityTaglibForReflection(BuildProducer reflectiveClass) { final List classes = new ArrayList<>(); classes.add(AnonymousTagHandler.class.getName()); classes.add(AuthenticatedTagHandler.class.getName()); classes.add(AuthorizeTagHandler.class.getName()); - classes.stream() - .map(RuntimeInitializedPackageBuildItem::new) - .forEach(runtimeInitializedPackages::produce); + reflectiveClass.produce(ReflectiveClassBuildItem.builder(classes.toArray(new String[0])) + .constructors() + .methods() + .fields() + .serialization() + .build()); } @Record(ExecutionTime.STATIC_INIT) diff --git a/runtime/pom.xml b/runtime/pom.xml index dadcfdd..67d32f5 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -21,6 +21,10 @@ io.quarkus quarkus-jaxp + + io.quarkus + quarkus-security + io.quarkus quarkus-info-runtime-spi From 26af650b5592b235bc8e1cd34f530b927a22aa51 Mon Sep 17 00:00:00 2001 From: melloware Date: Tue, 30 Dec 2025 08:44:13 -0500 Subject: [PATCH 4/6] OmniFaces 5.0 (adds new Security Tags) --- .../resources/dev-ui/qwc-omnifaces-card.js | 92 ------------------- 1 file changed, 92 deletions(-) delete mode 100644 deployment/src/main/resources/dev-ui/qwc-omnifaces-card.js diff --git a/deployment/src/main/resources/dev-ui/qwc-omnifaces-card.js b/deployment/src/main/resources/dev-ui/qwc-omnifaces-card.js deleted file mode 100644 index 066a02f..0000000 --- a/deployment/src/main/resources/dev-ui/qwc-omnifaces-card.js +++ /dev/null @@ -1,92 +0,0 @@ -import { LitElement, html, css} from 'lit'; -import { pages } from 'build-time-data'; -import {JsonRpc} from 'jsonrpc'; -import 'qwc/qwc-extension-link.js'; - -export class QwcOmniFacesCard extends LitElement { - - jsonRpc = new JsonRpc(this); - - static styles = css` - .identity { - display: flex; - justify-content: flex-start; - } - - .description { - padding-bottom: 10px; - } - - .logo { - padding-bottom: 10px; - margin-right: 5px; - } - - .card-content { - color: var(--lumo-contrast-90pct); - display: flex; - flex-direction: column; - justify-content: flex-start; - padding: 2px 2px; - height: 100%; - } - - .card-content slot { - display: flex; - flex-flow: column wrap; - padding-top: 5px; - } - `; - - static properties = { - extensionName: {attribute: true}, - description: {attribute: true}, - guide: {attribute: true}, - namespace: {attribute: true}, - }; - - constructor() { - super(); - } - - connectedCallback() { - super.connectedCallback(); - } - - render() { - return html`
-
- -
${this.description}
-
- ${this._renderCardLinks()} -
- `; - } - - _renderCardLinks(){ - return html`${pages.map(page => html` - - - `)}`; - } - -} -customElements.define('qwc-omnifaces-card', QwcOmniFacesCard); \ No newline at end of file From 6ddf1afc0d00e081b89e598e655997b600984734 Mon Sep 17 00:00:00 2001 From: melloware Date: Tue, 30 Dec 2025 08:44:21 -0500 Subject: [PATCH 5/6] OmniFaces 5.0 (adds new Security Tags) --- .../omnifaces/deployment/OmnifacesProcessor.java | 1 + .../deployment/devui/OmnifacesDevUIProcessor.java | 14 ++------------ pom.xml | 2 +- 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/deployment/src/main/java/io/quarkiverse/omnifaces/deployment/OmnifacesProcessor.java b/deployment/src/main/java/io/quarkiverse/omnifaces/deployment/OmnifacesProcessor.java index 1346e4d..993e34e 100644 --- a/deployment/src/main/java/io/quarkiverse/omnifaces/deployment/OmnifacesProcessor.java +++ b/deployment/src/main/java/io/quarkiverse/omnifaces/deployment/OmnifacesProcessor.java @@ -223,6 +223,7 @@ void substrateResourceBuildItems(BuildProducer nat "META-INF/omnifaces.taglib.xml", "META-INF/omnifaces-functions.taglib.xml", "META-INF/omnifaces-ui.taglib.xml", + "META-INF/omnifaces-security.taglib.xml", "META-INF/web-fragment.xml", "META-INF/faces-config.xml", "META-INF/web.xml", diff --git a/deployment/src/main/java/io/quarkiverse/omnifaces/deployment/devui/OmnifacesDevUIProcessor.java b/deployment/src/main/java/io/quarkiverse/omnifaces/deployment/devui/OmnifacesDevUIProcessor.java index 9c72151..d73c099 100644 --- a/deployment/src/main/java/io/quarkiverse/omnifaces/deployment/devui/OmnifacesDevUIProcessor.java +++ b/deployment/src/main/java/io/quarkiverse/omnifaces/deployment/devui/OmnifacesDevUIProcessor.java @@ -1,7 +1,5 @@ package io.quarkiverse.omnifaces.deployment.devui; -import org.omnifaces.config.WebXml; - import io.quarkus.deployment.IsDevelopment; import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; @@ -17,18 +15,12 @@ */ public class OmnifacesDevUIProcessor { - private static final String EXTENSION_NAME = "OmniFaces"; - @BuildStep(onlyIf = IsDevelopment.class) void createCard(BuildProducer cardPageBuildItemBuildProducer) { final CardPageBuildItem card = new CardPageBuildItem(); - final PageBuilder versionPage = Page.externalPageBuilder("Version") - .icon("font-awesome-solid:book") - .url("https://omnifaces.org/") - .doNotEmbed() - .staticLabel(WebXml.class.getPackage().getImplementationVersion()); - card.addPage(versionPage); + card.addLibraryVersion("org.omnifaces", "omnifaces", "OmniFaces", + "https://omnifaces.org/"); final PageBuilder localePage = Page.externalPageBuilder("Locale") .icon("font-awesome-solid:location-dot") @@ -44,8 +36,6 @@ void createCard(BuildProducer cardPageBuildItemBuildProducer) .dynamicLabelJsonRPCMethodName("getSessionTimeout"); card.addPage(sessionPage); - card.setCustomCard("qwc-omnifaces-card.js"); - cardPageBuildItemBuildProducer.produce(card); } diff --git a/pom.xml b/pom.xml index ebbc941..55ba346 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ 17 - 3.27.0 + 3.27.1 4.1.2 5.0 From c95ac786920448812cf673f3c262fac2d0d35d6e Mon Sep 17 00:00:00 2001 From: melloware Date: Tue, 30 Dec 2025 08:52:26 -0500 Subject: [PATCH 6/6] OmniFaces 5.0 (adds new Security Tags) --- pom.xml | 1 + runtime/pom.xml | 5 ++ .../runtime/SecurityContextImpl.java | 74 +++++++++++++++++++ 3 files changed, 80 insertions(+) create mode 100644 runtime/src/main/java/io/quarkus/omnifaces/runtime/SecurityContextImpl.java diff --git a/pom.xml b/pom.xml index 55ba346..efd465e 100644 --- a/pom.xml +++ b/pom.xml @@ -24,6 +24,7 @@ 17 + 4.0.0 3.27.1 4.1.2 5.0 diff --git a/runtime/pom.xml b/runtime/pom.xml index 67d32f5..3c2d4b4 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -41,6 +41,11 @@ org.omnifaces omnifaces
+ + jakarta.security.enterprise + jakarta.security.enterprise-api + ${jakarta-security.version} + org.graalvm.sdk graal-sdk diff --git a/runtime/src/main/java/io/quarkus/omnifaces/runtime/SecurityContextImpl.java b/runtime/src/main/java/io/quarkus/omnifaces/runtime/SecurityContextImpl.java new file mode 100644 index 0000000..6b496ac --- /dev/null +++ b/runtime/src/main/java/io/quarkus/omnifaces/runtime/SecurityContextImpl.java @@ -0,0 +1,74 @@ +package io.quarkus.omnifaces.runtime; + +import java.security.Principal; +import java.util.HashSet; +import java.util.Set; + +import jakarta.enterprise.context.RequestScoped; +import jakarta.inject.Inject; +import jakarta.inject.Named; +import jakarta.security.enterprise.AuthenticationStatus; +import jakarta.security.enterprise.SecurityContext; +import jakarta.security.enterprise.authentication.mechanism.http.AuthenticationParameters; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; + +import io.quarkus.security.identity.SecurityIdentity; + +/** + * Basic Jakarta SecurityContext implementation + * based on Quarkus' SecurityIdentity + * + * @author Leonardo Bernardes + */ +@Named +@RequestScoped +public class SecurityContextImpl implements SecurityContext { + + @Inject + SecurityIdentity identity; + + @Override + public Principal getCallerPrincipal() { + return identity.isAnonymous() ? null : identity.getPrincipal(); + } + + @Override + public Set getPrincipalsByType(Class pType) { + Set result = new HashSet<>(); + + if (!identity.isAnonymous()) + result.add(identity.getPrincipal(pType)); + + return result; + } + + @Override + public boolean isCallerInRole(String role) { + if (identity.isAnonymous()) + return false; + + return identity.hasRole(role); + } + + @Override + public Set getAllDeclaredCallerRoles() { + Set result = new HashSet<>(); + + if (!identity.isAnonymous()) + result = identity.getRoles(); + + return result; + } + + @Override + public boolean hasAccessToWebResource(String resource, String... methods) { + throw new UnsupportedOperationException("Not implemented"); + } + + @Override + public AuthenticationStatus authenticate(HttpServletRequest request, HttpServletResponse response, + AuthenticationParameters parameters) { + throw new UnsupportedOperationException("Not implemented"); + } +}