... public static final String ADMIN_USERNAME = "admin"; public static final String ADMIN_PASSWORD = "admin"; public static final String GROUP_AUTHORITY_TYPE = "GROUP"; public static final String CP01_USERNAME = "cp01"; protected static final String CONTENT_PROVIDER_GROUPNAME = "RBT_CONTENT_PROVIDER"; public static void main(String[] args) throws Exception { // Start the session AuthenticationUtils.startSession(ADMIN_USERNAME, ADMIN_PASSWORD); try { createGroups(); //createUsers(); addUsersToGroup(); } finally { // End the session AuthenticationUtils.endSession(); } } private static void createGroups() throws AccessControlFault, RemoteException { AccessControlServiceSoapBindingStub accessControlService = WebServiceFactory.getAccessControlService(); NewAuthority cpGrpAuth = new NewAuthority(GROUP_AUTHORITY_TYPE, CONTENT_PROVIDER_GROUPNAME); NewAuthority[] newAuthorities = {cpGrpAuth}; String result[] = accessControlService.createAuthorities(null, newAuthorities); } private static void addUsersToGroup() throws AccessControlFault, RemoteException { String[] cpUsers = {CP01_USERNAME}; String parentAuthority = GROUP_AUTHORITY_TYPE + "_" + CONTENT_PROVIDER_GROUPNAME; AccessControlServiceSoapBindingStub accessControlService = WebServiceFactory.getAccessControlService(); String[] result = accessControlService.addChildAuthorities(parentAuthority, cpUsers); } ...Reference:
How to create group and add users to group using WebService?
沒有留言:
張貼留言
留個話吧:)