ORACLE 密碼驗證函式
點選(此處)摺疊或開啟
-
CREATE OR REPLACE FUNCTION 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) < 4 THEN
-
raise_application_error(-20002, 'Password length less than 4');
-
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);
-
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;
-
-- 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;
-
-- 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
-
m := length(password);
-
ELSE
-
m := 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;
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26250550/viewspace-2131237/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 自定義密碼驗證函式密碼函式
- Oracle 密碼驗證方式Oracle密碼
- Oracle 8i 密碼驗證Oracle密碼
- 強密碼驗證正規表示式密碼
- oracle 開啟複雜密碼驗證Oracle密碼
- ORACLE密碼錯誤驗證延遲Oracle密碼
- oracle本地驗證和密碼檔案Oracle密碼
- 密碼檢驗函式verify_function密碼函式Function
- Oracle資料庫密碼延遲驗證Oracle資料庫密碼
- 啟用oracle資料庫密碼函式Oracle資料庫密碼函式
- 生成密碼函式密碼函式
- oracle 11g 密碼延遲驗證問題Oracle密碼
- ACCESS 密碼驗證/文字驗證中的小坑密碼
- 驗證virtual函式的原理函式
- JS函式驗證總結JS函式
- ORACLE 11g的密碼錯誤延時驗證Oracle密碼
- Oracle11g新增密碼錯誤延遲驗證Oracle密碼
- 無密碼驗證:客戶端密碼客戶端
- orapwd建立密碼及驗證方法密碼
- 正規表示式驗證密碼格式和長度程式碼例項密碼
- mssql sqlserver 驗證整型函式分享SQLServer函式
- 通用表單驗證函式-FormCheckJavaScriptFunction函式ORMJavaScriptFunction
- 使用 bcrypt 函式生成密碼函式密碼
- 現代密碼學之加密雜湊函式與訊息認證碼密碼學加密函式
- 賬戶、密碼格式···正則驗證密碼
- php 驗證格式的函式總結PHP函式
- Oracle密碼規則及資源限制函式指令碼utlpwdmg.sqlOracle密碼函式指令碼SQL
- JQuery表單驗證(包括:使用者名稱,手機號,密碼,確認密碼,驗證碼60s)jQuery密碼
- 正規表示式驗證密碼包含數字字母6到10位密碼
- jquery 驗證密碼一致性jQuery密碼
- 取消 11G延遲密碼驗證密碼
- 使用Docker部署帶密碼驗證的RedisDocker密碼Redis
- 安裝Oracle RAC時,不能驗證ASMSNMP密碼問題的解決OracleASM密碼
- Flutter 密碼輸入框 驗證碼輸入框Flutter密碼
- oracle實驗記錄 (函式index)Oracle函式Index
- 密碼複雜度設定函式密碼複雜度函式
- swift 郵箱、密碼、手機號、身份證驗證正則Swift密碼
- Oracle11G密碼延遲驗證導致的系統HANG住Oracle密碼