[java-identity-provider] branch main updated: Add executable option to module resources.
Scott Cantor
cantor.2 at osu.edu
Thu Feb 4 14:59:13 UTC 2021
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=809427520a31b9632df776773590596b61dae8ec
The following commit(s) were added to refs/heads/main by this push:
new 809427520 Add executable option to module resources.
809427520 is described below
commit 809427520a31b9632df776773590596b61dae8ec
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Thu Feb 4 09:59:09 2021 -0500
Add executable option to module resources.
---
.../java/net/shibboleth/idp/module/AbstractIdPModule.java | 15 ++++++++++++++-
.../main/java/net/shibboleth/idp/module/IdPModule.java | 7 +++++++
.../shibboleth/idp/module/PropertyDrivenIdPModule.java | 8 +++++++-
.../resources/net/shibboleth/idp/module/module.properties | 1 +
4 files changed, 29 insertions(+), 2 deletions(-)
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 b61f39dc5..abfabb638 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
@@ -199,6 +199,9 @@ public abstract class AbstractIdPModule implements IdPModule {
/** Optional criteria. */
private final boolean optional;
+ /** Executable criteria. */
+ private final boolean executable;
+
/**
* Constructor.
*
@@ -206,13 +209,15 @@ public abstract class AbstractIdPModule implements IdPModule {
* @param dest destination
* @param shouldReplace whether to replace when enabling
* @param isOptional whether the resource is optional
+ * @param isExecutable whether the resource is executable
*/
public BasicModuleResource(@Nonnull @NotEmpty final String src, @Nonnull final Path dest,
- final boolean shouldReplace, final boolean isOptional) {
+ final boolean shouldReplace, final boolean isOptional, final boolean isExecutable) {
source = Constraint.isNotNull(StringSupport.trimOrNull(src), "Source cannot be null");
destination = Constraint.isNotNull(dest, "Destination cannot be null");
replace = shouldReplace;
optional = isOptional;
+ executable = isExecutable;
}
/** {@inheritDoc} */
@@ -249,6 +254,11 @@ public abstract class AbstractIdPModule implements IdPModule {
return optional;
}
+ /** {@inheritDoc} */
+ public boolean isExecutable() {
+ return executable;
+ }
+
/**
* Gets whether the resource has been altered at its destination from the source material.
*
@@ -430,6 +440,9 @@ public abstract class AbstractIdPModule implements IdPModule {
Files.createDirectories(destPath.getParent());
Files.copy(srcStream, destPath, StandardCopyOption.REPLACE_EXISTING);
+ if (isExecutable()) {
+ destPath.toFile().setExecutable(true);
+ }
log.debug("Module {} created {}", getId(), destPath);
return result;
} catch (final IOException e) {
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 ee007e848..ec57d1f10 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
@@ -162,6 +162,13 @@ public interface IdPModule extends IdentifiedComponent {
* @return true iff the resource may be removed by a deployer without disabling the module
*/
public boolean isOptional();
+
+ /**
+ * Gets whether the resource should be marked executable where applicable.
+ *
+ * @return true iff the resource should be marked executable
+ */
+ public boolean isExecutable();
}
/** Resource management outcome. */
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 dd3912496..4b912ecf2 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
@@ -76,6 +76,9 @@ public class PropertyDrivenIdPModule extends AbstractIdPModule {
/** Suffix of property for resource optionality. */
@Nonnull @NotEmpty public static final String MODULE_OPTIONAL_PROPERTY = ".optional";
+ /** Suffix of property for resource executability. */
+ @Nonnull @NotEmpty public static final String MODULE_EXEC_PROPERTY = ".exec";
+
/** Suffix of property for module post-enable message. */
@Nonnull @NotEmpty public static final String MODULE_POSTENABLE_PROPERTY = ".postenable";
@@ -184,6 +187,9 @@ public class PropertyDrivenIdPModule extends AbstractIdPModule {
final Boolean optional = Boolean.valueOf(
moduleProperties.getProperty(getId() + renumstr + MODULE_OPTIONAL_PROPERTY, "false"));
+ final Boolean exec = Boolean.valueOf(
+ moduleProperties.getProperty(getId() + renumstr + MODULE_EXEC_PROPERTY, "false"));
+
final Path destPath = Path.of(dest);
if (dest.contains("..") || destPath.isAbsolute() || destPath.startsWith("/")) {
throw new ModuleException("Module contained a suspect resource destination");
@@ -193,7 +199,7 @@ public class PropertyDrivenIdPModule extends AbstractIdPModule {
requireHttpClient = src.startsWith("https://") || src.startsWith("http://");
}
- resources.add(new BasicModuleResource(src, destPath, replace, optional));
+ resources.add(new BasicModuleResource(src, destPath, replace, optional, exec));
}
setResources(resources);
diff --git a/idp-admin-api/src/test/resources/net/shibboleth/idp/module/module.properties b/idp-admin-api/src/test/resources/net/shibboleth/idp/module/module.properties
index 55a7788cf..17bcaa2c7 100644
--- a/idp-admin-api/src/test/resources/net/shibboleth/idp/module/module.properties
+++ b/idp-admin-api/src/test/resources/net/shibboleth/idp/module/module.properties
@@ -14,6 +14,7 @@ idp.test.url = https://wiki.shibboleth.net/confluence/display/IDP4/Home
idp.test.1.src = /net/shibboleth/idp/module/test.xml
idp.test.1.dest = conf/test.xml
idp.test.1.replace = true
+idp.test.1.exec = true
idp.test.2.src = https://test.shibboleth.net/git/view/?p=java-identity-provider.git&a=blob_plain&f=idp-admin-api/src/test/resources/net/shibboleth/idp/module/test.vm&hb=HEAD
idp.test.2.dest = views/test.vm
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list