📄 testaclplugin.java
字号:
/*
* OPIAM Suite
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package opiam.admin.faare.unittests.service.services.acl;
import opiam.admin.faare.config.javabeans.JBAcl;
import opiam.admin.faare.config.javabeans.JBAcls;
import opiam.admin.faare.exception.ServiceException;
import opiam.admin.faare.persistence.javabeans.JBTop;
import opiam.admin.faare.service.UserContext;
import opiam.admin.faare.service.services.acl.AclPluginInterface;
import opiam.admin.faare.unittests.TestUtils;
import org.apache.log4j.Logger;
/**
* Test plugin to use to test the acls.
*/
public class TestAclPlugin implements AclPluginInterface
{
/** Set of the acl definitions. */
private static JBAcls tacls = null;
/** Test Acl. */
private static JBAcl tacl = null;
/** Acl name. */
private static final String ACL_NAME = "test_acl";
/** Modified attribute name. */
private static final String ATTRIBUTE_NAME = "cn";
/** Instance of the loger. */
private static Logger _logger = Logger.getLogger(TestAclPlugin.class);
/** Instance of the trace class. */
private static TestUtils _test = new TestUtils(_logger);
/**
* Initializes the plugin.
*
* @param acls Set of the acls definitions.
*
* @see opiam.admin.faare.service.services.acl.AclPluginInterface#initialize(JBAcls)
*/
public void initialize(JBAcls acls)
{
_test.displayMsg("Initialize the TestAclPlugin.");
try
{
tacls = acls;
tacl = (JBAcl) (tacls.getAclsMap()).get(ACL_NAME);
}
catch (Exception ex)
{
StringBuffer msg = new StringBuffer();
msg.append("TestAclPlugin initialization error\n");
msg.append(ex.toString());
_test.displayResultFailure(msg.toString());
}
}
/**
* Indicates if the modification is enabled.
*
* @param arg0 Reference entry.
* @param arg1 Entry with the modification.
* @param userContext Context of the user.
*
* @see opiam.admin.faare.service.services.acl.AclPluginInterface#
* isModificationEnabled(JBTop, JBTop, UserContext)
* @return see opiam.admin.faare.service.services.acl.AclPluginInterface#
* isModificationEnabled(JBTop, JBTop, UserContext)
* @throws ServiceException Not thrown.
*/
public boolean isModificationEnabled(JBTop arg0, JBTop arg1,
UserContext userContext) throws ServiceException
{
if ((tacl != null) && (tacl.canModify(ATTRIBUTE_NAME)))
{
return true;
}
return false;
}
/**
* Indicates if the visualisation is enabled.
*
* @param entry Reference entry.
* @param userContext Context of the user.
*
* @see opiam.admin.faare.service.services.acl.AclPluginInterface#isVisualisationEnabled(JBTop, UserContext)
* @return see opiam.admin.faare.service.services.acl.AclPluginInterfac
* @throws ServiceException see opiam.admin.faare.service.services.acl.AclPluginInterfac
*/
public boolean isVisualisationEnabled(JBTop entry, UserContext userContext)
throws ServiceException
{
if ((tacl != null) && (tacl.canVisualize()))
{
return true;
}
return false;
}
/**
* Indicates if the creation is enabled.
*
* @param entry Reference entry.
* @param userContext Context of the user.
*
* @see opiam.admin.faare.service.services.acl.AclPluginInterface#isCreationEnabled(JBTop, UserContext)
* @return see opiam.admin.faare.service.services.acl.AclPluginInterfac
* @throws ServiceException see opiam.admin.faare.service.services.acl.AclPluginInterfac
*/
public boolean isCreationEnabled(JBTop entry, UserContext userContext)
throws ServiceException
{
if ((tacl != null) && (tacl.canCreate()))
{
return true;
}
return false;
}
/**
* Indicates if the deletion is enabled.
*
* @param entry Reference entry.
* @param userContext Context of the user.
*
* @see opiam.admin.faare.service.services.acl.AclPluginInterface#isDeletionEnabled(JBTop, UserContext)
* @return see opiam.admin.faare.service.services.acl.AclPluginInterfac
* @throws ServiceException see opiam.admin.faare.service.services.acl.AclPluginInterfac
*/
public boolean isDeletionEnabled(JBTop entry, UserContext userContext)
throws ServiceException
{
if ((tacl != null) && (tacl.canDelete()))
{
return true;
}
return false;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -