Storing user Information

Hi Guys and Girls,
I am trying to store user information. I retrieve the user ID by the following code:
public String getUser() {
        FacesContext ctx = FacesContext.getCurrentInstance();
        HttpServletRequest request = (HttpServletRequest)ctx.getExternalContext().getRequest();
        //return (String)request.getAttribute("User");
        return (String)request.getSession().getAttribute("User");
    }Through out the application I will need the userId, username, email, admin status. I would like to retrieve this information once and be able to reference it. My first thought is a stateful session bean. But I am not sure if this is the best approach and I am also not sure exactly how to set the values. Do I put the above code into the bean or do I set the values in the bean from my opening jsf page. If someone could give me some direction with some code examples it would be very helpful. Thank you.

Use a session scoped managed bean.
Something like:public void login() {
    User user = UserDAO.getUser(username, password);
    if (user != null) {
        FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("user", user);
    } else {
        // Handle.
public void logout() {
    FacesContext.getCurrentInstance().getExternalContext().getSessionMap().remove("user");
}Userpublic static User getCurrentUser() {
    return (User) FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("user");
}Any beanpublic void doSomething() {
    User currentUser = User.getCurrentUser();
public void isLoggedIn() {
    return User.getCurrentUser() != null;
}faces-config:<managed-bean>
    <managed-bean-name>user</managed-bean-name>
    <managed-bean-class>mypackage.User</managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
</managed-bean>JSF<h:outputText value="Welcome, #{user.name}" rendered="#{bean.loggedIn}" />

Similar Messages

  • Storing user information into session best practice.

    I am developing an web application where user first have to login to be able to enter.
    When user correctly logged in an UserAccount object with all user data (except loginName and Password) is being stored into session. An Filter is checking session for UserAccount object and if user correctly logged in forwards the request to the next filter in the application.
    When user logged out, the session object is being destroyed. �Session invalidate()�
    I would like to know if there are better solutions for this.
    Thank you in advance.
    --Nermin B.

    You may want to also re-evaluate your "application" as a whole.
    In most cases - yours may be the exception - session objects are used to well, associate a particular web browser with a particular user. There usually is little need to retain additional information about that person, unless that information is frequently accessed. I think Shok used a poor example; a person's address, phone number, credit card number and so on is usually accessed once per visit, whereas the contents of that person's shopping cart is generally accessed every time the user changes web pages.
    The key concept here is you want to balance memory consumption verses database hits (or file i/o). Authorization info should be in the object, whereas general background info can be in the data source and accessed when needed.
    If on the other hand, you don't have a data source, you don't really have much of a choice and a session object (or similarly, a JavaBean) should just go ahead and contain all of the information about the user.
    To change the subject, session objects and JavaBeans are server side. As long as you keep a careful eye on the interfaces to those objects, you should be fine security wise. For example, if a person passes a parameter to your web page, make sure the parameter is anticipated and correct before you save it in the object. In other words, don't write a generic function that blindly accepts parameter names and values and sets them accordingly within the session object. The only place you should be able to set the password attribute is from the change-your-password JSP page.
    Cookies on the other hand are definitely stored on the client's machine, and yes, you want to be really paranoid and make sure that the cookie you are retrieving is the cookie you are expecting. I think the source of confusion is that session ids corresponding to session objects can be stored within a cookie - so you if can change the id, the server thinks you are someone else and uses that person's session object.

  • In which table deleted user information is stored

    Hi all,
    I have made one user ZTEST in sap through SU01. Its details has been stored in USR01 .
    When i deleted this user than the details of this user has been deleted from the tables USR01.
    After deletion on which table deleted user information is stored.
    Any BAPI is available which sgives the deleted table list .
    Thanks & regards

    Hi
    You can get current database status using the following BAPIs-
    BAPI_USER_EXISTENCE_CHECK
    BAPI_USER_GETLIST
    BAPI_USER_GET_DETAIL
    Also check the report RPUAUD00 in which you can find out new infotype creation/modification etc.
    Regards

  • Where is owb user information stored in tables

    Hi All,
    I am using OWB Repository 10.2.0.4.0 . I need to know, where is OWB User information stored in physical tables of repository.
    Please help me in this regard?

    You can refer the following queries
    1. select owner from dba_objects where object_name = 'ALL_IV_INSTALLATIONS' and owner not in ('PUBLIC');
    2. select distinct grantee, substr(granted_role,5,25)
    from dba_role_privs
    where substr(granted_role,1,4)='OWB_'
    and substr(granted_role,1,6) not in ('OWB_A_','OWB_D_','OWB_O_','OWBR_')
    and default_role='NO'
    and admin_option='NO';
    Thanks,
    Sutirtha

  • How to verify the user information pass by the form with a stored procedure?

    Hi,
    I would like to know how to verify user information pass by the form with a stored procedure.
    I want make a portal which accepts to new user registration, but I want verify the new user's informations (like the name don't contain a number etc).
    Thanks for your help
    regards
    jla

    Hi Samson,
    You can use the UI API to do this. You can catch the form_ADD event and then validate the input from the users. You can even block the event from completing (and stop the document from being added) if your code finds some incorrect data using the bubbleEvent functionality.
    I don't have one specific example to show you, but if you look at some of the SDK samples (for example C:\Program Files\SAP\SAP Business One SDK\Samples\COM UI\VB.NET\02.CatchingEvents) to see how to work with events, you can then create your own validation to ensure the users data is valid.
    Regards,
    Niall

  • Table name in which user information is stored in weblogic portal

    Hi Friends,
    Please specify the name of the table which stores user information(such as username,firstname,lastname,email,etc.)in weblogic portal.
    Thanx in advance.
    Chiku.

    Default table is PROPERTY_VALUE. You can write your own property manager to
    save is somewhere else
    Rajneesh
    <John Wayne> wrote in message news:[email protected]..
    Hi Friends,
    Please specify the name of the table which stores user information(such
    as username,firstname,lastname,email,etc.)in weblogic portal.
    Thanx in advance.
    Chiku.

  • Displaying the current users information instead of the value of the person who completed the form in the first place.

    I found this fantatic post regarding querying the user profile service 
    http://blogs.technet.com/b/anneste/archive/2011/11/02/how-to-create-an-infopath-form-to-auto-populate-data-in-sharepoint-2010.aspx?pi47623=2#comments 
    However i have an issue whenever the form is opened again either to view or edit, it displays the current users information
    instead of the value of the person who completed the form in the first place.
    Please help me, I'm turning more grey each minute

    I think it is how the current user information is stored based on your logic.
    You might be quering current value again when loading the form (Form load Rule).
    you have to tweak your logic, after the user submits the form you can set the username to the one who saved it.
    or in form load, write a logic to see if the form was not saved before and then query the username( by using internal field like "formstatue")
    Hope this helps!
    Ram - SharePoint Architect
    Blog - SharePointDeveloper.in
    Please vote or mark your question answered, if the reply helps you

  • User Profile email address not updated on Site Collection User Information

    Hi All,
    Ok here we go....SharePoint 2007 with SSP profile sync not enabled, however I have a few profiles I need to update (email address).  This has been completed by editing the user profile in SSP, but when viewing the information via Site Collection >
    People & Groups > User Information "Work E-mail" is still showing the old one.
    All alerts are still being sent to the old email address, SSP DB UserProfile_Full shows the new email address as per SSP.
    Anyone know where else user profile emails are stored which is used by Exchange?
    Many Thanks, Roger

    As per the following post from GuYuming
    http://social.technet.microsoft.com/Forums/sharepoint/en-US/319d5b0e-336a-4815-9ee5-5d1685db867f/how-to-send-sharepoint-alerts-to-users-on-different-domain?forum=sharepointadminlegacy
    After the email address in SharePoint user profile is updated to [email protected], you have to wait until
    they are synchronized into the user information list in SharePoint site collections so that alert can be sent to that address. For detail, please read http://vspug.com/mirjam/2009/06/17/user-profiles-and-the-user-information-list-or-userinfo-table/ and http://blogs.technet.com/paulpaa/archive/2009/10/01/user-profile-information-not-updated-on-site-collection-s-people-and-group.aspx
    --Cheers

  • Anonymous user information

    Hi,
    where wil be anonymous user information wil be stored.
    I think that information is not stored persistently, after login only that info wil persist before that whr it wil store.
    Thanks in advance

    Yes, you are right. It persist after that you are logged in only..
    Refer http://docs.oracle.com/cd/E24152_01/Platform.10-1/ATGPersProgGuide/html/s0502trackingguestusers01.html the link to know more..
    JK

  • Extending user information entries?

    Hi there!
    Is it possible to extend the user information (such as E-Mail address or Telephone) with "arbitrary" data (e.g. Age / Date of Birth)?
    The entries "Position" and "Department" of "Additional Information" make it seem possible to me, I haven't found anything so far, though...
    Thanks in advance!
    Dennis

    Hi Dennis,
    yes it is.
    http://help.sap.com/saphelp_nw04/helpdata/en/a3/d2ffd64602c149949ca3cf379dc295/content.htm
    These additional attributes are stored in the database.
    If you only want to display addtional iViews that are stored in your corporate ldap, the configuration would be different.
    Regards, Karsten

  • CCMS Alerts with user information

    Dear SAP professionals,
    We are required by our custoner to generate CCMS alerts for dialog steps per user.
    We found alerts for dialog steps in the SAP defined monitor.
    However, our customer want user information included in the alerts.
    In particular, we need to have these information in the alert message;
    A notice that dialog steps per user exceeded the threshold.
    A namd of the user who executes the dialog steps.
    If there is no pre-defined monitoring template which satisfies the above requirement, we are looking into defining our own alerts.
    So, if anybody can help us by giving ideas on how we can create an alert to satisfy the requirements above.
    Best Regards
    Kentaro Kawamoto

    Dear Ms. Sanchez,
    Thank you very much for your help.
    I will try to follow the set-up material for custom-exit to see if our customer's requirements could be satisfied.
    For mow, it has been very helpful for us to know the web page area where technical documents are stored.
    Thank you very much for your help.
    Could we wait to close this message  until we try the documents?
    Nonethless please let me express that we all thank for your information.
    Best Regards
    Kentaro Kawamoto

  • Error storing authorisation information

    I recently installed iTunes on my new computer, but when I want to purchase a song or even play a preview I get to following error message:
    "An error occured storing authorisation information on your computer."
    I tried reinstalling iTunes to no avail.
    This is getting quite annoying because I also can't play previously purchased songs anymore.
    Thanks in advance for any insights.

    Ok, finally I solved it (for me that is);
    1.First go to the folder:
    C:\Documents and Settings\All Users\Application Data\Apple Computer\iTunes\SC Info
    2.Then:
    In Windows Explorer, go to Tools/Folder Options/View, then
    scroll down and remove the checkmark on the "Use Simple File Sharing..." option. Windows XP (pro) use simple file sharing by default. You have more control without it.
    Now go to the folder you want to share, right-click and select the "sharing and security" option, select the "share this folder" radio button, click "maximum allowed", click "Permissions" and make sure to select the permissions to the user or group you want. I would select Full Control to Everyone first just to make sure it works.
    On the "security" tab, allow everything!
    Now iTunes is allowed to save authorisation information on your system!

  • How to pre-populate xellerate user information

    i an trying to pre-ppopulate xellerate user information in object form but i note that when i start request, the user informations in my object form is the infomations of the requester.
    I hope the above problem make understandable.
    Thanks in advance,
    user568142

    I asked Oracle the same question. Currently prepopulating values on the User Form is not supported, unless they are user defined fields, and even so, you do not get any kind of functionality to determine the value. Here is oracle response i recieved over metalink when i asked about how to have a default organization selected so the user did have to chose it:
    Currently this is not supported by OIM. There is no option for providing any 'default' value for a form field which comes from the FormMetaData.xml unless source code customization is done. For lookups, hard-coding values in the FormMetaData.xml gets more complicated because what the user sees on the screen may not be what is stored in the database.
    -Kevin

  • Displaying User information

    Hi!
    When i use any iview to display user information, i get in the user name fiel de id user instead of the user name.
    It is the same for all the place where the portal use the user infomation display (CLP, search user, roles search, etc).
    Is anybody knows how to change this?
    I thank you in advance.

    Customizing Users' Display Name
    Use
    A user’s display name is the friendly name that is displayed for a user in most user interfaces, for example in list of results when you search for a user in the UME administration console. Programmatically, it is the name that is returned by the method IUser.getDisplayName().
    By default the display name is the user’s last name followed by the first name. It is possible to customize it, to display a different friendly name, for example the users salutation followed by first name and then last name.
    Procedure
    The name returned by the method IUser.getDisplayName() is calculated by the user attributes specified in the user management property ume.users.displayname_template.
    The default value is ume.users.displayname_template=,
    To change the display name, change the value of this property. It can be a combination of:
    u00B7        User attributes: The available user attributes are: , , , , , , , , , , , , , , , , , , ,
    u00B7        Characters: Most characters whose unicode lies between \u0020 and \u007E can be written as they are. These are characters such as A-Z, a-z, commas, semicolons, and so on.
    u00B7        Unicode characters: Characters whose unicode does not lie between \u0020 and \u007E, must be written in the form \uXXXX
    Example
    You change the value to:
    ume.users.displayname_template=
    For a user whose first name is ‘Peter’, second name is ‘Miller’ and salutation is ‘Mr’, the display name would be ‘Mr Peter Miller’.
    This display name would appear on all user interfaces that use the method IUser.getDisplayName().
    attributeMapping>
    If you are using an LDAP directory as a data source for your user-related data, the ‘logical’ attribute names used by the Java application programming interface (API) of SAP User Management Engine (UME) must be mapped to the ‘physical’ attribute names used in the schema of your corporate LDAP directory.
    In the preconfigured files shipped with UME, the logical attributes of the Java user management API are mapped to the physical attributes used for the object class inetOrgPerson in the X.500 standard. If you use this standard without any modifications, you will not need to change the attribute mapping data. If you have extended this object class in your LDAP directory, or use a different object class, you can flexibly add additional attributes to the attribute mapping data or change the attribute mapping data as required. By providing you with the means to map attributes, UME allows you to use any schema that suits your company’s requirements.  
    The following examples illustrate scenarios where you need to change the attribute mapping data:
    The logical attribute for a user’s e-mail address used by the user management component is named email, but the physical attribute in the schema for your corporate LDAP directory is named mail. You must map email to mail in the configuration file.
    In your company, you wish users to log on with their e-mail address and password instead of with their user ID and password. In a user account, the logical attribute j_user defines the logon ID. By default this attribute is mapped to the unique ID (uid) of a user. By mapping j_user to the physical attribute for the user’s e-mail address, for example mail, users can in future log on with their e-mail address.
    For a list of the set of fixed logical attribute names used in the API, see Logical Attributes.
    Example
    <dataSources>
    <dataSource id="CORP_LDAP"
        className="com.sap.security.core.persistence.datasource.imp.LDAPPersistence"
        isReadonly="false"
        isPrimary="true">
      <responsibleFor>
        <principal type="account">
        </principal>
        <principal type="user">
          <nameSpaces>
            <nameSpace name="com.sap.security.core.usermanagement">
              <attributes>
                <attribute name="firstname" populateInitially="true"/>
                <attribute name="displayname" populateInitially="true"/>
                <attribute name="lastname" populateInitially="true"/>
                <attribute name="fax"/>
                <attribute name="email"/>
                <attribute name="title"/>
                <attribute name="department"/>
                <attribute name="description"/>
                <attribute name="mobile"/>
                <attribute name="telephone"/>
                <attribute name="streetaddress"/>
                <attribute name="uniquename" populateInitially="true"/>
              </attributes>
            </nameSpace>
          </nameSpaces>
        </principal>
          <principal type="group">
          </principal>
      </responsibleFor>
      <attributeMapping>
        <principals>
          <principal type="account">
          </principal>
          <principal type="user">
            <nameSpaces>
              <nameSpace name="com.sap.security.core.usermanagement">
                <attributes>
                  <attribute name="firstname">
                    <physicalAttribute name="givenname"/>
                  </attribute>
                  <attribute name="displayname">
                    <physicalAttribute name="displayname"/>
                  </attribute>
                  <attribute name="lastname">
                    <physicalAttribute name="sn"/>
                  </attribute>
                  <attribute name="fax">
                    <physicalAttribute name="facsimiletelephonenumber"/>
                  </attribute>
                  <attribute name="uniquename">
                    <physicalAttribute name="uid"/>
                  </attribute>
                  <attribute name="loginid">
                    <physicalAttribute name="null"/>
                  </attribute>
                  <attribute name="email">
                    <physicalAttribute name="mail"/>
                  </attribute>
                  <attribute name="mobile">
                    <physicalAttribute name="mobile"/>
                  </attribute>
                  <attribute name="telephone">
                    <physicalAttribute name="telephonenumber"/>
                  </attribute>
                  <attribute name="department">
                    <physicalAttribute name="ou"/>
                  </attribute>
                  <attribute name="description">
                    <physicalAttribute name="description"/>
                  </attribute>
                  <attribute name="streetadress">
                    <physicalAttribute name="postaladdress"/>
                  </attribute>
                  <attribute name="pobox">
                    <physicalAttribute name="postofficebox"/>
                  </attribute>
                  <attribute name="preferredlanguage">
                    <physicalAttribute name="preferredlanguage"/>
                  </attribute>
                </attributes>
              </nameSpace>
            </nameSpaces>
          </principal>
          <principal type="group">
          </principal>
        </principals>
      </attributeMapping>
    </dataSources>
    In the above example, the section on the data source CORP_LDAP contains all the configuration data for the LDAP directory.
    The section on <responsibleFor> defines which data is stored in the LDAP directory and in particular the logical attributes that are stored in the directory. For each attribute listed here, there must be an entry in the attribute mapping section.
    By default the section on <attributeMapping> contains attribute mapping data for the object class inetOrgPerson in the X.500 standard. Here you can modify the physicalAttribute name (the attribute name in the LDAP directory) or you can add an additional attribute mapping for attributes outside of inetOrgPerson that you have added to your LDAP schema. 
        <attribute name="firstname">
            <physicalAttribute name="givenname"/>
        </attribute>
    Even if the physical and logical attribute name are identical, you should map them. For example, in the above example, displayname maps to displayname.
    If an attribute is not mapped, the API will not have access to this data.
    Some logical attributes are mapped to "null". This means that the API uses this logical attribute, but the logical attribute does not map to a physical attribute. Instead it maps to a computed value.
    Ensure that all inetOrgPersons in your LDAP directory contain a valid value for the attribute uid. In the default configuration, this attribute is used to search for users for display in user-management applications such as the role assignment tool.
    Alternatively, change the attribute mapping so that uniquename is mapped to cn instead of uid.
        <attribute name="uniquename">
            <physicalAttribute name="cn"/>
        </attribute>
    In this way, cn is used to search for users for display in user-management applications.
    Namespaces
    Another useful feature is that you can map logical attributes to different physical attributes depending on the namespace. For example, an application in the namespace com.mycompany.app1 might use the physical attribute uid as displayname, whereas another application com.mycompany.app2might use the physical attribute sn as displayname. This would be mapped as follows:
      <attributeMapping>
        <principals>
          <principal type="user">
            <nameSpaces>
              <nameSpace name="com.mycompany.app1">
                <attributes>
                  <attribute name="displayname">
                    <physicalAttribute name="uid"/>
                  </attribute>
                </attributes>
              </nameSpace>
              <nameSpace name="com.mycompany.app2">
                <attributes>
                  <attribute name="displayname">
                    <physicalAttribute name="sn"/>
                  </attribute>
                </attributes>
              </nameSpace>
            </nameSpaces>
          </principal>
        </principals>
      </attributeMapping>
    You need to meintain this property in the sapup.properties file.
    Therefore in the portal you select: System Administration ->
    System Configuration -> UM Cinfiguration -> Direct editing.
    Then you add the property in the textfield, save and restart the
    J2EE Engine in order to activate this value.
    Best regards,
    Patricio.

  • Getting Logged on User'Information in an Oracle-Form SSO Partner Application

    Hi.
    I could run Flight-of Fancy Application and capture user's information by calling the
    "Parse_cookie " Procedure.(use the Scenario 2 - Access the Portal and then the FOF App)
    and defined an Oracle-Form application as Partner application like FOF.
    I want to have Logged on user'Information in the "Oracle-Form" . But the Fucntion owa_cookie.get dosen't work correctly.please let me know what can I do ?
    Thanks in advanced.

    Hi.
    I could run Flight-of Fancy Application and capture user's information by calling the
    "Parse_cookie " Procedure.(use the Scenario 2 - Access the Portal and then the FOF App)
    and defined an Oracle-Form application as Partner application like FOF.
    I want to have Logged on user'Information in the "Oracle-Form" . But the Fucntion owa_cookie.get dosen't work correctly.please let me know what can I do ?
    Thanks in advanced. If you're writing your own partner application, then you are correct to get the user information from the output variables
    from the parse_url_cookie procedure. You should then set the information you want to keep track of in the cookie, or combination
    of cookie and persistent storage in the database. Take care of the security implications while doing this.
    On subsequent calls to your application, the user info should be obtained from the cookie and the database, if you
    are using a combination of the cookie and database storage to keep your info.
    The owa_cookie.get routine is used to read the cookie, which is generated with owa_cookie.send.
    These routines work fine, when invoked correctly.
    If you are having trouble with them, you're probably not using the calls properly.
    The following code provides an example of how to use the owa_cookie calls...
    create or replace package testcookie
    is
        procedure show (p_name IN VARCHAR2);
        procedure send
            p_name    IN VARCHAR2,
            p_value   IN VARCHAR2,
            p_path    IN VARCHAR2 default null,
            p_expires IN VARCHAR2 default null
    end testcookie;
    show error package testcookie
    create or replace package body testcookie is
        procedure show (p_name IN VARCHAR2) is
            v_cookie owa_cookie.cookie;
        begin
            v_cookie := owa_cookie.get(upper(p_name));
            htp.htmlopen;
            htp.bodyopen;
            htp.print(v_cookie.vals(1));
            htp.bodyclose;
            htp.htmlclose;
        exception
            when others then
                htp.htmlopen;
                htp.bodyopen;
                htp.print('NO COOKIE FOUND.');
                htp.print(SQLERRM);
                htp.bodyclose;
                htp.htmlclose;
        end;
        procedure send
            p_name    IN VARCHAR2,
            p_value   IN VARCHAR2,
            p_path    IN VARCHAR2 default null,
            p_expires IN VARCHAR2 default null
        is
            v_cookie owa_cookie.cookie;
            l_agent varchar2(30);
            l_expires varchar2(30);
            l_path varchar2(100);
        begin
            if p_expires is null then
                l_expires := null;
            else
               l_expires := to_date(p_expires, 'MMDDYYYY');
            end if;
            if p_path = 'ALL' then
                l_path := '/';
            else
                l_path := null;
            end if;
            owa_util.mime_header('text/html', FALSE);
            l_agent := owa_util.get_owa_service_path;
            l_agent := substr(l_agent, 1, length(l_agent) - 1 ) ;
            owa_cookie.send(
                name    => upper(p_name),
                value   => p_value,
                expires => l_expires,
                path    => l_path
            owa_util.http_header_close;
            htp.htmlopen;
            htp.headopen;
            htp.headclose;
            htp.bodyopen;
            htp.print ('Cookie set.');
            htp.bodyclose;
            htp.htmlclose;
        end;
    end testcookie;
    show error package body testcookie;
    grant execute on testcookie to public;If you load this into a schema which a DAD can access, then you can invoke the show and send procedures to view and
    generate cookies.
    To generate a cookie, issue the following from your browser ...
    http://server.domain.com/pls/dad/schema.testcookies.send?p_name=test&p_value=hello
    To view the cookie:
    http://server.domain.com/pls/dad/schema.testcookies.show?p_name=test

Maybe you are looking for