Tuesday, 24 April 2018

Java Code to get security on FileNet Domain

//Java Code to get security on FileNet Domain


import java.io.IOException;
import java.util.Iterator;
import javax.security.auth.Subject;
import com.filenet.api.collection.AccessPermissionList;
import com.filenet.api.core.Connection;
import com.filenet.api.core.Domain;
import com.filenet.api.core.Factory;
import com.filenet.api.security.AccessPermission;
import com.filenet.api.util.UserContext;

public class GetDomainSecurity {
private static Connection conn = null;

static String GranteeName =null;
static String GranteeType =null;
static String PermissionSource =null;
static String accessType =null;
static String InheritableDepth =null;
static String AccessMask=null;

public static Connection getCEConn()
{
try {
String ceURI="localhost:9080/wsi/FNCEWS40MTOM/";
String userName ="userName";
String password ="password";
if(conn==null){
conn = Factory.Connection.getConnection(ceURI);
Subject subject = UserContext.createSubject(conn, userName, password, null);
UserContext uc = UserContext.get();
uc.pushSubject(subject);
}

} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
System.out.println("CE Connection"+conn);
return conn;
}

public static void getObjectStorePermissions() throws IOException{

try{
  conn=null;
      conn = getCEConn();
Domain domain = Factory.Domain.fetchInstance(conn,null, null);
AccessPermissionList apld = domain.get_Permissions();
Iterator itd = apld.iterator();

while (itd.hasNext())
{
AccessPermission permission = (AccessPermission)itd.next();

GranteeName=permission.get_GranteeName();
GranteeType=permission.get_GranteeType().toString();
PermissionSource=permission.get_PermissionSource().toString();
accessType=permission.get_AccessType().toString();
InheritableDepth=permission.get_InheritableDepth().toString();
AccessMask=permission.get_AccessMask().toString();
System.out.println(domain.get_Name());
System.out.println("GranteeName="+ GranteeName);
System.out.println("GranteeType=" + GranteeType);
System.out.println("PermissionSource=" +PermissionSource);
System.out.println("Accesstype =" +accessType);
System.out.println("Inheritabledepth=" +InheritableDepth);

}
       
}
catch(Exception e){
e.printStackTrace();
}
}

public static void main(String[] args) throws IOException {


getObjectStorePermissions();
        
       
        }
}

1 comment:

  1. Nice blog! I really loved reading through this Blog... Thanks for sharing such a very interesting post with us and keep blogging.
    Visit our website-
    Xamarin App Developers
    blazor app developer
    Angularjs app developer



    ReplyDelete