Tuesday, February 20, 2024

Advanced Policy Violation evaluate based on the Organization Role

  import java.util.ArrayList;

  import java.util.HashMap;

  import java.util.List;

  import java.util.Map;

  import sailpoint.object.Bundle;

  import sailpoint.object.Custom;

  import sailpoint.object.Identity;

  import sailpoint.object.PolicyViolation;

  import sailpoint.tools.GeneralException;


  public Map getRoleMap(Identity identity) {

    Map rolesMap = new HashMap();

    if (identity != null @and identity.getAssignedRoles() != null) {

      List<Bundle> assingedRoles = identity.getAssignedRoles();

      if (assingedRoles.size() > 0 @and !assingedRoles.isEmpty()) {

        for (Bundle bundle : assingedRoles) {          

          if (bundle.getInheritance().size() > 0 @and bundle.getInheritance().get(0).getName().toString().trim() != null) {            

            current_role = bundle.getName().toString().trim();

            current_container = bundle.getInheritance().get(0).getName().toString().trim();

            if (sodContainers.contains(current_container)) {

              rolesMap.put(current_role, current_container);

            }

          }

        }

      }

    }

    return rolesMap;

  }

  public HashMap getDuplicateValues(HashMap in) {

    // Clone input HashMap because we're removing stuff from it

    in = (HashMap) in.clone();

    HashMap rval = new HashMap();

    Object[] keys = in.keySet().toArray();

    // iterate through all keys

    for (int x = 0; x < keys.length; x++) {

      Object value = in.get(keys[x]);

      in.remove(keys[x]);

      // if value is in input HashMap, store it in duplicate HashMap because it has

      // another value

      if (in.containsValue(value)) {

        rval.put(keys[x], value);

      }

      // if value is in duplicate HashMap, store it also because it HAD another value

      // earlier

      if (rval.containsValue(value)) {

        rval.put(keys[x], value);

      }

    }

    return (rval);

  }

  Boolean isVaiolated = false;

  String current_container = "";

  String current_role = "";

  String roleA = "";

  String roleB = "";

  String duplicateValue = null;

  Map assingedRoles = new HashMap();

  Map requestedRoles = new HashMap();

  Map duplicateRolesMap = new HashMap();

  Map allRolesMap = new HashMap();

  PolicyViolation violation = null;

  List sodContainers = new ArrayList();  

  try {

Custom customObj = context.getObjectByName(Custom.class, "Mighty - Container - Organization Custom Object");

    if (customObj != null @and customObj.getAttributes().getList("SOD_Containers") != null) {

      sodContainers = customObj.getAttributes().getList("SOD_Containers");

      log.error("sodContainers : " + sodContainers);

      Identity assignedIdentity = context.getObjectByName(Identity.class, identity.getName());

      if (assignedIdentity != null) {

        assingedRoles = getRoleMap(assignedIdentity);

        log.error("assingedRoles : " + assingedRoles);

        if (assingedRoles != null @and assingedRoles.size() > 0) {

          allRolesMap.putAll(allRolesMap);

        }

      }


      if (identity != null) {

        requestedRoles = getRoleMap(identity);

        log.error("requestedRoles : " + requestedRoles);

        if (requestedRoles != null @and requestedRoles.size() > 0) {

          allRolesMap.putAll(requestedRoles);

        }

      }

      if (allRolesMap.size() > 0 @and !allRolesMap.isEmpty()) {

        if (duplicateRolesMap.get(duplicateRolesMap.keySet().toArray()[0]) != null) {

          isVaiolated = true;

          duplicateValue = duplicateRolesMap.get(duplicateRolesMap.keySet().toArray()[0]).toString().trim();

          if (duplicateRolesMap.keySet().toArray()[0] != null) {

            roleA = duplicateRolesMap.keySet().toArray()[0].toString().trim();

            duplicateRolesMap.remove(roleA);

            for (Map.Entry dupEntryRole : duplicateRolesMap.entrySet()) {

              if (dupEntryRole.getValue() != null @and dupEntryRole.getKey() != null) {

                if (dupEntryRole.getValue().equals(duplicateValue)) {

                  roleB = dupEntryRole.getKey().toString().trim();

                  break;

                }

              }

            }

          }

        }

      }

    }

    if (isVaiolated) {

      violation = new PolicyViolation();

      violation.setActive(true);

      violation.setIdentity(identity);

      violation.setPolicy(policy);

      violation.setConstraint(constraint);

      violation.setDescription("");

     // violation.setStatus(sailpoint.object.PolicyViolation.Status.Open); // workitem will be disabled if this line is disabled

      return violation;

    }

  } catch (GeneralException e) {

    log.error("GeneralException : " + e.getMessage());

  }

  return violation; 

