Skip to content

Commit

Permalink
initial version of example IDP
Browse files Browse the repository at this point in the history
  • Loading branch information
tripodsan committed Jul 23, 2015
1 parent e66a8a6 commit 8050285
Show file tree
Hide file tree
Showing 6 changed files with 384 additions and 195 deletions.
76 changes: 18 additions & 58 deletions example-idp/pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
Expand All @@ -16,43 +15,37 @@
See the License for the specific language governing permissions and
limitations under the License.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd ">
<modelVersion>4.0.0</modelVersion>

<!-- ====================================================================== -->
<!-- P A R E N T P R O J E C T D E S C R I P T I O N -->
<!-- ====================================================================== -->
<parent>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>oak-parent</artifactId>
<version>1.2.2</version>
<relativePath/>
</parent>

<!-- ====================================================================== -->
<!-- P R O J E C T D E S C R I P T I O N -->
<!-- ====================================================================== -->
<groupId>com.adobe.gems</groupId>
<artifactId>com.adobe.gems.exampleidp</artifactId>
<version>1.0-SNAPSHOT</version>
<name>Example IDP that reads users and groups from a json file</name>
<name>AEM 6.1 Gems Example IDP</name>
<description>Example IDP that reads users and groups from a json file</description>
<packaging>bundle</packaging>

<!-- ====================================================================== -->
<!-- B U I L D -->
<!-- ====================================================================== -->
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<!--<configuration>-->
<!--<instructions>-->
<!--<Import-Package>-->
<!--!org.dom4j.*,-->
<!--!org.xmlpull.v1,-->
<!--!sun.net.util,-->
<!--*-->
<!--</Import-Package>-->
<!--<Embed-Dependency>-->
<!--api-all,commons-pool,commons-lang,mina-core,antlr-->
<!--</Embed-Dependency>-->
<!--<Embed-Transitive>true</Embed-Transitive>-->
<!--</instructions>-->
<!--</configuration>-->
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
Expand All @@ -70,37 +63,16 @@
</plugins>
</build>

<!-- ====================================================================== -->
<!-- D E P E N D E N C I E S -->
<!-- ====================================================================== -->
<dependencies>
<dependency>
<groupId>biz.aQute.bnd</groupId>
<artifactId>bndlib</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.scr.annotations</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>oak-core</artifactId>
<version>1.2.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>oak-commons</artifactId>
<version>1.2.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>oak-auth-external</artifactId>
<version>1.2.2</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.commons.json</artifactId>
Expand All @@ -109,32 +81,20 @@
</dependency>

<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<scope>provided</scope>
</dependency>

<!-- JCR and Jackrabbit dependencies -->
<dependency>
<groupId>javax.jcr</groupId>
<artifactId>jcr</artifactId>
<version>2.0</version>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<scope>provided</scope>
</dependency>

<!-- Logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.scr.annotations</artifactId>
<scope>provided</scope>
</dependency>

<!-- Findbugs annotations -->
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<scope>provided</scope>
</dependency>

</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
/*************************************************************************
* ADOBE CONFIDENTIAL
* ___________________
* <p/>
* Copyright ${today.year} Adobe Systems Incorporated
* All Rights Reserved.
* <p/>
* NOTICE: All information contained herein is, and remains
* the property of Adobe Systems Incorporated and its suppliers,
* if any. The intellectual and technical concepts contained
* herein are proprietary to Adobe Systems Incorporated and its
* suppliers and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Adobe Systems Incorporated.
**************************************************************************/
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.adobe.gems.exampleidp.impl;

import java.util.HashSet;
Expand All @@ -25,31 +27,30 @@
import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalGroup;
import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityException;
import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef;
import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser;
import org.apache.sling.commons.json.JSONArray;

