- package com.oimacademy.provision;
- import java.io.Serializable;
- import java.util.Calendar;
- import java.util.Date;
- import java.util.GregorianCalendar;
- import java.util.HashMap;
- import oracle.iam.platform.Platform;
- import oracle.iam.platform.kernel.ValidationException;
- import oracle.iam.platform.kernel.ValidationFailedException;
- import oracle.iam.platform.kernel.spi.ConditionalEventHandler;
- import oracle.iam.platform.kernel.spi.PreProcessHandler;
- import oracle.iam.platform.kernel.vo.AbstractGenericOrchestration;
- import oracle.iam.platform.kernel.vo.BulkEventResult;
- import oracle.iam.platform.kernel.vo.BulkOrchestration;
- import oracle.iam.platform.kernel.vo.EventResult;
- import oracle.iam.platform.kernel.vo.Orchestration;
- import oracle.iam.provisioning.api.ApplicationInstanceService;
- import oracle.iam.provisioning.util.Constants;
- import oracle.iam.provisioning.vo.ApplicationInstance;
- import oracle.iam.provisioning.vo.Entitlement;
- public class AccessPreProcessHandler implements PreProcessHandler, ConditionalEventHandler {
- String handlerName;
- String _appInstName;
- private void log(String msg) {
- System.out.println("[***" +handlerName+ "***]" + msg);
- }
- @Override
- public void initialize(HashMap<String, String> arg0) {
- handlerName = getClass().getSimpleName();
- }
- private boolean checkIfApplicable(AbstractGenericOrchestration orchn){
- String appInstName;
- appInstName = getAppInstanceName(orchn);
- if(appInstName == null)
- return false;
- _appInstName = appInstName;
- log("Enhanced check: AppInstName [" + appInstName + "] is configured for BreakGlass");
- return true;
- }
- private String getAppInstanceName(AbstractGenericOrchestration orchn) {
- HashMap<String, Serializable> orchParams = orchn.getParameters();
- String appInstanceId = (String)orchParams.get(Constants.ORCH_PARAM_APPINSTANCE_KEY);
- ApplicationInstance appInst = getApplicationInstance(appInstanceId);
- if(appInst == null)
- return null;
- log("App instance name for this ENT is: " + appInst.getApplicationInstanceName());
- return appInst.getApplicationInstanceName();
- }
- private ApplicationInstance getApplicationInstance(String appInstanceId){
- ApplicationInstance ai = null;
- try {
- ApplicationInstanceService aiService = getService(ApplicationInstanceService.class);
- if(aiService == null)
- return null;
- if (appInstanceId != null) {
- ai = aiService.findApplicationInstanceByKey(new Long(appInstanceId));
- }
- } catch (Exception e) {
- log("Exception getting AppInst based on Id: " + appInstanceId + ". Error: " + e);
- }
- return ai;
- }
- @Override
- public boolean isApplicable(AbstractGenericOrchestration orchn) {
- return checkIfApplicable(orchn);
- }
- @Override
- public boolean cancel(long arg0, long arg1,
- AbstractGenericOrchestration arg2) {
- return false;
- }
- @Override
- public void compensate(long arg0, long arg1,
- AbstractGenericOrchestration arg2) {
- }
- @Override
- public EventResult execute(long processId, long eventId, Orchestration orchestration) throws ValidationException, ValidationFailedException {
- try {
- log("In execute()");
- if(!checkIfApplicable(orchestration))
- return new EventResult();
- HashMap<String, Serializable> orchParams = orchestration.getParameters();
- Entitlement entitlement = (Entitlement) orchParams.get(Constants.ORCH_PARAM_ENTITLEMENT);
- String entitlementDisplayName = entitlement.getEntitlementValue();
- String beneficiaryKey = (String) orchParams.get(Constants.ORCH_PARAM_BENEFICIARY_KEY);
- HashMap orchParamsChildDataMap = (HashMap)orchParams.get(Constants.ORCH_PARAM_CHILD_DATA);
- String mins = "15";
- if(mins == null) {
- log(entitlementDisplayName + " is setup without prefixing AppInstName tilde. Pls check.");
- return new EventResult();
- }
- Date endDate = getEntitlementEndDate(mins);
- log("Benefeciary: " + beneficiaryKey);
- log("Entitlement assigned: " + entitlementDisplayName);
- log("Entitlement END DATE is set to value: " + endDate);
- orchParamsChildDataMap.put("endDate", endDate);
- return new EventResult();
- } catch (Exception exc) {
- return new EventResult();
- }
- }
- private Date getEntitlementEndDate(String minsToRevoke){
- int mins = Integer.parseInt(minsToRevoke);
- Calendar calender = new GregorianCalendar();
- log("GENERIC CODE - CURRENT DATE: " + calender.getTime());
- calender.add(Calendar.MINUTE, mins);
- return calender.getTime();
- }
- private <T> T getService(Class<T> serviceClass) {
- return Platform.getService(serviceClass);
- }
- @Override
- public BulkEventResult execute(long arg0, long arg1, BulkOrchestration arg2) {
- log("REQUEST CAME IN BULK ORCHESTRATION. NUMBER OF REQUEST PARAMS ARE: " + arg2.getBulkParameters().length);
- return new BulkEventResult();
- }
- }
Oracle Identity Manager(OIM) is the Provisioning Solution from oracle. This page contains an index with references to all OIM related posts in the oracle identity manager Academy blog. The posts included herein are intended to provide oracle identity management customers and developers with technical information about best practices for implementing OIM based solutions.
OIM API For Custom Access Pre Process Handler sample
Subscribe to:
Post Comments (Atom)
-
Connection Related API's : OIM DB Connection/ Data Source connection OIMClient API / OIMConnection API OIM Platform API to getSer...
-
Error : Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory at org.springframewor...
-
In this post, we set the middle name as “MiddleName” if user does not provide middle name during user create operation. Below are high...
No comments:
Post a Comment