How to use your own database with your users to authenticate in a Web app?

Hello, everybody!
I'm starting to write my first web application and I'm going to use JSF, JPA and EJB3 in this application. One of the first things that I have to do on it is the authentication part where I'll have a page with a user name and a password for the user to login. So, as I'm new to all this in Java (I've already implemented this on .NET in the past), I was studying the Java EE 5 Tutorial, especifically the section "Example: Using Form-Based Authentication with a JSP Page". But I saw that the users that the sample application uses come from the file realm on the Application Server. The users are created there and assigned a name, a password and a group. After the users are in the Application Server we can simply uses forms authentication declaratively in the deployment descriptor (web.xml).
But the problem is that this doesn't work to me as I already have my own database with my users, so I want to use it instead of having to create the users on the Application Server.
So, I'm asking you how to do that. Of course I'm not expecting that you place the code here to me as I know that such a thing could be complicated. Instead, I'm asking if you know about some tutorial, article, book or something that teaches how to do what I want. But I would like to see theses examples using JSF and/or EJB3 because these are the technologies that I'm using to develop. It's a pity that the Java EE 5 Tutorial doesn't have an example using a custom database as I know that this situation is very common in the majority of web sites.
Thank you very much.
Marcos

From memory, it goes like this... You just create a
raw jdbc connection on your user database using a
special "login" DB user account, which has
permissions only to an "authenticate" stored query,
which accepts two arguments: username & password, and
returns a boolean 0 or 1 rows found.When I implemented this in .NET's ASP.NET I had the same solution. I had an special user created in the database that I used to log in. When the real user entered his username and password I was already logged in and I had just to check his username and password agains the right table in my database.
But that was only possible bacause when I connected to the database using my hidden user, I used the rights APIs in ASP.NET that coordinate the authentication process. This means that before login in, no one could access any resources (pages, atc...). So what I'm saying is that I can't manager this manually in Java. Java has to have some API or whatever to allow me to control the login process programmatically, while letting the Application Server control the access to the resources.

Similar Messages

  • How to use the JE database with other data types than byte arrays?

    Hi! I searched the javadoc of Berkley DB JE, for a way to introduce entry (but I need also retrieve) data with other type than byte arrays, e.g. String, or anything else, as int may be, etc.
    Still, I didn't find any such way, because the main (only?!) method to entry data into an open database - according what I found in javadoc - is:
    "public OperationStatus put(Transaction txn, DatabaseEntry key, DatabaseEntry data) throws DatabaseException"
    and both this and the corresponding method for retrieves, are based on the same DatabaseEntry type, which allow only entry data on byte[] support.
    What if I need to use Strings or int, or even char? I must do a special conversion from these types, to byte[], to use the database?
    Thank you!

    On the doc page (this is also in the download package),
    http://download.oracle.com/docs/cd/E17277_02/html/index.html
    see:
    Getting Started Guide
    Java Collections Tutorial
    Direct Persistence Layer (DPL)
    All of these describe how to use data types other than byte arrays.
    --mark                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How to use non-MySQL database with DW and PHP...???

    I need to connect to a data-source that is not MySQL from
    with my PHP scripts. The only option I get under the Databases tab
    in the Application panel is MySQL Connection. What about just
    standard ODBC connections? Will DW not handle those for me? Do I
    have to do all of that by hand??
    Any information would be greatly appreciated. Thanks!

    "Angell EYE" <[email protected]> wrote in
    message
    news:fc4eaj$fmn$[email protected]..
    >I need to connect to a data-source that is not MySQL from
    with my PHP
    >scripts.
    > The only option I get under the Databases tab in the
    Application panel is
    > MySQL
    > Connection. What about just standard ODBC connections?
    Will DW not
    > handle
    > those for me? Do I have to do all of that by hand??
    >
    > Any information would be greatly appreciated. Thanks!
    There once existed an opensource servermodel called phakt
    that used the
    ADODB database abstraction library,
    the company that created and supported it was bought by Adobe
    and
    subsequently the project was cancelled.
    A group of people (including me) started a community
    initiative@
    http://openphakt.sourceforge.net
    to continue distribution and development of
    phakt, but unfortunately I don't have access to Dreamweaver
    CS3 due to lack
    of funding.
    Phakt will almost certainly NOT run on CS3 in it's current
    state, but is
    should support previous versions.
    Joris

  • How to use Final Cut Pro with multiple user accounts?

    Hi,
    I want to use Final Cut Pro on a clean user account. How do I set it up? How can I access my old FCP library and still work on it from multiple users?
    Also, I want my DropBox account to back-up my media. Any tips?

    I use external drives as backup. But I don't trust them. And in case of fire or what ever...It is of no use...
    But I agree on your comment about DropBox. It would have been the perfect solution though.
    What else is there?
    I have a 2TB HD but these projects are huge and still growing - so I have to move my projects to several external drives. So maybe I should just work directly from external drives and skip the partition of the computers main drive? I am thinking of the disadvantage of reducing the total storage of the disk.

  • How To Use Your Own Router with Out Loosing Verizon's FIOS Services

    How to use your own router with Verizon’s FIOS Service
    First, you need a basic understanding of how FIOS works but unfortunately there are two types of FIOS systems out there. All of the systems utilize a fiber optic cable to bring TV, phone and internet to your location over one optic cable. In addition these systems provide interactivity including widgets, remote DVR, movies on demand and so forth via an IP (Internet Protocol) signal.  Your STB (Set Tip Box) requires both a video and IP signal. The IP signal is necessary for all of the aforementioned interactivity.  The fiber cable terminates at the Optical Network Terminal or ONT for short.  The ONT converts the optics into a digital signal that can be utilized by ones equipment.  From the ONT your video, phone and internet are provided to the location.  This is where things can differ as the internet signal can be provided via a coaxial (MoCA or Multimedia over Coax Alliance) or RJ45 Cat5 (Ethernet) cable.  It is important to identify and understand the differences of these two setups.  In my case I have my internet entering via Ethernet cable, which in my humble opinion makes things a heck of a lot easier.
    How does one tell the difference? In most cases it’s rather simple; just look at the Verizon’s router WAN (Wide Area Network) Port.  Does it have a RJ45 (Ethernet) or Coax (TV cable Cord) going to it? If the router’s WAN port doesn’t have a coaxial connector then one will need to convert the MoCA signal into a usable Ethernet signal that routers understand. The easiest way is to use Verizon’s router as a bridge. In this method the Verizon’s router simply converts the signal and passes it along to your own router. The challenge is to try to maintain the interactivity that FIOS TV provides. Because of this one needs to supply the IP routed signal back to the FIOS router.  There are multiple methods for doing this and I would recommend investigates which one make the most sense.   
    In my particular case the IP signal was provided by Ethernet.  Again there are various ways of installing one’s own router. The hardest is to utilize Verizon’s router as a bridge.  This setup requires configuring Verizon’s router as a bridge and also creating a VLAN (Virtual Local Area Networks). In addition one needs to set up their own router so it will work with the various routing tables and networks. For me this is too complex for the average person and it can be difficult to trouble shoot if something goes wrong. Please consider that Verizon will not support utilizing third party routers.   
    The easier method is to request an Ethernet signal (if you don’t already have one) from their ONT.  I would highly recommend getting your hands on a NIM or Network Interface Module. This device is used to convert Ethernet to Coaxial so it can be fed back to your STBs.  These can be purchased online and Verizon technicians can be a valuable resource with these sorts of acquisition.  At the very least they can point you to the right direction.  Once you have a NIM the rest is rather simple.
    Log into the current Verizon Router.
    Located the router’s MAC address and copy it down.
    Go to the port forwarding section and copy down the Applied Rules. 
    Example:  
    Network Computer/Device: 192.168.1.100:63145
    Application & Ports Forward:  Application UDP Any -> 6347  
    Note: There may be up to three entries for each one of your Set Top Boxes.
    Look at your current device list, typically found on the home screen. Copy down your STB MAC and IP address.
    Example:
    IP-STB1
    Connection Type: Ethernet
    * IP Address: 192.168.1.100
    IP Address Allocation: DHCP
    *MAC Address:                07:73:fFe:ad:8b:3f
    * Things you will need to write down
    Go to the network section and look for the main Ethernet connection.  Select this and then select more setting, typically found at the bottom. Release the current lease.
    Remove the Verizon router
    Install your router
    Connect the NIM by plugging in an Ethernet from one of the routers LAN (Local Area Network) ports to your NIM. Then connect the coax cable, the same cable that was used by Verizon router.
    Set you DHCP routing IP pool to accommodate Verizon’s STB IP’s  (note their IP’s start at 192.168.1.100)
    Go to DHCP section and reserve the STB IP’s by inserting the IP’s and MAC addresses. This shall ensure that nothing else utilizes the same IPs as the STBs thereby preventing IP address conflict.  
    Add the port forwards from Step 5 above.
    Clone Verizon’s Mac Address utilizing the info from step 2
    Finish setting up the router in typical fashion.
    Unplug and re-plugin your STB’s and test functionality.  It’s best to try using a widget or Movie on demand function.
    Note: if the new router can net get an internet signal contact Verizon’s support and have them release the IP and reset the ONT.  
    EVERYTHING should be working at this point.

     3 Go to the port forwarding section and copy down the Applied Rules. 
    Example:  
    Network Computer/Device: 192.168.1.100:63145
    Application & Ports Forward:  Application UDP Any -> 6347  
    Note: There may be up to three entries for each one of your Set Top Boxes.G
    Your display obviously is not like mine as mine does not dosplay the port associated with the ip address
    whatever, the STB's start at 192.168.1.100 and icement by 1 for each
    the port addr's will be 63145 alo incrementing by 1
    there is 1 entry for each in my pf list
    however each ip addr also has a port entry starting at 35000 also incrementing by 1 for each ip addr
    For some unknow reason these are duplicated e.g I appear to have 11 entries exaactly the same for each stb and as the fios services rules have no action switc there is nowhere to delete the extraneous garbage.
    Why do you clone the mac addr??

  • Hello, I'm from Belgium and I just bought the iPad 2. I watched a lot of movies and I saw that it's possible to make your own movie with the iPad, but which app do you need to make movies. Greetings, Lars

    Hello, I'm from Belgium and I just bought the iPad 2. I watched a lot of movies and I saw that it's possible to make your own movie with the iPad, but which app do you need to make movies. Greetings, Lars

    Hier kun je er meer over lezen; http://www.wikihow.com/Use-the-Cameras-on-Your-iPad-2
    En hier kun je meer informatie vinden over de iPad;  www.iPadforum.tk

  • How do I turn off "your recent download with your apple id" emails? Annoyingly often and they fill up my inbox.

    How do I turn off "your recent download with your apple id" emails? Annoyingly often and they fill up my inbox.  Is there a way to unsubscribe from these?

    It is in Settings>iTunes & App Stores to change automatic downloads. But it isn't your device that needs to be changed if you are the one that made the download. He needs to turn off the setting for automatic downloads on his phone. I'm guessing here, but you are all sharing the same Apple ID?

  • How do you load microsoft office with your product key number?

    how do you load microsoft office with your product key number?

    I am assuming you have the key number, but not the actual software.  Like you I have the key number (my key number good for 3 Macs), but didn't want to dig out the disc to install on another Mac.  Going to Office's site I couldn't find any links to download Office, so I had to get the disc to load the program.  Once that's done the Office installer will ask for your key number. 

  • How to use JavaMail 1.4 with Oracle Application Server 10g (9.0.4.0.0)

    Hi all,
    I'd like to know if it's possible and how to use JavaMail 1.4 with Oracle Application Server 10g (9.0.4.0.0), Windows version.
    With the following code, I can see that the mail.jar used by the server is the one included in the jdk installation :
    // I'm testing InternetAddress.class because I want to use commons-email-1.2.jar that requires mail.jar 1.4 (or higher) and activation.jar 1.1 (or higher)
    // and I know that inside the commons-email-1.2.jar file, I need to call the InternetAddress.validate() method that throws a java.lang.NoSuchMethodError: javax.mail.internet.InternetAddress.validate()V if it is used with mail.jar 1.2.
    Class cls = javax.mail.internet.InternetAddress.class;
    java.security.ProtectionDomain pDomain = cls.getProtectionDomain();
    java.security.CodeSource cSource = pDomain.getCodeSource();
    java.net.URL location = cSource.getLocation();
    System.out.println(location.toString());
    This code returns : file:/C:/oracle/app/jdk/jre/lib/ext/mail.jar and this mail.jar file has an implementation version number: 1.2
    - I've tried to include my own mail.jar (1.4.2) and activation.jar (1.1.1) files in the war file that I deploy, but it doesn't work (the server still uses the same mail.jar 1.2)
    - I've tried to put the mail.jar (1.4.2) and activation.jar (1.1.1) files in the applib directory of my OC4J instance, but it doesn't work (the server still uses the same mail.jar 1.2)
    - I know that a patch exists : I've read the following document: How to Make Libraries such as mail.jar and activation.jar Swappable ? [ID 552432.1]
    This article talks about the Patch 6514136, but this patch only applies to : Oracle Containers for J2EE - Version: 10.1.3.3.0
    Can you please help me ?
    Thanks in advance for your answers,
    Laurent

    I strongly suggest to upgrade to AS 10.1.3 to get this.
    Think of future support of AS 9.0.4. You will get not critical patch updates anymore.
    --olaf                                                                                                                                                                                                                                                                                                               

  • Anybody using 11g RAC Database with OIM 9.1.0.2?

    Hi,
    We have poor performance problems with 11g RAC Database with OIM 9.1.0.2.
    It looks like the issue could be because of RAC Ccluster.
    Anybody using 11g RAC Database with OIM 9.1.0.2?
    If so, What is the JDBC Driver r u using? Also what App Server (Weblogic or OAS etc) ?
    Appreciate your input.
    Regards
    Vijay Chinnasamy

    We are using weblogic 10.3. And I am sorry to tell you that we are yet to move to production.
    We are planning to have Database in RAC, so i just thought of taking inputs from you.
    can you tell me under what operations you face the poor performance issue?
    For us the max no. of users in production is around 6k. So I am wondering how this RAC availability will affect the performance.
    Thanks for sharing your inputs.

  • [HTML DB] How to use the existing database table?

    [HTML DB] How to use the existing database table?
    I installed Oracle 10g database in Computer A(Windows 2000), and I already create all the tables with data and the data size is about 300MB.
    In Computer B(Windows 2000), I installed HTML DB 1.6.
    How can I use /get the existing database table (in computer A) for HTML DB?
    Could anyone help me on this? I am newbie and I need some detail instructions. or Where can I find the examples.....
    Thanks

    Well I guess if you wish to retain that architecture, i.e. HTMLDB on one machine and your data on another, you will have to establish database links to access the data. Oracle documentation will describe how to achieve that.

  • How can I link my database with flash?

    Hi…
    How can I link my database with flash to display image (to
    display it in master details page)
    Please your help ASAP.
    Regards,

    You could use some server-side scripting like PHP or ASP.
    http://www.kirupa.com/web/index.htm

  • How to use Two main windows with in a page in script ?

    Hi any body explain me...
    How to use Two main windows with in a page in script ?
    with  header data in one main window,
    & Item data in other main window.

    HI..,
    u need to go for <b>SPLITTING THE MAIN WINDOW</b> !!!
    Main windows in page windows allow you to format text in multiple columns. Define an area in the page window, in which to position the main windows.
    Here is the procedure !!
    -->Create a page window and assign it to a page.
    Choose <b>Edit --> Main windows</b>.
    A dialog box appears.
    -->Enter values in the fields <b>Area width</b> and A<b>rea height</b> in accordance with the input guidelines for main windows.
    -->Enter values in the fields <b>Spacing</b> and Number in the <b>Horizontal group</b> if you want to use multiple columns. You can ignore the fields in the Vertical group.
    Determine how many columns and line areas are required for label printing. Then enter the corresponding values in the fields in the <b>Horizontal and Vertical groups</b>.
    -->The value in the field Left margin varies from main window to main window if multiple columns are used. The following applies:
    <b>
    Left margin of current column + Window width + Horizontal spacing = Left margin of next column</b>
    In label printing, the field Upper margin also varies from main window to main window:
    <b>
      Upper margin of current main window +  Window height + Vertical spacing = Upper margin of next main window</b>
    -->Enter a value in the field Start position.
    This is a counter. Enter a starting value which is equal to or greater than 1.
    -->The main windows are added to the list.
    -->Save your form.
    reward if it helps u...
    sai ramesh

  • Your recent download with your Apple ID

    To the Apple Customer Service, two issues:
    1. Related to the "Your recent download with your Apple ID" e-mail:
    I suspect it's about fishing attempt but I'm not sure  :/
    I received a "Your recent download with your Apple ID" e-mail yesterday mentioning not my primary Apple ID, but the backup/auxiliar one. BTW, I'm from Brazil:
    "Dear [EDITED MY NAME],
    Your Apple ID, [EDITED AUXILIAR E-MAIL], was just used to download Snake!Snake!Snake from the App Store on a computer or device that had not previously been associated with that Apple ID.
    This download was initiated from China.
    If you initiated this download, you can disregard this email. It was only sent to alert you in case you did not initiate the download yourself.
    If you did not initiate this download, we recommend that you go to iforgot.apple.comto change your password, then see Apple ID: Security and your Apple ID for further assistance.
    Regards,
    Apple"
    BUT, the links seems to be legit:
    http://iforgot.apple.com/
    Apple ID: Security and your Apple ID
    If they're legit it could be some weird bug from Apple, right?
    2. Related to one album from my Itunes Cloud
    One of my purchased album (all songs where purchased) was split in two albums: 3 songs on one album and the others on the other exact identical one.
    How I can merge the songs on ONE album?
    Thanks!

    1. Check your account history in the usual way from within iTunes and look for anything you didn't buy. Use the report a problem links there rather than these public boards if there is an issue.
    2. See Grouping tracks into albums.
    tt2

  • How to use a Logical Database in Function Module.

    Hi Experts,
    I want to use a logical database in a Function Module to fetch data from a standard SAP table into a Internal table for certain filter conditions.
    How can I get get this done????
    I called LDB_PROCESS FM in my FM, but I could not figure out how to store the extract in my IT table since we cant use GET in FM.
    Please provide me a sample code if possible.
    Thanks in Advance,
    Alex.

    Hi,
    i had an example program like this ,in this i want to get the data using pnp logical database with 5 fields in an interface program.
    data: begin of it_final occurs 0,
            pernr like pa0002-pernr,
            vorna like pa0002-vorna,
            nachn like pa0002-nachn,
           usrid like pa0105-usrid,
           usrid_long like pa0105-usrid_long,
           end of it_final.
    get pernr.
      clear : p0000,p0002,p0105.
      rp-provide-from-last p0000 space p_date p_date.
      if p0000-stat2 = '3'.
        v_pernr = pnppernr-low.
      else.
        reject.
      endif.
    *---Get employee pernr, First name ,Last name into final table
      rp-provide-from-last p0002 space p_date p_date.
      if pnp-sw-found = '1'.
       it_final-pernr = p0002-pernr.
       it_final-vorna = p0002-vorna.
       it_final-nachn = p0002-nachn.
      else.
    *---Error message if not infotype 0002 maintained
      T_ERROR-PERNR   = pnppernr-low.
      CONCATENATE TEXT-EMI '0002'
      INTO T_ERROR-MESSAGE SEPARATED BY SPACE.
      APPEND T_ERROR.
      CLEAR T_ERROR.
      endif.
    **--Get SYSTEM USERNAME to final table
      rp-provide-from-last p0105 0001 p_date p_date.
      if pnp-sw-found = '1'.
        it_final-usrid = p0105-usrid.
      else.
    *---Error message if not SYSTEM USERNAME maintained
        T_ERROR-PERNR   = pnppernr-low.
        CONCATENATE TEXT-003 '0105'
        INTO T_ERROR-MESSAGE SEPARATED BY SPACE.
        APPEND T_ERROR.
        CLEAR T_ERROR.
      endif.
    **--Get Email ID to final table
      rp-provide-from-last p0105 0010 p_date p_date.
      if pnp-sw-found = '1'.
        it_final-usrid_long = p0105-usrid_long.
      else.
    *---Error message if not Email ID maintained
        T_ERROR-PERNR   = pnppernr-low.
        CONCATENATE TEXT-004 '0105'
        INTO T_ERROR-MESSAGE SEPARATED BY SPACE.
        APPEND T_ERROR.
        CLEAR T_ERROR.
      endif.
       append it_final.
        clear it_final.
    reward points if useful,
    venkat.

Maybe you are looking for

  • Help Needed in Building JTree

    HI, I've a doubt in Building a JTree.It wud be helpful if some one helps me with a better logic for building this Tree.. I have a tree like this: root | A--B--C--D A--B--C--D A--B--C A--B--C--E--F I have the tree nodes like this . i need to merge the

  • How to invoke the store procedure(Oracle) in java ?

    There is a store procedure in Oracle. the out parameter type is %ROWTYPE. how to invoke it in java ? create or replace procedure select_on_test(outtable out test%rowtype) is cursor ctest is select id,name from test; begin open ctest; fetch ctest into

  • Unable to update to latest After Effects 2014 version

    This is on a MacBook Pro. For the past week or so I haven't been able to update After Effects. If always gives me the same error. Below, is the log file. 12/12/14 15:36:00:769 | [INFO] |  | OOBE | DE |  |  |  | 49532 | *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*

  • Why do I keep getting the Flash Player update message?

    Every time I switch on my PC I get a message from Adobe about an available update to Flash Player.  If I try to download/install from the message, it fails. I already have Flash Player. I asked Norton to help and yesterday they downloaded Flash Playe

  • Java client occurs error

    when my java client invokes a rpc webservice , receiving XML is ok,but when sending XML,the error shows as below:what's the possible reason? -------------- SENDING XML -------------- Exception in thread "main" java.lang.reflect.UndeclaredThrowableExc