1 package org.nextime.ion.backoffice.security; 2 3 import org.nextime.ion.framework.business.Group; 4 import org.nextime.ion.framework.business.Publication; 5 import org.nextime.ion.framework.business.Section; 6 import org.nextime.ion.framework.business.User; 7 8 import com.opensymphony.workflow.basic.*; 9 10 public class SecurityManagerImpl implements SecurityManager { 11 12 15 public boolean canAdminResources(User user) { 16 try { 17 Group admins = Group.getInstance("admins"); 18 return user.isInGroup(admins); 19 } catch (Exception e) { 20 e.printStackTrace(); 21 } 22 return false; 23 } 24 25 28 public boolean canAdminSecurity(User user) { 29 try { 30 Group admins = Group.getInstance("admins"); 31 return user.isInGroup(admins); 32 } catch (Exception e) { 33 e.printStackTrace(); 34 } 35 return false; 36 } 37 38 41 public boolean canCreatePublication(Section section, User user) { 42 try { 43 String workflowType = section.getMetaData("workflow") + ""; 44 BasicWorkflow bw = new BasicWorkflow(user.getLogin()); 45 return bw.canInitialize(workflowType, 1); 46 } catch (Exception e) { 47 e.printStackTrace(); 48 } 49 return false; 50 } 51 52 55 public boolean canCreateSection(Section section, User user) { 56 try { 57 Group admins = Group.getInstance("admins"); 58 return user.isInGroup(admins); 59 } catch (Exception e) { 60 e.printStackTrace(); 61 } 62 return false; 63 } 64 65 68 public boolean canDeletePublication(Publication publication, User user) { 69 try { 70 Group admins = Group.getInstance("webmasters"); 71 return user.isInGroup(admins); 72 } catch (Exception e) { 73 e.printStackTrace(); 74 } 75 return false; 76 } 77 78 81 public boolean canDeleteSection(Section section, User user) { 82 try { 83 Group admins = Group.getInstance("admins"); 84 return user.isInGroup(admins); 85 } catch (Exception e) { 86 e.printStackTrace(); 87 } 88 return false; 89 } 90 91 94 public boolean canEditPublication( 95 Publication publication, 96 int version, 97 User user) { 98 try { 99 Group admins = Group.getInstance("admins"); 100 if (user.isInGroup(admins)) 101 return true; 102 return publication 103 .getVersion(version) 104 .getWorkflow(user) 105 .getPermissions() 106 .contains("canEdit"); 107 } catch (Exception e) { 108 e.printStackTrace(); 109 } 110 return false; 111 } 112 113 116 public boolean canEditSection(Section section, User user) { 117 try { 118 Group admins = Group.getInstance("admins"); 119 return user.isInGroup(admins); 120 } catch (Exception e) { 121 e.printStackTrace(); 122 } 123 return false; 124 } 125 126 129 public boolean canLogIntoBackoffice(User user) { 130 try { 131 Group admins = Group.getInstance("admins"); 132 Group contributeurs = Group.getInstance("users"); 133 Group webmasters = Group.getInstance("webmasters"); 134 return user.isInGroup(admins) || user.isInGroup(contributeurs) || user.isInGroup(webmasters); 135 } catch (Exception e) { 136 e.printStackTrace(); 137 } 138 return false; 139 } 140 141 } 142 | Popular Tags |