Showing posts with label 8. Show all posts
Showing posts with label 8. Show all posts

Thursday, February 7, 2013

Oracle Password Verification Function

I am sharing a password verification function that will satisfy most of the common complexity requirements. I have modified default password verification function that is available in ORACLE_HOME by default.

  • It will enforce below:
  • Alphanumeric
  • At least 8 characters
  • Password should not contain username
  • At least one punctuation mark
  • Should be mixed case




CREATE OR REPLACE FUNCTION f_passwordVerification(p_username    IN VARCHAR2,
                                                 p_password    IN VARCHAR2,
                                                 p_oldPassword IN VARCHAR2)
  RETURN BOOLEAN IS

  l_password VARCHAR2(100) := UPPER(p_password);
  l_alpha    BOOLEAN := FALSE;
  l_numeric  BOOLEAN := FALSE;
  ispunct    BOOLEAN := FALSE;
  ismixed    BOOLEAN := FALSE;
  punctarray varchar2(25);
  invalidPassword EXCEPTION;

BEGIN

  ------------------------------------------
  -- Check for alpha and numeric characters.
  FOR j IN 1 .. LENGTH(p_password) LOOP
    IF INSTR('01234567890', SUBSTR(l_password, j, 1)) != 0 THEN
      l_numeric := TRUE;
    ELSIF INSTR('ABCDEFGHIJKLMNOPQRSTUVWXYZ', SUBSTR(l_password, j, 1)) != 0 THEN
      l_alpha := TRUE;
    END IF;
    EXIT WHEN l_alpha AND l_numeric;
  END LOOP;

  IF NOT (l_alpha AND l_numeric) THEN
     raise_application_error(-20020, 'Password should be alphanumeric!!');
  END IF;
  ------------------------------------------

  -- Check length is bewteen 8
  IF LENGTH(l_password) < 8 THEN
    raise_application_error(-20020, 'Password should have atleast 8 characters!!');
  END IF;
  ------------------------------------------

  -- Check length username in contained in password
  IF instr(upper(p_password), upper(p_username)) > 0 THEN
    raise_application_error(-20020, 'Password should not contain username!!');
  END IF;
  ------------------------------------------

  -- Check if the password contains at least one punctuation mark
  punctarray := '!"#$%&()``*+,-/:;<=>?_';

  ispunct := FALSE;
  FOR i IN 1 .. length(punctarray) LOOP
    FOR j IN 1 .. LENGTH(p_password) LOOP
      IF substr(p_password, j, 1) = substr(punctarray, i, 1) THEN
        ispunct := TRUE;
      END IF;
    END LOOP;
  END LOOP;
  IF ispunct = FALSE THEN
    raise_application_error(-20020, 'Password should contain at least one punctuation mark!!');
  END IF;

  ------------------------------------------
  -- check for mixed case
  ismixed := FALSE;

  FOR i IN 1 .. length(p_password) LOOP
    if INSTR('ABCDEFGHIJKLMNOPQRSTUVWXYZ', SUBSTR(p_password, i, 1)) != 0 then
      FOR j IN 1 .. length(p_password) LOOP
        if INSTR('abcdefghijklmnopqrstuvwxyz', SUBSTR(p_password, j, 1)) != 0 then
          ismixed := TRUE;
        end if;
      end loop;
    end if;
  end loop;

  IF ismixed = FALSE THEN
     raise_application_error(-20020, 'Password should be mixed case!!');    
  END IF;

  RETURN(TRUE);

--EXCEPTION
  --WHEN invalidPassword THEN
    --RETURN(FALSE);  
END;
/

Tuesday, March 29, 2011

Exadata: Implementing Database Machine Bundle Patch (8)

According to the readme and companion documents we have prepared below action plan:
(We need to monitor Oracle MOS Note 888828.1 for Exadata supported patch)

** This patch is RAC Rolling Installable for ourcase, as BP5 9870547 is currently installed

-- -------------
-- Prerequisites
-- -------------

1. Inatall latest version of OPatch and dismount all DBFS:

** Logon to each(4) DB Machine and follow below steps:

For GI HOME:
------------
$ echo $ORACLE_HOME
/u01/app/11.2.0/grid

$ mv /u01/app/11.2.0/grid/OPatch /u01/app/11.2.0/grid/OPatch_old
$ unzip p6880880_112000_Linux-x86-64.zip -d /u01/app/11.2.0/grid/
$ cd $ORACLE_HOME/OPatch
$ ./opatch version [to check that the version is 11.2.0.1.4]

For DB HOME:
------------
$ echo $ORACLE_HOME
/u01/app/oracle/product/11.2.0/dbhome_1