Saturday, February 17, 2024

Map inside Map

HashMap primasRoleIdMap = new HashMap();

primasRoleIdMap.put("roleId", "");

primasRoleIdMap.put("roleType", "");

HashMap<String, HashMap> primasRoleMap = new HashMap();

primasRoleMap.put("roleIds", primasRoleIdMap);


Friday, February 16, 2024

Sample Before Rule

import java.util.ArrayList;

import java.util.HashMap;

import java.util.List;

import java.util.Map;

import org.apache.commons.logging.Log;

import org.apache.log4j.Logger;

import sailpoint.api.SailPointContext;

import sailpoint.connectorDependencies.EndPoint;

import sailpoint.object.Custom;

import sailpoint.object.ProvisioningPlan;

import sailpoint.object.ProvisioningPlan.AccountRequest;

import sailpoint.object.ProvisioningPlan.AttributeRequest;

import sailpoint.tools.Util;

import connector.common.JsonUtil;


String roleType = "";

String roleId = "";

List<String> securityGroup = new ArrayList<String>();

String secretAccountIndicator = "";

String phone = null;


String bcomSecGroupReqType = "";

List<String> bcomSecurityGroup = new ArrayList<String>();

List<String> ipccRoleId = new ArrayList<String>();

String ipccPhone = "";

String roleChangeReqType = "";

List<String> roleChangeRoleID = new ArrayList<String>();


String primasRole = "";

String primasPhone = "";


String secAccIndicator = "";

String bcomAccSecretAccountIndicator = "";


Custom custom = null;

AttributeRequest attributeRequest = null;

Map<String, Object> formMap = new HashMap<String, Object>();

List<AccountRequest> accountRequests = null;


custom = context.getObjectByName(Custom.class, "Mighty - Payload Details");


Map body = requestEndPoint.getBody();

String jsonBody = body.get("jsonBody").toString().trim();

log.error("jsonBody : " + jsonBody);


Map jsonMap = JsonUtil.toMap(jsonBody);

log.error("jsonMap : " + jsonMap);


accountRequests = provisioningPlan.getAccountRequests();

log.error("accountRequests : " + accountRequests);


