Home » SQL & PL/SQL » SQL & PL/SQL » Changes in Password Verification Function (please help urgently) (Oracle 9.2.0.8)
Changes in Password Verification Function (please help urgently) [message #302336] Mon, 25 February 2008 04:54 Go to next message
anjum.suri
Messages: 14
Registered: February 2008
Junior Member
Guys please help I have this code; but I need to modify it to cater my requirements. I need that my password should consist of

One lowercase one uppercase one number
OR
One lowercase one uppercase one litral

create or replace FUNCTION password_workbench_function
(username varchar2,
password varchar2,
old_password varchar2)
RETURN boolean IS
n boolean;
m integer;
total integer :=0;
is_lowerchar boolean;
is_upperchar boolean;
digitarray varchar2(20);
punctarray varchar2(35);
lower_chararray varchar2(30);
upper_chararray varchar2(30);


BEGIN
digitarray:= '0123456789';
lower_chararray:= 'abcdefghijklmnopqrstuvwxyz';
upper_chararray:= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
punctarray:='!"#$%&()``*+,-/:;<=>?_\^{[]}|.~';


-- Check for the minimum length of the password
IF length(password) < 7 THEN
raise_application_error(-20002, 'Password length should not be less than 7');
END IF;


-- 1. Check for the digit
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
total := total + 1;
GOTO findlowerchar;
END IF;
END LOOP;
END LOOP;

-- 2. Check for the lower character

<<findlowerchar>>
is_lowerchar:=FALSE;
FOR i IN 1..length(lower_chararray) LOOP
FOR j IN 1..m LOOP
IF substr(password,j,1) = substr(lower_chararray,i,1) THEN
is_lowerchar:=TRUE;
GOTO findupperchar;

--GOTO endsearch;
END IF;
END LOOP;
END LOOP;

-- 3. Check for the upper character

<<findupperchar>>
is_upperchar:=FALSE;
FOR i IN 1..length(upper_chararray) LOOP
FOR j IN 1..m LOOP
IF substr(password,j,1) = substr(upper_chararray,i,1) THEN
is_upperchar:=TRUE;
total := total + 1;
GOTO findpunct;

--GOTO endsearch;
END IF;
END LOOP;
END LOOP;


-- 4. Check for the punctuation

<<findpunct>>
FOR i IN 1..length(punctarray) LOOP
FOR j IN 1..m LOOP
IF substr(password,j,1) = substr(punctarray,i,1) THEN
total := total + 1;
GOTO endsearch;
END IF;
END LOOP;
END LOOP;

<<endsearch>>

IF total <= 2 THEN
raise_application_error(-20000, 'Must Have at least one character one number OR one number one litral OR one litral one charachter');
END IF;

-- Everything is fine; return TRUE ;
RETURN(TRUE);
END;

Please if someone can help me modifying this code and get it working for me, I will really thankful to you
Re: Changes in Password Verification Function (please help urgently) [message #302345 is a reply to message #302336] Mon, 25 February 2008 05:13 Go to previous messageGo to next message
Michel Cadot
Messages: 64103
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Oracle doesn't make difference between upper and lower case in your version.

Regards
Michel
Re: Changes in Password Verification Function (please help urgently) [message #302352 is a reply to message #302345] Mon, 25 February 2008 05:33 Go to previous messageGo to next message
anjum.suri
Messages: 14
Registered: February 2008
Junior Member
Thanks michel for your quick reply......
Re: Changes in Password Verification Function (please help urgently) [message #302374 is a reply to message #302336] Mon, 25 February 2008 07:05 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
Quote:
GOTO

ouch...

Search for isNumeric or translate. There are far superior ways to do this then how you do it.
Re: Changes in Password Verification Function (please help urgently) [message #302378 is a reply to message #302374] Mon, 25 February 2008 07:16 Go to previous messageGo to next message
Michel Cadot
Messages: 64103
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
This is the standard and delivered Oracle password verification function (but the name).
Seems Oracle guys are not expert in PL/SQL. Smile

Regards
Michel
Re: Changes in Password Verification Function (please help urgently) [message #302386 is a reply to message #302378] Mon, 25 February 2008 07:41 Go to previous message
MarcS
Messages: 312
Registered: March 2007
Location: Antwerp
Senior Member
Michel Cadot wrote on Mon, 25 February 2008 14:16
This is the standard and delivered Oracle password verification function (but the name).
Seems Oracle guys are not expert in PL/SQL. Smile

Regards
Michel



I don't want to perform a code-review on their code, that's for sure Laughing
Previous Topic: TRIGGER FOR CREATE VIEW
Next Topic: Merged: help in joining two tables
Goto Forum:
  


Current Time: Sat Dec 03 18:18:20 CST 2016

Total time taken to generate the page: 0.04849 seconds