Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE OR REPLACE FUNCTION SYS.VALIDATE_PASSW
- (username IN VARCHAR2,
- new_password IN VARCHAR2,
- old_password IN VARCHAR2)
- RETURN BOOLEAN AS valid BOOLEAN;
- n INTEGER;
- m CHAR(1);
- BEGIN
- IF old_password <> NULL THEN
- IF new_password = old_password
- THEN raise_application_error(-20004, 'New password cannot be equal to the last one');
- END IF;
- END IF;
- IF new_password = username THEN
- raise_application_error(-20001, 'Username not found');
- END IF;
- IF LENGTH(new_password) < 8
- THEN raise_application_error(-20002, 'New password should have at least 8 character');
- END IF;
- n:=LENGTH(new_password);
- FOR i IN 1..n LOOP
- m:=SUBSTR(new_password,i,1);
- IF m = 'ù' THEN raise_application_error(-20003,'New password shouldn''' t contain special character'); end if;
- if m = '!' then raise_application_error(-20003, 'NEW password shouldn''' t contain special character'); END IF;
- IF m = '"' THEN raise_application_error(-20003, 'New password shouldn'''t contain special character'); end if;
- if m = '$' then raise_application_error(-20003, 'NEW password shouldn''' t contain special character'); END IF;
- IF m = '%' THEN raise_application_error(-20003, 'New password shouldn''' t contain special character'); end if;
- if m = '&' then raise_application_error(-20003, 'NEW password shouldn''' t contain special character'); END IF;
- IF m = '(' THEN raise_application_error(-20003, 'New password shouldn''' t contain special character'); end if;
- if m = ')' then raise_application_error(-20003, 'NEW password shouldn''' t contain special character'); END IF;
- IF m = '=' THEN raise_application_error(-20003, 'New password shouldn''' t contain special character'); end if;
- if m = '?' then raise_application_error(-20003, 'NEW password shouldn''' t contain special character'); END IF;
- IF m = '^' THEN raise_application_error(-20003, 'New password shouldn''' t contain special character'); end if;
- if m = '''' then raise_application_error(-20003, 'NEW password shouldn''' t contain special character'); END IF;
- IF m = '|' THEN raise_application_error(-20003, 'New password shouldn''' t contain special character'); end if;
- if m = '.' then raise_application_error(-20003, 'NEW password shouldn''' t contain special character'); END IF;
- IF m = ',' THEN raise_application_error(-20003, 'New password shouldn''' t contain special character'); end if;
- if m = ';' then raise_application_error(-20003, 'NEW password shouldn''' t contain special character'); END IF;
- IF m = ':' THEN raise_application_error(-20003, 'New password shouldn''' t contain special character'); end if;
- if m = 'º' then raise_application_error(-20003, 'NEW password shouldn''' t contain special character'); END IF;
- IF m = '*' THEN raise_application_error(-20003, 'New password shouldn''' t contain special character'); end if;
- if m = '+' then raise_application_error(-20003, 'NEW password shouldn''' t contain special character'); END IF;
- IF m = '#' THEN raise_application_error(-20003, 'New password shouldn''' t contain special character'); end if;
- if m = '@' then raise_application_error(-20003, 'NEW password shouldn''' t contain special character'); END IF;
- IF m = ' ' THEN raise_application_error(-20003, 'New password shouldn''' t contain special character'); end if;
- end loop;
- valid:=TRUE;
- RETURN valid;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement