How to compare Entering Password with existing encrypted pasword in APEX4.1

Hello everyone,
In my application am using the following package,
create or replace PACKAGE BODY app_security_pkg
AS
PROCEDURE login
           p_uname IN VARCHAR2
          ,p_password IN VARCHAR2
          ,p_session_id IN VARCHAR2
          ,p_flow_page IN VARCHAR2
IS
lv_goto_page NUMBER DEFAULT 1;
BEGIN
-- This logic is a demonstration of how to redirect
-- to different pages depending on who successfully
-- authenticates. In my example, it simply demonstrates
-- the ADMIN user going to page 1 and all other users going
-- to page 2. Add you own logic here to detrmin which page
-- a user should be directed to post authentication.
IF UPPER(p_uname) = 'ADMIN'
THEN
  lv_goto_page := 1;
ELSE
  lv_goto_page := 2;
END IF;
APEX_UTIL.SET_SESSION_STATE('FSP_AFTER_LOGIN_URL');
wwv_flow_custom_auth_std.login
  p_uname => p_uname,
  p_password => p_password,
  p_session_id => p_session_id,
  p_flow_page => p_flow_page || ':' || lv_goto_page
EXCEPTION
WHEN OTHERS
THEN
RAISE;
END login;
PROCEDURE add_user
p_username IN VARCHAR2
,p_password IN VARCHAR2
AS
BEGIN
INSERT INTO app_users (username, PASSWORD)
    VALUES (UPPER (p_username),
        get_hash (TRIM (p_username), p_password));
COMMIT;
EXCEPTION
WHEN OTHERS
THEN
ROLLBACK;
RAISE;
END add_user;
-- Function to Perform a oneway hash of the users
-- passwords. This cannot be reversed. This exmaple
-- is a very week hash and if been used on a production
-- system, you may want to use a stronger hash algorithm.
-- Read the Documentation for more info on DBMS_CRYPTO as
-- this is the supported package from Oracle and
-- DBMS_OBFUSCATION_TOOLKIT is now depricated.
FUNCTION get_hash (p_username IN VARCHAR2, p_password IN VARCHAR2)
RETURN VARCHAR2
AS
BEGIN
RETURN DBMS_OBFUSCATION_TOOLKIT.md5 (
input_string => UPPER (p_username)
                || '/'
                || UPPER (p_password));
END get_hash;
PROCEDURE valid_user2 (p_username IN VARCHAR2, p_password IN VARCHAR2)
AS
v_dummy VARCHAR2 (1);
BEGIN
SELECT '1'
INTO v_dummy
FROM app_users
WHERE UPPER (username) = UPPER (p_username)
AND PASSWORD = get_hash (p_username, p_password);
EXCEPTION
WHEN NO_DATA_FOUND
THEN raise_application_error (-20000, 'Invalid username / password.');
END valid_user2;
FUNCTION valid_user (p_username IN VARCHAR2, p_password IN VARCHAR2)
RETURN BOOLEAN
AS
BEGIN
valid_user2 (UPPER (p_username), p_password);
RETURN TRUE;
EXCEPTION
WHEN OTHERS
THEN RETURN FALSE;
END valid_user;
END app_security_pkg;Here the ADD_USER Procedure will convert the password and stores into the app_users Table in encrypted form.
In my application the users can change their password,
so I need to compare the entering password in the Current_password field with the Encrypted password in the app_users table,
so I used the following code,
declare
  l_x varchar2(30);
begin
  select username into l_x
        from app_users
    where upper(username) = upper(:P7_USERNAME)
      and password = :P7_CURRENT_PASSWORD;
  return (true);
exception
  when no_data_found then
    return (false);
end;This code is working fine when the password is stored without encryption,but after encryption it showing error,
because the entering password is simply password and not encrypted so both are different even if the user enters right password,
Please tel me how to encrypt the entering password to compare with existing encrypted password.
Thank you,
Regards,
gurujothi.

Dear Sunil and vdotcherukuri     ,
Thank you for your reply as per your suggestion I tried the following code and its working fine.
declare
  l_x varchar2(30);
begin
  select username into l_x
        from app_users
    where upper(username) = upper(:P7_USERNAME)
      and password = app_security_pkg.get_hash (TRIM (:p7_username), :P7_CURRENT_PASSWORD);
  return (true);
