Package net.shibboleth.profile.module

# Class PropertyDrivenModule

java.lang.Object
net.shibboleth.profile.module.AbstractModule
net.shibboleth.profile.module.PropertyDrivenModule

All Implemented Interfaces:
  `Module`, `Component`, `IdentifiedComponent`

public abstract class PropertyDrivenModule extends AbstractModule implements Module
Implementation of `Module` relying on Java `Properties`.

Since:
  9.0.0

## Nested Class Summary

## Nested classes/interfaces inherited from class net.shibboleth.profile.module.AbstractModule

`AbstractModule.BasicModuleResource`

## Nested classes/interfaces inherited from interface net.shibboleth.profile.module.Module

`Module.ModuleResource, Module.ResourceResult`

## Field Summary

Fields
Modifier and Type
Field
Description
`static final String`
`DEFAULT_RESOURCE`
Default name of module properties resource.
`private List<String>`
`locales`
Available message locales.
`private org.slf4j.Logger`
`log`
Class logger.
`static final String`
`MODULE_DESC_PROPERTY`
Suffix of property for module description.
`static final String`
`MODULE_DEST_PROPERTY`
Suffix of property for resource destination.
`static final String`
`MODULE_EXEC_PROPERTY`
Suffix of property for resource executability.
`static final String`
`MODULE_LANGS_PROPERTY`
Suffix of property for module languages.
`static final String`
`MODULE_NAME_PROPERTY`
Suffix of property for module name.
`static final String`
`MODULE_NONWINDOWS_PROPERTY`
Suffix of property for resource non-Windows applicability.
`static final String`
`MODULE_OPTIONAL_PROPERTY`
Suffix of property for resource optionality.
`static final String`
`MODULE_PLUGIN_PROPERTY`
Suffix of property for module plugin owner.
`static final String`
`MODULE_POSTDISABLE_PROPERTY`
Suffix of property for module post-disable message.
`static final String`
`MODULE_POSTENABLE_PROPERTY`
Suffix of property for module post-enable message.
`static final String`
`MODULE_REPLACE_PROPERTY`
Suffix of property for resource replacement.
`static final String`
`MODULE_SRC_PROPERTY`
Suffix of property for resource source.
`static final String`
`MODULE_URL_PROPERTY`
Suffix of property for module URL.
`static final String`
`MODULE_WINDOWS_PROPERTY`
Suffix of property for resource Windows applicability.
`private String`
`moduleId`
Module ID.
`private String`
`moduleName`
Module name.
`private final Properties`
`moduleProperties`
Properties describing module.
`private String`
`moduleURL`
Module URL.
`private String`
`pluginId`
Plugin ID.
`private boolean`
`requireHttpClient`
Whether to require an HTTP client.

## Constructor Summary