for (AccountRequest accountRequest : accountRequests) {

if (Util.isNotNullOrEmpty(accountRequest.getApplicationName())

&& accountRequest.getApplicationName().toString().trim().equalsIgnoreCase("BCOM")) {


formMap = provisioningPlan.getArguments().getMap();

log.error("formMap : " + formMap);


if (accountRequest.getAttributeRequest("rolesIds") != null) {

attributeRequest = accountRequest.getAttributeRequest("rolesIds");

log.error("attributeRequest : " + attributeRequest);

if (attributeRequest.getName().equalsIgnoreCase("IPCC")) {

if (formMap.get("Role ID") != null) {

ipccRoleId = (List<String>) formMap.get("Role ID");

log.error("ipccRoleId : " + ipccRoleId);

}

if (formMap.get("Phone") != null) {

phone = formMap.get("Phone").toString().trim();

log.error("phone : " + phone);

}

if (Util.isNotNullOrEmpty(phone)) {

jsonMap.put("phoneNo", phone);

}

// To - Do

// Map postBodyMap = (Map) requestEndPoint.getBody();


}

if (attributeRequest.getName().equalsIgnoreCase("IPCC update Roles")) {

if (formMap.get("Request Type") != null) {

roleChangeReqType = formMap.get("Request Type").toString().trim();

log.error("roleChangeReqType : " + roleChangeReqType);

}

if (formMap.get("Role ID") != null) {

roleChangeRoleID = (List<String>) formMap.get("Role ID");

log.error("roleChangeRoleID : " + roleChangeRoleID);

}


// To - Do

}

if (attributeRequest.getName().equalsIgnoreCase("BCOM update Security Group")) {


if (formMap.get("Request Type") != null) {

bcomSecGroupReqType = formMap.get("Request Type").toString();

log.error("bcomSecGroupReqType : " + bcomSecGroupReqType);

}

if (formMap.get("Security Group") != null) {

bcomSecurityGroup = (List<String>) formMap.get("Security Group");

log.error("bcomSecurityGroup : " + bcomSecurityGroup);

}


// To - Do

}

if (attributeRequest.getName().equalsIgnoreCase("BCOM")) {


if (formMap.get("Role ID") != null) {

roleId = formMap.get("Role ID").toString();

}

if (formMap.get("Security Group") != null) {

securityGroup = (List) formMap.get("Security Group");

}

if (formMap.get("Secret Account Indicator") != null) {

secretAccountIndicator = formMap.get("Secret Account Indicator").toString().trim();

}

if (formMap.get("Phone") != null) {

phone = formMap.get("Phone").toString().trim();

}


// To - Do


}

if (attributeRequest.getName().equalsIgnoreCase("PRIMAS")) {

if (formMap.get("Role ID") != null) {

primasRole = formMap.get("Role ID").toString();

if (formMap.get("PRIMAS") != null) {

roleType = custom.getString("PRIMAS");

log.error("roleType : " + roleType);

}

}

if (formMap.get("Phone") != null) {

primasPhone = formMap.get("Phone").toString().trim();

log.error("primasPhone : " + primasPhone);

}

// To - Do


if (Util.isNotNullOrEmpty(primasPhone)) {

jsonMap.put("phoneNo", primasPhone);

}

}

if (attributeRequest.getName().equalsIgnoreCase("BCOM update Account Indicator")) {

if (formMap.get("Secret Account Indicator") != null) {

secretAccountIndicator = formMap.get("Secret Account Indicator").toString().trim();

log.error("secretAccountIndicator : " + secretAccountIndicator);


if (secretAccountIndicator.equalsIgnoreCase("Normal Account")) {

secAccIndicator = custom.getString("Normal Account");

log.error("secAccIndicator : " + secretAccountIndicator);

}

if (secretAccountIndicator.equalsIgnoreCase("Confidential and Normal Account")) {

secAccIndicator = custom.getString("Confidential and Normal Account");

log.error("secAccIndicator : " + secretAccountIndicator);

}

}

// To - Do

if (Util.isNotNullOrEmpty(secAccIndicator)) {

jsonMap.put("secretAccountIndicator", secAccIndicator);

}

}

}

}

}


Thursday, February 15, 2024

Before Rule for JSON body update

import java.util.ArrayList;

import java.util.HashMap;

import java.util.List;

import java.util.Map;

import org.apache.log4j.Logger;

import openconnector.JsonUtil;

import sailpoint.api.SailPointContext;

import sailpoint.connectorDependencies.EndPoint;

import sailpoint.object.Attributes;

import sailpoint.object.Identity;

import sailpoint.object.ProvisioningPlan;

import sailpoint.object.ProvisioningPlan.AccountRequest;

import sailpoint.object.ProvisioningPlan.AttributeRequest;

import sailpoint.tools.Util;