exception
  when no_data_found then
    return (false);
end;Thank you,
Regards,
Gurujothi.

Similar Messages

  • How to compare the texted password with the encrypted password of dba_users

    Hi,
    I have Oracle 10g in my system. I know dba_users table has information of all the created users of the oracle, along with their encrypted passwords.If I want to make a login page based on this table ,how could I compare the password in that case?
    In above situation, I am getting the username with the regular texted password for authentication check. How can we checked this texted password with the encrypted password of dba_users, for the respective username?
    Your input would be appreciated.

    Try use the username/password from login page to create an connection to database.

  • How to migrate Apex users with existing passwords.

    Hi Guys,
    Our apex env finally getting a upgrade from 3.1.1 to 4.1.1 (I know, it's been overdue for years)
    Some of our apps use 'Application Express' authentication, and have few hundreds users in Apex (and users belong to diff user groups).
    The issue is, the 4.1.1 env is set up on a brand new server and DB, we want to migrate these users with their existing passwords from the 3.1.1 env.
    I tried exporting the workspace, and the users are exported as below,
         begin
         wwv_flow_fnd_user_api.create_fnd_user (
         p_user_id => '10592934818556549584',
         p_user_name => 'TEST',
         p_first_name => 'a',
         p_last_name => 'b',
         p_description => '',
         p_email_address=> '[email protected]',
         p_web_password => 'E92903DEAD135E6E86BD6B64544D2BD9',
         p_web_password_format => 'HEX_ENCODED_DIGEST_V2',
         p_group_ids => '10592435401495787816:',
         p_developer_privs=> '',
         p_default_schema=> 'TEST',
         p_account_locked=> 'N',
         p_account_expiry=> to_date('201212040000','YYYYMMDDHH24MI'),
         p_failed_access_attempts=> 0,
         p_change_password_on_first_use=> 'Y',
         p_first_password_use_occurred=> 'N',
         p_allow_access_to_schemas => '');
         end;
    when I run this in 4.1.1 I had to modify it to the new format as below,
    also changed the p_group_ids to new user group but kept the password the same
         begin
         wwv_flow_fnd_user_api.create_fnd_user (
         p_user_id => '',
         p_user_name => 'TEST',
         p_first_name => 'a',
         p_last_name => 'b',
         p_description => '',
         p_email_address=> '[email protected]',
         p_web_password => 'E92903DEAD135E6E86BD6B64544D2BD9',
         p_web_password_format => 'HEX_ENCODED_DIGEST_V2',
         p_group_ids => '1399416797653068:',
         p_developer_privs=> '',
         p_default_schema=> 'TEST',
         p_account_locked=> 'N',
         p_account_expiry=> to_date('201209041006','YYYYMMDDHH24MI'),
         p_failed_access_attempts=> 0,
         p_change_password_on_first_use=> 'Y',
         p_first_password_use_occurred=> 'N',
    p_allow_app_building_yn=> 'N',
    p_allow_sql_workshop_yn=> 'N',
    p_allow_websheet_dev_yn=> 'N',
    p_allow_team_development_yn=> 'N',     
    p_allow_access_to_schemas => '');
         end;
    the result was that the user is created fine, but the password is not valid.
    Anyone knows how to export apex users with existing password to a new server?
    Thanks.
    Edited by: Danny on 3/12/2012 20:51

    Hi,
    Not sure why you say
    when I run this in 4.1.1 I had to modify it to the new format as below, If you just run the workspace export sql it should create the Workspace, Groups and Users
    The signature of the procedure is below. See the highlighted lines.
    procedure create_fnd_user (-- Description:
    -- This procedure allows for programatic and bulk creation of users.
    -- Example:
    -- From sqlplus logged in as the privileged flows user, first
    -- ensure that the security group id is set properly, then create
    -- your users.
    <b> -- begin wwv_flow_security.g_security_group_id := 20; end;</b>
    -- begin
    -- for i in 1..10 loop
    -- wwv_flow_fnd_user_api.create_fnd_user(
    -- p_user_name => 'USER_'||i,
    -- p_email_address => 'user_'||i||'@mycompany.com',
    -- p_web_password => 'user_'||i) ;
    -- end loop;
    -- commit;
    -- end;
    -- Arguments:
    -- p_user_id numeric primary key of user
    -- p_user_name the username the user uses to login
    -- p_first_name informational only
    -- p_last_name informational only
    <b> -- p_web_password the unencrypted password for the new user</b>
    -- p_group_ids A colon delimited list of group IDs from the table wwv_flow_fnd_user_groups
    -- p_developer_privs A colon delmited list of developer privs, privs include:
    -- ADMIN:BROWSE:CREATE:DATA_LOADER:DB_MONITOR:EDIT:HELP:MONITOR:SQL:USER_MANAGER
    -- p_default_schema A valid oracle schema that is the default schema for use in browsing and
    -- creating flows
    -- p_allow_access_to_schemas A colon delimited list of oracle schemas that the user is allowed to
    -- parse as. If null the user can parse as any schema available to the company.
    -- This does not provide privilege it only resticts privilege, so listing a schema
    -- does not provide the privilege to parse as a schema, it only restricts that user
    -- to that list of schemas.
    -- p_attributes_XX These attributes allow you to store arbitary information about a given user.
    -- They are for use by flow developers who want to extend user information.
    <b> -- p_web_password_format Identifies the format of the web password.
    -- The range of values is CLEAR_TEXT, HEX_ENCODED_DIGEST, DIGEST </b>
    -- p_person_type "E" marks the user as external
    -->
    Note there is no HEX_ENCODED_DIGEST, DIGEST_V2 listed. It may work, but not obvious from the signature.
    Cheers,

  • How do you change password with out using cd on imac?

    How do you change password with out cd on imac?

    Please read:
    http://osxdaily.com/2011/08/24/reset-mac-os-x-10-7-lion-password/

  • Can anybody tell how to compare two documents with two pointers controlled with the same mouse

    can anybody tell how to compare two documents with two pointers controlled with the same mouse ??

    I saw what I need but in a game to find the differences between two photos (two screens, two pointers controlled by one mouse), and I need a program to make the same thing   (compare a chosen files)

  • I can receive email from my regulare email account but I cannot send. I get an error message that I have to go to settings and enter a password, but when I do the password is there. I have tried re-entering password with the same result.How can I send?

    I am able to receive email, but when I try to reply I get an error message to go to settings and enter a password. My password is there and I have re-entered it with no success. How can I enable send feature from my I Phone?

    You have to go to SMTP settings for your email account and enter a password there. Sended and receiving are two different activities managed by 2 differet servers, and each may require a separate user ID and password.

  • How to compare current date with past date

    Sample code for comparing current date with past date
    i dont want to Calender.set method to compare it.
    How can i do it?

    PLEASE stay with ONE thread:
    http://forum.java.sun.com/thread.jspa?threadID=5143991&tstart=0

  • How to compare Sale data with Previous data

    Hi Guys,
        Any one tell me how we will compare Sales data with Last year Sale data. Is there any T.Code or any kind of Report in the SAP. If available please suggest the same.
    Thanks & regards,
    Naveen Bhatia

    Hi Naveen,
    Did yo ucheck t-code SD01
    Regards
    Rohit.

  • How to compare single value with multiple values

    In my query I have something like this:
    A.SOR_CD=B.SOR_CODE where A and B are 2 different tables. This condition is in the where clause. The column in table A has single values but some values in table B have multiple comma separated values (822, 869, 811, ..).  I want to match this single
    value on the left side with each of the comma separated values. Please let me know how will I be able to do it. The number of comma separated values on the right side may vary.

    Hi MadRad123,
    According to your description, you want to compare single value with multiple values in your query. Right?
    In this scenario, the table B has comma separated values, however those comma separated values are concatenated into a string. So we can use charindex() function to return the index of the table A value. And use this index as condition in
    your where clause. See the sample below:
    CREATE TABLE #temp1(
    ID nvarchar(50),
    Name nvarchar(50))
    INSERT INTO #temp1 VALUES
    ('1','A'),
    ('2','A'),
    ('3','A'),
    ('4','A'),
    ('5','A')
    CREATE TABLE #temp2(
    ID nvarchar(50),
    Name nvarchar(50))
    INSERT INTO #temp2 VALUES
    ('1','a,A'),
    ('2','A,B'),
    ('3','c'),
    ('4','A,C'),
    ('5','d')
    select * from #temp1 a inner join #temp2 b on a.ID=b.ID
    where CHARINDEX(a.Name,b.Name)>0
    The result looks like below:
    Reference:
    CHARINDEX (Transact-SQL)
    If you have any question, please feel free to ask.
    Best Regards,
    Simon Hou

  • Iphone is disabled and old will allow emergency phone calls, how can I enter password

    iphone is disables and will only allow emergency phone calls, how can I enter a password to unlock it?

    Just restore it by putting the phone into DFU mode. You will loose every thing but it will be back to normal pal
    Press and hold power and home button together for 10 seconds by connecting it to cable, leave the power button but keep holding the home button for 30 seconds and it will go into DFU mode. Open Itunes and just perform a restore or update

  • How to compare 2 arrays with different operator options using parameters in Teststand

    Pls let me know how to compare 2 arrays using different operators like <= or >= or ==......

     I am using TS 2010. FYI
    ex:
    Array XX [ A_Temp,
                   B_Temp,
                   C_Oil Pressure,
                   D_Oilpressure,
    Note : A_Temp, B_Temp,C_Oil Pressure,D_Oilpressure all these parameters will be getting  numerical values (dynamically) from the simulink models and also in future I may need to add parameters to this array.
    Array YY [A_Temp_1,
                   B_Temp_2,
                   C_Oil Pressure_3,
                   D_Oilpressure_4,
    Note : A_Temp_1, B_Temp_2,C_Oil Pressure_3,D_Oilpressure_4 all these parameters will be getting  numerical values (dynamically) from the simulink models
    So my question :
    I would like to verify A_Temp >= A_Temp_1
                                B_Temp >= B_Temp_2
                                C_Oil Pressure  >= C_Oil Pressure_3  etc

  • Just received update 7.1.1. How do I enter passcode with letters

    Just received advice of update 7.1.1
    I am being asked to enter Passcode using a telephone keypad. My passcode has letters. How do I enter them?

    I have only ever used my 10 digit code which contains mainly words. Never used a all numbered code.

  • USB External HD with WRT350N - How to Avoid Entering Password to Access?

    I just purchased my new WRT350N primarily to use the storage link feature. I have connected a 300 GB HP personal media drive (USB) to the router. The router shows up on my home network just fine. I have one wired desktop and one wireless desktop (both XP SP2) and one wireless laptop (Vista Ultimate 64-bit). When I connect to the router in XP ("My Network Places") or in Vista ("Network"), I have to enter a username (default "admin") and password (default "admin") to access the router and get to my external HD. I use the HD to, among other things, store my Thunderbird mail profile (which includes all my e-mail folders) and my KeyPass password database, as well as other applications that I want to use from my various computers. Having to use a password means I can't connect to the drive on start-up, use shortcuts to applications on the HD, etc. It's a pain in the butt, basically. Is there any way to configure the router to allow access to it, and my external HD, without the password (e.g., MAC filters)? Any other workaround's? Many thanks.

    dRdoS7 wrote:
    Hi,
    Have you tried enabling "Reconnect at logon" when mapping the drive?
    dRdoS7
    Yes, I have tried the "Reconnect at Logon" switch selected. What happens then is that I get an error message on startup stating "Unable to Connect Some Network Drives" or something similar. I still have to use the username and password to get through the router to my external drive. I just got off the phone with Linksys tech support, a nice, knowledgeable Indian fellow who affirmed that the router could not be accessed without having to sign in. He said it was "for my security." It strikes me as odd that you can completely disable the security features of your entire wireless network by simply adjusting some settings in the router setup. But you CANNOT disable the security feature of the router access! How weird can you get - Linksys allows you to completely leave your network unprotected, but by god, you're not gonna get into that router!!! He said all of the USB-equipped routers have the same feature - Netgear, Belkin, D-link ... I am SO frustrated! I bought, and returned, the Belkin "wireless" network hub before I got the 350N. It was not possible to run Thunderbird using a profile on the HD (connected to the hub USB) because of severe stability issues. Guess what? Same thing happens when I run it through the Linksys router! Firefox simply shuts down. There was never an issue when I ran Firefox on the external HD when it was connected to my desktop. So, the search goes on - trying to find a way to access my external HD without having to have it connected to a powered PC. What a drag ...

  • How to use Portal SSO with existing BSP application

    Hi all,
    we run SAP EP 6.0 here and have a single start BSP page of
    an application integrated with the SAP appintegrator for BSP. The rest of the existing BSP application still uses
    the login functionality based on CL_BSP_LOGIN_APPLICATION
    and is not integrated in the portal.
    Problem: If a user directly accesses one of the "old" BSP pages, he should be redirected to the portal to auth. him via SSO and afterwards the original BSP page with all its parameters should be processed.
    How to deal with that? Is there a similar mechanism like with the BSP_LOGIN_APP in between for the SAP EP?
    Thanks for your help!
    -RAINER-

    I think that doesnt solve the problem.
    I have 2 systems: SAP ECC with all BSPs and the portal on another system. So I have to entry points: Via portal using the appIntegrator BSP or directly to the ECC.
    As-is: If the auth. for the BSP appl. fails, the user is re-directed via the error page given in the service (SICF)
    to a BSP login app. and from there to the requested page.
    No portal in this concept.
    Must-be: A user is still able to directly access a BSP on the SAP ECC by entering the URL in the browser. It's not a must entering via the portal first.
    So when the login failed on the ECC (no SSO ticket), he should be redirected to the portal for getting his SSO.
    After he signed in successfully the user will be forwarded to the BSP page he entered in the browser the first place.
    I can't see a way to use the URL iView. I am thinking of simply changing the login mechanism of the BSP using the portal login functionality.
    The link you gave me offers an implementation of CL_ICF_SYSTEM_LOGIN. Any ideas?
    Regards,
    -RAINER-

  • Entering password for an encrypted time machine backup

    During a recent hard disk failure. I have had to restore my system from a time machine backup.
    I keep this backup on an encrytped external drive.
    I booted into recovery mode,  erased the drive to fix the hard disk errors (it wasn't repairable).
    Then I tried to mount the encrypted drive for recovery.
    Everytime I entered the password, a 50 character string with all character types it failed to unlock.
    I tried the disk on another mac and it unlocked fine.
    Then I noticed that the recovery mode defaults to US Input Source and I have a UK macbook (2007).
    So I changed the input source to British.
    Still the password doesn't work.
    Then I noticed that once you click unlock the password entry box defaults to US again and doesn't let you change it.
    Fortunately UK keyboard isn't very different to US and I figured out that the only difference was to use Shift 3 for # rather than option 3 that we normally use on the UK keyboard.
    Is there a work around this?  Is it a known issue. 
    Glad I don't have an arabic or russian keyboard :-)

    File a bug report with Apple.

Maybe you are looking for

  • HP P1102W Smart Install not showing up

    Hello HP!  I've aquired a new HP P1102W and I'm facing some installation problems.  My desktop runs on Windows 7 x64, including all updates, I do not have an antivirus or firewall, I do not have other 3rd party applications. Only things installed are

  • E7 and Microsoft Apps

    I noticed that Nokia Suite is no longer listing Microsoft Apps as a 'Software Update'. I did not install it when it first came up, as I do not think I need it. Is this suite being phased out for the E7 since it is no longer listed as an update?

  • How to call the column names into the prompt and display values dynamically

    Hi, i have a typical requirement where I have to call 3 columns into the AGE Prompt (I know we can use the Column Selector to call the columns) .Below is the Screen Shot. !http://i46.tinypic.com/2qjfukh.jpg! 2nd Requirement) The three columns I have

  • Menu not showing - Process external statement.

    Hi am using the superuser manager login, In banking modules, banks and external reconcilation, process external statement will come. its coming other professional user login, but its not showing in manager super user login. What will be the issue. Re

  • Zen V JOYSTICK PROBLEM

    Bought my teenage daughter a Zen V for Christmas 2006. Seemed like a good deal for the money?since this was her first experience with an mp3 player, but now I seriously?question if?perhaps?I should have spent a little bit more?money for a better qual