Browse code

BM-15049 Fix: no RBAC for annotations internal api, mailbox-acls container does not exist when a user is deleted and replication triggers

Thomas Cataldo authored on 15/07/2019 13:58:19
Showing 1 changed files
... ...
@@ -20,35 +20,29 @@ package net.bluemind.backend.mail.replica.service.internal;
20 20
 import java.sql.SQLException;
21 21
 import java.util.List;
22 22
 
23
-import net.bluemind.backend.cyrus.partitions.CyrusBoxes;
24
-import net.bluemind.backend.cyrus.partitions.CyrusBoxes.ReplicatedBox;
25
-import net.bluemind.backend.cyrus.partitions.CyrusPartition;
23
+import org.slf4j.Logger;
24
+import org.slf4j.LoggerFactory;
25
+
26 26
 import net.bluemind.backend.mail.replica.api.ICyrusReplicationAnnotations;
27 27
 import net.bluemind.backend.mail.replica.api.MailboxAnnotation;
28 28
 import net.bluemind.backend.mail.replica.persistence.AnnotationStore;
29 29
 import net.bluemind.core.api.fault.ServerFault;
30
-import net.bluemind.core.container.model.ItemValue;
31
-import net.bluemind.core.container.model.acl.Verb;
32
-import net.bluemind.core.container.service.internal.RBACManager;
33 30
 import net.bluemind.core.rest.BmContext;
34
-import net.bluemind.mailbox.api.IMailboxAclUids;
35
-import net.bluemind.mailbox.api.IMailboxes;
36
-import net.bluemind.mailbox.api.Mailbox;
37 31
 
38 32
 public class CyrusAnnotationsService implements ICyrusReplicationAnnotations {
39 33
 
34
+	private static final Logger logger = LoggerFactory.getLogger(CyrusAnnotationsService.class);
40 35
 	private final AnnotationStore annoStore;
41 36
 	private final BmContext context;
42 37
 
43 38
 	public CyrusAnnotationsService(BmContext context, AnnotationStore annoStore) {
44 39
 		this.annoStore = annoStore;
45 40
 		this.context = context;
41
+		logger.debug("Created in ctx {}", this.context);
46 42
 	}
47 43
 
48 44
 	@Override
49 45
 	public void storeAnnotation(MailboxAnnotation ss) {
50
-		new RBACManager(context).forContainer(IMailboxAclUids.uidForMailbox(mbox(ss.mailbox))).check(Verb.Write.name());
51
-
52 46
 		try {
53 47
 			annoStore.store(ss);
54 48
 		} catch (SQLException e) {
... ...
@@ -58,8 +52,6 @@ public class CyrusAnnotationsService implements ICyrusReplicationAnnotations {
58 52
 
59 53
 	@Override
60 54
 	public void deleteAnnotation(MailboxAnnotation ss) {
61
-		new RBACManager(context).forContainer(IMailboxAclUids.uidForMailbox(mbox(ss.mailbox))).check(Verb.Write.name());
62
-
63 55
 		try {
64 56
 			annoStore.delete(ss);
65 57
 		} catch (SQLException e) {
... ...
@@ -68,8 +60,6 @@ public class CyrusAnnotationsService implements ICyrusReplicationAnnotations {
68 60
 	}
69 61
 
70 62
 	public List<MailboxAnnotation> annotations(String mbox) {
71
-		new RBACManager(context).forContainer(IMailboxAclUids.uidForMailbox(mbox(mbox))).check(Verb.Read.name());
72
-
73 63
 		try {
74 64
 			return annoStore.byMailbox(mbox);
75 65
 		} catch (SQLException e) {
... ...
@@ -78,15 +68,4 @@ public class CyrusAnnotationsService implements ICyrusReplicationAnnotations {
78 68
 
79 69
 	}
80 70
 
81
-	private String mbox(String mailbox) {
82
-		ReplicatedBox box = CyrusBoxes.forCyrusMailbox(mailbox);
83
-		String domain = CyrusPartition.forName(box.partition).domainUid;
84
-		ItemValue<Mailbox> mboxItem = context.su().provider().instance(IMailboxes.class, domain)
85
-				.byName(box.local.replace('^', '.'));
86
-		if (mboxItem == null) {
87
-			throw ServerFault.notFound("mailbox uid for " + box + " (domain " + domain + ") not found");
88
-		}
89
-		return mboxItem.uid;
90
-	}
91
-
92 71
 }