public class RoleCreation {

static SailPointContext context = null;

static Logger logger = null;

static ProvisioningPlan provisioningPlan = null;

static EndPoint requestEndPoint = null;

public static void main(String[] args) {

String appName = null;

String roleId = "";

List<String> securityGroup = new ArrayList<String>();

String secretAccountIndicator = "";

String phone = null;

String ecomSecGroupReqType = "";

List<String> ecomSecurityGroup = new ArrayList<String>();

List<String> ipccRoleId = new ArrayList<String>();

String ipccPhone = "";

String roleChangeReqType = "";

List<String> roleChangeRoleID = new ArrayList<String>();

String primasRole = "";

String primasPhone = "";

String ecomAccSecretAccountIndicator = "";

AttributeRequest attributeRequest = null;

Map<String, Object> formMap = new HashMap<String, Object>();

List<AccountRequest> accountRequests = null;

accountRequests = provisioningPlan.getAccountRequests();

for (AccountRequest accountRequest : accountRequests) {


if (Util.isNotNullOrEmpty(accountRequest.getApplicationName())

&& accountRequest.getApplicationName().toString().trim().equalsIgnoreCase("ECOM")) {


appName = accountRequest.getApplicationName().toString().trim();

formMap = provisioningPlan.getArguments().getMap();

if (accountRequest.getOperation().equals(AccountRequest.Operation.Create)) {

if (accountRequest.getAttributeRequest("rolesIds") != null) {

attributeRequest = accountRequest.getAttributeRequest("rolesIds");


if (attributeRequest.getName().equalsIgnoreCase("ECOM")) {


if (formMap.get("Role ID") != null) {

String roleID = formMap.get("Role ID").toString();

}

if (formMap.get("Security Group") != null) {

securityGroup = (List) formMap.get("Security Group");

}

if (formMap.get("Secret Account Indicator") != null) {

secretAccountIndicator = formMap.get("Secret Account Indicator").toString().trim();

}

if (formMap.get("Phone") != null) {

phone = formMap.get("Phone").toString().trim();

}


}

if (attributeRequest.getName().equalsIgnoreCase("ECOM Security Group")) {


if (formMap.get("Request Type") != null) {

String roleID = formMap.get("Request Type").toString();

}

if (formMap.get("Security Group") != null) {

ecomSecurityGroup = (List<String>) formMap.get("Security Group");

}

}

if (attributeRequest.getName().equalsIgnoreCase("IPCC")) {

if (formMap.get("Role ID") != null) {

ipccRoleId = (List<String>) formMap.get("Role ID");

}

if (formMap.get("Phone") != null) {

phone = formMap.get("Phone").toString().trim();

}

}

if (attributeRequest.getName().equalsIgnoreCase("IPCCRoleChange")) {

if (formMap.get("Request Type") != null) {

roleChangeReqType = formMap.get("Request Type").toString().trim();

}

if (formMap.get("Role ID") != null) {

roleChangeRoleID = (List<String>) formMap.get("Role ID");

}

}

if (attributeRequest.getName().equalsIgnoreCase("PRIMAS")) {

if (formMap.get("Role ID") != null) {

primasRole = formMap.get("Role ID").toString();

}

if (formMap.get("Phone") != null) {

primasPhone = formMap.get("Phone").toString().trim();

}

}

if (attributeRequest.getName().equalsIgnoreCase("ECOM Account Indicator")) {

if (formMap.get("Secret Account Indicator") != null) {

secretAccountIndicator = formMap.get("Secret Account Indicator").toString().trim();

}

}

}

if (formMap.size() > 0) {

if (formMap.get("Role ID") != null) {

}

Map body = requestEndPoint.getBody();

String jsonBody = (String) body.get("jsonBody");

logger.info("Rule - Modify Body: running");

}

}

}

}

}

}

Wednesday, February 14, 2024

Retry enable

 <entry key="retryableErrors"> 

 <value> 

  <List> 

   <String>Server is not operational</String> 

  </List> 

 </value>

