Java OSGi Bundle AEM 6.5 & AEMaaCS Cloud Manager Ready v1.0.0-SNAPSHOT

Download the AEM OSGi Plugin
— Start Your Free Trial

The aem-edge-csp-plugin.ui.apps package installs a Sling SAX Transformer that automatically attaches nonce="CF_EDGE_NONCE" to every script and style tag during AEM publish rendering — keeping your Dispatcher cache hit ratio at 100%. Register your domain to get instant download access.

100%
Dispatcher Cache Hit Ratio
< 0.5 ms
SAX Transform Overhead
0
Template Rewrites Needed
View integration guide ↓
🔒 Secure payment  ·  ✔ Instant download after registration  ·  ✔ 14-day free trial on all plans

Deep-Dive: AEM Integration

Unlike generic CDN scripts, EdgeNonce natively integrates into AEM's core Apache Sling rendering pipeline, preparing your HTML to be processed by your Cloudflare Worker service at https://edge-nonce.com.

1. Sling Rewriter SAX Pipeline

Our Java OSGi bundle registers `com.adobe.aem.edge.csp.rewriter.EdgeCspTransformerFactory`. As Apache Sling renders AEM page components and Client Libraries (`/etc.clientlibs/`), our SAX transformer intercepts open tag events (`startElement`) in real time and attaches the static placeholder attribute (`nonce="CF_EDGE_NONCE"`).

<!-- RewriterPipelineConfiguration-edgecsp.xml -->
<generator type="htmlparser"/>
<transformer type="edge-csp-nonce"/> <-- EdgeNonce Pipeline
<serializer type="htmlwriter"/>

2. WCMMode Live Authoring Intelligence

On AEM Author instances (`localhost:4502`), Content Authors edit pages without a CDN in front. Our transformer inspects `WCMMode`: if `EDIT` or `PREVIEW`, it dynamically generates a live 16-character random nonce on the Java JVM so authoring previews work seamlessly without CDN interception!

// EdgeCspTransformer.java
if (mode == WCMMode.EDIT || mode == WCMMode.PREVIEW) {
    return generateRandomLocalNonce();
} return siteConfig.getPlaceholderNonceString();

3. Multi-Tenant OSGi Configuration

Managed via AEM OSGi Console (`com.adobe.aem.edge.csp.config.EdgeCspSiteService`). Enterprise administrators can configure factory definitions for distinct brand hierarchies (`/content/wknd/us` vs `/content/portal`) with custom placeholder tokens.

// OSGi Config JSON (.cfg.json)
{
  "contentPathPrefix": "/content/wknd",
  "placeholderNonceString": "CF_EDGE_NONCE",
  "processScripts": true,
  "processStyles": true
}

4. HTL (Sightly) & Cloud Manager CI/CD

Template developers can inject nonces into custom inline HTL scripts using our Sling Model helper (`EdgeCspModel`). All packages pass Jackrabbit FileVault validation (`mvn clean package`), guaranteeing zero deployment failures in Adobe Cloud Manager pipelines!

<sly data-sly-use.csp="com...EdgeCspModel"/>
<script nonce="${csp.nonce}">window.brandConfig = {};</script>

Universal AEM Flavor & Deployment Compatibility

Because EdgeNonce decouples HTML rendering from cryptographic nonce injection, our architecture operates cleanly across all historical and modern AEM deployment models:

✔ AEM 6.5 On-Premise / AMS

Interprets Sling SAX events before Apache 2.4 Dispatcher disk caching. Preserves 100% on-prem static cache files.

✔ AEM Cloud Service (AEMaaCS / LTS)

Passes automated Jackrabbit FileVault validation in Cloud Manager CI/CD pipelines. Compatible with Adobe Fastly CDN.

✔ Edge Delivery Services (Franklin)

Zero-code modification required. Edge compute worker injects nonces dynamically into document-based HTML output.

✔ Headless AEM & SPA Editor

Injects dynamic nonces into React / Angular SPA boot bundles and attaches real-time Content-Security-Policy headers.

How to Install the AEM Plugin (`aem-edge-csp-plugin`)

Choose the installation method that best matches your enterprise development workflow:

Method A: Maven POM Inclusion

Add the bundle as a sub-module dependency inside your parent AEM project's `all/pom.xml` package:

<dependency>
  <groupId>com.adobe.aem</groupId>
  <artifactId>aem-edge-csp.all</artifactId>
  <version>1.0.0</version>
  <type>zip</type>
