Total Pageviews

Tuesday, July 21, 2015

OIM plugin to generate custom userid

package oracle.iam.plugins;

import java.util.Locale;
import java.util.Map;

import java.util.Random;
import java.util.logging.Level;
import java.util.logging.Logger;

import oracle.iam.identity.exception.UserNameGenerationException;
import oracle.iam.identity.usermgmt.api.UserNamePolicy;
import oracle.iam.identity.usermgmt.utils.UserNameGenerationUtil;
import oracle.iam.identity.usermgmt.utils.UserNamePolicyUtil;
import oracle.iam.platform.kernel.ValidationFailedException;

public class ShahbazUserNamePolicy implements UserNamePolicy {
    private static final String CLASS_NAME =
        ShahbazUserNamePolicy.class.getSimpleName();

    private static final String policy =
        "ShahbazUserNamePolicy:Validation Failed: ";
    private static Logger logger =
        Logger.getLogger("COM.SHAHBAZ.ShahbazUserNamePolicy");

    public ShahbazUserNamePolicy() {
        super();
    }

    /**
     *This is the main method which gets trigger and generate user name based on requested input data e.g. first name and last name.
     * @param reqData - Map contains request data e.g. first name and last name
     * @return- generated user name
     * @throws ValidationFailedException
     */
    public String getUserNameFromPolicy(Map<String, String> reqData) throws ValidationFailedException {


        String METHOD_NAME = CLASS_NAME + ":" + "getUserNameFromPolicy: ";
        logger.log(Level.FINE, METHOD_NAME + ":START");

        String userName = null;

        String fullName =
            (String)reqData.get("First Name") + " " + (String)reqData.get("Last Name");
        logger.log(Level.FINE,
                   METHOD_NAME + ":Generating Network ID for User Full Name:" +
                   fullName);


        userName = generateNetworkId();
        userName = UserNameGenerationUtil.trimWhiteSpaces(userName);


        try {
            if ((UserNamePolicyUtil.isUserExists(userName)) ||
                (UserNamePolicyUtil.isUserNameReserved(userName))) {

                boolean userNameGenerated = false;

                for (int ix = 1; ix < Integer.MAX_VALUE; ix++) {
                    userName = generateNetworkId();
                    if (UserNameGenerationUtil.isUserNameExistingOrReserved(userName)) {
                        continue;
                    }
                    userNameGenerated = true;
                    break;
                }

                if (!userNameGenerated) {
                    String error_message =
                        "This should never happen. OIM is failed to generate unique user name for " +
                        fullName;
                    showErrorMessagePopup(error_message);
                }
            }
        } catch (UserNameGenerationException e) {
            logger.log(Level.SEVERE,
                       METHOD_NAME + "Exception: " + e.getMessage(), e);
        }

        System.out.println(METHOD_NAME +
                           ":Successfully generated unique network ID for " +
                           fullName + " Network ID: " + userName);
        logger.log(Level.FINE,
                   METHOD_NAME + ":Successfully generated unique network ID for " +
                   fullName + " Network ID: " + userName);
        logger.log(Level.FINE, METHOD_NAME + ":END");

        return userName;
    }

    @Override
    public boolean isUserNameValid(String string, Map<String, String> map) {
        return false;
    }

    @Override
    public String getDescription(Locale locale) {
        return "Generate Unique Network ID n + 5 random numbers + 2 random chars ShahbazUserNamePolicy";
    }

    /**
     *This method is used to generate random netowork id
     * @returns random network id
     */
    private static String generateNetworkId() {

        Random rand = new Random();
        String userid = "n";

        int pick = rand.nextInt(90000) + 10000;
        userid = userid.concat(Integer.toString(pick));

        char c1 = (char)(rand.nextInt(26) + 'a');
        char c2 = (char)(rand.nextInt(26) + 'a');
        userid = userid.concat(Character.toString(c1));
        userid = userid.concat(Character.toString(c2));

        return userid;

    }


    /**
     *This method is used to show error message popup if there is any validation failure.
     * @param errorMessage - Message to be displayed.
     * @throws ValidationFailedException
     */
    private void showErrorMessagePopup(String errorMessage) throws ValidationFailedException {

        String error_message = policy + errorMessage;
        ValidationFailedException exception =
            new ValidationFailedException(error_message);
        exception.setErrorCode("IAM-3050105");
        exception.setErrorData(new Object[] { error_message });
        throw exception;

    }