/**
* {@code ExternalGroupImpl}...
* {@code ExternalGroupImpl} implements an external group based on properties
*/
public class ExternalGroupImpl extends ExternalIdentityImpl implements ExternalGroup {

private Set<ExternalIdentityRef> members;

public ExternalGroupImpl(JsonFileIdentityProvider provider, ExternalIdentityRef ref, String id, Map<String, Object> properties) {
super(provider, ref, id, properties);
public ExternalGroupImpl(String providerName, ExternalIdentityRef ref, String id, Map<String, Object> properties) {
super(providerName, ref, id, properties);
}

@Nonnull
@Override
public Iterable<ExternalIdentityRef> getDeclaredMembers() throws ExternalIdentityException {
if (members == null) {
members = new HashSet<ExternalIdentityRef>();
JSONArray gs = (JSONArray) properties.get("members");
JSONArray gs = (JSONArray) properties.get(JsonFileIdentityProvider.PN_MEMBERS);
if (gs != null) {
for (int i = 0; i<gs.length(); i++) {
String gid = gs.optString(i);
if (gid != null) {
members.add(new ExternalIdentityRef(gid, provider.getName()));
members.add(new ExternalIdentityRef(gid, providerName));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
/*************************************************************************
* ADOBE CONFIDENTIAL
* ___________________
* <p/>
* Copyright ${today.year} Adobe Systems Incorporated
* All Rights Reserved.
* <p/>
* NOTICE: All information contained herein is, and remains
* the property of Adobe Systems Incorporated and its suppliers,
* if any. The intellectual and technical concepts contained
* herein are proprietary to Adobe Systems Incorporated and its
* suppliers and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Adobe Systems Incorporated.
**************************************************************************/
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.adobe.gems.exampleidp.impl;

import java.util.HashSet;
Expand All @@ -28,11 +30,11 @@
import org.apache.sling.commons.json.JSONArray;

/**
* {@code ExternalIdentityImpl}...
* {@code ExternalIdentityImpl} implements an external identity based on properties
*/
public abstract class ExternalIdentityImpl implements ExternalIdentity {

protected final JsonFileIdentityProvider provider;
protected final String providerName;

protected final ExternalIdentityRef ref;

Expand All @@ -42,14 +44,13 @@ public abstract class ExternalIdentityImpl implements ExternalIdentity {

protected final Map<String, Object> properties;

protected ExternalIdentityImpl(JsonFileIdentityProvider provider, ExternalIdentityRef ref, String id, Map<String, Object> properties) {
this.provider = provider;
protected ExternalIdentityImpl(String providerName, ExternalIdentityRef ref, String id, Map<String, Object> properties) {
this.providerName = providerName;
this.ref = ref;
this.id = id;
this.properties = properties;
}


@Nonnull
@Override
public ExternalIdentityRef getExternalId() {
Expand Down Expand Up @@ -78,12 +79,12 @@ public String getIntermediatePath() {
public Iterable<ExternalIdentityRef> getDeclaredGroups() throws ExternalIdentityException {
if (groups == null) {
groups = new HashSet<ExternalIdentityRef>();
JSONArray gs = (JSONArray) properties.get("groups");
JSONArray gs = (JSONArray) properties.get(JsonFileIdentityProvider.PN_GROUPS);
if (gs != null) {
for (int i = 0; i<gs.length(); i++) {
String gid = gs.optString(i);
if (gid != null) {
groups.add(new ExternalIdentityRef(gid, provider.getName()));
groups.add(new ExternalIdentityRef(gid, providerName));
}
}
}
Expand All @@ -96,4 +97,10 @@ public Iterable<ExternalIdentityRef> getDeclaredGroups() throws ExternalIdentity
public Map<String, ?> getProperties() {
return properties;
}

@Override
public String toString() {
return "ExternalIdentityImpl{" + "ref=" + ref + ", id='" + id + '\'' + '}';
}

}
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
/*************************************************************************
* ADOBE CONFIDENTIAL
* ___________________
* <p/>
* Copyright ${today.year} Adobe Systems Incorporated
* All Rights Reserved.
* <p/>
* NOTICE: All information contained herein is, and remains
* the property of Adobe Systems Incorporated and its suppliers,
* if any. The intellectual and technical concepts contained
* herein are proprietary to Adobe Systems Incorporated and its
* suppliers and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Adobe Systems Incorporated.
**************************************************************************/
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.adobe.gems.exampleidp.impl;

import java.util.Map;
Expand All @@ -22,11 +24,11 @@
import org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser;

/**
* {@code ExternalUserImpl}...
* {@code ExternalUserImpl} implements an external user based on properties
*/
public class ExternalUserImpl extends ExternalIdentityImpl implements ExternalUser {

public ExternalUserImpl(JsonFileIdentityProvider provider, ExternalIdentityRef ref, String id, Map<String, Object> properties) {
super(provider, ref, id, properties);
public ExternalUserImpl(String providerName, ExternalIdentityRef ref, String id, Map<String, Object> properties) {
super(providerName, ref, id, properties);
}
}
Loading

0 comments on commit 8050285

Please sign in to comment.