</entry>

Test after Rule

log.error("processedResponseObject : " + processedResponseObject); 

log.error("rawResponseObject: " + rawResponseObject);

Tuesday, February 13, 2024

Bitbucket

sudo su

cd /app/mighty/spadmin/

mkdir Mighty_Code_Path

chmod 777 Mighty_Code_Path -R

userName : "abcd"

EmailAdd : "abcd@gmail.com"

git config --global http.sslVerify false

cd "/app/mighty/spadmin/Mighty_Code_Path"

pwd

git clone "URL"

cd identityiq

git checkout Master_Code_Rev


cd /app/mighty/spadmin/Mighty_Code_Path/identityiq"

git add --all

git commit -m "Commit -12345 -Master_Code_Rev_Test"

git push -u origin HEAD:Master_Code_Rev

# Create Pull Request

# Scroll down and click on Create.

Friday, February 9, 2024

Fetch Resource Object entitlements and validate against custom object.

 import java.util.List;

  import java.util.Map;

  import org.apache.commons.logging.Log;

  import sailpoint.api.SailPointContext;

  import sailpoint.object.Custom;

  import sailpoint.object.ResourceObject;

  import sailpoint.tools.GeneralException;


  ResourceObject object = null;

  ResourceObject resourceObject = null;

  Custom custom = null;

  Map tablueauMap = null;

  Map tablueauENTMap = null;

  List listENT = null;

  try {

    if (object != null) {

      if (object.getStringList("memberOf") != null && object.getStringList("memberOf").size() > 0

&& !object.getStringList("memberOf").isEmpty()) {      

         listENT = object.getStringList("memberOf");

        log.error("TABLEAU groups are : "+listENT);

        custom = context.getObjectByName(Custom.class, "Test Custom Object");

        if (custom != null) {

          tablueauMap = custom.getAttributes().getMap();

          if (tablueauMap.size() > 0 @and tablueauMap.get("TABLEAU") != null) {

            tablueauENTMap = (Map) tablueauMap.get("TABLEAU");

            resourceObject = new ResourceObject();

            for (String ent: listENT) {

              if (tablueauENTMap.containsValue(ent)) {

                resourceObject = object;

              }

            }

          } else {

            log.error("Custom Object doesn't contains TABLEAU ");

          } 

        }  else {

          log.error("Custom Object is null");

        } 

      } else {

        log.error("Resource Object doesn't contains groups and length is zero");

      }

    } else {

      log.error("ResourceObject is null");

    }

    return resourceObject;

  } catch (GeneralException e) {

    log.error("GeneralException : " + e.getMessage());

  }

==========================================================================

import java.util.List;

import java.util.Map;

import org.apache.commons.logging.Log;

import sailpoint.api.SailPointContext;

import sailpoint.object.Custom;

import sailpoint.object.ResourceObject;

import sailpoint.tools.GeneralException;


public class ResourceObjectTest {


static SailPointContext context = null;

static ResourceObject object = null;

static ResourceObject resourceObject = null;

static Log log = null;


public static void main(String[] args) {

Custom custom = null;

Map tablueauMap = null;

Map tablueauENTMap = null;

List listENT = null;

try {

if (object != null) {

if (object.getAttribute("memberOf") != null) {

listENT = (List) object.getAttribute("memberOf");

if (listENT.size() > 0) {

custom = context.getObjectByName(Custom.class, "");


if (custom != null) {

tablueauMap = custom.getAttributes().getMap();


if (tablueauMap.size() > 0 && tablueauMap.get("TABLEAU") != null) {

tablueauENTMap = (Map) tablueauMap.get("TABLEAU");


for (Object object1 : listENT) {

if (tablueauENTMap.containsValue(object1)) {

resourceObject = object;

}

}


}

}

}

} else {

log.error("Resource Object doesn't contains groups ");

}

} else {

log.error("ResourceObject is : " + object);

}

} catch (GeneralException e) {

log.error("GeneralException : " + e.getMessage());

}

}

}