 /*   public static void main(String[] args) {
        ShahbazUserNamePolicy unamePolicy = new ShahbazUserNamePolicy();
        for (int j = 0; j < 10; j++) {
            System.out.println(unamePolicy.generateNetworkId());
        }
    }
*/
}

Wednesday, July 1, 2015

OPAM 11g certificate import error


OPAM certificate import error

Error:
keytool error: java.io.IOException: Keystore was tampered with, or password was incorrect

Solution:

if you did not setup the keystore password please use default values. here are the

Default Weblogic DemoTrust & DemoIdentity KeyStore passwords 

 

Trust store location
%ORACLE_HOME%/weblogic/wlserver_10.3/ server/lib/DemoTrust.jks
Trust store password
DemoTrustKeyStorePassPhrase
Key store location
%ORACLE_HOME%/weblogic/wlserver_10.3/ server/lib/DemoIdentity.jks
Key store password
DemoIdentityKeyStorePassPhrase
Private key password
DemoIdentityPassPhrase


run the command again with this default value

 

keytool -import -file /oracle/software/repo/filename.pem -keystore /oracle/Middleware/wlserver_10.3/server/lib/DemoTrust.jks -storepass DemoTrustKeyStorePassPhrase -trustcacerts -alias opam

Sunday, June 28, 2015

OIM 11g R2 RCU-6130:Action failed - RCU-6136:Error while trying to execute SQLPlus action

Error
OIM 11g R2  RCU-6130:Action failed - RCU-6136:Error while trying to execute SQLPlus action

Solution:
you are running wrong RCU utility or your RCU files are corrupted. please get the correct version from oracle site and re-run after extracting it.


OIM 11.1.2.2 error while configurint OIM server INST-6193



 Error
 error : INST-6193: The attribute JpsContextName in MBean com.oracle.sdp.messaging:Location=soa_server1,name=ServerConfig

Solution:
most likely you did not applied SOA mandatory patches. Oracle clearly tells that these patches are mandatory. at this stage even if apply SOA patches again, it will not work. i have to reinstall everything again and after applying Mandatory SOA patches i was able to complete installation.


 

OIM 11.1.2.2 dropping repository error

error

oracle.sysman.assistants.rcu.backend.validation.PrereqException: RCU-6083:Failed - Check prerequisites requirement for selected component:MDS 
The schema owner 'PROD_MDS' is connected to the database. Please disconnect and try again.
 
 
solution
restart the database. it will kill the sessions. i have tried to kill the sessions but it did not work. only restart work

OIM 11gR2 steps to configure design console

to configure design console do the following 2 steps

1. run this command to generate .jar file
/app/oracle/wlserver_10.3/server/lib and run "java -jar wljarbuilder.jar"
 
2. Copy wlfullclient.jar to /<OIM_HOME>/designconsole/ext and lib

Monday, June 22, 2015

OIM 11g r2 property to confige delay delete users account in IM

Here is the process if you dont want to delete users from OIM or want to set different delete date than default (same day) after end date(end date disable users account but do not delete).

1. Disable/Delete User After End Date
An end date is defined when a user account is created. This scheduled task disables user accounts for which the end date had passed the current date at the time when the task is run.
  
2. Delayed Delete User
This scheduled task automatically deletes the user whose delete date is before the start of today.
The XL.UserDeleteDelayPeriod system property indicates the number of days after which the user is to be deleted. When the administrator deletes a user, the user is marked in the Disabled state, and the user's 'Automatically Delete On' date is set for the future date after the number of days indicated in the XL.UserDeleteDelayPeriod system property.

if you want to only disable account but we don't want to delete accounts from OIM, you can change system  property value of  "Period to Delay User Delete"  default value is set to "0" it means delete users after disabling(same day) . we can set any value like 365(for one year), 1825(for 5 years) or any value to delete a users account after disabling it.
 
if we don't want to delete any account after disabling it, you can stop "Delayed Delete User" schedule job to run(it is not a good practice to keep the old accounts in OIM).