Skip to content

Commit

Permalink
[NOTASK]
Browse files Browse the repository at this point in the history
refactoring for consistency
update tests
  • Loading branch information
jj committed Aug 23, 2022
1 parent 5e57087 commit d2bd921
Show file tree
Hide file tree
Showing 7 changed files with 349 additions and 17 deletions.
37 changes: 28 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
Loading

0 comments on commit d2bd921

Please sign in to comment.