Constructors
Constructor
Description
`PropertyDrivenModule(String version, InputStream inputStream)`
Constructor.
`PropertyDrivenModule(String version, Class<? extends Module> claz)`
Constructor.
`PropertyDrivenModule(String version, Properties properties)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`Map<Module.ModuleResource,Module.ResourceResult>`
`disable(ModuleContext moduleContext, boolean clean)`
Disable the module.
`Map<Module.ModuleResource,Module.ResourceResult>`
`enable(ModuleContext moduleContext)`
Enable the module.
`String`
`getDescription(ModuleContext moduleContext)`
Gets module description.
`String`
`getId()`
`String`
`getName(ModuleContext moduleContext)`
Gets module name.
`String`
`getOwnerId()`
Gets the plugin name of the module's owner, if the module is provided by a plugin.
`String`
`getURL()`
Gets module URL.
`boolean`
`isHttpClientRequired()`
Gets whether module enablement requires access to an `HttpClient`.
`protected void`
`load()`
Load module information from properties.
`void`
`setURL(String url)`
Set the module URL.

### Methods inherited from class net.shibboleth.profile.module.AbstractModule

`equals, getResources, hashCode, isEnabled, setResources, toString`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface net.shibboleth.profile.module.Module

`enable, getNewExtension, getResources, getSaveExtension, isEnabled`

## Field Details

### DEFAULT_RESOURCE

@Nonnull @NotEmpty public static final String DEFAULT_RESOURCE
Default name of module properties resource.

See Also:
  - Constant Field Values

### MODULE_NAME_PROPERTY

@Nonnull @NotEmpty public static final String MODULE_NAME_PROPERTY
Suffix of property for module name.

See Also:
  - Constant Field Values

### MODULE_DESC_PROPERTY

@Nonnull @NotEmpty public static final String MODULE_DESC_PROPERTY
Suffix of property for module description.

See Also:
  - Constant Field Values

### MODULE_URL_PROPERTY

@Nonnull @NotEmpty public static final String MODULE_URL_PROPERTY
Suffix of property for module URL.

See Also:
  - Constant Field Values

### MODULE_PLUGIN_PROPERTY

@Nonnull @NotEmpty public static final String MODULE_PLUGIN_PROPERTY
Suffix of property for module plugin owner.

See Also:
  - Constant Field Values

### MODULE_SRC_PROPERTY

@Nonnull @NotEmpty public static final String MODULE_SRC_PROPERTY
Suffix of property for resource source.

See Also:
  - Constant Field Values

### MODULE_DEST_PROPERTY

@Nonnull @NotEmpty public static final String MODULE_DEST_PROPERTY
Suffix of property for resource destination.

See Also:
  - Constant Field Values

### MODULE_REPLACE_PROPERTY

@Nonnull @NotEmpty public static final String MODULE_REPLACE_PROPERTY
Suffix of property for resource replacement.

See Also:
  - Constant Field Values

### MODULE_OPTIONAL_PROPERTY

@Nonnull @NotEmpty public static final String MODULE_OPTIONAL_PROPERTY
Suffix of property for resource optionality.

See Also:
  - Constant Field Values

### MODULE_EXEC_PROPERTY

@Nonnull @NotEmpty public static final String MODULE_EXEC_PROPERTY
Suffix of property for resource executability.

See Also:
  - Constant Field Values

### MODULE_WINDOWS_PROPERTY

@Nonnull @NotEmpty public static final String MODULE_WINDOWS_PROPERTY
Suffix of property for resource Windows applicability.

See Also:
  - Constant Field Values

### MODULE_NONWINDOWS_PROPERTY

@Nonnull @NotEmpty public static final String MODULE_NONWINDOWS_PROPERTY
Suffix of property for resource non-Windows applicability.

See Also:
  - Constant Field Values

### MODULE_POSTENABLE_PROPERTY

@Nonnull @NotEmpty public static final String MODULE_POSTENABLE_PROPERTY
Suffix of property for module post-enable message.

See Also:
  - Constant Field Values

### MODULE_POSTDISABLE_PROPERTY

@Nonnull @NotEmpty public static final String MODULE_POSTDISABLE_PROPERTY
Suffix of property for module post-disable message.

See Also:
  - Constant Field Values

### MODULE_LANGS_PROPERTY

@Nonnull @NotEmpty public static final String MODULE_LANGS_PROPERTY
Suffix of property for module languages.

See Also:
  - Constant Field Values

### log

@Nonnull private org.slf4j.Logger log
Class logger.

### moduleProperties

@Nonnull private final Properties moduleProperties
Properties describing module.

### moduleId

@Nonnull @NotEmpty private String moduleId
Module ID.

### moduleName

@Nonnull @NotEmpty private String moduleName
Module name.

### moduleURL

@Nullable @NotEmpty private String moduleURL
Module URL.

### pluginId

@Nullable @NotEmpty private String pluginId
Plugin ID.

### locales

@Nonnull private List<String> locales
Available message locales.

### requireHttpClient

private boolean requireHttpClient
Whether to require an HTTP client.

## Constructor Details

### PropertyDrivenModule

public PropertyDrivenModule(@Nullable String version, @Nonnull Class<? extends Module> claz) throws IOException, ModuleException
Constructor.

Parameters:
  `claz` - type of object used to locate default module.properties resource
  `version` - version of the containing application (or null if none available)
Throws:
  `IOException` - if unable to read file
  `ModuleException` - if the module is not in a valid state

### PropertyDrivenModule

public PropertyDrivenModule(@Nullable String version, @Nonnull InputStream inputStream) throws IOException, ModuleException
Constructor.

Parameters:
  `inputStream` - property stream
  `version` - version of the containing application (or null if none available)
Throws:
  `IOException` - if unable to read file
  `ModuleException` - if the module is not in a valid state

### PropertyDrivenModule

public PropertyDrivenModule(@Nullable String version, @Nonnull Properties properties) throws ModuleException
Constructor.

Parameters:
  `properties` - property set
  `version` - version of the containing application (or null if none available)
Throws:
  `ModuleException` - if the module is not in a valid state

## Method Details

### load

protected void load() throws ModuleException
Load module information from properties.

Throws:
  `ModuleException` - on errors

### getId

@Nonnull @NotEmpty public String getId()

Specified by:
  `getId` in interface `IdentifiedComponent`

### getName

@Nonnull @NotEmpty public String getName(@Nullable ModuleContext moduleContext)
Gets module name.

Specified by:
  `getName` in interface `Module`
Parameters:
  `moduleContext` - optional context for supplying i18n input
Returns:
  a human-readable name for the module

### getDescription

@Nullable @NotEmpty public String getDescription(@Nullable ModuleContext moduleContext)
Gets module description.

Specified by:
  `getDescription` in interface `Module`
Parameters:
  `moduleContext` - optional context for supplying i18n input
Returns:
  a human-readable description for the module

### getURL

@Nullable @NotEmpty public String getURL()
Gets module URL.

Specified by:
  `getURL` in interface `Module`
Returns:
  a URL for obtaining additional information about the module

### setURL

public void setURL(@Nullable @NotEmpty String url)
Set the module URL.

Parameters:
  `url` - URL to set

### getOwnerId

@Nullable @NotEmpty public String getOwnerId()
Gets the plugin name of the module's owner, if the module is provided by a plugin.

Specified by:
  `getOwnerId` in interface `Module`
Returns:
  plugin ID, if any

### isHttpClientRequired

public boolean isHttpClientRequired()
Gets whether module enablement requires access to an `HttpClient`.

Specified by:
  `isHttpClientRequired` in interface `Module`
Returns:
  true iff enabling the module requires HTTP client

### enable

@Nonnull @Unmodifiable @NotLive public Map<Module.ModuleResource,Module.ResourceResult> enable(@Nonnull ModuleContext moduleContext) throws ModuleException
Enable the module.

This operation MUST be idempotent.

Specified by:
  `enable` in interface `Module`
Overrides:
  `enable` in class `AbstractModule`
Parameters:
  `moduleContext` - module context
Returns:
  summary of resource results
Throws:
  `ModuleException` - if not successful

### disable

@Nonnull @Unmodifiable @NotLive public Map<Module.ModuleResource,Module.ResourceResult> disable(@Nonnull ModuleContext moduleContext, boolean clean) throws ModuleException
Disable the module.

This operation MUST be idempotent with respect to the value of the input parameter.

Specified by:
  `disable` in interface `Module`
Overrides:
  `disable` in class `AbstractModule`
Parameters:
  `moduleContext` - module context
  `clean` - if true, the module should attempt to fully remove traces of previous use in a potentially destructive fashion
Returns:
  summary of resource results
Throws:
  `ModuleException` - if not successful