1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.student.common.ui.server.gwt; |
17 | |
|
18 | |
import org.kuali.rice.kim.bo.types.dto.AttributeSet; |
19 | |
import org.kuali.rice.kim.service.IdentityManagementService; |
20 | |
import org.kuali.student.common.rice.StudentIdentityConstants; |
21 | |
import org.kuali.student.common.rice.authorization.PermissionType; |
22 | |
import org.kuali.student.common.ui.client.service.SecurityRpcService; |
23 | |
import org.kuali.student.common.ui.client.service.exceptions.OperationFailedException; |
24 | |
import org.kuali.student.common.util.security.SecurityUtils; |
25 | |
|
26 | |
import com.google.gwt.user.server.rpc.RemoteServiceServlet; |
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | 0 | public class SecurityRpcGwtServlet extends RemoteServiceServlet implements SecurityRpcService{ |
35 | |
|
36 | |
private static final long serialVersionUID = 1L; |
37 | |
private IdentityManagementService permissionService; |
38 | |
|
39 | |
public String getPrincipalUsername(){ |
40 | 0 | return SecurityUtils.getPrincipalUserName(); |
41 | |
} |
42 | |
|
43 | |
@Override |
44 | |
public Boolean checkAdminPermission(String principalId, String screenComponent) throws OperationFailedException { |
45 | 0 | System.out.println("SecurityRpcGwtServlet.checkAdminPermission for : " + principalId + " component " + screenComponent); |
46 | 0 | AttributeSet permDetails = new AttributeSet(); |
47 | 0 | permDetails.put(StudentIdentityConstants.SCREEN_COMPONENT,screenComponent); |
48 | 0 | boolean hasAccess = false; |
49 | 0 | hasAccess = getPermissionService().isAuthorizedByTemplateName(principalId, |
50 | |
PermissionType.KS_ADMIN_SCREEN.getPermissionNamespace(), |
51 | |
PermissionType.KS_ADMIN_SCREEN.getPermissionTemplateName(), permDetails, |
52 | |
permDetails); |
53 | 0 | System.out.println(principalId + " has access : " + hasAccess); |
54 | 0 | return hasAccess; |
55 | |
} |
56 | |
|
57 | |
public void setPermissionService(IdentityManagementService permissionService) { |
58 | 0 | this.permissionService = permissionService; |
59 | 0 | } |
60 | |
|
61 | |
public IdentityManagementService getPermissionService()throws OperationFailedException{ |
62 | 0 | if(permissionService==null){ |
63 | 0 | throw new OperationFailedException("Permission Service is unavailable"); |
64 | |
} |
65 | |
|
66 | 0 | return permissionService; |
67 | |
} |
68 | |
} |