Wednesday, February 7, 2024

Payload Configuration in IIQ

Payload :

{

"empID": "12345",

"firstName": "ABC",

"lastName": "XYZ",

"email": "abc@gmail.com"

"roles":[

{

"roleID": "123",

"roleName":""MighytRole

}

],

region:"Asia"

}

Aggregation:

Left-side fields should be exactly matched with schema fields.

Right-side fields should be exactly matched with payload or application fields.

Create / Update Account:

Left-side fields should be exactly matched with payload fields.

Right-side fields should be exactly matched with provisioning policy fields

Methods:

Create Account: POST

Update Account: PUT

Disable Account: PUT

Enable Account: GET

Delete Account: DELETE

Get Account: GET

Payload Mapping Template

Payload Mapping:




Postman

Headers:

Content-Type : application/json

Accept : text/json


Host URL / Base URL: https://blogger.net/

Path URL / Context URL: / mighty

Response = > Successful Response Code : 2** 


Payload / Json Body:

{

"empID": "12345",

"firstName": "ABC",

"lastName": "XYZ",

"email": "abc@gmail.com"

"roles":[

{

"roleID": "123",

"roleName":""MighytRole

}

],

region:"Asia"

}


Before Operation Rule

Troubleshooting purpose:

log.error("requestEndPoint : " + requestEndPoint ); 

log.error("requestEndPoint : "+requestEndPoint.getBody());

requestEndPoint.setFullUrl(requestEndPoint.getFullUrl().replaceAll("40", "@")); 

// updating the endpoint URL

Tuesday, February 6, 2024

Adv Policy Java

import java.util.ArrayList;

import java.util.HashMap;

import java.util.List;

import java.util.Map;

