ORACLE密码策略验证程序

数据库 Oracle
ORACLE数据库的密码策略关系到数据库的安全,下文对密码策略验证程序作了详细的介绍,希望对您能够有所帮助。

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;  
: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(-20003, 'Password should contain at least one digit, one character and one punctuation');  
END IF; 
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.

-- 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;  
END IF;  
END LOOP;  
END LOOP;  
IF ischar = FALSE THEN  
raise_application_error(-20003, 'Password should contain at least one   
digit, one character and one punctuation');  
END IF; 
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.

-- 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(-20003, 'Password should contain at least one   
digit, one character and one punctuation');  
END IF;  
 
<<endsearch>> 
-- Check if the password differs from the previous password by at least  
-- 3 letters  
IF old_password IS NOT NULL THEN  
differ :length(old_password) - length(password);  
 
IF abs(differ) < 3 THEN  
IF length(password) < length(old_password) THEN  
:length(password);  
ELSE  
:length(old_password);  
END IF;  
 
differ :abs(differ);  
FOR i IN 1..m LOOP  
IF substr(password,i,1) != substr(old_password,i,1) THEN  
differ :differ + 1;  
END IF;  
END LOOP;  
 
IF differ < 3 THEN  
raise_application_error(-20004, 'Password should differ by at   
least 3 characters');  
END IF;  
END IF;  
END IF;  
-- Everything is fine; return TRUE ;   
RETURN(TRUE);  
END;   
 
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.

 

 

 

【编辑推荐】

Oracle密码文件管理

教您如何检查oracle死锁

Oracle存储过程读写文件

Oracle物化视图创建全过程

ORACLE创建实例的过程

 

责任编辑:段燃 来源: 互联网
相关推荐

2009-11-18 09:52:21

Oracle密码验证

2013-03-12 09:51:02

2015-12-02 16:46:20

2015-10-28 15:35:33

Oracle策略

2022-06-06 06:10:00

密码验证安全

2010-01-30 11:23:59

2009-11-19 15:32:50

Oracle索引

2010-02-22 14:53:17

WCF用户密码

2012-04-10 09:36:58

2010-04-07 11:04:52

Oracle用户密码

2012-10-23 16:12:35

2021-01-03 09:33:48

密码数字身份加密解密

2010-11-19 11:51:40

Oracle密码文件

2010-10-26 13:17:28

oracle备份策略

2009-09-27 17:07:04

Hibernate J

2009-11-06 17:21:36

验证Oracle SQ

2012-01-06 10:35:07

2020-04-01 12:20:15

Linux密码策略

2011-08-10 10:30:46

2019-04-09 09:50:00

点赞
收藏

51CTO技术栈公众号