1 package org.apache.fulcrum.security; 2 3 56 57 import org.apache.fulcrum.TurbineServices; 58 59 import org.apache.fulcrum.security.entity.Group; 60 import org.apache.fulcrum.security.entity.Permission; 61 import org.apache.fulcrum.security.entity.Role; 62 import org.apache.fulcrum.security.entity.User; 63 64 import org.apache.fulcrum.security.util.AccessControlList; 65 import org.apache.fulcrum.security.util.GroupSet; 66 import org.apache.fulcrum.security.util.RoleSet; 67 import org.apache.fulcrum.security.util.PermissionSet; 68 import org.apache.fulcrum.security.util.DataBackendException; 69 import org.apache.fulcrum.security.util.UnknownEntityException; 70 import org.apache.fulcrum.security.util.EntityExistsException; 71 import org.apache.fulcrum.security.util.PasswordMismatchException; 72 import org.apache.fulcrum.security.util.TurbineSecurityException; 73 74 import org.apache.torque.util.Criteria; 75 76 93 public abstract class TurbineSecurity 94 { 95 101 public static SecurityService getService() 102 { 103 return (SecurityService) TurbineServices.getInstance(). 104 getService(SecurityService.SERVICE_NAME); 105 } 106 107 110 111 121 public static String encryptPassword(String password) 122 { 123 return getService().encryptPassword(password); 124 } 125 126 134 public static Class getUserClass() 135 throws UnknownEntityException 136 { 137 return getService().getUserClass(); 138 } 139 140 149 public static User getUserInstance() 150 throws UnknownEntityException 151 { 152 return getService().getUserInstance(); 153 } 154 155 164 public static boolean accountExists(User user) 165 throws DataBackendException 166 { 167 return getService().accountExists(user); 168 } 169 170 181 public static boolean accountExists(String userName) 182 throws DataBackendException 183 { 184 return getService().accountExists(userName); 185 } 186 187 197 public static User getAuthenticatedUser(String username, String password) 198 throws DataBackendException, UnknownEntityException, PasswordMismatchException 199 { 200 return getService().getAuthenticatedUser(username, password); 201 } 202 203 211 public static User getUser(String username) 212 throws DataBackendException, UnknownEntityException 213 { 214 return getService().getUser(username); 215 } 216 217 231 public static User[] getUsers(Criteria criteria) 232 throws DataBackendException 233 { 234 return getService().getUsers(criteria); 235 } 236 237 244 public static User getAnonymousUser() 245 throws UnknownEntityException 246 { 247 return getService().getAnonymousUser(); 248 } 249 250 261 public static void saveUser(User user) 262 throws UnknownEntityException, DataBackendException 263 { 264 getService().saveUser(user); 265 } 266 267 280 public static void changePassword(User user, String oldPassword, String newPassword) 281 throws PasswordMismatchException, UnknownEntityException, 282 DataBackendException 283 { 284 getService().changePassword(user, oldPassword, newPassword); 285 } 286 287 302 public static void forcePassword(User user, String password) 303 throws UnknownEntityException, DataBackendException 304 { 305 getService().forcePassword(user, password); 306 } 307 308 311 312 322 public static AccessControlList getACL(User user) 323 throws DataBackendException, UnknownEntityException 324 { 325 return getService().getACL(user); 326 } 327 328 331 332 341 public static void grant(User user, Group group, Role role) 342 throws DataBackendException, UnknownEntityException 343 { 344 getService().grant(user, group, role); 345 } 346 347 356 public static void revoke(User user, Group group, Role role) 357 throws DataBackendException, UnknownEntityException 358 { 359 getService().revoke(user, group, role); 360 } 361 362 371 public static void revokeAll(User user) 372 throws DataBackendException, UnknownEntityException 373 { 374 getService().revokeAll(user); 375 } 376 377 385 public static void grant(Role role, Permission permission) 386 throws DataBackendException, UnknownEntityException 387 { 388 getService().grant(role, permission); 389 } 390 391 399 public static void revoke(Role role, Permission permission) 400 throws DataBackendException, UnknownEntityException 401 { 402 getService().revoke(role, permission); 403 } 404 405 414 public static void revokeAll(Role role) 415 throws DataBackendException, UnknownEntityException 416 { 417 getService().revokeAll(role); 418 } 419 420 423 424 435 public static void addUser(User user, String password) 436 throws DataBackendException, EntityExistsException 437 { 438 getService().addUser(user, password); 439 } 440 441 442 451 public static void removeUser(User user) 452 throws DataBackendException, UnknownEntityException 453 { 454 getService().removeUser(user); 455 } 456 457 458 461 467 public static Group getGlobalGroup() 468 { 469 return getService().getGlobalGroup(); 470 } 471 472 480 public static Group createGroup(String name) 481 throws TurbineSecurityException 482 { 483 return getService().addGroup(getNewGroup(name)); 484 } 485 486 494 public static Permission createPermission(String name) 495 throws TurbineSecurityException 496 { 497 return getService().addPermission(getNewPermission(name)); 498 } 499 500 510 public static Role createRole(String name) 511 throws TurbineSecurityException 512 { 513 return getService().addRole(getNewRole(name)); 514 } 515 516 526 public static Group getGroup(String groupName) 527 throws DataBackendException, UnknownEntityException 528 { 529 return getService().getGroup(groupName); 530 } 531 532 544 public static Group getNewGroup(String groupName) 545 throws DataBackendException 546 { 547 return getService().getNewGroup(groupName); 548 } 549 550 562 public static Role getNewRole(String roleName) 563 throws TurbineSecurityException 564 { 565 return getService().getNewRole(roleName); 566 } 567 568 580 public static Permission getNewPermission(String permissionName) 581 throws DataBackendException 582 { 583 return getService().getNewPermission(permissionName); 584 } 585 586 596 public static Role getRole(String roleName) 597 throws DataBackendException, UnknownEntityException 598 { 599 return getService().getRole(roleName); 600 } 601 602 612 public static Permission getPermission(String permissionName) 613 throws DataBackendException, UnknownEntityException 614 { 615 return getService().getPermission(permissionName); 616 } 617 618 628 public static GroupSet getGroups(Criteria criteria) 629 throws DataBackendException 630 { 631 return getService().getGroups(criteria); 632 } 633 634 635 644 public static RoleSet getRoles(Criteria criteria) 645 throws DataBackendException 646 { 647 return getService().getRoles(criteria); 648 } 649 650 660 public static PermissionSet getPermissions(Criteria criteria) 661 throws DataBackendException 662 { 663 return getService().getPermissions(criteria); 664 } 665 666 674 public static GroupSet getAllGroups() 675 throws DataBackendException 676 { 677 return getService().getAllGroups(); 678 } 679 680 687 public static RoleSet getAllRoles() 688 throws DataBackendException 689 { 690 return getService().getAllRoles(); 691 } 692 693 700 public static PermissionSet getAllPermissions() 701 throws DataBackendException 702 { 703 return getService().getAllPermissions(); 704 } 705 706 716 public static PermissionSet getPermissions(Role role) 717 throws DataBackendException, UnknownEntityException 718 { 719 return getService().getPermissions(role); 720 } 721 722 730 public static void saveGroup(Group group) 731 throws DataBackendException, UnknownEntityException 732 { 733 getService().saveGroup(group); 734 } 735 736 744 public static void saveRole(Role role) 745 throws DataBackendException, UnknownEntityException 746 { 747 getService().saveRole(role); 748 } 749 750 758 public static void savePermission(Permission permission) 759 throws DataBackendException, UnknownEntityException 760 { 761 getService().savePermission(permission); 762 } 763 764 771 public static void addGroup(Group group) 772 throws DataBackendException, EntityExistsException 773 { 774 getService().addGroup(group); 775 } 776 777 784 public static void addRole(Role role) 785 throws DataBackendException, EntityExistsException 786 { 787 getService().addRole(role); 788 } 789 790 797 public static void addPermission(Permission permission) 798 throws DataBackendException, EntityExistsException 799 { 800 getService().addPermission(permission); 801 } 802 803 811 public static void removeGroup(Group group) 812 throws DataBackendException, UnknownEntityException 813 { 814 getService().removeGroup(group); 815 } 816 817 824 public static void removeRole(Role role) 825 throws DataBackendException, UnknownEntityException 826 { 827 getService().removeRole(role); 828 } 829 830 837 public static void removePermission(Permission permission) 838 throws DataBackendException, UnknownEntityException 839 { 840 getService().removePermission(permission); 841 } 842 843 851 public static void renameGroup(Group group, String name) 852 throws DataBackendException, UnknownEntityException 853 { 854 getService().renameGroup(group, name); 855 } 856 857 865 public static void renameRole(Role role, String name) 866 throws DataBackendException, UnknownEntityException 867 { 868 getService().renameRole(role, name); 869 } 870 871 879 public static void renamePermission(Permission permission, String name) 880 throws DataBackendException, UnknownEntityException 881 { 882 getService().renamePermission(permission, name); 883 } 884 } 885 | Popular Tags |