public class Policy{

Map<String, String> identityRoles = new HashMap<>();

Map<String, String> requestRoles = new HashMap<>();

Map<String, Integer> tempMap = new HashMap<>();

List<String> duplicateReq = new ArrayList<>();

Map<String, String> customOrg = new HashMap<>();


public void validationInProcess() {

customOrg.put("orgO1", "Organization One DName");

customOrg.put("orgO2", "Organization two DName");


identityRoles.put("BR1", "orgO1");

identityRoles.put("BR2", "orgO2");

identityRoles.put("BR9", "orgO3");

identityRoles.put("BR12", "orgO4");


requestRoles.put("BR2", "orgO1");

requestRoles.put("BR1", "orgO2");

requestRoles.put("BR10", "orgO4");

requestRoles.put("BR11", "orgO5");


if (!requestRoles.isEmpty() && identityRoles.isEmpty()) {

if (requestRoles.size() == 1) {

System.out.println("Requested one role and no assigned roles found. Processing request. ");

} else {

System.out.println("Requested multiple Roles. Undergoing Organization duplicate valdiation.");

List<String> listOfReqRoles = new ArrayList<>(requestRoles.values());

List<String> duplicateReq = validateDuplicateOrg(listOfReqRoles);

processRequest(duplicateReq);

}

} else if (!identityRoles.isEmpty() && requestRoles.isEmpty()) {

if (requestRoles.size() == 1) {

System.out.println("Requested one role and no assigned roles found. Processing request. ");

} else {

System.out.println("Requested multiple Roles. Undergoing Organization duplicate valdiation.");

List<String> listOfDetRoles = new ArrayList<>(identityRoles.values());

List<String> duplicateDet = validateDuplicateOrg(listOfDetRoles);

processRequest(duplicateDet);

}

} else if (!identityRoles.isEmpty() && !requestRoles.isEmpty()) {

if (requestRoles.size() == 1) {

System.out.println("Requested One Role");

validateRoleCount(identityRoles, requestRoles);

} else {

List<String> listOfReqRoles = new ArrayList<>(requestRoles.values());

List<String> duplicateReq = validateDuplicateOrg(listOfReqRoles);

if (processRequest(duplicateReq)) {

validateRoleCount(identityRoles, requestRoles);

}

}

}

}

public List<String> validateDuplicateOrg(List<String> listOfRoles) {

List<String> duplicate = new ArrayList<>();

System.out.println("Validating Duplication. Requested Role's Organization : " + listOfRoles.toString());

for (int i = 0; i < listOfRoles.size(); i++) {

for (int j = i + 1; j < listOfRoles.size(); j++) {

if (listOfRoles.get(i).equalsIgnoreCase(listOfRoles.get(j))) {

duplicate.add(listOfRoles.get(i));

}

}

}

return duplicate;

}

public boolean processRequest(List<String> processList) {

boolean flag = false;

if (!processList.isEmpty()) {

for (int i = 0; i < processList.size(); i++) {

if (customOrg.containsKey(processList.get(i))) {

System.out.println("Requested Roles found Duplicate Org : " + processList.get(i));

flag = false;

} else {

System.out.println("Requeste role not found in Org . Processing Request");

flag = true;

}

}

} else {

System.out.println("No duplicate found. Processing request.");

flag = true;

}

return flag;

}

public Map<String, Integer> validateRoleCount(Map<String, String> identityRoles, Map<String, String> requestRoles) {

int OrgCount = 0;

for (Map.Entry<String, String> identityRole : identityRoles.entrySet()) {

for (Map.Entry<String, String> requestRole : requestRoles.entrySet()) {

if (customOrg.containsKey(identityRole.getValue()) && customOrg.containsKey(requestRole.getValue())) {

if (identityRole.getValue().equalsIgnoreCase(requestRole.getValue())) {

OrgCount++;

}

}

}

if (OrgCount >= 1) {

for (Map.Entry<String, String> customRole : customOrg.entrySet()) {

if (customRole.getKey().equalsIgnoreCase(identityRole.getValue())) {

OrgCount += 1;

tempMap.put(customRole.getKey(), OrgCount);

}

}

}

OrgCount = 0; }

for (Map.Entry<String, Integer> entry : tempMap.entrySet())

System.out.println("Key = " + entry.getKey() + ", Value = " + entry.getValue());

return tempMap;

}

public static void main(String[] args) {

new Policy().validationInProcess();

}

}


Monday, February 5, 2024

UAT Template

UAT Template Fields:

1. Test Case #

2. Test Case

3. Test Case Description

4. Pre-requisites

5. Test Steps

6. Tester

7. Test Account Used

8. Group Used (Optional)

9. Expected Results

10. Pass / Fail

11. Actual Results

12. Remarks

13. Retest Required

14. Retest Condition

15. Retest Pass/Fail

16. Retest Actual Results




Thursday, February 1, 2024

Finding Duplicate Organization Names

import java.util.HashMap;

import java.util.Map;

public class OrgRole {

Map<String,String> custom=new HashMap<>();

Map<String,String> identityRoles=new HashMap<>();

Map<String,Integer> tempMap=new HashMap<>();

void ValidatingRole(){

custom.put("OrgR1", "OR1");

custom.put("OrgR2", "OR2");

custom.put("OrgR3", "OR3");

custom.put("OrgR4", "OR4");

identityRoles.put("OrgKey1", "OR4");

identityRoles.put("OrgKey2", "OR4");

identityRoles.put("OrgKey3", "OR4");

identityRoles.put("OrgKey4", "OR2");

identityRoles.put("OrgKey5", "OR2");

int OrgCount = 0;

for (Map.Entry<String,String> orgRole : custom.entrySet()) {

for (Map.Entry<String,String> identityRole : identityRoles.entrySet()) {

if(orgRole.getValue().equalsIgnoreCase(identityRole.getValue())) {

OrgCount++;

}

}

if(OrgCount >= 2){

tempMap.put(orgRole.getValue(), OrgCount);

}

OrgCount=0;

}

for (Map.Entry<String,Integer> entry : tempMap.entrySet())  

            System.out.println("Key = " + entry.getKey() + ", Value = " + entry.getValue()); 

}

public static void main(String[] args) {

new OrgRole().ValidatingRole();

}

}

