[java-sp-server] branch main updated: Classes missing from earlier commit.
Scott Cantor
cantor.2 at osu.edu
Wed May 18 17:45:03 UTC 2022
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch main
in repository java-sp-server.
View the commit online:
http://git.shibboleth.net/view/?p=java-sp-server.git;a=commit;h=80120c1049bc996d9fcfc8d6ff47c6813fe438dc
The following commit(s) were added to refs/heads/main by this push:
new 80120c1 Classes missing from earlier commit.
80120c1 is described below
commit 80120c1049bc996d9fcfc8d6ff47c6813fe438dc
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed May 18 13:45:00 2022 -0400
Classes missing from earlier commit.
---
.../shibboleth/sp/conf/access-control-system.xml | 32 ++++++++++
.../net/shibboleth/sp/conf/endpoints-system.xml | 33 +++++++++++
.../net/shibboleth/sp/conf/services-system.xml | 32 ++++++++--
.../net/shibboleth/sp/remoting/impl/echo.msg | 2 +
.../shibboleth/sp/remoting/EndpointManager.java | 47 +++++++++++++++
.../sp/remoting/impl/BasicEndpointManager.java | 68 ++++++++++++++++++++++
.../java/net/shibboleth/sp/remoting/impl/Echo.java | 39 +++++++++++++
.../sp/remoting/impl/ReloadingEndpointManager.java | 67 +++++++++++++++++++++
8 files changed, 316 insertions(+), 4 deletions(-)
diff --git a/sp-conf-impl/src/main/resources/net/shibboleth/sp/conf/access-control-system.xml b/sp-conf-impl/src/main/resources/net/shibboleth/sp/conf/access-control-system.xml
new file mode 100644
index 0000000..4c33842
--- /dev/null
+++ b/sp-conf-impl/src/main/resources/net/shibboleth/sp/conf/access-control-system.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xmlns:util="http://www.springframework.org/schema/util"
+ xmlns:p="http://www.springframework.org/schema/p"
+ xmlns:c="http://www.springframework.org/schema/c"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
+ http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"
+
+ default-init-method="initialize"
+ default-destroy-method="destroy">
+
+ <bean class="net.shibboleth.idp.security.ReloadingAccessControlService">
+ <constructor-arg>
+ <bean class="net.shibboleth.utilities.java.support.security.impl.BasicAccessControlService"
+ p:id="shibboleth.AccessControlService"
+ p:policyMap-ref="shibboleth.AccessControlPolicies" />
+ </constructor-arg>
+ </bean>
+
+ <bean id="shibboleth.IPRangeAccessControl" abstract="true"
+ class="net.shibboleth.utilities.java.support.security.impl.IPRangeAccessControl" />
+
+ <bean id="shibboleth.PredicateAccessControl" abstract="true"
+ class="org.opensaml.profile.logic.PredicateAccessControl" />
+
+ <!-- Wildcard import hook for plugins. -->
+ <import resource="classpath*:/META-INF/net/shibboleth/sp/service/access-control/postconfig.xml" />
+
+</beans>
diff --git a/sp-conf-impl/src/main/resources/net/shibboleth/sp/conf/endpoints-system.xml b/sp-conf-impl/src/main/resources/net/shibboleth/sp/conf/endpoints-system.xml
new file mode 100644
index 0000000..440cdb9
--- /dev/null
+++ b/sp-conf-impl/src/main/resources/net/shibboleth/sp/conf/endpoints-system.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xmlns:util="http://www.springframework.org/schema/util"
+ xmlns:p="http://www.springframework.org/schema/p"
+ xmlns:c="http://www.springframework.org/schema/c"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
+ http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"
+
+ default-init-method="initialize"
+ default-destroy-method="destroy">
+
+ <!-- Needed to allow for auto-wiring of componnents. -->
+ <context:annotation-config />
+
+ <!-- ServiceableComponent exposed to the root context. -->
+ <bean class="net.shibboleth.sp.remoting.impl.ReloadingEndpointManager"
+ c:_0-ref="shibboleth.EndpointManager"
+ p:id="shibboleth.ReloadingEndpointManager" />
+
+ <!-- This bean auto-wires the remoting endpoints into a map exposed by the surrounding service. -->
+ <bean id="shibboleth.EndpointManager" class="net.shibboleth.sp.remoting.impl.BasicEndpointManager" />
+
+ <!-- Auto-wired remoting endpoints. -->
+
+ <bean class="net.shibboleth.sp.remoting.impl.Echo" />
+
+ <!-- Wildcard import hook for plugins. -->
+ <import resource="classpath*:/META-INF/net/shibboleth/sp/service/provider/postconfig.xml" />
+
+</beans>
diff --git a/sp-conf-impl/src/main/resources/net/shibboleth/sp/conf/services-system.xml b/sp-conf-impl/src/main/resources/net/shibboleth/sp/conf/services-system.xml
index 4afe72a..c7eb8e9 100644
--- a/sp-conf-impl/src/main/resources/net/shibboleth/sp/conf/services-system.xml
+++ b/sp-conf-impl/src/main/resources/net/shibboleth/sp/conf/services-system.xml
@@ -34,15 +34,39 @@
<!-- Auto-append system config file to resource set. -->
<bean id ="ExtendedServiceProviderResources" class="net.shibboleth.ext.spring.factory.CombiningListFactoryBean"
- p:firstList="#{getObject('%{sp.service.provider.resources:shibboleth.ServiceProviderResources}'.trim()) ?:
- getObject('shibboleth.DefaultServiceProviderResources')}" >
+ p:firstList="#{getObject('%{sp.service.provider.resources:shibboleth.ServiceProviderResources}'.trim())}" >
<property name="secondList">
<util:list >
<value>classpath:/net/shibboleth/sp/conf/endpoints-system.xml</value>
</util:list>
</property>
</bean>
-
- <util:list id="shibboleth.DefaultServiceProviderResources" />
+
+ <bean id="shibboleth.AccessControlService" class="net.shibboleth.ext.spring.service.ReloadableSpringService"
+ c:claz="net.shibboleth.utilities.java.support.security.AccessControlService"
+ p:serviceConfigurations-ref="ExtendedAccessControlResources"
+ p:failFast="%{sp.service.access.failFast:%{idp.service.failFast:true}}"
+ p:reloadCheckDelay="%{sp.service.access.checkInterval:PT0S}"
+ p:beanPostProcessors-ref="shibboleth.IdentifiableBeanPostProcessor"
+ p:beanFactoryPostProcessors-ref="shibboleth.PropertySourcesPlaceholderConfigurer" />
+ <!-- Auto-append system config file to resource set. -->
+ <bean id ="ExtendedAccessControlResources" class="net.shibboleth.ext.spring.factory.CombiningListFactoryBean"
+ p:firstList="#{getObject('%{sp.service.access.resources:shibboleth.AccessControlResources}'.trim())}" >
+ <property name="secondList">
+ <util:list >
+ <value>classpath:/net/shibboleth/sp/conf/access-control-system.xml</value>
+ </util:list>
+ </property>
+ </bean>
+
+ <!-- TODO: add attribute and metadata services (at least) -->
+
+ <!-- Service facades. -->
+
+ <bean id="shibboleth.WrappedAccessControlService"
+ class="net.shibboleth.utilities.java.support.security.impl.DelegatingAccessControlService"
+ c:acService-ref="shibboleth.AccessControlService" />
+
+ <import resource="conditional:%{sp.home}/conf/services.xml" />
</beans>
diff --git a/sp-conf-impl/src/test/resources/net/shibboleth/sp/remoting/impl/echo.msg b/sp-conf-impl/src/test/resources/net/shibboleth/sp/remoting/impl/echo.msg
new file mode 100644
index 0000000..c14dd5c
--- /dev/null
+++ b/sp-conf-impl/src/test/resources/net/shibboleth/sp/remoting/impl/echo.msg
@@ -0,0 +1,2 @@
+echo 1 abc123
+
diff --git a/sp-server-api/src/main/java/net/shibboleth/sp/remoting/EndpointManager.java b/sp-server-api/src/main/java/net/shibboleth/sp/remoting/EndpointManager.java
new file mode 100644
index 0000000..fd16e34
--- /dev/null
+++ b/sp-server-api/src/main/java/net/shibboleth/sp/remoting/EndpointManager.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed 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
+ *
+ * https://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.sp.remoting;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import javax.annotation.concurrent.ThreadSafe;
+
+import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
+import net.shibboleth.utilities.java.support.component.DestructableComponent;
+import net.shibboleth.utilities.java.support.component.IdentifiedComponent;
+import net.shibboleth.utilities.java.support.component.InitializableComponent;
+import net.shibboleth.utilities.java.support.component.UnmodifiableComponent;
+
+/**
+ * Handles message dispatch to {@link Endpoint} objects that implemenat actual business logic.
+ *
+ * <p>There may be a way to utilize Spring Integration message routing for this, but I was
+ * unable to see an obvious way to use the simple TCP gateway design to dispatch to
+ * channels dynamically.</p>
+ */
+ at ThreadSafe
+public interface EndpointManager extends InitializableComponent, DestructableComponent, IdentifiedComponent,
+ UnmodifiableComponent {
+
+ /**
+ * Gets the {@link Endpoint} registered for a particular address.
+ *
+ * @param address the message address
+ *
+ * @return the registered {@link Endpoint} or null
+ */
+ @Nullable Endpoint getEndpoint(@Nonnull @NotEmpty final String address);
+
+}
\ No newline at end of file
diff --git a/sp-server-impl/src/main/java/net/shibboleth/sp/remoting/impl/BasicEndpointManager.java b/sp-server-impl/src/main/java/net/shibboleth/sp/remoting/impl/BasicEndpointManager.java
new file mode 100644
index 0000000..930e08d
--- /dev/null
+++ b/sp-server-impl/src/main/java/net/shibboleth/sp/remoting/impl/BasicEndpointManager.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed 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
+ *
+ * https://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.sp.remoting.impl;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import net.shibboleth.sp.remoting.Endpoint;
+import net.shibboleth.sp.remoting.EndpointManager;
+import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
+import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
+import net.shibboleth.utilities.java.support.component.AbstractIdentifiableInitializableComponent;
+
+/**
+ * Simple implementation of {@link EndpointManager} that relies on an in-memory map
+ * of auto-wired components.
+ */
+public class BasicEndpointManager extends AbstractIdentifiableInitializableComponent implements EndpointManager {
+
+ /** Class logger. */
+ @Nonnull private final Logger log = LoggerFactory.getLogger(BasicEndpointManager.class);
+
+ /** Map of auto-wired message sinks. */
+ @Nonnull @NonnullElements Map<String,Endpoint> addressMap;
+
+ /**
+ * Constructor.
+ *
+ * @param remotedObjects auto-wired endpoints
+ */
+ @Autowired
+ public BasicEndpointManager(@Nullable @NonnullElements Collection<Endpoint> remotedObjects) {
+ if (remotedObjects != null) {
+ addressMap = remotedObjects.stream().collect(Collectors.toMap(Endpoint::getAddress, r -> r));
+ } else {
+ addressMap = Collections.emptyMap();
+ }
+
+ log.debug("Registered addresses: {}", addressMap.keySet());
+ }
+
+ /** {@inheritDoc} */
+ @Nullable public Endpoint getEndpoint(@Nonnull @NotEmpty final String address) {
+ return addressMap.get(address);
+ }
+
+}
\ No newline at end of file
diff --git a/sp-server-impl/src/main/java/net/shibboleth/sp/remoting/impl/Echo.java b/sp-server-impl/src/main/java/net/shibboleth/sp/remoting/impl/Echo.java
new file mode 100644
index 0000000..1876005
--- /dev/null
+++ b/sp-server-impl/src/main/java/net/shibboleth/sp/remoting/impl/Echo.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed 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
+ *
+ * https://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.sp.remoting.impl;
+
+import net.shibboleth.sp.remoting.RemoteProcessingException;
+import net.shibboleth.sp.remoting.Endpoint;
+import net.shibboleth.utilities.java.support.ddf.DDF;
+
+/**
+ * Echo service endpoint.
+ *
+ * <p>This bean just echoes the input as the output for validation/testing.
+ */
+public class Echo implements Endpoint {
+
+ /** {@inheritDoc} */
+ public String getAddress() {
+ return "echo";
+ }
+
+ /** {@inheritDoc} */
+ public DDF receive(DDF input) throws RemoteProcessingException {
+ return input;
+ }
+
+}
\ No newline at end of file
diff --git a/sp-server-impl/src/main/java/net/shibboleth/sp/remoting/impl/ReloadingEndpointManager.java b/sp-server-impl/src/main/java/net/shibboleth/sp/remoting/impl/ReloadingEndpointManager.java
new file mode 100644
index 0000000..4592d25
--- /dev/null
+++ b/sp-server-impl/src/main/java/net/shibboleth/sp/remoting/impl/ReloadingEndpointManager.java
@@ -0,0 +1,67 @@
+/*
+ * 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.sp.remoting.impl;
+
+import javax.annotation.Nonnull;
+
+import net.shibboleth.ext.spring.service.AbstractServiceableComponent;
+import net.shibboleth.sp.remoting.Endpoint;
+import net.shibboleth.sp.remoting.EndpointManager;
+import net.shibboleth.utilities.java.support.annotation.ParameterName;
+import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
+import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
+import net.shibboleth.utilities.java.support.logic.Constraint;
+
+/**
+ * This class wraps an {@link EndpointManager} in a
+ * {@link net.shibboleth.utilities.java.support.service.ServiceableComponent}.
+ */
+public class ReloadingEndpointManager extends AbstractServiceableComponent<EndpointManager>
+ implements EndpointManager {
+
+ /** The embedded service. */
+ @Nonnull private final EndpointManager service;
+
+ /**
+ * Constructor.
+ *
+ * @param svc the embedded service
+ */
+ public ReloadingEndpointManager(@Nonnull @ParameterName(name="svc") final EndpointManager svc) {
+ service = Constraint.isNotNull(svc, "EndpointManager cannot be null");
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ protected void doInitialize() throws ComponentInitializationException {
+ setId(service.getId());
+ super.doInitialize();
+ }
+
+ /** {@inheritDoc} */
+ public Endpoint getEndpoint(@Nonnull @NotEmpty final String address) {
+ return service.getEndpoint(address);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public EndpointManager getComponent() {
+ return this;
+ }
+
+}
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list