[java-identity-provider] branch main updated: Add new module dependencies and eliminate old Logging service classes.

Scott Cantor cantor.2 at osu.edu
Thu Sep 1 18:09:51 UTC 2022


This is an automated email from the git hooks/post-receive script.

scantor pushed a commit to branch main
in repository java-identity-provider.

View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=d0c3587151f71c449c43a8878921031c02717804

The following commit(s) were added to refs/heads/main by this push:
     new d0c358715 Add new module dependencies and eliminate old Logging service classes.
d0c358715 is described below

commit d0c3587151f71c449c43a8878921031c02717804
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Thu Sep 1 14:09:48 2022 -0400

    Add new module dependencies and eliminate old Logging service classes.
---
 .../shibboleth/idp/log/LogbackLoggingService.java  | 227 ---------------------
 .../net/shibboleth/idp/log/LoggingService.java     |  42 ----
 idp-authn-api/pom.xml                              |   5 +
 idp-cas-api/pom.xml                                |   5 +
 .../shibboleth/idp/conf/access-control-system.xml  |   2 +-
 .../net/shibboleth/idp/conf/primitives.xml         |   2 +-
 .../net/shibboleth/idp/conf/services-system.xml    |   4 +-
 idp-consent-impl/pom.xml                           |   5 +
 idp-core/pom.xml                                   |   5 +
 .../security/ReloadingAccessControlService.java    |  67 ------
 .../net/shibboleth/idp/security/package-info.java  |  22 --
 idp-parent/pom.xml                                 |   1 +
 12 files changed, 25 insertions(+), 362 deletions(-)

