ORACLE密码策略验证程序
创始人
2024-07-18 00:01:11
0

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. m := 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. <
  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. <
  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. <
  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. m := length(password);  
  25. ELSE  
  26. m := 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创建实例的过程

 

相关内容

热门资讯

如何允许远程连接到MySQL数... [[277004]]【51CTO.com快译】默认情况下,MySQL服务器仅侦听来自localhos...
如何利用交换机和端口设置来管理... 在网络管理中,总是有些人让管理员头疼。下面我们就将介绍一下一个网管员利用交换机以及端口设置等来进行D...
施耐德电气数据中心整体解决方案... 近日,全球能效管理专家施耐德电气正式启动大型体验活动“能效中国行——2012卡车巡展”,作为该活动的...
Windows恶意软件20年“... 在Windows的早期年代,病毒游走于系统之间,偶尔删除文件(但被删除的文件几乎都是可恢复的),并弹...
20个非常棒的扁平设计免费资源 Apple设备的平面图标PSD免费平板UI 平板UI套件24平图标Freen平板UI套件PSD径向平...
德国电信门户网站可实时显示全球... 德国电信周三推出一个门户网站,直观地实时提供其安装在全球各地的传感器网络检测到的网络攻击状况。该网站...
为啥国人偏爱 Mybatis,... 关于 SQL 和 ORM 的争论,永远都不会终止,我也一直在思考这个问题。昨天又跟群里的小伙伴进行...
《非诚勿扰》红人闫凤娇被曝厕所... 【51CTO.com 综合消息360安全专家提醒说,“闫凤娇”、“非诚勿扰”已经被黑客盯上成为了“木...