Advertisement
Guest User

aaa

a guest
Jul 18th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PL/SQL 3.79 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.               if m = ' ' then raise_application_error(-20003, 'NEW password shouldn t contain special character'); end if;
  48.      end loop;
  49.       valid:=TRUE;
  50.       RETURN valid;
  51. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement