I'm trying to find a way to get the complete user list for a lotus notes document. I am unable to fetch the users and display their permissions in openCMIS.
Does anyone know how to obtain the complete ACL of every user for a specific document?
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("<1__=EABBF5CEDFB501988f9e8a93df93869091@local>");
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));
}
}