</dependency>

Method B: CRX Package Manager

Build locally using Maven and deploy directly to your local AEM Author instance (`localhost:4502`):

# Build & Auto-Install to AEM
cd aem-edge-csp-plugin
mvn clean install -PautoInstallPackage

# Or upload built .zip file to:
http://localhost:4502/crx/packmgr

Method C: Cloud Manager CI/CD

Commit the plugin module to your Adobe Cloud Manager Git repository branch and run a Full Stack Deployment:

git add aem-edge-csp-plugin
git commit -m "feat: add CSP OSGi plugin"
git push origin main

# Cloud Manager pipeline executes
✔ FileVault Validation Passed

Legacy Component Migration (CSP-Compat Script)

Strict Content-Security-Policy completely blocks inline event handlers (onclick) and inline styles (style=""). For older AEM JSP or HTL components that rely heavily on inline JavaScript, we provide a client-side compatibility delegator (csp-compat.js).

Blocked (Unsafe Inline)

<button onclick="submitForm()">Submit</button>
<div style="color: red;">Error</div>

Allowed (CSP-Compat)

<button data-evt-click="submitForm()">Submit</button>
<div data-style="color: red;">Error</div>

How to use: Simply include <script src="https://edge-nonce.com/assets/js/csp-compat.js"></script> in your AEM page header. The script automatically executes on load, scans the DOM for data-evt-* and data-style attributes, and securely attaches the JavaScript events and CSS values dynamically without violating the Strict CSP.

Interactive Installation Wizard

Follow each step to configure the EdgeNonce AEM plugin for your project. Your progress is saved automatically.

0 of 6 steps complete 0%
1
Download & Verify the Plugin Bundle
Get aem-edge-csp-plugin.zip and confirm the JAR contents
Required ›

Download the plugin ZIP from the button above or directly from the URL below. Verify it contains the required OSGi bundle JAR before proceeding.

https://edge-nonce.com/download/aem-edge-csp-plugin.zip

Once downloaded, unzip and confirm the structure:

# Expected ZIP contents aem-edge-csp-plugin.zip ├── aem-edge-csp-plugin.ui.apps-1.0.0.zip # CRX package for AEM └── aem-edge-csp-plugin.core-1.0.0.jar # OSGi bundle (Java)
  • ✅ ZIP downloaded from edge-nonce.com
  • ✅ Contains ui.apps CRX package
  • ✅ Contains core OSGi bundle JAR
2
Install into AEM (Choose Method)
CRX Package Manager · Maven Auto-Install · Cloud Manager CI/CD
Required ›

Choose the installation method that matches your project workflow. All three produce the same result.

  1. Open http://localhost:4502/crx/packmgr in your browser
  2. Click Upload Package
  3. Upload aem-edge-csp-plugin.ui.apps-1.0.0.zip
  4. Click Install → confirm dialog
  5. Verify status shows Installed
http://localhost:4502/crx/packmgr
# From your aem-edge-csp-plugin directory: cd aem-edge-csp-plugin mvn clean install -PautoInstallPackage \ -Daem.host=localhost \ -Daem.port=4502 \ -Daem.password=admin
mvn clean install -PautoInstallPackage -Daem.host=localhost -Daem.port=4502

For AEM Publish on port 4503, change -Daem.port=4503. Repeat for each AEM instance.

# 1. Add plugin module to your parent pom.xml all/pom.xml <dependency> <groupId>com.adobe.aem</groupId> <artifactId>aem-edge-csp.all</artifactId> <version>1.0.0</version> <type>zip</type> </dependency> # 2. Commit and push to Cloud Manager Git branch git add . && git commit -m "feat: add EdgeNonce CSP OSGi plugin" git push origin main # 3. Cloud Manager executes Full Stack Deployment ✔ FileVault Validation Passed ✔ Bundle installed on Author + Publish
git add . && git commit -m "feat: add EdgeNonce CSP OSGi plugin" && git push origin main
3
Generate OSGi Site Configuration
Tells the plugin which content path to protect — one config per brand/site
Required ›

Fill in your project details and click Generate Config. The plugin reads this OSGi factory config to know which AEM content path to protect.

Save this file to your project at the path shown below, then commit and deploy:

ui.config/.../com.adobe.aem.edge.csp.config.EdgeCspSiteService-myproject.cfg.json
Contents shown above
4
Verify Bundle Active in OSGi Console
Confirm the transformer and config service are Active
Required ›