$ mv /u01/app/oracle/product/11.2.0/dbhome_1/OPatch /u01/app/oracle/product/11.2.0/dbhome_1/OPatch_old
$ unzip p6880880_112000_Linux-x86-64.zip -d /u01/app/oracle/product/11.2.0/dbhome_1/
$ cd $ORACLE_HOME/OPatch
$ ./opatch version [to check that the version is 11.2.0.1.4]


2. Verify the OUI Inventory:

** Logon to each(4) DB Machine and follow below steps:

For GI HOME:
------------
$ echo $ORACLE_HOME
/u01/app/11.2.0/grid

$cd $ORACLE_HOME/OPatch
$./opatch lsinventory

For DB HOME:
------------
$ echo $ORACLE_HOME
/u01/app/oracle/product/11.2.0/dbhome_1

$ cd $ORACLE_HOME/OPatch
$ ./opatch lsinventory

[If the command errors out, contact Oracle Support]

3. Create a location PATCH_TOP

** Logon All 4 DB Machine and follow below steps:

$ mkdir /u01/app/patch/p10389035_112010_Linux-x86-64
$ export PATCH_TOP=/u01/app/patch/p10389035_112010_Linux-x86-64
$ unzip -d $PATCH_TOP p10389035_112010_Linux-x86-64.zip

4. Determine whether any currently installed one-off patches conflict with the DBM bundle patch8 10389035:
** For Both RDBMS & GI_HOME on all 4 nodes, check below

$ $ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -phBaseDir $PATCH_TOP/10389035
- Conflicts with a patch already applied to the ORACLE_HOME - In this case, stop the patch installation and contact Oracle Support Services
- Conflicts with subset patch already applied to the ORACLE_HOME - In this case, continue with the patch installation because as the new patch

-- ------------
-- Installation
-- ------------
**for all 4 nodes repeat below steps [steps 5 to 7]:

5. Install Patch on GI_HOME
- As oracle run below:
$ export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
$ $ORACLE_HOME/bin/srvctl stop instance -d db_unique_name -n node_name

- As root run below:
# /u01/app/11.2.0/grid/bin/crsctl stop crs
# /u01/app/11.2.0/grid/crs/install/rootcrs.pl -unlock

- As oracle run below:
$ export ORACLE_HOME=/u01/app/11.2.0/grid
$ export PATH=$PATH:$ORACLE_HOME/OPatch
$ which opatch
/u01/app/11.2.0/grid/OPatch/opatch
$ export PATCH_TOP=/u01/app/patch/p10389035_112010_Linux-x86-64
$ cd $PATCH_TOP/10389035
$ opatch apply -local

- As root run below:
# /u01/app/11.2.0/grid/crs/install/rootcrs.pl -patch
# /u01/app/11.2.0/grid/bin/crsctl start crs

- As oracle run below:
$ export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
$ $ORACLE_HOME/bin/srvctl start instance -d db_unique_name -n node_name

6. Install Patch on DB_HOME [Start a new session to unset ENV variable in step:5]
- As oracle run below:
$ export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
$ $ORACLE_HOME/bin/srvctl stop home -o /u01/app/oracle/product/11.2.0/dbhome_1 -s STAT_FILE_LOCATION -n NODE_NAME
$ export PATH=$PATH:$ORACLE_HOME/OPatch
$ which opatch
/u01/app/oracle/product/11.2.0/dbhome_1/OPatch/opatch
$ export PATCH_TOP=/u01/app/patch/p10389035_112010_Linux-x86-64
$ cd $PATCH_TOP/10389035
$ opatch apply -local
$ $ORACLE_HOME/bin/srvctl start home -o /u01/app/oracle/product/11.2.0/dbhome_1 -s STAT_FILE_LOCATION -n NODE_NAME

-- ---------------------------------------------
-- Postinstallation only on a ***single instance
-- --------------------------------------------

7. Reload the packages into the database:

$ sqlplus /nolog
SQL> connect / as sysdba
SQL> @?/rdbms/admin/catbundle.sql exa apply

8. Navigate to the $ORACLE_HOME/cfgtoollogs/catbundle directory
(if $ORACLE_BASE is defined then the logs will be created under $ORACLE_BASE/cfgtoollogs/catbundle),
and check the following log files for any errors like "grep ^ORA | sort -u".
If there are errors, refer to "Known Issues". Here, the format of the is YYYYMMMDD_HH_MM_SS.

catbundle_EXA__APPLY_.log
catbundle_EXA__GENERATE_.log

-- --------------
-- Deinstallation
-- --------------

9. **for all 4 nodes repeat steps 5 to 7 except use "opatch rollback -id 10389035 -local" inetead of "opatch apply -local"