Manage security on custom objects

The development of security on external objects have been made to be able to restrict access to external data (Ex: read database tables).

Apply VDoc security on custom objects

It's possible to apply VDoc security on a custom object by implementing the IChildSecuritySupport.
The IChildSecuritySupport class will handle complex security for custom object (with inheritance).
The getSecurityParent() method will returns the security parent of the object for security inheritance.

Example : Apply security on a local folder.

import com.axemble.vdoc.sdk.Modules;
import com.axemble.vdoc.sdk.exceptions.DirectoryModuleException;
import com.axemble.vdoc.sdk.exceptions.ModuleException;
import com.axemble.vdoc.sdk.exceptions.SDKException;
import com.axemble.vdoc.sdk.interfaces.IContext;
import com.axemble.vdoc.sdk.interfaces.IOrganization;
import com.axemble.vdoc.sdk.modules.IDirectoryModule;
import com.axemble.vdoc.sdk.supports.IChildSecuritySupport;
import com.axemble.vdoc.sdk.supports.ISecuritySupport;
import java.io.File;

public class CustomFolderObject implements IChildSecuritySupport
{
        private String name;
        private String label;
        public File myfolder = null;
        public final static String SYSADMIN_LOGIN = "sysadmin";

        public CustomFolderObject( String name )
        {
                super();
                this.name = name;
                this.label = name + " Label";
                String pathname = "C:\\";

                myfolder = new File( pathname );

        }

        public String getName()
        {
                return name;
        }
        public void setName( String name )
        {
                this.name = name;
        }
        public String getLabel()
        {
                return label;
        }
        public void setLabel( String label )
        {
                this.label = label;
        }

        @Override
        public String getProtocolURI()
        {
                try
                {
                        return Modules.getPortalModule().getProtocolURI( this );
                }
                catch( ModuleException e )
                {
                        throw new SDKException( e );
                }

        }

        @Override
        public String getProtocolURI( boolean useNames )
        {
                try
                {
                        return Modules.getPortalModule().getProtocolURI( this, useNames );
                }
                catch( ModuleException e )
                {
                        throw new SDKException( e );
                }
        }

        @Override
        public ISecuritySupport getSecurityParent()
        { 
                // In this situation, the parent is the organization by default.
                IDirectoryModule directorymodule = Modules.getDirectoryModule();
                IContext sysadminContext = directorymodule.getContextByLogin( SYSADMIN_LOGIN );
                IOrganization folderOrganization;
                try
                {
                        folderOrganization = directorymodule.getOrganization( sysadminContext, "DefaultOrganization" );
                        return folderOrganization;
                }
                catch( DirectoryModuleException e )
                {
                        throw new SDKException( e );
                }
        }
}