ORACLE密码策略非常重要,下面就为您详细介绍ORACLE密码策略验证程序,如果您对ORACLE密码策略方面感兴趣的话,不妨一看。
密码字符串要求:
— Check if the password is same as the username — Check for the minimum length of the password — Check if the password contains at least one letter, one digit and one — Check if the password differs from the previous password by at least
CREATE OR REPLACE FUNCTION SYS.verify_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(25); chararray varchar2(52);
BEGIN digitarray:= ‘0123456789’; chararray:= ‘abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ’; punctarray:=’!"#$%&()“*+,-/:;<=>?_’;
— Check if the password is same as the username IF NLS_LOWER(password) = NLS_LOWER(username) THEN raise_application_error(-20001, ‘Password same as or similar to user’); END IF;
— Check for the minimum length of the password IF length(password) < 8 THEN raise_application_error(-20002, ‘Password length less than 8’); END IF;
— Check if the password is too simple. A dictionary of words may be — maintained and a check may be made so as not to allow the words — that are too simple for the password. IF NLS_LOWER(password) IN (‘welcome’, ‘database’, ‘account’, ‘user’, ‘password’, ‘oracle’, ‘computer’, ‘abcd’) THEN raise_application_error(-20002, ‘Password too simple’); 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); FORiIN1..10LOOP FORjIN1..mLOOP IFsubstr(password,j,1)=substr(digitarray,i,1)THEN isdigit:=TRUE; GOTOfindchar; ENDIF; ENDLOOP; ENDLOOP; IFisdigit=FALSETHEN raise_application_error(-20003,'Passwordshouldcontainatleastonedigit,onecharacterandonepunctuation'); ENDIF;
— 2. Check for the character
<<findchar>> ischar:=FALSE; FORiIN1..length(chararray)LOOP FORjIN1..mLOOP IFsubstr(password,j,1)=substr(chararray,i,1)THEN ischar:=TRUE; GOTOfindpunct; ENDIF; ENDLOOP; ENDLOOP; IFischar=FALSETHEN raise_application_error(-20003,'Passwordshouldcontainatleastone digit,onecharacterandonepunctuation'); ENDIF;
— 3. Check for the punctuation
<<findpunct>> ispunct:=FALSE; FORiIN1..length(punctarray)LOOP FORjIN1..mLOOP IFsubstr(password,j,1)=substr(punctarray,i,1)THEN ispunct:=TRUE; GOTOendsearch; ENDIF; ENDLOOP; ENDLOOP; IFispunct=FALSETHEN raise_application_error(-20003,'Passwordshouldcontainatleastone digit,onecharacterandonepunctuation'); ENDIF; <<endsearch>> --Checkifthepassworddiffersfromthepreviouspasswordbyatleast --3letters IFold_passwordISNOTNULLTHEN differ:=length(old_password)-length(password); IFabs(differ)<3THEN IFlength(password)<length(old_password)THEN m:=length(password); ELSE m:=length(old_password); ENDIF; differ:=abs(differ); FORiIN1..mLOOP IFsubstr(password,i,1)!=substr(old_password,i,1)THEN differ:=differ+1; ENDIF; ENDLOOP; IFdiffer<3THEN raise_application_error(-20004,'Passwordshoulddifferbyat least3characters'); ENDIF; ENDIF; ENDIF; --Everythingisfine;returnTRUE; RETURN(TRUE); END;