[java-identity-provider] branch main updated: Add platfom flags for module resources to control installation.
Scott Cantor
cantor.2 at osu.edu
Thu May 11 16:50:55 UTC 2023
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=b94b9183eaa0ccb7dd6c4272b7c71afe57986162
The following commit(s) were added to refs/heads/main by this push:
new b94b9183e Add platfom flags for module resources to control installation.
b94b9183e is described below
commit b94b9183eaa0ccb7dd6c4272b7c71afe57986162
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Thu May 11 12:50:51 2023 -0400
Add platfom flags for module resources to control installation.
---
idp-admin-api/pom.xml | 5 +++
.../shibboleth/idp/module/AbstractIdPModule.java | 44 ++++++++++++++++++++--
.../java/net/shibboleth/idp/module/IdPModule.java | 20 +++++++++-
.../idp/module/PropertyDrivenIdPModule.java | 16 +++++++-
4 files changed, 79 insertions(+), 6 deletions(-)
diff --git a/idp-admin-api/pom.xml b/idp-admin-api/pom.xml
index ec0d1c005..29d3265f6 100644
--- a/idp-admin-api/pom.xml
+++ b/idp-admin-api/pom.xml
@@ -75,6 +75,11 @@
<artifactId>guava</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ </dependency>
+
<dependency>
<groupId>${httpclient.groupId}</groupId>
<artifactId>${httpclient.artifactId}</artifactId>
diff --git a/idp-admin-api/src/main/java/net/shibboleth/idp/module/AbstractIdPModule.java b/idp-admin-api/src/main/java/net/shibboleth/idp/module/AbstractIdPModule.java
index 9f22e8339..86b31b6a8 100644
--- a/idp-admin-api/src/main/java/net/shibboleth/idp/module/AbstractIdPModule.java
+++ b/idp-admin-api/src/main/java/net/shibboleth/idp/module/AbstractIdPModule.java
@@ -39,6 +39,7 @@ import java.util.Objects;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
+import org.apache.commons.lang3.SystemUtils;
import org.apache.hc.client5.http.classic.methods.HttpGet;
import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
import org.apache.hc.client5.http.protocol.HttpClientContext;
@@ -171,7 +172,15 @@ public abstract class AbstractIdPModule implements IdPModule {
results = new LinkedHashMap<>(moduleResources.size());
for (final ModuleResource resource : moduleResources) {
- results.put(resource, ((BasicModuleResource) resource).enable(moduleContext));
+ if (SystemUtils.IS_OS_WINDOWS) {
+ if (resource.isWindows()) {
+ results.put(resource, ((BasicModuleResource) resource).enable(moduleContext));
+ }
+ } else {
+ if (resource.isNonWindows()) {
+ results.put(resource, ((BasicModuleResource) resource).enable(moduleContext));
+ }
+ }
}
} else {
results = CollectionSupport.emptyMap();
@@ -197,7 +206,15 @@ public abstract class AbstractIdPModule implements IdPModule {
if (!moduleResources.isEmpty()) {
results = new LinkedHashMap<>(moduleResources.size());
for (final ModuleResource resource : moduleResources) {
- results.put(resource, ((BasicModuleResource) resource).disable(moduleContext, clean));
+ if (SystemUtils.IS_OS_WINDOWS) {
+ if (resource.isWindows()) {
+ results.put(resource, ((BasicModuleResource) resource).disable(moduleContext, clean));
+ }
+ } else {
+ if (resource.isNonWindows()) {
+ results.put(resource, ((BasicModuleResource) resource).disable(moduleContext, clean));
+ }
+ }
}
} else {
results = CollectionSupport.emptyMap();
@@ -246,6 +263,12 @@ public abstract class AbstractIdPModule implements IdPModule {
/** Executable criteria. */
private final boolean executable;
+
+ /** Process on Windows? */
+ private final boolean windows;
+
+ /** Process on non-Windows? */
+ private final boolean nonwindows;
/**
* Constructor.
@@ -255,14 +278,19 @@ public abstract class AbstractIdPModule implements IdPModule {
* @param shouldReplace whether to replace when enabling
* @param isOptional whether the resource is optional
* @param isExecutable whether the resource is executable
+ * @param isWindows whether the resource should be processed on Windows
+ * @param isNonWindows whether the resource should be processed on non-Windows platforms
*/
public BasicModuleResource(@Nonnull @NotEmpty final String src, @Nonnull final Path dest,
- final boolean shouldReplace, final boolean isOptional, final boolean isExecutable) {
+ final boolean shouldReplace, final boolean isOptional, final boolean isExecutable,
+ final boolean isWindows, final boolean isNonWindows) {
source = Constraint.isNotNull(StringSupport.trimOrNull(src), "Source cannot be null");
destination = Constraint.isNotNull(dest, "Destination cannot be null");
replace = shouldReplace;
optional = isOptional;
executable = isExecutable;
+ windows = isWindows;
+ nonwindows = isNonWindows;
}
/** {@inheritDoc} */
@@ -304,6 +332,16 @@ public abstract class AbstractIdPModule implements IdPModule {
return executable;
}
+ /** {@inheritDoc} */
+ public boolean isWindows() {
+ return windows;
+ }
+
+ /** {@inheritDoc} */
+ public boolean isNonWindows() {
+ return nonwindows;
+ }
+
/**
* Gets whether the resource has been altered at its destination from the source material.
*
diff --git a/idp-admin-api/src/main/java/net/shibboleth/idp/module/IdPModule.java b/idp-admin-api/src/main/java/net/shibboleth/idp/module/IdPModule.java
index 7edcf8d62..5528dba35 100644
--- a/idp-admin-api/src/main/java/net/shibboleth/idp/module/IdPModule.java
+++ b/idp-admin-api/src/main/java/net/shibboleth/idp/module/IdPModule.java
@@ -167,7 +167,25 @@ public interface IdPModule extends IdentifiedComponent {
* @return true iff the resource should be marked executable
*/
public boolean isExecutable();
-}
+
+ /**
+ * Gets whether the resource should be processed on Windows.
+ *
+ * @return true iff the resource should be processed on Windows
+ *
+ * @since 5.0.0
+ */
+ public boolean isWindows();
+
+ /**
+ * Gets whether the resource should be processed on non-Windows platforms.
+ *
+ * @return true iff the resource should be processed on non-Windows platforms
+ *
+ * @since 5.0.0
+ */
+ public boolean isNonWindows();
+ }
/** Resource management outcome. */
public enum ResourceResult {
diff --git a/idp-admin-api/src/main/java/net/shibboleth/idp/module/PropertyDrivenIdPModule.java b/idp-admin-api/src/main/java/net/shibboleth/idp/module/PropertyDrivenIdPModule.java
index cb111999b..4ed170efa 100644
--- a/idp-admin-api/src/main/java/net/shibboleth/idp/module/PropertyDrivenIdPModule.java
+++ b/idp-admin-api/src/main/java/net/shibboleth/idp/module/PropertyDrivenIdPModule.java
@@ -80,6 +80,12 @@ public class PropertyDrivenIdPModule extends AbstractIdPModule {
/** Suffix of property for resource executability. */
@Nonnull @NotEmpty public static final String MODULE_EXEC_PROPERTY = ".exec";
+ /** Suffix of property for resource Windows applicability. */
+ @Nonnull @NotEmpty public static final String MODULE_WINDOWS_PROPERTY = ".windows";
+
+ /** Suffix of property for resource non-Windows applicability. */
+ @Nonnull @NotEmpty public static final String MODULE_NONWINDOWS_PROPERTY = ".nonwindows";
+
/** Suffix of property for module post-enable message. */
@Nonnull @NotEmpty public static final String MODULE_POSTENABLE_PROPERTY = ".postenable";
@@ -199,7 +205,13 @@ public class PropertyDrivenIdPModule extends AbstractIdPModule {
final Boolean exec = Boolean.valueOf(
moduleProperties.getProperty(getId() + renumstr + MODULE_EXEC_PROPERTY, "false"));
-
+
+ final Boolean windows = Boolean.valueOf(
+ moduleProperties.getProperty(getId() + renumstr + MODULE_WINDOWS_PROPERTY, "true"));
+
+ final Boolean nonwindows = Boolean.valueOf(
+ moduleProperties.getProperty(getId() + renumstr + MODULE_NONWINDOWS_PROPERTY, "true"));
+
final Path destPath = Path.of(dest);
if (dest.contains("..") || destPath.isAbsolute() || destPath.startsWith("/")) {
throw new ModuleException("Module contained a suspect resource destination");
@@ -209,7 +221,7 @@ public class PropertyDrivenIdPModule extends AbstractIdPModule {
requireHttpClient = src.startsWith("https://") || src.startsWith("http://");
}
- resources.add(new BasicModuleResource(src, destPath, replace, optional, exec));
+ resources.add(new BasicModuleResource(src, destPath, replace, optional, exec, windows, nonwindows));
}
setResources(resources);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list