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

  1. isdigit:=FALSE;  
  2. :length(password);  
  3. FOR i IN 1..10 LOOP   
  4. FOR j IN 1..m LOOP   
  5. IF substr(password,j,1) = substr(digitarray,i,1) THEN  
  6. isdigit:=TRUE;  
  7. GOTO findchar;  
  8. END IF;  
  9. END LOOP;  
  10. END LOOP;  
  11. IF isdigit = FALSE THEN  
  12. raise_application_error(-20003, 'Password should contain at least one digit, one character and one punctuation');  
  13. END IF; 

-- 2. Check for the character

  1. <<findchar>> 
  2. ischar:=FALSE;  
  3. FOR i IN 1..length(chararray) LOOP   
  4. FOR j IN 1..m LOOP   
  5. IF substr(password,j,1) = substr(chararray,i,1) THEN  
  6. ischar:=TRUE;  
  7. GOTO findpunct;  
  8. END IF;  
  9. END LOOP;  
  10. END LOOP;  
  11. IF ischar = FALSE THEN  
  12. raise_application_error(-20003, 'Password should contain at least one   
  13. digit, one character and one punctuation');  
  14. END IF; 

-- 3. Check for the punctuation

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

2012-10-23 16:12:35

2021-01-03 09:33:48

密码数字身份加密解密

2010-04-07 11:04:52

Oracle用户密码

2012-01-06 10:35:07

2010-11-19 11:51:40

Oracle密码文件

2009-09-27 17:07:04

Hibernate J

2011-08-10 10:30:46

2020-04-01 12:20:15

Linux密码策略

2019-04-09 09:50:00

2009-05-26 15:18:45

2014-06-24 09:24:24

密码身份验证
点赞
收藏

51CTO技术栈公众号