package oimproject;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
import javax.security.auth.login.LoginException;
import oracle.iam.identity.exception.NoSuchRoleException;
import oracle.iam.identity.exception.RoleAlreadyExistsException;
import oracle.iam.identity.exception.RoleCreateException;
import oracle.iam.identity.exception.RoleModifyException;
import oracle.iam.identity.exception.ValidationFailedException;
import oracle.iam.identity.rolemgmt.api.RoleManager;
import oracle.iam.identity.rolemgmt.api.RoleManagerConstants;
import oracle.iam.identity.rolemgmt.vo.Role;
import oracle.iam.platform.OIMClient;
public class RoleUtility {
public RoleUtility() {
super();
}
public static OIMClient oimClient;
private static RoleManager roleManager = null;
public static void main(String[] args) throws LoginException,
ValidationFailedException,
RoleAlreadyExistsException,
RoleCreateException,
RoleModifyException,
NoSuchRoleException {
oimClient= oimConnect.getOIMConnection();
// that connection method is write in another class
// Role r1 = new Role("");
//
// r1.setName("JAVA ROLE1");
roleManager= oimClient.getService(RoleManager.class);
//// roleManager.create(r1);
//
// Role r2 = new Role("62");
// // r2.setAttribute("Role Owner Key", 70L);
// r2.setAttribute(RoleManagerConstants.ROLE_OWNER_KEY, 88L);
//
// System.out.println(RoleManagerConstants.ROLE_OWNER_KEY);
// RoleManagerResult result = roleManager.modify(r2);
//
// System.out.println(result.getStatus());
//
// // HashMap<String, Object> attributes = new HashMap<String, Object>();
Set<String> roleKeys = new HashSet<String>();
roleKeys.add("61"); // REPORT ADMINISTRATORS
roleKeys.add("62"); // PLUGIN ADMINISTRATORS
HashMap<String, Object> attributes = new HashMap<String, Object>();
attributes.put(RoleManagerConstants.ROLE_OWNER_KEY, 67L);
attributes.put(RoleManagerConstants.ROLE_NAME, "ADVANCED ROLE");
attributes.put(RoleManagerConstants.ROLE_CATEGORY_KEY, 2L);
attributes.put(RoleManagerConstants.ROLE_DESCRIPTION, "Hello");
attributes.put(RoleManagerConstants.ROLE_EMAIL, "abc@example.com");
Role r4 = new Role (attributes);
roleManager.create(r4);
//
//Role r3 = new Role(attributes);
////r3.setAttribute(RoleManagerConstants.ROLE_OWNER_KEY, 67L);
//
//roleManager.modify(roleKeys, r3);
// roleManager.search(arg0, arg1, arg2)
}
}
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
import javax.security.auth.login.LoginException;
import oracle.iam.identity.exception.NoSuchRoleException;
import oracle.iam.identity.exception.RoleAlreadyExistsException;
import oracle.iam.identity.exception.RoleCreateException;
import oracle.iam.identity.exception.RoleModifyException;
import oracle.iam.identity.exception.ValidationFailedException;
import oracle.iam.identity.rolemgmt.api.RoleManager;
import oracle.iam.identity.rolemgmt.api.RoleManagerConstants;
import oracle.iam.identity.rolemgmt.vo.Role;
import oracle.iam.platform.OIMClient;
public class RoleUtility {
public RoleUtility() {
super();
}
public static OIMClient oimClient;
private static RoleManager roleManager = null;
public static void main(String[] args) throws LoginException,
ValidationFailedException,
RoleAlreadyExistsException,
RoleCreateException,
RoleModifyException,
NoSuchRoleException {
oimClient= oimConnect.getOIMConnection();
// that connection method is write in another class
// Role r1 = new Role("");
//
// r1.setName("JAVA ROLE1");
roleManager= oimClient.getService(RoleManager.class);
//// roleManager.create(r1);
//
// Role r2 = new Role("62");
// // r2.setAttribute("Role Owner Key", 70L);
// r2.setAttribute(RoleManagerConstants.ROLE_OWNER_KEY, 88L);
//
// System.out.println(RoleManagerConstants.ROLE_OWNER_KEY);
// RoleManagerResult result = roleManager.modify(r2);
//
// System.out.println(result.getStatus());
//
// // HashMap<String, Object> attributes = new HashMap<String, Object>();
Set<String> roleKeys = new HashSet<String>();
roleKeys.add("61"); // REPORT ADMINISTRATORS
roleKeys.add("62"); // PLUGIN ADMINISTRATORS
HashMap<String, Object> attributes = new HashMap<String, Object>();
attributes.put(RoleManagerConstants.ROLE_OWNER_KEY, 67L);
attributes.put(RoleManagerConstants.ROLE_NAME, "ADVANCED ROLE");
attributes.put(RoleManagerConstants.ROLE_CATEGORY_KEY, 2L);
attributes.put(RoleManagerConstants.ROLE_DESCRIPTION, "Hello");
attributes.put(RoleManagerConstants.ROLE_EMAIL, "abc@example.com");
Role r4 = new Role (attributes);
roleManager.create(r4);
//
//Role r3 = new Role(attributes);
////r3.setAttribute(RoleManagerConstants.ROLE_OWNER_KEY, 67L);
//
//roleManager.modify(roleKeys, r3);
// roleManager.search(arg0, arg1, arg2)
}
}
No comments:
Post a Comment