diff --git a/idp-admin-api/src/main/java/net/shibboleth/idp/log/LogbackLoggingService.java b/idp-admin-api/src/main/java/net/shibboleth/idp/log/LogbackLoggingService.java
deleted file mode 100644
index 424bdb1e7..000000000
--- a/idp-admin-api/src/main/java/net/shibboleth/idp/log/LogbackLoggingService.java
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
- * Licensed to the University Corporation for Advanced Internet Development,
- * Inc. (UCAID) under one or more contributor license agreements.  See the
- * NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The UCAID 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 net.shibboleth.idp.log;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.time.Instant;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import org.slf4j.LoggerFactory;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextAware;
-import org.springframework.core.io.ClassPathResource;
-import org.springframework.core.io.Resource;
-
-import com.google.common.io.Closeables;
-
-import ch.qos.logback.classic.LoggerContext;
-import ch.qos.logback.classic.joran.JoranConfigurator;
-import ch.qos.logback.core.joran.spi.JoranException;
-import ch.qos.logback.core.status.ErrorStatus;
-import ch.qos.logback.core.status.InfoStatus;
-import ch.qos.logback.core.status.StatusManager;
-import net.shibboleth.idp.spring.IdPPropertiesApplicationContextInitializer;
-import net.shibboleth.utilities.java.support.annotation.constraint.NonnullAfterInit;
-import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
-import net.shibboleth.utilities.java.support.logic.Constraint;
-import net.shibboleth.utilities.java.support.service.AbstractReloadableService;
-import net.shibboleth.utilities.java.support.service.ServiceException;
-import net.shibboleth.utilities.java.support.service.ServiceableComponent;
-
-/**
- * Simple {@link LoggingService} that watches for logback configuration file changes
- * and reloads the file when a change occurs.
- */
- at SuppressWarnings("removal")
-public class LogbackLoggingService extends AbstractReloadableService<Object>
-        implements LoggingService, ApplicationContextAware {
-    
-    /** Logback logger context. */
-    private LoggerContext loggerContext;
-
-    /** Logger used to log messages without relying on the logging system to be full initialized. */
-    private StatusManager statusManager;
-
-    /** URL to the fallback logback configuration found in the IdP jar. */
-    @NonnullAfterInit private Resource fallbackConfiguration;
-
-    /** Logging configuration resource. */
-    @NonnullAfterInit private Resource configurationResource;
-
-    /** Spring application context. */
-    @Nullable private ApplicationContext applicationContext;
-
-    /**
-     * Gets the logging configuration.
-     * 
-     * @return logging configuration
-     */
-    @NonnullAfterInit public Resource getLoggingConfiguration() {
-        return configurationResource;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void setLoggingConfiguration(@Nonnull final Resource configuration) {
-        checkSetterPreconditions();
-
-        configurationResource = Constraint.isNotNull(configuration, "Logging configuration resource cannot be null");
-    }
-
-    /** {@inheritDoc} */
-    @Override public void setApplicationContext(final ApplicationContext context) {
-        applicationContext = context;
-    }
-
-    /**
-     * {@inheritDoc}.
-     * 
-     * This service does not support a ServiceableComponent, so return null.
-     */
-    @Override @Nullable public ServiceableComponent<Object> getServiceableComponent() {
-        return null;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void doInitialize() throws ComponentInitializationException {
-        if (configurationResource == null) {
-            throw new ComponentInitializationException("Logging configuration must be specified.");
-        }
-    
-        fallbackConfiguration = new ClassPathResource("/logback.xml");
-        loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
-        statusManager = loggerContext.getStatusManager();
-        if (!fallbackConfiguration.exists()) {
-            if (isFailFast()) {
-                throw new ComponentInitializationException(getLogPrefix() + "Cannot locate fallback logger");
-            }
-            statusManager.add(new ErrorStatus("Cannot locate fallback logger at "
-                    + fallbackConfiguration.getDescription(), this));
-        }
-        super.doInitialize();
-    }
-
-    /** {@inheritDoc} */
-    @Override protected synchronized boolean shouldReload() {
-        try {
-            final Instant lastReload = getLastSuccessfulReloadInstant();
-            if (null == lastReload) {
-                return true;
-            }
-            return configurationResource.lastModified() > lastReload.toEpochMilli();
-        } catch (final IOException e) {
-            statusManager.add(new ErrorStatus(
-                    "Error checking last modified time of logging service configuration resource "
-                            + configurationResource.getDescription(), this, e));
-            return false;
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override protected synchronized void doReload() {
-        loadLoggingConfiguration();
-    }
-
-    /**
-     * Reads and loads in a new logging configuration.
-     * 
-     * @throws ServiceException thrown if there is a problem loading the logging configuration
-     */
-    protected void loadLoggingConfiguration() {
-        InputStream ins = null;
-        try {
-            statusManager.add(new InfoStatus("Loading new logging configuration resource: "
-                    + configurationResource.getDescription(), this));
-            ins = configurationResource.getInputStream();
-            loadLoggingConfiguration(ins);
-        } catch (final Exception e) {
-            try {
-                Closeables.close(ins, true);
-            } catch (final IOException e1) {
-                // swallowed && logged by Closeables but...
-                throw new ServiceException(e1);
-            }
-            statusManager.add(new ErrorStatus("Error loading logging configuration file: "
-                    + configurationResource.getDescription(), this, e));
-            try {
-                statusManager.add(new InfoStatus("Loading fallback logging configuration", this));
-                ins = fallbackConfiguration.getInputStream();
-                loadLoggingConfiguration(ins);
-            } catch (final IOException ioe) {
-                try {
-                    Closeables.close(ins, true);
-                } catch (final IOException e1) {
-                    // swallowed && logged by Closeables
-                    throw new ServiceException(e1);
-                }
-                statusManager.add(new ErrorStatus("Error loading fallback logging configuration", this, e));
-                throw new ServiceException("Unable to load fallback logging configuration");
-            }
-        } finally {
-            try {
-                Closeables.close(ins, true);
-            } catch (final IOException e) {
-                // swallowed && logged by Closeables
-                throw new ServiceException(e);
-            }
-        }
-    }
-
-    /**
-     * Loads a logging configuration in to the active logger context. Error messages are printed out to the status
-     * manager.
-     * 
-     * @param loggingConfig logging configuration file
-     * 
-     * @throws ServiceException thrown is there is a problem loading the logging configuration
-     */
-    protected void loadLoggingConfiguration(final InputStream loggingConfig) {
-        try {
-            loggerContext.reset();
-            loadIdPHomeProperty();
-            final JoranConfigurator configurator = new JoranConfigurator();
-            configurator.setContext(loggerContext);
-            configurator.doConfigure(loggingConfig);
-            loggerContext.start();
-        } catch (final JoranException e) {
-            throw new ServiceException(e);
-        }
-    }
-
-    /**
-     * Add the {@link IdPPropertiesApplicationContextInitializer#IDP_HOME_PROPERTY} property from the Spring application
-     * context to the logger context.
-     */
-    protected void loadIdPHomeProperty() {
-        if (applicationContext != null) {
-            final String idpHome =
-                    applicationContext.getEnvironment().getProperty(
-                            IdPPropertiesApplicationContextInitializer.IDP_HOME_PROPERTY);
-            if (idpHome != null) {
-                statusManager
-                        .add(new InfoStatus("Setting logger property '"
-                                + IdPPropertiesApplicationContextInitializer.IDP_HOME_PROPERTY + "' to '" + idpHome
-                                + "'", this));
-                loggerContext.putProperty(IdPPropertiesApplicationContextInitializer.IDP_HOME_PROPERTY, idpHome);
-            }
-        }
-    }
-
-}
\ No newline at end of file
diff --git a/idp-admin-api/src/main/java/net/shibboleth/idp/log/LoggingService.java b/idp-admin-api/src/main/java/net/shibboleth/idp/log/LoggingService.java
deleted file mode 100644
index 12df48704..000000000
--- a/idp-admin-api/src/main/java/net/shibboleth/idp/log/LoggingService.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the University Corporation for Advanced Internet Development,
- * Inc. (UCAID) under one or more contributor license agreements.  See the
- * NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The UCAID 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 net.shibboleth.idp.log;
-
-import javax.annotation.Nonnull;
-import net.shibboleth.utilities.java.support.service.ReloadableService;
-
-import org.springframework.core.io.Resource;
-
-/**
- * A logging configuration abstraction that piggybacks on the {@link ReloadableService} interface.
- * 
- * <p>This interface is being moved to a supporting library.</p>
- * 
- * @deprecated
- */
- at Deprecated(forRemoval=true, since="4.2.2")
-public interface LoggingService extends ReloadableService<Object> {
-
-    /**
-     * Sets the logging configuration.
-     * 
-     * @param configuration logging configuration
-     */
-    void setLoggingConfiguration(@Nonnull final Resource configuration);
-
-}
\ No newline at end of file
diff --git a/idp-authn-api/pom.xml b/idp-authn-api/pom.xml
index 9270da104..54a118a29 100644
--- a/idp-authn-api/pom.xml
+++ b/idp-authn-api/pom.xml
@@ -50,6 +50,11 @@
             <artifactId>opensaml-messaging-api</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>net.shibboleth.shared</groupId>
+            <artifactId>shib-velocity</artifactId>
+        </dependency>
+
         <dependency>
             <groupId>net.shibboleth.utilities</groupId>
             <artifactId>java-support</artifactId>
diff --git a/idp-cas-api/pom.xml b/idp-cas-api/pom.xml
index b131c984d..8a596f147 100644
--- a/idp-cas-api/pom.xml
+++ b/idp-cas-api/pom.xml
@@ -56,6 +56,11 @@
             <artifactId>opensaml-saml-api</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>${shib-shared.groupId}</groupId>
+            <artifactId>shib-service</artifactId>
+        </dependency>
+
         <dependency>
             <groupId>net.shibboleth.ext</groupId>
             <artifactId>spring-extensions</artifactId>
diff --git a/idp-conf-impl/src/main/resources/net/shibboleth/idp/conf/access-control-system.xml b/idp-conf-impl/src/main/resources/net/shibboleth/idp/conf/access-control-system.xml
index b6fbb1632..44c4dfa36 100644
--- a/idp-conf-impl/src/main/resources/net/shibboleth/idp/conf/access-control-system.xml
+++ b/idp-conf-impl/src/main/resources/net/shibboleth/idp/conf/access-control-system.xml
@@ -12,7 +12,7 @@
        default-init-method="initialize"
        default-destroy-method="destroy">
 
-    <bean class="net.shibboleth.idp.security.ReloadingAccessControlService">
+    <bean class="net.shibboleth.shared.service.security.impl.ReloadingAccessControlService">
         <constructor-arg>
             <bean class="net.shibboleth.utilities.java.support.security.impl.BasicAccessControlService"
                 p:id="shibboleth.AccessControlService"
diff --git a/idp-conf-impl/src/main/resources/net/shibboleth/idp/conf/primitives.xml b/idp-conf-impl/src/main/resources/net/shibboleth/idp/conf/primitives.xml
index ee5f88412..ecf22dfe5 100644
--- a/idp-conf-impl/src/main/resources/net/shibboleth/idp/conf/primitives.xml
+++ b/idp-conf-impl/src/main/resources/net/shibboleth/idp/conf/primitives.xml
@@ -22,7 +22,7 @@
     <!-- Parent bean for indirecting a lookup into a managed/reloadable bean. -->
     
     <bean id="shibboleth.ManagedBean" abstract="true"
-        class="net.shibboleth.ext.spring.factory.ProxiedFactoryBean"
+        class="net.shibboleth.shared.service.reloadable.ProxiedFactoryBean"
         c:service-ref="shibboleth.ManagedBeanService" />
 
     <!-- TrustEngine helpers. -->
diff --git a/idp-conf-impl/src/main/resources/net/shibboleth/idp/conf/services-system.xml b/idp-conf-impl/src/main/resources/net/shibboleth/idp/conf/services-system.xml
index 28b354819..ced89c5de 100644
--- a/idp-conf-impl/src/main/resources/net/shibboleth/idp/conf/services-system.xml
+++ b/idp-conf-impl/src/main/resources/net/shibboleth/idp/conf/services-system.xml
@@ -20,7 +20,7 @@
     -->
 
     <bean id="shibboleth.LoggingService"
-        class="%{idp.service.logging.class:net.shibboleth.idp.log.LogbackLoggingService}"
+        class="%{idp.service.logging.class:net.shibboleth.shared.service.impl.LogbackLoggingService}"
         p:loggingConfiguration="%{idp.service.logging.resource:%{idp.home}/conf/logback.xml}"
         p:reloadCheckDelay="%{idp.service.logging.checkInterval:PT0S}"
         p:failFast="%{idp.service.logging.failFast:%{idp.service.failFast:true}}" />
@@ -250,7 +250,7 @@
         c:mdResolver-ref="shibboleth.MetadataResolver" />   
         
     <bean id="shibboleth.AccessControlService"
-        class="net.shibboleth.utilities.java.support.security.impl.DelegatingAccessControlService"
+        class="net.shibboleth.shared.service.security.impl.DelegatingAccessControlService"
         c:acService-ref="shibboleth.ReloadableAccessControlService" />
 
     <bean id="shibboleth.CASServiceRegistry"
diff --git a/idp-consent-impl/pom.xml b/idp-consent-impl/pom.xml
index 94fd76913..6b10c0904 100644
--- a/idp-consent-impl/pom.xml
+++ b/idp-consent-impl/pom.xml
@@ -60,6 +60,11 @@
             <artifactId>opensaml-storage-api</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>${shib-shared.groupId}</groupId>
+            <artifactId>shib-service</artifactId>
+        </dependency>
+
         <dependency>
             <groupId>org.cryptacular</groupId>
             <artifactId>cryptacular</artifactId>
diff --git a/idp-core/pom.xml b/idp-core/pom.xml
index 38a8fd354..17ea87e45 100644
--- a/idp-core/pom.xml
+++ b/idp-core/pom.xml
@@ -84,6 +84,11 @@
             <artifactId>guava</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>${shib-shared.groupId}</groupId>
+            <artifactId>shib-security</artifactId>
+        </dependency>
+
         <dependency>
             <groupId>net.shibboleth.utilities</groupId>
             <artifactId>java-support</artifactId>
diff --git a/idp-core/src/main/java/net/shibboleth/idp/security/ReloadingAccessControlService.java b/idp-core/src/main/java/net/shibboleth/idp/security/ReloadingAccessControlService.java
deleted file mode 100644
index 52b8f4701..000000000
--- a/idp-core/src/main/java/net/shibboleth/idp/security/ReloadingAccessControlService.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the University Corporation for Advanced Internet Development,
- * Inc. (UCAID) under one or more contributor license agreements.  See the
- * NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The UCAID 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 net.shibboleth.idp.security;
-
-import javax.annotation.Nonnull;
-
-import net.shibboleth.ext.spring.service.AbstractServiceableComponent;
-import net.shibboleth.utilities.java.support.annotation.ParameterName;
-import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
-import net.shibboleth.utilities.java.support.logic.Constraint;
-import net.shibboleth.utilities.java.support.security.AccessControl;
-import net.shibboleth.utilities.java.support.security.AccessControlService;
-
-/**
- * This class wraps an {@link AccessControlService} in a
- * {@link net.shibboleth.utilities.java.support.service.ServiceableComponent}.
- */
-public class ReloadingAccessControlService extends AbstractServiceableComponent<AccessControlService>
-        implements AccessControlService {
-
-    /** The embedded service. */
-    private final AccessControlService service;
-
-    /**
-     * Constructor.
-     * 
-     * @param svc the embedded service
-     */
-    public ReloadingAccessControlService(@Nonnull @ParameterName(name="svc") final AccessControlService svc) {
-        service = Constraint.isNotNull(svc, "AccessControlService cannot be null");
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    protected void doInitialize() throws ComponentInitializationException {
-        setId(service.getId());
-        super.doInitialize();
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public AccessControl getInstance(@Nonnull final String name) {
-        return service.getInstance(name);
-    }
-
-    /** {@inheritDoc} */
-    @Override
-    public AccessControlService getComponent() {
-        return this;
-    }
-    
-}
\ No newline at end of file
diff --git a/idp-core/src/main/java/net/shibboleth/idp/security/package-info.java b/idp-core/src/main/java/net/shibboleth/idp/security/package-info.java
deleted file mode 100644
index eea9fea51..000000000
--- a/idp-core/src/main/java/net/shibboleth/idp/security/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the University Corporation for Advanced Internet Development,
- * Inc. (UCAID) under one or more contributor license agreements.  See the
- * NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The UCAID 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.
- */
-
-/**
- * Classes that support the internal security of the IdP.
- */
-
-package net.shibboleth.idp.security;
\ No newline at end of file
diff --git a/idp-parent/pom.xml b/idp-parent/pom.xml
index 5702f6c5a..65405c1f0 100644
--- a/idp-parent/pom.xml
+++ b/idp-parent/pom.xml
@@ -63,6 +63,7 @@
         <opensaml.version>5.0.0-SNAPSHOT</opensaml.version>
         <shib-attribute.version>5.0.0-SNAPSHOT</shib-attribute.version>
         <shib-metadata.version>5.0.0-SNAPSHOT</shib-metadata.version>
+        <shib-shared.groupId>net.shibboleth.shared</shib-shared.groupId>
         <shib-shared.version>9.0.0-SNAPSHOT</shib-shared.version>
         <checkstyle.configLocation>${project.basedir}/../idp-parent/resources/checkstyle/checkstyle.xml</checkstyle.configLocation>
         <idp-parent.site.url>${shibboleth.site.deploy.url}java-identity-provider/${project.version}/</idp-parent.site.url>

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list