Open the Felix OSGi Web Console on your AEM instance and confirm all three components are in Active state.

http://localhost:4502/system/console/components

Search for EdgeCsp — you should see:

  • ✓ com.adobe.aem.edge.csp.rewriter.EdgeCspTransformerFactory — Active
  • ✓ com.adobe.aem.edge.csp.config.EdgeCspSiteRegistry — Active
  • ✓ com.adobe.aem.edge.csp.config.EdgeCspSiteService — Active (one per site config)

Also verify the Sling Rewriter pipeline includes edgecsp:

http://localhost:4502/system/console/configMgr → Search "RewriterPipeline"
# Quick curl check — should return 200 with bundle info curl -u admin:admin \ "http://localhost:4502/system/console/bundles/com.adobe.aem.edge.csp.core.json" \ | python3 -m json.tool | grep "state" # Expected: "state": "Active"
curl -u admin:admin "http://localhost:4502/system/console/bundles/com.adobe.aem.edge.csp.core.json"
5
Test Nonce Injection on a Page
Confirm nonce="CF_EDGE_NONCE" appears on published HTML
Required ›

Run these checks on both AEM Publish (should show static placeholder) and through your Cloudflare Worker (should show a real nonce).

① AEM Publish — verify placeholder is present:

curl -s "http://localhost:4503/content/YOUR-SITE/en/home.html" \ | grep 'nonce=' # Expected output (every <script> and <style> has the placeholder): <script src="/etc.clientlibs/base.js" nonce="CF_EDGE_NONCE"></script> <style nonce="CF_EDGE_NONCE"> ... </style>
curl -s "http://localhost:4503/content/YOUR-SITE/en/home.html" | grep 'nonce='
curl -sI "https://YOUR-SITE.com/en/home.html" | grep -i "content-security-policy"

③ AEM Author — verify live random nonce on edit pages:

curl -u admin:admin -s \ "http://localhost:4502/content/YOUR-SITE/en/home.html" \ | grep 'nonce=' # Expected: a 16-char random nonce (not CF_EDGE_NONCE) <script nonce="a3f9c2e1b7d04f8a"> ... </script>
6
HTL Template & Legacy Component Integration
Add csp-compat.js for inline handlers + use EdgeCspModel in HTL
Optional ›

These steps are only needed if your AEM components use inline onclick/style="" attributes or have custom inline <script> blocks in HTL templates.

① Add csp-compat.js to your AEM Client Library (clientlib):

<!-- In your AEM page HTL template (e.g. customheaderlibs.html) --> <script src="/etc.clientlibs/YOUR-SITE/clientlibs/clientlib-base/resources/csp-compat.js" nonce="CF_EDGE_NONCE"> </script> <!-- OR: load from edge-nonce.com CDN directly --> <script src="https://edge-nonce.com/assets/js/csp-compat.prod.js" nonce="CF_EDGE_NONCE"> </script>
<script src="https://edge-nonce.com/assets/js/csp-compat.prod.js" nonce="CF_EDGE_NONCE"></script>

② Replace inline handlers in legacy JSP/HTL components:

<!-- BEFORE — blocked by strict CSP --> <button onclick="submitForm()">Submit</button> <div style="color:red">Error</div> <!-- AFTER — csp-compat.js wires these at runtime --> <button data-evt-click="submitForm">Submit</button> <div data-style="color:red">Error</div>

③ Custom inline scripts in HTL — use EdgeCspModel:

<!-- In your HTL component file --> <sly data-sly-use.csp="com.adobe.aem.edge.csp.models.EdgeCspModel"/> <script nonce="${csp.nonce}"> window.brandConfig = { locale: "${locale @ context='scriptString'}", env: "${environment @ context='scriptString'}" }; </script> <!-- csp.nonce returns: • CF_EDGE_NONCE on AEM Publish (static, Dispatcher-cacheable) • a3f9c2e1... on AEM Author (live random UUID fragment) -->
🎉

Installation Complete!

Your EdgeNonce AEM plugin is fully configured. Every <script> and <style> tag on your AEM Publish instance now carries nonce="CF_EDGE_NONCE" — which Cloudflare replaces with a cryptographic nonce on every request, maintaining 100% Dispatcher cache hit ratio.

Need help? Contact contact@edge-nonce.com  ·  Read the deep-dive guide ↑