[java-identity-provider] branch main updated: IDP-1664 - Support Module service API
Scott Cantor
cantor.2 at osu.edu
Wed Sep 2 19:25:18 UTC 2020
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=73624e9baeb9554bf93cf6cbe3b7ddca0dffe122
The following commit(s) were added to refs/heads/main by this push:
new 73624e9ba IDP-1664 - Support Module service API
73624e9ba is described below
commit 73624e9baeb9554bf93cf6cbe3b7ddca0dffe122
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed Sep 2 15:25:09 2020 -0400
IDP-1664 - Support Module service API
https://issues.shibboleth.net/jira/browse/IDP-1664
Add post-enable/disable messaging.
---
.../net/shibboleth/idp/module/ModuleContext.java | 24 ++++++++++++++
.../idp/module/PropertyDrivenIdPModule.java | 38 +++++++++++++++++++---
2 files changed, 57 insertions(+), 5 deletions(-)
diff --git a/idp-admin-api/src/main/java/net/shibboleth/idp/module/ModuleContext.java b/idp-admin-api/src/main/java/net/shibboleth/idp/module/ModuleContext.java
index 69c031a17..4998a483e 100644
--- a/idp-admin-api/src/main/java/net/shibboleth/idp/module/ModuleContext.java
+++ b/idp-admin-api/src/main/java/net/shibboleth/idp/module/ModuleContext.java
@@ -17,6 +17,7 @@
package net.shibboleth.idp.module;
+import java.io.PrintStream;
import java.nio.file.Path;
import javax.annotation.Nonnull;
@@ -41,6 +42,9 @@ public final class ModuleContext {
/** HTTP security parameters. */
@Nullable private HttpClientSecurityParameters httpClientSecurityParams;
+ /** Output stream for sending output to the module consumer. */
+ @Nullable private PrintStream messageStream;
+
/**
* Constructor.
*
@@ -95,4 +99,24 @@ public final class ModuleContext {
httpClientSecurityParams = params;
}
+ /**
+ * Gets the output stream to receive any instructioons or additional information after
+ * performing operations.
+ *
+ * @return output stream, or null
+ */
+ @Nullable public PrintStream getMessageStream() {
+ return messageStream;
+ }
+
+ /**
+ * Sets the output stream to receive any instructioons or additional information after
+ * performing operations.
+ *
+ * @param stream output stream
+ */
+ public void setMessageStream(@Nullable final PrintStream stream) {
+ messageStream = stream;
+ }
+
}
\ No newline at end of file
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 4fd2fd17c..f46dc5d02 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
@@ -63,6 +63,12 @@ public class PropertyDrivenIdPModule extends AbstractIdPModule {
/** Suffix of property for resource replacement. */
@Nonnull @NotEmpty public static final String MODULE_REPLACE_PROPERTY = ".replace";
+ /** Suffix of property for module post-enable message. */
+ @Nonnull @NotEmpty public static final String MODULE_POSTENABLE_PROPERTY = ".postenable";
+
+ /** Suffix of property for module post-disable message. */
+ @Nonnull @NotEmpty public static final String MODULE_POSTDISABLE_PROPERTY = ".postdisable";
+
/** Class logger. */
@Nonnull private Logger log = LoggerFactory.getLogger(PropertyDrivenIdPModule.class);
@@ -72,9 +78,6 @@ public class PropertyDrivenIdPModule extends AbstractIdPModule {
/** Module name. */
@Nonnull @NotEmpty private String moduleName;
- /** Module description. */
- @Nullable @NotEmpty private String moduleDesc;
-
/** Module URL. */
@Nullable private URL moduleURL;
@@ -126,7 +129,6 @@ public class PropertyDrivenIdPModule extends AbstractIdPModule {
moduleName = Constraint.isNotNull(
StringSupport.trimOrNull(moduleProperties.getProperty(getId() + MODULE_NAME_PROPERTY)),
"Module name missing from properties");
- moduleDesc = StringSupport.trimOrNull(moduleProperties.getProperty(getId() + MODULE_DESC_PROPERTY));
final String url = StringSupport.trimOrNull(moduleProperties.getProperty(getId() + MODULE_URL_PROPERTY));
if (url != null) {
moduleURL = new URL(url);
@@ -183,7 +185,7 @@ public class PropertyDrivenIdPModule extends AbstractIdPModule {
/** {@inheritDoc} */
@Nullable @NotEmpty public String getDescription() {
- return moduleDesc;
+ return StringSupport.trimOrNull(moduleProperties.getProperty(getId() + MODULE_DESC_PROPERTY));
}
/** {@inheritDoc} */
@@ -196,4 +198,30 @@ public class PropertyDrivenIdPModule extends AbstractIdPModule {
return requireHttpClient;
}
+ /** {@inheritDoc} */
+ @Override
+ public void enable(@Nullable final ModuleContext moduleContext) throws ModuleException {
+ super.enable(moduleContext);
+
+ if (moduleContext.getMessageStream() != null) {
+ final String msg = moduleProperties.getProperty(getId() + MODULE_POSTENABLE_PROPERTY);
+ if (msg != null) {
+ moduleContext.getMessageStream().println(msg);
+ }
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void disable(@Nullable final ModuleContext moduleContext, final boolean clean) throws ModuleException {
+ super.disable(moduleContext, clean);
+
+ if (moduleContext.getMessageStream() != null) {
+ final String msg = moduleProperties.getProperty(getId() + MODULE_POSTDISABLE_PROPERTY);
+ if (msg != null) {
+ moduleContext.getMessageStream().println(msg);
+ }
+ }
+ }
+
}
\ 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