OIM 11G R2 PS3 (11.1.2.3.0) CreateUserDataSetValidator Request Dataset and Custom Validation

Export /metadata/iam-features-requestactions/model-data/CreateUserDataSet.xml

Attach your dataset validator

<DataSetValidator name="CreateUserDataValidator" classname="oracle.iam.requestactions.plugins.datavalidator.CreateUserDataValidator"/>


<DataSetValidator name="MyValidator" classname="com.deepak.dubey.validator.MyValidator"/> 



import oracle.iam.platform.context.ContextManager;
  
 //How to get the currently logged in User
String subjectId = (String)ContextManager.getUserPreference(ContextManager.USERDETAILS.KEY.getKey());






import java.util.List;

import javax.swing.text.html.HTMLDocument.Iterator;

import oracle.iam.identity.exception.NoSuchUserException;
import oracle.iam.identity.exception.UserLookupException;
import oracle.iam.platform.Platform;
import oracle.iam.platform.authz.exception.AccessDeniedException;
import oracle.iam.platform.context.ContextManager;
import oracle.iam.request.exception.InvalidRequestDataException;
import oracle.iam.request.plugins.RequestDataValidator;
import oracle.iam.request.vo.Beneficiary;
import oracle.iam.request.vo.RequestBeneficiaryEntity;
import oracle.iam.request.vo.RequestBeneficiaryEntityAttribute;
import oracle.iam.request.vo.RequestData;
import oracle.iam.requestactions.plugins.datavalidator.CreateUserDataValidator;

public class MyValidator extends CreateUserDataValidator implements RequestDataValidator{
   
     public void validate(RequestData requestdata) throws InvalidRequestDataException {
       
       
         //How to get the currently logged in User

         String subjectId = (String)ContextManager.getUserPreference(ContextManager.USERDETAILS.KEY.getKey());
       
         oracle.iam.request.api.RequestService reqSvc = Platform 
                 .getService(oracle.iam.request.api.RequestService.class);
       
         oracle.iam.identity.usermgmt.api.UserManager usersvc = Platform 
                 .getService(oracle.iam.identity.usermgmt.api.UserManager.class); 
       
         java.util.List<oracle.iam.request.vo.RequestEntity> l = requestdata.getTargetEntities(); 
         for( oracle.iam.request.vo.RequestEntity r: l){ 
         java.util.List<oracle.iam.request.vo.RequestEntityAttribute> attributes = r.getEntityData(); 
         for(oracle.iam.request.vo.RequestEntityAttribute attribute : attributes){ 
          
         System.out.println("**  ->"+attribute.getName()+  "--->  "+attribute.getValue()); 
          
         if (attribute.getName().toString().equalsIgnoreCase("First Name")) 
         { 
         String firstName = attribute.getValue().toString(); 
         } 
         if (attribute.getName().toString().equalsIgnoreCase("Last Name")) 
         { 
             String lastName = attribute.getValue().toString(); 
         } 
          
          
         if (attribute.getName().toString().equalsIgnoreCase("User Manager")) 
         { 
         String managerKey  = attribute.getValue().toString(); 
       
         if(subjectId.equalsIgnoreCase(managerKey)){
             throw new InvalidRequestDataException("Manager cannot be Self");
         }
   
         oracle.iam.identity.usermgmt.vo.User user = null;
        try {
            user = usersvc.getDetails(managerKey, null, false);
        } catch (NoSuchUserException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (UserLookupException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (AccessDeniedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } 
         System.out.println("manager login is --->"+user.getLogin()); 
         String contractorManager = user.getLogin(); 
          
         } 
         } 
         } 

          
        }

}
 



plugin.xml

<plugins pluginpoint="oracle.iam.request.plugins.RequestDataValidator"> 
<plugin pluginclass="com.deepak.dubey.request.MyValidator"
version="1.0"
name="MyValidator">
</plugin>
</plugins>

Comments

  1. Thank you . It was very helpful to do from start to end.

    ReplyDelete

Post a Comment

Popular posts from this blog

OIM 11g R2 PS2 : SOA Approval Workflow Sample

OHS 12c (12.1.3) webgate deployment and configuration

Oracle Identity Manager (OIM) Interview Questions