Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[NOTASK]
refactoring for consistency
update tests
jj committed Aug 23, 2022
1 parent 5e57087 commit d2bd921
Showing 7 changed files with 349 additions and 17 deletions.
37 changes: 28 additions & 9 deletions pom.xml
@@ -24,28 +24,24 @@

<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>edu.internet2.middleware.grouper</groupId>
<artifactId>grouper-parent</artifactId>
<version>2.6.0-SNAPSHOT</version>
<relativePath>../../grouper-parent</relativePath>
</parent>

<name>Grouper Authentication Plugin</name>
<description>Authentication Library Plugin</description>
<groupId>edu.internet2.middleware.grouper.plugins</groupId>
<artifactId>grouper-authentication-plugin</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>bundle</packaging>

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<pac4j.version>4.3.1</pac4j.version>
<jee-pac4j.version>5.0.0</jee-pac4j.version>
<grouper.version>2.6.0-SNAPSHOT</grouper.version>
</properties>

<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<groupId>edu.internet2.middleware.grouper</groupId>
<artifactId>grouperClient</artifactId>
<version>${grouper.version}</version>
<scope>provided</scope>
@@ -113,14 +109,37 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<groupId>edu.internet2.middleware.grouper</groupId>
<artifactId>grouper</artifactId>
<version>${grouper.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
<version>4.7.0</version>
<scope>test</scope>
</dependency>
</dependencies>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>edu.internet2.middleware.grouper</groupId>
<artifactId>grouper</artifactId>
<version>2.6.15</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<build>
<plugins>
<plugin>
@@ -1,6 +1,5 @@
package edu.internet2.middleware.grouper.authentication.plugin;

import edu.internet2.middleware.grouper.cfg.GrouperHibernateConfig;
import edu.internet2.middleware.grouperClient.config.ConfigPropertiesCascadeBase;
import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil;
@@ -38,8 +37,8 @@ public static ConfigPropertiesCascadeBase getBestGrouperConfiguration() {

public static ConfigPropertiesCascadeBase getConfigPropertiesCascadeBase(String type) {
try {
ServiceReference<ConfigPropertiesCascadeBase> serviceReference = (ServiceReference<ConfigPropertiesCascadeBase>) FrameworkUtil.getBundle(ConfigUtils.class.getClassLoader()).get().getBundleContext().getServiceReferences(ConfigPropertiesCascadeBase.class, "(type=" + type + ")").toArray()[0];
return FrameworkUtil.getBundle(ConfigUtils.class.getClassLoader()).get().getBundleContext().getService(serviceReference);
ServiceReference<ConfigPropertiesCascadeBase> serviceReference = (ServiceReference<ConfigPropertiesCascadeBase>) bundleContext.getServiceReferences(ConfigPropertiesCascadeBase.class, "(type=" + type + ")").toArray()[0];
return bundleContext.getService(serviceReference);
} catch (InvalidSyntaxException e) {
throw new RuntimeException(e);
}
@@ -21,7 +21,7 @@ public class Pac4jConfigFactory implements ConfigFactory {
private static final Log LOGGER;
static {
try {
BundleContext bundleContext = FrameworkUtil.getBundle(Pac4jConfigFactory.class).getBundleContext();
BundleContext bundleContext = FrameworkUtil.getBundle(GrouperAuthentication.class).getBundleContext();
//TODO: figure out why this is weird
ServiceReference<LogFactory> logfactoryReference = (ServiceReference<LogFactory>) bundleContext.getAllServiceReferences("org.apache.commons.logging.LogFactory", null)[0];
LOGGER = bundleContext.getService(logfactoryReference).getInstance(ExternalAuthenticationServletContainerInitializer.class);
@@ -2,6 +2,7 @@

import edu.internet2.middleware.grouper.authentication.plugin.ConfigUtils;
import edu.internet2.middleware.grouper.authentication.plugin.ExternalAuthenticationServletContainerInitializer;
import edu.internet2.middleware.grouper.authentication.plugin.GrouperAuthentication;
import edu.internet2.middleware.grouper.authentication.plugin.Pac4jConfigFactory;
import edu.internet2.middleware.grouper.authentication.plugin.oidc.client.ClaimAsUsernameOidcClient;
import edu.internet2.middleware.grouper.authentication.plugin.oidc.config.ClaimAsUsernameOidcConfiguration;
@@ -20,7 +21,7 @@ public class OidcClientProvider implements ClientProvider {
private static final Log LOGGER;
static {
try {
BundleContext bundleContext = FrameworkUtil.getBundle(Pac4jConfigFactory.class).getBundleContext();
BundleContext bundleContext = FrameworkUtil.getBundle(GrouperAuthentication.class).getBundleContext();
//TODO: figure out why this is weird
ServiceReference<LogFactory> logfactoryReference = (ServiceReference<LogFactory>) bundleContext.getAllServiceReferences("org.apache.commons.logging.LogFactory", null)[0];
LOGGER = bundleContext.getService(logfactoryReference).getInstance(ExternalAuthenticationServletContainerInitializer.class);
@@ -2,6 +2,7 @@

import edu.internet2.middleware.grouper.authentication.plugin.ConfigUtils;
import edu.internet2.middleware.grouper.authentication.plugin.ExternalAuthenticationServletContainerInitializer;
import edu.internet2.middleware.grouper.authentication.plugin.GrouperAuthentication;
import edu.internet2.middleware.grouper.authentication.plugin.Pac4jConfigFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -18,7 +19,7 @@ public class ReinitializingTimer extends TimerTask {
private static final Log LOGGER;
static {
try {
BundleContext bundleContext = FrameworkUtil.getBundle(Pac4jConfigFactory.class).getBundleContext();
BundleContext bundleContext = FrameworkUtil.getBundle(GrouperAuthentication.class).getBundleContext();
//TODO: figure out why this is weird
ServiceReference<LogFactory> logfactoryReference = (ServiceReference<LogFactory>) bundleContext.getAllServiceReferences("org.apache.commons.logging.LogFactory", null)[0];
LOGGER = bundleContext.getService(logfactoryReference).getInstance(ExternalAuthenticationServletContainerInitializer.class);

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions src/test/resources/grouper-ui.properties
@@ -1,2 +0,0 @@
external.authentication.mechanism.elConfig = ${"cas"}
external.authentication.cas.loginUrl.elConfig = ${"login"}

0 comments on commit d2bd921

Please sign in to comment.