====================================================================================================================================================

HashMap hashMap = null;

Custom custom = context.getObjectByName(Custom.class, "Container - SODRoles Custom Object");

attributes = custom.getAttributes();

List SODRolekeys = attributes.getKeys();

for (String containerRolekey : SODRolekeys) {

hashMap.put(containerRolekey, custom.get(containerRolekey));

}

====================================================================================================================================================

import java.util.ArrayList;

import java.util.HashMap;

import java.util.List;

import java.util.Map;

public class AdvPolicyViolation {

List<String> duplicateReq = new ArrayList<>();

Map<String, String> customOrg = new HashMap<>();

Map<String, String> identityRoles = new HashMap<>();

Map<String, String> requestRoles = new HashMap<>();

Map<String, Integer> tempMap = new HashMap<>();

void ValidatingRole() {

customOrg.put("orgO1", "Organization One DName");

customOrg.put("orgO2", "Organization two DName");

identityRoles.put("BR1", "orgO1");

identityRoles.put("BR5", "orgO2");

identityRoles.put("BR9", "orgO3");

identityRoles.put("BR12", "orgO4");

requestRoles.put("BR2", "orgO1");

requestRoles.put("BR5", "orgO2");

requestRoles.put("BR10", "orgO4");

requestRoles.put("BR11", "orgO5");

if (requestRoles.size() == 1) {

System.out.println("One request role found");

validateRoleCount(identityRoles, requestRoles);

} else {

System.out.println("Multiple request roles are found");

List<String> listOfReqRoles = new ArrayList<>(requestRoles.values());

for (int i = 0; i < requestRoles.size(); i++) {

for (int j = i + 1; j < listOfReqRoles.size(); j++) {

if (listOfReqRoles.get(i).equalsIgnoreCase(listOfReqRoles.get(j))) {

duplicateReq.add(listOfReqRoles.get(i));

}

}

}

if (!duplicateReq.isEmpty()) {

for (int i = 0; i < duplicateReq.size(); i++) {

if (customOrg.containsKey(duplicateReq.get(i))) {

System.out.println("Requested Roles found Duplicate Org " + duplicateReq.get(i));

// return duplicates found

} else {

System.out.println("Requeste role not found in Org . Processing Request");

// process request

}

}

} else {

System.out.println("No duplicate found. Processing request.");

validateRoleCount(identityRoles, requestRoles);

}

}

}

public Map<String, Integer> validateRoleCount(Map<String, String> identityRoles, Map<String, String> requestRoles) {

int orgCount = 0;

for (Map.Entry<String, String> identityRole : identityRoles.entrySet()) {

for (Map.Entry<String, String> requestRole : requestRoles.entrySet()) {

if (customOrg.containsKey(identityRole.getValue()) && customOrg.containsKey(requestRole.getValue())) {

if (identityRole.getValue().equalsIgnoreCase(requestRole.getValue())) {

orgCount++;

}

}

}

if (orgCount >= 1) {

for (Map.Entry<String, String> customRole : customOrg.entrySet()) {

if (customRole.getKey().equalsIgnoreCase(identityRole.getValue())) {

orgCount += 1;

tempMap.put(customRole.getKey(), orgCount);

}

}

}

orgCount = 0;

}

for (Map.Entry<String, Integer> entry : tempMap.entrySet())

System.out.println("Key = " + entry.getKey() + ", Value = " + entry.getValue());

return tempMap;

}

public static void main(String[] args) {

new AdvPolicyViolation().ValidatingRole();

}

}

Fetch Members from Workgroup

  import java.util.ArrayList;   import java.util.Iterator;   import java.util.List;   import sailpoint.api.ObjectUtil;   import sailpoint.ob...