4 Replies Latest reply: Mar 30, 2012 1:10 PM by BikashBagaria RSS

    Request Validation

      Hi all. I have a sort of implementation problem. I'm building a provisioning process for some resources, with appropriate dataset. My scenario is as following:

      1. Requester "X" requests provision resource "RES" for user Beneficiary "Y"
      2. In dataset I have 2 fields, say "Approver1" and "Approver2" (this fields are Lookup fields from USR table)
      3. Dataset has a Validator, in which I can verify that "Approver1" must differ from "Approver2", throwing appropriate InvalidRequestDataException.

      Now I would like to verify that, before request submission, Requester "X" and Beneficiary "Y" differ from "Approver1".

      How could I achieve this goal? With RequestData object in validator, I've not been able to get requester details.

      Please help me,
      thanks in advance.

        • 1. Re: Request Validation
          If you have achieved I can verify that "Approver1" must differ from "Approver2, than why not rest part,
          Below is not complete code...
          1. You have requester key (),
          request = RequestService.getCompleteRequestData(reqId);
          X = request.getRequesterKey();

          2. You have Y =
          beneficiariesList = reqData.getBeneficiaries();
          List<RequestBeneficiaryEntity> rqstBeneficiaryEntitiesList = beneficiary.getTargetEntities();

          3. You have approver1 and approver2

          So you have all the information now, So you can do your desired validation.
          • 2. Re: Request Validation
            Thank you for the answer kuldeep. But... in the validator the request is not submitted yet. So I haven't got the reqId, right?
            So calling RequestService.getCompleteRequestData(reqId) I will only get a java.lang.NullPointerException.

            This is my code, could you help me?

            import java.util.List;

            import javax.security.auth.login.LoginException;

            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;

            public class SSHDataValidator implements RequestDataValidator {

                 public void validate(RequestData reqData) throws InvalidRequestDataException{

                      try {

                           java.util.Hashtable env = new java.util.Hashtable();
                           oracle.iam.platform.OIMClient oimClient = new oracle.iam.platform.OIMClient(env);

                           oimClient.login("xelsysadm", "idmAdmin1");

                           String templateName = reqData.getRequestTemplateName();

                           boolean isAdministrativeRequest = false;

                           String requesterUserName = "";

                           List<Beneficiary> beneficiaries = null;
                           beneficiaries = reqData.getBeneficiaries();

                           String beneficiaryUserName = "";

                           String lineManagerUserName = "";
                           String appOwnerUserName = "";
                           String password = "";
                           String passwordConfirm = "";

                           if (beneficiaries != null) {    

                                for(oracle.iam.request.vo.Beneficiary beneficiary: beneficiaries){

                                     oracle.iam.request.vo.Request req = beneficiary.getRequest();

                                     Thor.API.tcUtilityFactory ioUtilityFactory =
                                          new Thor.API.tcUtilityFactory(env, "xelsysadm", "idmAdmin1");

                                     Thor.API.Operations.tcUserOperationsIntf moUserUtility = null;
                                     Thor.API.tcResultSet usrResultSet = null;

                                     moUserUtility = (Thor.API.Operations.tcUserOperationsIntf)

                                     java.util.Map v = new java.util.HashMap();
                                     usrResultSet = moUserUtility.findUsers(v);

                                     if (usrResultSet.getRowCount() > 0) {

                                          for (int i = 0; i < usrResultSet.getRowCount(); i++) {

                                               requesterUserName = usrResultSet.getStringValue("Users.User ID");

                                     String beneficiaryKey = beneficiary.getBeneficiaryKey();

                                     v = new java.util.HashMap();
                                     usrResultSet = moUserUtility.findUsers(v);

                                     if (usrResultSet.getRowCount() > 0) {

                                          for (int i = 0; i < usrResultSet.getRowCount(); i++) {

                                               beneficiaryUserName = usrResultSet.getStringValue("Users.User ID");

                                     java.util.List<RequestBeneficiaryEntity> rbes = beneficiary.getTargetEntities();

                                     for(oracle.iam.request.vo.RequestBeneficiaryEntity rbe : rbes){

                                          java.util.List<RequestBeneficiaryEntityAttribute> requestEntityAttributesList = rbe.getEntityData();

                                          if (requestEntityAttributesList != null && !requestEntityAttributesList.isEmpty()) {

                                               for (RequestBeneficiaryEntityAttribute attr : requestEntityAttributesList) {      

                                                    String attrName = attr.getName();

                                                         password = attr.getValue().toString();

                                                    if(attrName.equalsIgnoreCase("Conferma Password")){
                                                         passwordConfirm = attr.getValue().toString();

                                                    if(attrName.equalsIgnoreCase("Application Owner")){
                                                         appOwnerUserName = attr.getValue().toString();

                                                    if(attrName.equalsIgnoreCase("Line Manager")){
                                                         lineManagerUserName = attr.getValue().toString();
                                                         throw new InvalidRequestDataException("LM_NOT_SET");
                                                         throw new InvalidRequestDataException("AO_NOT_SET");

                                                         throw new InvalidRequestDataException("BENEFICIARY_EQ_LM");

                                                         throw new InvalidRequestDataException("REQUESTER_EQ_LM");

                                                         throw new InvalidRequestDataException("LM_EQ_AO");

                                                    throw new InvalidRequestDataException("INVALID_PWD_CONFIRMATION");

                      catch (Exception e) {
                           // TODO Auto-generated catch block

            Edited by: Giuseppe on Mar 30, 2012 12:27 PM
            • 3. Re: Request Validation
              My Mistake,

              But first of all you don't need OIMClient. Instated of OIMCLient use Platform, in which you don't need to login. You can directly get any service class
              Now Just check
              Platform.getConfiguration().getBPELConfig().getUsername();, I am not sure It will return you logged in user name that is requester. Or might be weblogic user.
              • 4. Re: Request Validation
                Use query to get the Requester information

                "SELECT USR_LOGIN as UKEY, USR_LOGIN as ULOGIN FROM USR where USR_LOGIN='$Requester Information.User Login'"