Required slight modification to oracle supplied Password Verification Function [message #301798] |
Thu, 21 February 2008 14:54 |
anjum.suri
Messages: 14 Registered: February 2008
|
Junior Member |
|
|
Hi Guys, I need an urgent help in modifying password verification function. My requirement is rather then checking for all three conditions (i.e. for digit, character and litral)I need function to check only two conditions (for e.g. abcdef~# OR 12356#@~ OR acbdjd1234 OR abcd#~123) atleast two condition should met. Please help me writing code, i am too bad in writing program
create or replace FUNCTION password_test_function
(username varchar2,
password varchar2,
old_password varchar2)
RETURN boolean IS
n boolean;
m integer;
differ integer;
isdigit boolean;
ischar boolean;
ispunct boolean;
digitarray varchar2(20);
punctarray varchar2(35);
chararray varchar2(60);
BEGIN
digitarray:= '0123456789';
chararray:= 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
punctarray:='!"#$%&()``*+,-/:;<=>?_\^{[]}|.~';
-- Check for the minimum length of the password
IF length(password) < 7 THEN
raise_application_error(-20002, 'Password length less than 7');
END IF;
-- Check if the password contains at least one letter, one digit and one punctuation mark.
-- 1. Check for the digit
isdigit:=FALSE;
m := length(password);
FOR i IN 1..10 LOOP
FOR j IN 1..m LOOP
IF substr(password,j,1) = substr(digitarray,i,1) THEN
isdigit:=TRUE;
GOTO findchar;
END IF;
END LOOP;
END LOOP;
IF isdigit = FALSE THEN
raise_application_error(-20004, 'Password should contain at least one digit, one character and one punctuation');
END IF;
-- 2. Check for the character
<<findchar>>
ischar:=FALSE;
FOR i IN 1..length(chararray) LOOP
FOR j IN 1..m LOOP
IF substr(password,j,1) = substr(chararray,i,1) THEN
ischar:=TRUE;
GOTO findpunct;
--GOTO endsearch;
END IF;
END LOOP;
END LOOP;
IF ischar = FALSE THEN
raise_application_error(-20004, 'Password should contain at least one digit, one character and one punctuation');
END IF;
-- 3. Check for the punctuation
<<findpunct>>
ispunct:=FALSE;
FOR i IN 1..length(punctarray) LOOP
FOR j IN 1..m LOOP
IF substr(password,j,1) = substr(punctarray,i,1) THEN
ispunct:=TRUE;
GOTO endsearch;
END IF;
END LOOP;
END LOOP;
IF ispunct = FALSE THEN
raise_application_error(-20004, 'Password should contain at least one digit, one character and one punctuation');
END IF;
<<endsearch>>
-- Everything is fine; return TRUE ;
RETURN(TRUE);
END;
|
|
|
|
|
|
|