Advertisement
Guest User

aaa

a guest
Jul 18th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PL/SQL 3.74 KB | None | 0 0
  1. CREATE OR REPLACE FUNCTION SYS.VALIDATE_PASSW
  2. (username IN VARCHAR2,
  3.      new_password IN VARCHAR2,
  4.      old_password IN VARCHAR2)
  5.      RETURN BOOLEAN  AS valid BOOLEAN;
  6.      n INTEGER;
  7.      m CHAR(1);
  8.      BEGIN
  9.        IF old_password <> NULL THEN
  10.        IF new_password = old_password
  11.               THEN raise_application_error(-20004, 'New password cannot be equal to the last one');
  12.        END IF;
  13.        END IF;
  14.  
  15.        IF new_password = username THEN
  16.        raise_application_error(-20001, 'Username not found');
  17.        END IF;
  18.        IF LENGTH(new_password) < 8
  19.                THEN raise_application_error(-20002, 'New password should have at least 8 character');
  20.        END IF;
  21.        n:=LENGTH(new_password);
  22.        FOR i IN 1..n  LOOP
  23.                m:=SUBSTR(new_password,i,1);
  24.                IF m = 'ù' THEN raise_application_error(-20003,'New password shouldn''' t contain special character'); end if;
  25.               if m = '!' then raise_application_error(-20003, 'NEW password shouldn''' t contain special character'); END IF;
  26.                IF m = '"' THEN raise_application_error(-20003, 'New password shouldn'''t contain special character'); end if;
  27.               if m = '$' then raise_application_error(-20003, 'NEW password shouldn''' t contain special character'); END IF;
  28.                IF m = '%' THEN raise_application_error(-20003, 'New password shouldn''' t contain special character'); end if;
  29.               if m = '&' then raise_application_error(-20003, 'NEW password shouldn''' t contain special character'); END IF;
  30.                IF m = '(' THEN raise_application_error(-20003, 'New password shouldn''' t contain special character'); end if;
  31.               if m = ')' then raise_application_error(-20003, 'NEW password shouldn''' t contain special character'); END IF;
  32.                IF m = '=' THEN raise_application_error(-20003, 'New password shouldn''' t contain special character'); end if;
  33.               if m = '?' then raise_application_error(-20003, 'NEW password shouldn''' t contain special character'); END IF;
  34.                IF m = '^' THEN raise_application_error(-20003, 'New password shouldn''' t contain special character'); end if;
  35.               if m = '''' then raise_application_error(-20003, 'NEW password shouldn''' t contain special character'); END IF;
  36.                IF m = '|' THEN raise_application_error(-20003, 'New password shouldn''' t contain special character'); end if;
  37.               if m = '.' then raise_application_error(-20003, 'NEW password shouldn''' t contain special character'); END IF;
  38.                IF m = ',' THEN raise_application_error(-20003, 'New password shouldn''' t contain special character'); end if;
  39.               if m = ';' then raise_application_error(-20003, 'NEW password shouldn''' t contain special character'); END IF;
  40.                IF m = ':' THEN raise_application_error(-20003, 'New password shouldn''' t contain special character'); end if;
  41.               if m = 'º' then raise_application_error(-20003, 'NEW password shouldn''' t contain special character'); END IF;
  42.                IF m = '*' THEN raise_application_error(-20003, 'New password shouldn''' t contain special character'); end if;
  43.               if m = '+' then raise_application_error(-20003, 'NEW password shouldn''' t contain special character'); END IF;
  44.                IF m = '#' THEN raise_application_error(-20003, 'New password shouldn''' t contain special character'); end if;
  45.               if m = '@' then raise_application_error(-20003, 'NEW password shouldn''' t contain special character'); END IF;
  46.                IF m = ' ' THEN raise_application_error(-20003, 'New password shouldn''' t contain special character'); end if;
  47.      end loop;
  48.       valid:=TRUE;
  49.       RETURN valid;
  50. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement