Class ClassifiedFeature
- java.lang.Object
-
- com.jalios.jcms.security.classified.ClassifiedFeature
-
public class ClassifiedFeature extends java.lang.ObjectRepresentantion of an application feature whose access may be limited to publications with a classification level lower than or equal to a specific level.Core features constants are declared in
ClassifiedFeatures.You can manage your own plugin feature in your plugin's properties and API :
1) Declare an empty property, prefixed with "classification.feature." in your
plugin.propfile :classification.feature.plugin.myplugin.some-feat:
2) Declare the I18N label of your feature in your I18N properties files :
en.propclassification.feature.plugin.myplugin.some-feat: My wonderful feature
fr.propclassification.feature.plugin.myplugin.some-feat: Ma super fonctionnalité
- ...
ClassifiedFeature(String):public static final ClassifiedFeature MY_PLUGIN_FEAT = new ClassifiedFeature("plugin.myplugin.some-feat");4) Check feature access authorization usingcanBeUsedFor(Publication), when you want to propose your feature (in the user interface) AND when validating a request to use the feature (in a java handler or API).To explain the operation refusal to the end user, you can either return a failed controller status using
getControllerStatus()(it will include an I18N explanation message), or add an I18N explanation message usinggetMessage(String).Optionnally, you can provide a log message for diagnostic purpose, using
getLogMessage().if (!MY_PLUGIN_FEAT.canBeUsedFor(somePublication)) { if (logger.isDebugEnabled() { logger.debug(MessageFormat.format("Feature access refused for publication {0} : {1}", JcmsUtil.dataToString(somePublication), MY_PLUGIN_FEAT.getLogMessage()); ); } return MY_PLUGIN_FEAT.getControllerStatus(); } ... // provide acces to feature- Since:
- 10.0.8 / JCMS-10746
-
-
Constructor Summary
Constructors Constructor Description ClassifiedFeature(java.lang.String featureName)Create a new ClassifiedFeature with the specified name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanBeUsedFor(Publication pub)Check if this feature can be used for the specified publication.ControllerStatusgetControllerStatus()Retrieve a failed ControllerStatus suitable to explain the feature limit relative to classified publication.java.lang.StringgetFeatureName()Retrieve the technical name of this feature.java.lang.StringgetIcon()Retrieve the icon of this feature.java.lang.StringgetLabel(java.lang.String lang)Retrieve the I18Ned label of this feature.java.lang.StringgetLogMessage()Retrieve an english message explaining the feature limit relative to classified publication.intgetMaxLevel()Retrieve the maximum authorized classification level of this feature.java.lang.StringgetMessage(java.lang.String lang)Retrieve the I18Ned message explaining the feature limit relative to classified publication.PlugingetPlugin()Retrieve the plugin in which this feature was declared (if it is not a core feature)java.lang.StringtoString()
-
-
-
Constructor Detail
-
ClassifiedFeature
public ClassifiedFeature(java.lang.String featureName)
Create a new ClassifiedFeature with the specified name.- Parameters:
featureName- the technical name of this feature, as declared in properties prefixed with "classification.feature.".Examples :
"core.share.public-link"or"plugin.jdrive.add-in-jdrive".Must not be null.
- Throws:
java.lang.NullPointerException- iffeatureNameisnull
-
-
Method Detail
-
getFeatureName
public java.lang.String getFeatureName()
Retrieve the technical name of this feature.- Returns:
- the feature's name, as declared in property prefixed with "classification.feature.".
-
canBeUsedFor
public boolean canBeUsedFor(Publication pub)
Check if this feature can be used for the specified publication.- Parameters:
pub- a publication, null accepted.- Returns:
trueif feature can be used or when classification is disabled.falseif publication is null, or has a classification level higher than what is authorized for the specified feature.
-
getMaxLevel
public int getMaxLevel()
Retrieve the maximum authorized classification level of this feature.- Returns:
- the maximum classification level which is allowed to used this feature (inclusive)
-
getLabel
public java.lang.String getLabel(java.lang.String lang)
Retrieve the I18Ned label of this feature.- Parameters:
lang- the ISO-639 code language to use to retrieve the label- Returns:
- an I18Ned label such as
"Public link","Add to my JDrive"
-
getMessage
public java.lang.String getMessage(java.lang.String lang)
Retrieve the I18Ned message explaining the feature limit relative to classified publication.- Parameters:
lang- the ISO-639 code language to use to retrieve the message- Returns:
- an I18Ned message such as
"The 'Public link' feature can only be used for publication with a classification level less than or equal to 'Confidential'."
-
getControllerStatus
public ControllerStatus getControllerStatus()
Retrieve a failed ControllerStatus suitable to explain the feature limit relative to classified publication.- Returns:
- a ControllerStatus instance, never return null
-
getLogMessage
public java.lang.String getLogMessage()
Retrieve an english message explaining the feature limit relative to classified publication.- Returns:
- an english message suitable for logging of behavior explanation, such as
"The 'Public link' feature can only be used for publication with a classification level less than or equal to 'Confidential'."
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getIcon
public java.lang.String getIcon()
Retrieve the icon of this feature.- Returns:
- an icon property name.
-
getPlugin
public Plugin getPlugin()
Retrieve the plugin in which this feature was declared (if it is not a core feature)- Returns:
- a Plugin instance, or null if it is a core feature.
-
-