Friday, 23 March 2018

OIM API - Code Snippet to get all Accounts Provisioned to User.

public List<Long> fetchProvisionedAccountsOfUser(String usrKey){
            final String logp = CN + " :: fetchProvisionedAccountsOfUser - ";
            LOGGER.debug(logp + "START");
            List<Long> appInstanceKeys = new ArrayList<Long>();

            try{               
                ProvisioningService provService = Platform.getService(ProvisioningService.class);
                List<Account> provAccounts = provService.getAccountsProvisionedToUser(usrKey);

                for(Account act : provAccounts){
                    if ((act.getAccountStatus().equalsIgnoreCase("Provisioned"))
                                    || (act.getAccountStatus().equalsIgnoreCase("Enabled"))){    
                        Long appInstanceKey = act.getAppInstance().getApplicationInstanceKey();
                       
                        if (!appInstanceKeys.contains(appInstanceKey)){
                                appInstanceKeys.add(appInstanceKey);
                        }
                    }
                }
            } catch (Exception e) {
                    LOGGER.error("Error while fetching provisioned accounts of User" + e);
            }
            LOGGER.debug(logp + "END");
            return appInstanceKeys;
    }


Happy Learning!!!

Thursday, 22 March 2018

OIM - How to Fix 'Application Blocked' Import/Export Error.


 

Search 'Java' and open 'Configure Java'.


 

Go to 'Security' tab and then open 'Edit Site List'.



Click on Add.



Add below URLs and then click 'OK':


http://<REPLACE_HOST_NAME>:14000/xlWebApp/DeploymentManager/loadDU.do?method=displayImport

http://<REPLACE_HOST_NAME>:14000/xlWebApp/DeploymentManager/loadDU.do?method=displayExport 






Happy Learning!!!

OIM ADF UI - Code Snippet to get Selected Entitlements form Cart.

    public static final String CART_ITMS_ITR = "CartItemsVOIterator";
    public static final String ENTITY_TYPE = "entityType";
    public static final String ENTITY_KEY = "entityKey";
    public static final String ENTITY_NAME = "entityName";


    public HashMap<String,String> getSelectedEntitlementsFromCart() throws Exception{
        final String logp = CN + " :: getSelectedEntitlementsFromCart - ";
        LOGGER.debug(logp + "START");

        List<Row> cartRows = null;
        HashMap<String,String> entDetails = new HashMap<String,String>();
       
        cartRows = this.getAllRowsOfIterator(CART_ITMS_ITR);

        for (Row cartRow : cartRows) {
            String entityType = (String)cartRow.getAttribute(ENTITY_TYPE);
           
            if(ApprovalConstants.ENTITLEMENT_ENTITY.equalsIgnoreCase(entityType)){
                String entKey = (String)cartRow.getAttribute(ENTITY_KEY);
                String entName = (String)cartRow.getAttribute(ENTITY_NAME);
                entDetails.put(entKey,entName);
            }
        }
       
        LOGGER.debug(logp + "END");
        return entDetails;
    }


Happy Learning!!!

OIM ADF UI - Code Snippet to get Selected Roles form Cart.

    public static final String CART_ITMS_ITR = "CartItemsVOIterator";
    public static final String ENTITY_TYPE = "entityType";
    public static final String ENTITY_KEY = "entityKey";
    public static final String ENTITY_NAME = "entityName";


    public HashMap<String,String> getSelectedRolesFromCart() throws Exception{
        final String logp = CN + " :: getSelectedRolesFromCart - ";
        LOGGER.debug(logp + "START");

        List<Row> cartRows = null;
        HashMap<String,String> roleDetails = new HashMap<String,String>();
       
        cartRows = this.getAllRowsOfIterator(CART_ITMS_ITR);

        for (Row cartRow : cartRows) {
            String entityType = (String)cartRow.getAttribute(ENTITY_TYPE);


            if(ApprovalConstants.ROLE_ENTITY.equalsIgnoreCase(entityType)){
                String roleKey = (String)cartRow.getAttribute(ENTITY_KEY);
                String roleName = (String)cartRow.getAttribute(ENTITY_NAME);
                roleDetails.put(roleKey,roleName);
            }
        }
       
        LOGGER.debug(logp + "END");
        return roleDetails;
    }


Happy Learning!!!

OIM ADF UI - Code Snippet to get Selected Application Instances form Cart.

    public static final String CART_ITMS_ITR = "CartItemsVOIterator";
    public static final String ENTITY_TYPE = "entityType";
    public static final String ENTITY_KEY = "entityKey";
    public static final String ENTITY_NAME = "entityName";


    public HashMap<String,String> getSelectedAppInstFromCart() throws Exception{
        final String logp = CN + " :: getSelectedAppInstFromCart - ";
        LOGGER.debug(logp + "START");

        List<Row> cartRows = null;
        HashMap<String,String> appInstDetails = new HashMap<String,String>();
       
        cartRows = this.getAllRowsOfIterator(CART_ITMS_ITR);

        for (Row cartRow : cartRows) {
            String entityType = (String)cartRow.getAttribute(ENTITY_TYPE);


            if(ApprovalConstants.APP_INSTANCE_ENTITY.equalsIgnoreCase(entityType)){
                String appInstKey = (String)cartRow.getAttribute(ENTITY_KEY);
                String appInstName = (String)cartRow.getAttribute(ENTITY_NAME);
                appInstDetails.put(appInstKey,appInstName);
            }
        }
       
        LOGGER.debug(logp + "END");
        return appInstDetails;
    }


Happy Learning!!!

Wednesday, 21 March 2018

OIM UI Customization - Code Snippet to get Object of any UI Component.

    public UIComponent findComponentFromRoot(String id) {
            UIComponent component = null;
            FacesContext facesContext = FacesContext.getCurrentInstance();
           
            if (facesContext != null) {
                UIComponent root = facesContext.getViewRoot();
                component = findComponent(root, id);
            }

            return component;
     }
   
    public UIComponent findComponent(UIComponent base, String id) {
            if (id.equals(base.getId()))
                return base;

            UIComponent kid = null;
            UIComponent result = null;
            Iterator kids = base.getFacetsAndChildren();
            while (kids.hasNext() && (result == null)) {
                kid = (UIComponent)kids.next();
                if (id.equals(kid.getId())) {
                    result = kid;
                    break;
                }
                result = findComponent(kid, id);
                if (result != null) {
                    break;
                }
            }
            return result;
        }


Happy Learning!!!

OIM UI Customization - Code Snippet to Invoke EL Expression.

public void invokeSubmitButtonEL(ActionEvent event) {
        MethodExpression originalActionListener =
FacesUtils.getMethodExpressionFromEL("#{backingBeanScope.cartReqBean.submitActionListener}", null, new Class[] { ActionEvent.class });
        

        originalActionListener.invoke(FacesUtils.getELContext(), new Object[] { event });
    }


Happy Learning!!!