1 package org.apache.turbine.services.security; 2 3 18 19 import java.util.List ; 20 21 import org.apache.torque.util.Criteria; 22 23 import org.apache.turbine.om.security.Group; 24 import org.apache.turbine.om.security.Permission; 25 import org.apache.turbine.om.security.Role; 26 import org.apache.turbine.om.security.User; 27 import org.apache.turbine.services.TurbineServices; 28 import org.apache.turbine.util.security.AccessControlList; 29 import org.apache.turbine.util.security.DataBackendException; 30 import org.apache.turbine.util.security.EntityExistsException; 31 import org.apache.turbine.util.security.GroupSet; 32 import org.apache.turbine.util.security.PasswordMismatchException; 33 import org.apache.turbine.util.security.PermissionSet; 34 import org.apache.turbine.util.security.RoleSet; 35 import org.apache.turbine.util.security.TurbineSecurityException; 36 import org.apache.turbine.util.security.UnknownEntityException; 37 38 56 public abstract class TurbineSecurity 57 { 58 64 public static SecurityService getService() 65 { 66 return (SecurityService) TurbineServices.getInstance(). 67 getService(SecurityService.SERVICE_NAME); 68 } 69 70 73 74 84 public static String encryptPassword(String password) 85 { 86 return getService().encryptPassword(password); 87 } 88 89 100 public static String encryptPassword(String password, String salt) 101 { 102 return getService().encryptPassword(password, salt); 103 } 104 105 114 115 public static boolean checkPassword(String checkpw, String encpw) 116 { 117 return getService().checkPassword(checkpw, encpw); 118 } 119 120 123 124 132 public static Class getUserClass() 133 throws UnknownEntityException 134 { 135 return getService().getUserClass(); 136 } 137 138 146 public static Class getGroupClass() 147 throws UnknownEntityException 148 { 149 return getService().getGroupClass(); 150 } 151 152 160 public static Class getPermissionClass() 161 throws UnknownEntityException 162 { 163 return getService().getPermissionClass(); 164 } 165 166 174 public static Class getRoleClass() 175 throws UnknownEntityException 176 { 177 return getService().getRoleClass(); 178 } 179 180 189 public static User getUserInstance() 190 throws UnknownEntityException 191 { 192 return getService().getUserInstance(); 193 } 194 195 200 public static UserManager getUserManager() 201 { 202 return getService().getUserManager(); 203 } 204 205 210 public void setUserManager(UserManager userManager) 211 { 212 getService().setUserManager(userManager); 213 } 214 215 225 public static boolean accountExists(User user) 226 throws DataBackendException 227 { 228 return getService().accountExists(user); 229 } 230 231 241 public static boolean accountExists(String userName) 242 throws DataBackendException 243 { 244 return getService().accountExists(userName); 245 } 246 247 259 public static User getAuthenticatedUser(String username, String password) 260 throws DataBackendException, UnknownEntityException, 261 PasswordMismatchException 262 { 263 return getService().getAuthenticatedUser(username, password); 264 } 265 266 276 public static User getUser(String username) 277 throws DataBackendException, UnknownEntityException 278 { 279 return getService().getUser(username); 280 } 281 282 296 public static User[] getUsers(Criteria criteria) 297 throws DataBackendException 298 { 299 return getService().getUsers(criteria); 300 } 301 302 316 public static List getUserList(Criteria criteria) 317 throws DataBackendException 318 { 319 return getService().getUserList(criteria); 320 } 321 322 330 public static User getAnonymousUser() 331 throws UnknownEntityException 332 { 333 return getService().getAnonymousUser(); 334 } 335 336 343 public static boolean isAnonymousUser(User user) 344 { 345 return getService().isAnonymousUser(user); 346 } 347 348 358 public static void saveUser(User user) 359 throws UnknownEntityException, DataBackendException 360 { 361 getService().saveUser(user); 362 } 363 364 376 public static void saveOnSessionUnbind(User user) 377 throws UnknownEntityException, DataBackendException 378 { 379 getService().saveOnSessionUnbind(user); 380 } 381 382 395 public static void changePassword(User user, String oldPassword, 396 String newPassword) 397 throws PasswordMismatchException, UnknownEntityException, 398 DataBackendException 399 { 400 getService().changePassword(user, oldPassword, newPassword); 401 } 402 403 418 public static void forcePassword(User user, String password) 419 throws UnknownEntityException, DataBackendException 420 { 421 getService().forcePassword(user, password); 422 } 423 424 427 428 437 public static AccessControlList getACL(User user) 438 throws DataBackendException, UnknownEntityException 439 { 440 return getService().getACL(user); 441 } 442 443 446 447 458 public static void grant(User user, Group group, Role role) 459 throws DataBackendException, UnknownEntityException 460 { 461 getService().grant(user, group, role); 462 } 463 464 475 public static void revoke(User user, Group group, Role role) 476 throws DataBackendException, UnknownEntityException 477 { 478 getService().revoke(user, group, role); 479 } 480 481 491 public static void revokeAll(User user) 492 throws DataBackendException, UnknownEntityException 493 { 494 getService().revokeAll(user); 495 } 496 497 506 public static void grant(Role role, Permission permission) 507 throws DataBackendException, UnknownEntityException 508 { 509 getService().grant(role, permission); 510 } 511 512 521 public static void revoke(Role role, Permission permission) 522 throws DataBackendException, UnknownEntityException 523 { 524 getService().revoke(role, permission); 525 } 526 527 537 public static void revokeAll(Role role) 538 throws DataBackendException, UnknownEntityException 539 { 540 getService().revokeAll(role); 541 } 542 543 546 547 558 public static void addUser(User user, String password) 559 throws DataBackendException, EntityExistsException 560 { 561 getService().addUser(user, password); 562 } 563 564 574 public static void removeUser(User user) 575 throws DataBackendException, UnknownEntityException 576 { 577 getService().removeUser(user); 578 } 579 580 583 589 public static Group getGlobalGroup() 590 { 591 return getService().getGlobalGroup(); 592 } 593 594 602 public static Group createGroup(String name) 603 throws TurbineSecurityException 604 { 605 return getService().addGroup(getGroupInstance(name)); 606 } 607 608 616 public static Permission createPermission(String name) 617 throws TurbineSecurityException 618 { 619 return getService().addPermission(getPermissionInstance(name)); 620 } 621 622 632 public static Role createRole(String name) 633 throws TurbineSecurityException 634 { 635 return getService().addRole(getRoleInstance(name)); 636 } 637 638 648 public static Group getGroup(String groupName) 649 throws DataBackendException, UnknownEntityException 650 { 651 return getService().getGroup(groupName); 652 } 653 654 663 public static Group getGroupByName(String groupName) 664 throws DataBackendException, UnknownEntityException 665 { 666 return getService().getGroupByName(groupName); 667 } 668 669 681 public static Group getGroupById(int groupId) 682 throws DataBackendException, 683 UnknownEntityException 684 { 685 return getService().getGroupById(groupId); 686 } 687 688 700 public static Group getGroupInstance(String groupName) 701 throws UnknownEntityException 702 { 703 return getService().getGroupInstance(groupName); 704 } 705 706 718 public static Group getNewGroup(String groupName) 719 throws DataBackendException 720 { 721 return getService().getNewGroup(groupName); 722 } 723 724 736 public static Role getRoleInstance(String roleName) 737 throws UnknownEntityException 738 { 739 return getService().getRoleInstance(roleName); 740 } 741 742 753 public static Role getNewRole(String roleName) 754 throws TurbineSecurityException 755 { 756 return getService().getNewRole(roleName); 757 } 758 759 770 public static Permission getPermissionInstance(String permName) 771 throws UnknownEntityException 772 { 773 return getService().getPermissionInstance(permName); 774 } 775 776 788 public static Permission getNewPermission(String permissionName) 789 throws DataBackendException 790 { 791 return getService().getNewPermission(permissionName); 792 } 793 794 804 public static Role getRole(String roleName) 805 throws DataBackendException, UnknownEntityException 806 { 807 return getService().getRole(roleName); 808 } 809 810 819 public static Role getRoleByName(String roleName) 820 throws DataBackendException, UnknownEntityException 821 { 822 return getService().getRoleByName(roleName); 823 } 824 825 837 public static Role getRoleById(int roleId) 838 throws DataBackendException, 839 UnknownEntityException 840 { 841 return getService().getRoleById(roleId); 842 } 843 844 854 public static Permission getPermission(String permissionName) 855 throws DataBackendException, UnknownEntityException 856 { 857 return getService().getPermission(permissionName); 858 } 859 860 869 public static Permission getPermissionByName(String permissionName) 870 throws DataBackendException, UnknownEntityException 871 { 872 return getService().getPermissionByName(permissionName); 873 } 874 875 887 public static Permission getPermissionById(int permissionId) 888 throws DataBackendException, 889 UnknownEntityException 890 { 891 return getService().getPermissionById(permissionId); 892 } 893 894 902 public static GroupSet getGroups(Criteria criteria) 903 throws DataBackendException 904 { 905 return getService().getGroups(criteria); 906 } 907 908 916 public static RoleSet getRoles(Criteria criteria) 917 throws DataBackendException 918 { 919 return getService().getRoles(criteria); 920 } 921 922 930 public static PermissionSet getPermissions(Criteria criteria) 931 throws DataBackendException 932 { 933 return getService().getPermissions(criteria); 934 } 935 936 943 public static GroupSet getAllGroups() 944 throws DataBackendException 945 { 946 return getService().getAllGroups(); 947 } 948 949 956 public static RoleSet getAllRoles() 957 throws DataBackendException 958 { 959 return getService().getAllRoles(); 960 } 961 962 969 public static PermissionSet getAllPermissions() 970 throws DataBackendException 971 { 972 return getService().getAllPermissions(); 973 } 974 975 984 public static PermissionSet getPermissions(Role role) 985 throws DataBackendException, UnknownEntityException 986 { 987 return getService().getPermissions(role); 988 } 989 990 998 public static void saveGroup(Group group) 999 throws DataBackendException, UnknownEntityException 1000 { 1001 getService().saveGroup(group); 1002 } 1003 1004 1012 public static void saveRole(Role role) 1013 throws DataBackendException, UnknownEntityException 1014 { 1015 getService().saveRole(role); 1016 } 1017 1018 1027 public static void savePermission(Permission permission) 1028 throws DataBackendException, UnknownEntityException 1029 { 1030 getService().savePermission(permission); 1031 } 1032 1033 1041 public static void addGroup(Group group) 1042 throws DataBackendException, EntityExistsException 1043 { 1044 getService().addGroup(group); 1045 } 1046 1047 1055 public static void addRole(Role role) 1056 throws DataBackendException, EntityExistsException 1057 { 1058 getService().addRole(role); 1059 } 1060 1061 1069 public static void addPermission(Permission permission) 1070 throws DataBackendException, EntityExistsException 1071 { 1072 getService().addPermission(permission); 1073 } 1074 1075 1083 public static void removeGroup(Group group) 1084 throws DataBackendException, UnknownEntityException 1085 { 1086 getService().removeGroup(group); 1087 } 1088 1089 1096 public static void removeRole(Role role) 1097 throws DataBackendException, UnknownEntityException 1098 { 1099 getService().removeRole(role); 1100 } 1101 1102 1110 public static void removePermission(Permission permission) 1111 throws DataBackendException, UnknownEntityException 1112 { 1113 getService().removePermission(permission); 1114 } 1115 1116 1125 public static void renameGroup(Group group, String name) 1126 throws DataBackendException, UnknownEntityException 1127 { 1128 getService().renameGroup(group, name); 1129 } 1130 1131 1140 public static void renameRole(Role role, String name) 1141 throws DataBackendException, UnknownEntityException 1142 { 1143 getService().renameRole(role, name); 1144 } 1145 1146 1155 public static void renamePermission(Permission permission, String name) 1156 throws DataBackendException, UnknownEntityException 1157 { 1158 getService().renamePermission(permission, name); 1159 } 1160} 1161 | Popular Tags |