2016-03-30 12 views
0

我試圖找到一種方法來獲取蓮花筆記文檔的完整用戶列表。 我無法取得用戶並在openCMIS中顯示他們的權限。如何實現AclServiceUtils.getAcl()以檢索用戶信息lotusnotes

有誰知道如何獲取每個用戶對特定文檔的完整ACL?

public class AclServiceUtils { 
private static final Logger LOGGER = LoggerFactory.getLogger(AclServiceUtils.class); 

public static Acl getAcl(Session session, String objectId, Boolean onlyBasicPermissions) throws IOException { 


    ObjectIdentity objId = ObjectIdentity.getObjectIdentity(objectId); 

    try {  
     AccessControlListImpl acl = new AccessControlListImpl(); 
     List<Ace> aces = new ArrayList<Ace>(); 

     PrincipalImpl principal=new PrincipalImpl(); 

     principal.setId(objId.getType() + " "); 
     // here we want info of user 
      AccessControlEntryImpl ace = new AccessControlEntryImpl(); 
      ace.setDirect(true); 
      ace.setPrincipal(principal); 
      aces.add(ace); 
      acl.setAces(aces); 
     return acl; 
    } catch (Exception e) { 
     e.printStackTrace(); 
    } 
    return null; 
} 

}

public class ObjectIdentity { 
@JsonIgnore 
private static final ObjectMapper mapper = new ObjectMapper(); 
@JsonIgnore 
private static final String UTF_8 = "UTF-8"; 

private ObjectIdentityType type; 
private String unid; 
private String id; 
private String parentFolderPath; 

public ObjectIdentityType getType() { 
    return type; 
} 

public void setType(ObjectIdentityType type) { 
    this.type = type; 
} 

public String getUnid() { 
    return unid; 
} 

public void setUnid(String unid) { 
    this.unid = unid; 
} 

public String getId() { 
    return id; 
} 

public void setId(String id) { 
    this.id = id; 
} 

public String getParentFolderPath() { 
    return parentFolderPath; 
} 

public void setParentFolderPath(String parentId) { 
    this.parentFolderPath = parentId; 
} 

@JsonIgnore 
public String getEncodedObjectId() throws IOException { 
    String json = mapper.writeValueAsString(this); 
    byte[] encodeBase64 = Base64.encode(json); 
    String result = new String(encodeBase64); 
    result = URLEncoder.encode(result, UTF_8); 
    return result; 
} 

@JsonIgnore 
public static ObjectIdentity getObjectIdentity(String encodedString) 
     throws IOException { 
    String decodedString = URLDecoder.decode(encodedString, UTF_8); 
    byte[] decodeBase64 = Base64.decode(decodedString); 
    String result = new String(decodeBase64); 
    return mapper.readValue(result, ObjectIdentity.class); 
} 

public static void main(String args[]) throws IOException{ 
    ObjectIdentity identity = new ObjectIdentity(); 
    identity.setId("<[email protected]>"); 
    identity.setUnid("DEF"); 
    identity.setType(ObjectIdentityType.ATTACHMENT); 


    ObjectIdentity decoded = ObjectIdentity.getObjectIdentity(identity.getEncodedObjectId()); 
    /*System.out.println(decoded.id); 
    System.out.println(decoded.unid); 
    System.out.println(decoded.type);*/ 

    System.out.println(decoded.id.equals(identity.id)); 

} 

}

+1

您想從IBM Notes Domino檢索哪種用戶信息? –

+0

關於訪問權限 –

+1

Notes文檔可以包含讀者和作者字段。它們可以包含用戶名,組名和角色。數據庫的ACL列出了所有用戶和用戶組及其特定的權限和角色。那麼,你需要什麼?所有可以閱讀或更新某個文檔的用戶? –

回答

1

由於沒有人回答,我走的是與我上面的意見普遍同意,所以我會爲他們提供一個答案。

不幸的是,答案是這並不容易 - 對可能的解決方案的完整技術處理超出了通過StackOverflow可以實現的範圍。

Domino的設計不是爲了輕鬆回答「誰是有權讀取或更新此文檔的所有用戶」的問題?回答「誰是所有可以在此服務器上讀取或更新此文檔的用戶都是誰?」這個問題並不容易?要回答這個問題,您必須首先列出所有可以訪問服務器的用戶列表,對於有權訪問數據庫的所有用戶來說都是狹義的,並將該組分爲以下組:那些訪問權限小於Reader的用戶,那些與讀者,訪問權限,具有作者訪問權限的人員以及具有編輯者權限或以上權限的人員。這需要諮詢ACL並解決所引用的一個或多個Domino目錄中的任何組。然後,您必須檢查文檔中的所有項目,以確定它們中的任何項目是否設置了「摘要讀取訪問」或「摘要讀取/寫入訪問」標記集,並且如果其中任何項需要讀取名稱列表包括必須從ACL解析的角色和/或從一個或多個Domino目錄解析的組。

我會再添加一件我上面評論過的東西。既然你提到你正在使用REST API,我認爲在這種方法上嘗試使用這將是不切實際的。如果我作爲一個需求面對這個問題,我只會考慮使用Notes Java或C API的方法,並且如果需要這些信息用於交互式使用,那麼我可能會構建一個服務器插件,它預先計算儘可能的信息。

相關問題