1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.ken.service.impl;
17
18 import java.util.List;
19
20 import org.kuali.rice.core.dao.GenericDao;
21 import org.kuali.rice.ken.bo.NotificationChannel;
22 import org.kuali.rice.ken.bo.NotificationProducer;
23 import org.kuali.rice.ken.service.NotificationAuthorizationService;
24 import org.kuali.rice.ken.util.NotificationConstants;
25 import org.kuali.rice.kim.bo.Person;
26 import org.kuali.rice.kim.service.KIMServiceLocator;
27 import org.kuali.rice.kim.util.KimConstants;
28
29
30
31
32
33
34 public class NotificationAuthorizationServiceImpl implements NotificationAuthorizationService {
35 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(NotificationAuthorizationServiceImpl.class);
36
37 private GenericDao businessObjectDao;
38
39
40
41
42
43 public NotificationAuthorizationServiceImpl(GenericDao businessObjectDao) {
44 this.businessObjectDao = businessObjectDao;
45 }
46
47
48
49
50 public boolean isProducerAuthorizedToSendNotificationForChannel(NotificationProducer producer, NotificationChannel channel) {
51 List channels = producer.getChannels();
52
53 if(channels.contains(channel)) {
54 return true;
55 } else {
56 return false;
57 }
58 }
59
60
61
62
63
64
65 public boolean isUserAdministrator(String userId) {
66 String groupNameId = NotificationConstants.KEW_CONSTANTS.NOTIFICATION_ADMIN_GROUP_NAME;
67 Person user = KIMServiceLocator.getPersonService().getPerson(userId);
68 if (user == null) {
69 return false;
70 }
71 return KIMServiceLocator.getIdentityManagementService().isMemberOfGroup(user.getPrincipalId(), KimConstants.KIM_GROUP_WORKFLOW_NAMESPACE_CODE, groupNameId);
72 }
73 }