Skip to content

Instantly share code, notes, and snippets.

import javax.servlet.http.HttpServletRequest;
import org.apache.jackrabbit.api.security.user.User;
import org.osgi.service.component.annotations.Component;
import com.adobe.granite.oauth.server.Scope;
import com.adobe.granite.oauth.server.ScopeWithPrivileges;
@Component(service=Scope.class)
public class DAMReadScope implements ScopeWithPrivileges{
private static final String DAM_RESOURCE_URI="/content/dam/digital";
private static final String DAM_RESOURCE_READ_SCOPE_NAME="dam_read";
import javax.servlet.http.HttpServletRequest;
import org.apache.jackrabbit.api.security.user.User;
import org.osgi.service.component.annotations.Component;
import com.adobe.granite.oauth.server.Scope;
import com.adobe.granite.oauth.server.ScopeWithPrivileges;
@Component(service=Scope.class)
public class DAMWriteScope implements ScopeWithPrivileges{
private static final String DAM_RESOURCE_URI="/content/dam/digital";
private static final String DAM_RESOURCE_WRITE_SCOPE_NAME="dam_write";
//Refer the original script - https://blog.cloudflare.com/edge-side-includes-with-cloudflare-workers/
//Modified the script - to include the main request headers while invoking the ESI resources
//- Support ESI source path with complete source URL, fetch the hostname and proptocol from original request
addEventListener("fetch", event => {
event.respondWith(fetchAndStream(event.request))
event.passThroughOnException()
})
@techforum-repo
techforum-repo / CustomAuthenticationInfoPostProcessor.java
Last active February 18, 2021 15:24
Custom AuthenticationInfoPostProcessor update the last logged in timestamp to the user profile
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import javax.jcr.Session;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils;
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
jcr:primaryType="nt:unstructured"
jcr:title=" Open Html/Script"
sling:resourceType="cq/gui/components/authoring/dialog">
<content
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/fixedcolumns">
<items jcr:primaryType="nt:unstructured">
<column
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.servlets.HttpConstants;
import org.apache.sling.api.servlets.SlingSafeMethodsServlet;
import org.apache.sling.resource.filter.ResourceFilterStream;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.propertytypes.ServiceDescription;
#!/bin/bash
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
#### Test Site1 Configuration Starts ###
##### Test Site1 301 ###
wget http://localhost:4502/content/redirectmanager/test-site1/_jcr_content.301.txt -O /tmp/redirectmap-testsite1-301.txt > /var/log/update-redirect-map-testsite1-301.log 2>&1
httxt2dbm -v -f db -i /tmp/redirectmap-testsite1-301.txt -o /etc/httpd/conf.dispatcher.d/redirectmaps/redirectmap-testsite1-301_temp.db >> /var/log/update-redirect-map-testsite1-301.log 2>&1
cp -rf /etc/httpd/conf.dispatcher.d/redirectmaps/redirectmap-testsite1-301.db /etc/httpd/conf.dispatcher.d/redirectmaps/redirectmap-testsite1-301.db_`date -I`

Create an RSA-2048 key and save it to a file rootCA.key

openssl genrsa -des3 -out rootCA.key 2048

Create a root certificate through the key generated

openssl req -x509 -new -nodes -key rootCA.key -sha256 -days 1460 -out rootCA.pem

Create a private key and CSR for local Certificare

openssl req -new -sha256 -nodes -out server.csr -newkey rsa:2048 -keyout server.key -config server.csr.cnf

Issue a certificate via the root SSL certificate and the CSR

[req]
default_bits = 2048
prompt = no
default_md = sha256
distinguished_name = dn
[dn]
C=US
ST=MN
L=Eagan
authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
subjectAltName = @alt_names
[alt_names]
DNS.1 = myexample.com
DNS.2=sub.myexample.com
DNS.3=myexample1.com
DNS.4=localhost