public class HostSecurity
extends java.lang.Object
A
makes use of a PluginHost
it cannot be guaranteed that this is the real
host application because a plugin developer can easily create a PluginHost
himself and set this
host instance in A
.
HostSecurity
. To get a functioning object the host must be registered with
registerHost(PluginHost)
. If there is registered an invalid host the object is not functioning and furthermore
the plugin is not usable because there are only two cases:
Constructor and Description |
---|
HostSecurity()
Creates a new security manager.
|
Modifier and Type | Method and Description |
---|---|
protected AlgorithmExerciseProvider |
getDefaultExerciseProvider()
Gets the default exercise provider of the host system.
|
protected PluginHost |
getHost()
Gets the secured host.
|
protected void |
hostAccepted()
Is invoked when the secured host is set meaning that
getHost() returns a valid host. |
protected boolean |
isActivePlugin(AlgorithmPlugin plugin)
Indicates if the given plugin is the active one in the host application.
|
void |
registerHost(PluginHost host)
Registers a new host.
|
protected void |
showMessage(AlgorithmPlugin plugin,
java.lang.String msg,
java.lang.String title,
MessageIcon icon)
Displays a message box.
|
protected void |
writeLogMessage(AlgorithmPlugin plugin,
java.lang.String msg,
java.lang.Exception e,
LogType type)
Writes a log message.
|
protected void |
writeLogMessage(AlgorithmPlugin plugin,
java.lang.String msg,
LogType type)
Writes a log message.
|
public final void registerHost(PluginHost host)
host
- the hostprotected void hostAccepted()
getHost()
returns a valid host.protected final PluginHost getHost()
null
if there is no secured hostisActivePlugin(AlgorithmPlugin)
protected final boolean isActivePlugin(AlgorithmPlugin plugin)
if(getHost() != null) active = getHost().isActivePlugin(...);
.plugin
- the pluginture
if the given plugin is the active one otherwise false
getHost()
protected final void writeLogMessage(AlgorithmPlugin plugin, java.lang.String msg, LogType type)
if(getHost() != null) getHost().writeLogMessage(...);
.plugin
- the plugin that wants to log a messagemsg
- the messagetype
- the message typeprotected final void writeLogMessage(AlgorithmPlugin plugin, java.lang.String msg, java.lang.Exception e, LogType type)
if(getHost() != null) getHost().writeLogMessage(...);
.plugin
- the plugin that wants to log a messagemsg
- the messagee
- the exception that occurredtype
- the message typeprotected final void showMessage(AlgorithmPlugin plugin, java.lang.String msg, java.lang.String title, MessageIcon icon)
if(getHost() != null) getHost().showMessage(...);
.plugin
- the plugin that wants to show a messagemsg
- the message texttitle
- the title of the messageicon
- the icon type of the messageprotected final AlgorithmExerciseProvider getDefaultExerciseProvider()
if(getHost() != null) getHost().getDefaultExerciseProvider();
.null
if there is no secured host