How to get SSO username in a JSP

Hi,
How can i get the value for SSO username in my JSP which is being called after the Single Sign On is done. Can anyone help on this?
Thanks in advance
Unmesh

Unmesh --
I think (albeit I've never tried) that you might be able to get it from the HttpServletRequest using something like:
User is <%=request.getUserPrincipal().getName()%>[b/]
The request.getUserPrincipal returns a java.security.UserPrincipal object, which should be populated with the name of the authenticated user.
Can you see if that works?
cheers
-steve-

Similar Messages

  • How 2 get WINDOWS USERNAME in a JSP

    <%@ page import="sun.misc.BASE64Encoder" %>
    <%
    String auth = request.getHeader("Authorization");
    if (auth == null) {
    response.setStatus(response.SC_UNAUTHORIZED);
    response.setHeader("WWW-Authenticate", "NTLM");
    return;
    if (auth.startsWith("NTLM ")) {
    byte[] msg = new sun.misc.BASE64Decoder().decodeBuffer(auth.substring(5));
    int off = 0, length, offset;
    String s;
    if (msg[8] == 1) {
    off = 18;
    byte z = 0;
    byte[] msg1 = {(byte)'N', (byte)'T', (byte)'L', (byte)'M', (byte)'S',
    (byte)'S', (byte)'P', z,
    (byte)2, z, z, z, z, z, z, z,
    (byte)40, z, z, z, (byte)1, (byte)130, z, z,
    z, (byte)2, (byte)2, (byte)2, z, z, z, z, //
    z, z, z, z, z, z, z, z};
    response.setStatus(response.SC_UNAUTHORIZED);
    response.setHeader("WWW-Authenticate", "NTLM "
    + new sun.misc.BASE64Encoder().encodeBuffer(msg1).trim());
    return;
         else if (msg[8] == 3) {
    off = 30;
    length = msg[off+9]*256 + msg[off+8];
    offset = msg[off+11]*256 + msg[off+10];
    s = new String(msg, offset, length);
    out.println(s + " ");
    else
    return;
    %></BODY>

    Please use Code tags
    Any of theses answer your question?
    Ohh, wait that code is a direct copy of the first two posts.
    What is wrong with it?

  • How to get SSO userid to URL-based app?

    I'm developing a web-app using Struts that will be accessed by Portal (I guess as a URL-based app). The web-app will not require login. The web-app will not be Portal "aware", except that it requires the SSO userid for auditing/logging purposes.
    I know little about Portal and SSO. How can Portal be configured to send the Portal userid of the logged-in Portal user? Can it send it as a parameter in a GET or POST?
    The version of Portal will be 9.0.2 (or greater).

    This topic is answered in the PDK forum here:
    How to get SSO userid to URL-based app?

  • *** How to get the username in a custom password change routine....

    How to get the username in a custom password change routine / procedure / form when a user's password has expired and is redirected automatically to this custom program?
    We use the 2nd parameter in LOGIN_URL column in WWSSO_LS_CONFIGURATION_INFO$ table to get to this custom change-password proc.

    OK !
    Use that maybe good :
    select USERID into v_user from sys.aud$
      where ntimestamp#=(
      select max(ntimestamp#)
      from sys.aud$ );

  • How to get windows username printed on each page irrespective of application? we have cm6030f.

    How to get windows username printed on each page irrespective of application? we have HP CM6030F.

    Hi,
    Normally, you will receive a Windows Azure Pass from your local Windows Azure team. Please try to contact your local Windows Azure contact (http://support.microsoft.com/gp/customer-service-phone-numbers?wa=wsignin1.0
    Also, you could see this page
    http://www.windowsazurepass.com/AzureU/AcademicFAQ and apply the free trial azure via (http://www.windowsazurepass.com/AzureU/).
    Q: I am a student. Can I apply for a pass?                     
    A: Windows Azure Educator Grants are only for valid faculty. If your faculty has been awarded a Windows Azure Educator Grant, you will be able to get a pass through him/her for you coursework. If you are interested in learning more about Windows Azure,
    we encourage you to share these Educator Grants with your faculty or sign up for the FREE 3-month trial offer. 
    Regards,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How to get CLIENT Username

    Hi Experts,
    I have a problem in retrieving my client's computer name and its username using windows api..
    Coz my program is using JNI so for the windowsAPI i used GetUserName and Get ComputerName --> It gives me the username and the computer name of the server..
    Any idea how to get another (computer username and its computer name PASSWORD IF POSSIBLE) that logon to my server.
    Any suggestion will be highly appreciated..
    Thank you
    Suwandy

    Any idea how to get another (computer username and its
    computer name PASSWORD IF POSSIBLE) that logon to my
    server.
    High hopes
    What are your clients?
    Java,jsp,html or are they servlets
    -Regards
    Manikantan

  • How to get windows username & password

    Hi friends,
    Requirement is to get windows username & password,
    My server is Tomcat4.0,
    My code in login.jsp page is
    <%
    String auth = request.getHeader("Authorization");
    if (auth == null) {
    response.setStatus(response.SC_UNAUTHORIZED);
    response.setHeader("WWW-Authenticate", "NTLM");
    return;
    if (auth.startsWith("NTLM ")) {
    byte[] msg = new sun.misc.BASE64Decoder().decodeBuffer(auth.substring(5));
    int off = 0, length, offset;
    String s;
    if (msg[8] == 1) {
    off = 18;
    byte z = 0;
    byte[] msg1 = {(byte)'N', (byte)'T', (byte)'L', (byte)'M', (byte)'S',
    (byte)'S', (byte)'P', z,
    (byte)2, z, z, z, z, z, z, z,
    (byte)40, z, z, z, (byte)1, (byte)130, z, z,
    z, (byte)2, (byte)2, (byte)2, z, z, z, z, //
    z, z, z, z, z, z, z, z};
    response.setStatus(response.SC_UNAUTHORIZED);
    response.setHeader("WWW-Authenticate", "NTLM "
    + new sun.misc.BASE64Encoder().encodeBuffer(msg1).trim());
    return;
    else if (msg[8] == 3) {
    off = 30;
    length = msg[off+17]*256 + msg[off+16];
    offset = msg[off+19]*256 + msg[off+18];
    s = new String(msg, offset, length);
    //out.println(s + " ");--------------------------> here getting system_name
    else
    return;
    length = msg[off+1]*256 + msg[off];
    offset = msg[off+3]*256 + msg[off+2];
    s = new String(msg, offset, length);
    //out.println(s + " ");
    length = msg[off+9]*256 + msg[off+8];
    offset = msg[off+11]*256 + msg[off+10];
    s = new String(msg, offset, length);
    out.println("Hello <span style='position:relative; width:190;"
    + " height:10;filter:glow(Color=#009966,Strength=1)'>");
    out.println(s + "</SPAN>");----------------------------------->here getting loginname.
    %>
    from this i was able to get systemname & username,How do i get password.
    Is it possible to get password?
    Thanks,
    Satya.

    There's no way to get the password. NTLM uses a two-round challenge-response scheme which never send the password (neither clear nor encrypted) on the wire.
    Why do you need the user's password? Is your service going to access a backend service using the user's credential? If so, you may need to use Kerberos delegation.

  • How to get SSO logged user information in a database trigger

    my database is 9i
    my application server is 9i too
    I need to track which SSO user is inserting data into a table , so how can i get the information of that user in a database trigger on that table
    thanks

    Hi,
    The only way I could figure out how to get it was to import the com.sap.security.api.
    1. From Window>Preferences>Java-->Classpath Variables, set up a variable called WEBAS_HOME pointing to:
    <drive>/usr/sap/<SID>/jc00/j2ee/cluster/server0/
    2. Right click on properties of your Dynpro Project->Properties->Java Build Path->Libraries and click "Add Variable." 
    3. Select WEBAS_HOME and click "Extend"
    4. Select /bin/ext/com.sap.api.sda/com.sap.security.api.jar and click OK.
    If you don't have access to a portal directory, you will have to get this jar file and copy it to your workspace to add to your build path instead of the above steps.
    Then in your code:
    import com.sap.security.api.IUser;
    import com.sap.security.api.IUserAccount;
      public void GetLogonID( )
         String LogonID;
         try {
              /*     create an user object from the current user */
              IWDClientUser wdUser = WDClientUser.getCurrentUser();
              IUser user = wdUser.getSAPUser();
              if (user != null) {
                   IUserAccount acct = user.getUserAccounts()[0];
                   if (acct != null) {
                        LogonID = acct.getLogonUid();
                   } else
                        LogonID = "acct null";
              } else {
                   LogonID = "user null";
              wdContext.currentContextElement().setDisplayName(user.getFirstName() + " " + user.getLastName());
              wdContext.currentContextElement().setLogonID(LogonID.toUpperCase());
         } catch (Exception e) {
              e.printStackTrace();
    Hope this helps...  I had to search several places before I found all the necessary stuff.  Maybe I can get my first points!
    Thanks,
    Andrew

  • How to get HTML form values in JSP

    retrieve<BR><BR>
    retrieveServicer<BR><BR>
    There are 2 links on a HTML page,code is in HTML page is above. I want to differentiate those two links at run time? Like which link the user has clicked, Is it possible I can do it request.getParameter() method, if so what is the syntax in HTML page and how to get it in JSP page.
    Could you please tell the answer? If anyone knows, Thanks,
    Nivas

    Hi!
    Your question is rather ambigouse!
    I guess you can use some javascript code like this!
    retrieve<BR><BR>
    retrieveServicer<BR><BR>
    <script language="javascript" >
    function a(){
    // you can change any form valuese here submit any form
    function b(){
    // you can change any form valuese here submit any form
    </script>
    If it's not your solution ,please describe you question
    in detail.
    Bye

  • How to get iStore template name from jsp filename?

    Hi,
    We have implemented Oracle iStore R12.
    We have a requirement where we want to get template access name based on jsp file name. e.g. If jsp is ibeCCkdBHdrShip.jsp it should return STORE_CHKOUT_B2B_SHIP_HEADER.
    Is there any java API available for the same?
    We know we can get jsp filename from template access name as follows:
    String jspFilename = DisplayManager.getTemplate("STORE_CHKOUT_B2B_SHIP_HEADER").getFileName()
    However our requirement is other way round..getting access name based on jsp filename.
    Any prompt help/suggestion in this regard is appreciated.
    Thanks,
    Vivek

    Hi Vivek,
                            how about the query? can you use the query in your code ? If yes please use the query below.
    SELECT distinct I.ACCESS_NAME,
    A.FILE_NAME,i.description,I.Item_Name
      FROM JTF.JTF_AMV_ATTACHMENTS A,
      APPS.JTF_AMV_ITEMS_VL I,
      IBE.IBE_DSP_LGL_PHYS_MAP M,
      IBE.IBE_MSITES_TL S
      WHERE
      A.ATTACHMENT_ID = M.ATTACHMENT_ID
      AND I.ITEM_ID = M.ITEM_ID
      AND M.MSITE_ID = S.MSITE_ID
      AND A.File_Name like 'ibeCCtdStBlSuStI.jsp'
      Order by A.File_Name
    Thanks
    Shahzad Qamer

  • How to get price in basket.inc.jsp

    Hi All,
    Could someone let me know if I can get the Gross Value (Total price) in basket.inc.jsp
    When I tried to display the value of price in this jsp I get 0 GBP because
    SalesDocument instance (salesDoc ) which is available in basket.inc.jsp is giving false value for below Boolean fields.
         boolean isTaxValueAvailable = salesDoc.isTaxValueAvailable();
         boolean isNetValueAvailable = salesDoc.isNetValueAvailable();
         boolean isGrossValueAvailable = salesDoc.isGrossValueAvailable();
    Also item.getGrossValue() gives 0 price.
    The reason is the at this stage, in SalesDocumentthe Gross Value is not available.
    Is there any way to get the price at this stage itself?
    I am currently able to get the price in checkout.inc.jsp this is the next file which gets displayed after basket.inc.jsp.
    Thanks
    Neha

    Hi Shanto
    We are using JAVA basket.
    There is absolutely no errors in Pricing.
    We are getting price in checkout.inc.jsp which is next screen to basket.inc.jsp
    The reason is, when program control comes to basket.inc.jsp, the price is not yet calculated due to the reason I think SD_SALESDOCUMENT_CREATE RFC is not yet called,
    Thatu2019s the reason, the methods in basket.inc.jsp which return price is this screen, give 0 price as the values are not yet set.
    It has been this way since beginning, also we checked in Sapu2019s standard code as well, basket.inc.jsp shows 0 price due to the fact, price values arenu2019t set yet.
    Now the scenario, we have new requirement to get the price value in basket.inc.jsp itself.
    Do you have any idea how this can be achieved.
    Thanks
    Neha

  • How to get the username/password of the current owner of the running code

    Dear friends,
    Our product is running on the App Server(weblogic/websphere...) and we also use security provider(OpenLDAP) and kerberos to support SSO. Before, when a user tyies to login in the first time, the way we use to authenticate the user is:
    1) Accept the username/password
    2) Query the security provider(OpenLDAP) to get the principles.
    3) verity if the username/password is corrent or not.
    As we know, to query the principles, we need to provide a search user(both username and password) if we configured the access control of the ldap server:
    I have configured my envirioment as follows
    1) In the LDAP server, configured the Middle Tire user(The Operating System user running the App Server) to have the permission to query principles.
    2) The server is configured to runing on SSO envirioment.
    My question is could I get the username/password of the OS user running the App Server at runtime so that I can query the ldap server without explicitly providing the search user?
    Thanks,
    RR
    Edited by: Ricky Ru on Oct 9, 2011 1:50 AM

    Thanks EJP.
    I have made some progress on this. But I have met another issue.
    *1) Using JAAS to login.*
    loginContext.login();
                   Subject subject = loginContext.getSubject();
                   ldapContext = (LdapContext) Subject.doAs(subject, this);
    *2) Init the ldapContext to use the GSSAPI authentication*
    // this is called automatically by login()
         public Object run() {
              Hashtable ldapEnv = new Hashtable();
              ldapEnv.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
              ldapEnv.put(Context.PROVIDER_URL, "ldap://9.30.215.197");
              ldapEnv.put(Context.SECURITY_AUTHENTICATION,"GSSAPI");
              ldapEnv.put(Context.SECURITY_PRINCIPAL,"");
              ldapEnv.put(Context.SECURITY_CREDENTIALS,"");
              //System.setProperty("sun.security.krb5.debug", "false");
              // This tells the GSS-API to use the cached ticket as
              // credentials, if it is available
              System.setProperty("javax.security.auth.useSubjectCredsOnly", "false");     
              try {
                   InitialLdapContext ctx = new InitialLdapContext(ldapEnv,null);
    But I got the following exception when excuting new InitialLdapContext(ldapEnv,null);
    Debug is true storeKey false useTicketCache true useKeyTab false doNotPrompt false ticketCache is null isInitiator true KeyTab is null refreshKrb5Config is false principal is null tryFirstPass is false useFirstPass is false storePass is false clearPass is false
    Acquire TGT from Cache
    Principal is [email protected]
    Commit Succeeded
    javax.naming.AuthenticationException: GSSAPI [Root exception is javax.security.sasl.SaslException: GSS initiate failed [Caused by GSSException: No valid credentials provided (Mechanism level: Integrity check on decrypted field failed (31))]]
         at com.sun.jndi.ldap.sasl.LdapSasl.saslBind(LdapSasl.java:150)
         at com.sun.jndi.ldap.LdapClient.authenticate(LdapClient.java:214)
         at com.sun.jndi.ldap.LdapCtx.connect(LdapCtx.java:2694)
         at com.sun.jndi.ldap.LdapCtx.<init>(LdapCtx.java:293)
         at com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(LdapCtxFactory.java:175)
         at com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(LdapCtxFactory.java:193)
         at com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstance(LdapCtxFactory.java:136)
         at com.sun.jndi.ldap.LdapCtxFactory.getInitialContext(LdapCtxFactory.java:66)
         at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
         at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
         at javax.naming.InitialContext.init(InitialContext.java:223)
         at javax.naming.ldap.InitialLdapContext.<init>(InitialLdapContext.java:134)
         at LDAPKerbService.run(LDAPKerbService.java:66)
         at java.security.AccessController.doPrivileged(Native Method)
         at javax.security.auth.Subject.doAs(Subject.java:337)
         at LDAPKerbService.login(LDAPKerbService.java:40)
         at LDAPKerbService.main(LDAPKerbService.java:82)
    Caused by: javax.security.sasl.SaslException: GSS initiate failed [Caused by GSSException: No valid credentials provided (Mechanism level: Integrity check on decrypted field failed (31))]
         at com.sun.security.sasl.gsskerb.GssKrb5Client.evaluateChallenge(GssKrb5Client.java:194)
         at com.sun.jndi.ldap.sasl.LdapSasl.saslBind(LdapSasl.java:105)
         ... 16 more
    Caused by: GSSException: No valid credentials provided (Mechanism level: Integrity check on decrypted field failed (31))
         at sun.security.jgss.krb5.Krb5Context.initSecContext(Krb5Context.java:663)
         at sun.security.jgss.GSSContextImpl.initSecContext(GSSContextImpl.java:230)
         at sun.security.jgss.GSSContextImpl.initSecContext(GSSContextImpl.java:162)
         at com.sun.security.sasl.gsskerb.GssKrb5Client.evaluateChallenge(GssKrb5Client.java:175)
         ... 17 more
    Caused by: KrbException: Integrity check on decrypted field failed (31)
         at sun.security.krb5.KrbTgsRep.<init>(KrbTgsRep.java:61)
         at sun.security.krb5.KrbTgsReq.getReply(KrbTgsReq.java:185)
         at sun.security.krb5.internal.CredentialsUtil.serviceCreds(CredentialsUtil.java:294)
         at sun.security.krb5.internal.CredentialsUtil.acquireServiceCreds(CredentialsUtil.java:106)
         at sun.security.krb5.Credentials.acquireServiceCreds(Credentials.java:562)
         at sun.security.jgss.krb5.Krb5Context.initSecContext(Krb5Context.java:594)
         ... 20 more
    Caused by: KrbException: Identifier doesn't match expected value (906)
         at sun.security.krb5.internal.KDCRep.init(KDCRep.java:133)
         at sun.security.krb5.internal.TGSRep.init(TGSRep.java:58)
         at sun.security.krb5.internal.TGSRep.<init>(TGSRep.java:53)
         at sun.security.krb5.KrbTgsRep.<init>(KrbTgsRep.java:46)
         ... 25 more
    Do you have any clue on this? Thanks.

  • How to get application username

    Hi All,
    I would like to get the application username, but I don't know how to get it. Can anyone tell me, thanks.

    Okay,
    and how does your application user connect to the application? Is there any kind of user authentication you perform before letting the user in?
    If not then all you can do is to try and get the VM system information if running with local deployment
    package mypackage5;
    import java.util.*;
    public class Class1
    public Class1()
    String user = System.getProperty("user.name");
    System.out.println("The user is:"+ user);
    public static void main(String[] args)
    Class1 class1 = new Class1();
    Frank
    Frank

  • HttpSessionListener: how to get the username?

    When a session is created, I want to read some data from database
    and store it as session variables. What data is to be read depends
    on the user name.
    I use the HttpSessionListener.
    How can I get the username from within the sessionCreated method?
    I could getRemoteUser() from HttpServletRequest, but how do I get
    the request?
    J2EE API documentation says:
    public interface HttpSession
    Provides a way to identify a user across more than one page request or
    visit to a Web site and to store information about that user.
    Therefore, my problem ought to have a solution, oughtn't it?

    You'd like to think so.
    Unfortunately, the Servlets 2.3 spec does not appear to address combining deployer-based authentication with deployer-based listener classes. This means it's pretty much up to the vendors whether you can do this.
    I'm using jetty/jboss, and the situation is as follows:
    Authentication info is stored in the session only if you use form-based authentication (which, as I found, means you're forced to use form-based authentication if you want your users to be able to log off.)
    However, even if you are using form-based authentication, there are two problems.
    1. your HttpSessionListener implementing class gets called BEFORE they login (i.e. before the login page is presented). So there's nothing in the session yet.
    2. How the container stores the authentication info in the session is entirely up to the vendor. In the case of jetty, the login is stored in the session property "org.mortbay.jetty.Auth".
    So in the case of Jetty, you'd need to implement HttpSessionAttributesListener, wait for that property to be set, and then get the stuff from the db based on that setting. Needless to say, this is highly non-portable. sigh.
    I think the only way to do what we want is to forget HttpServletRequest and use a filter instead. Bummer.
    Did you come up with any bright ideas in the end?

  • How to Skip SSO Username and passowrd.

    i just installed Oracle Application Server .2.0.2 on Windows 2003.
    Before i can view report i have to give SSO Username and password i want to skip this step and report can be executed directly from my Forms.
    i have already commented the SSO lines from my formsweb.cfg file. as shown below
    #ssoDynamicResourceCreate=true
    # Single Sign-On parameter: URL to redirect to if ssoDynamicResourceCreate=false
    #ssoErrorUrl=
    # Single Sign-On parameter: Cancel URL for the dynamic resource creation DAS page.
    #ssoCancelUrl=
    # Single Sign-On parameter: indicates whether the url is protected in which
    # case mod_osso will be given control for authentication or continue in
    # the FormsServlet if not. It is false by default. Set it to true in an
    # application-specific section to enable Single Sign-On for that application.
    #ssoMode=false
    Thanx in advance

    I assume you are not using Oracle's Portal or otherwise already using OID as an SSO server.
    There are two big steps you'll need to do this
    Enable and configure SSO for Forms
    http://www.oracle.com/technology/sample_code/products/forms/viewlets/10g/frmsso/frmsso_viewlet_swf.html
    Enable WNA for OAS : Read Metalink doc 345025.1. It is not a simple process.
    WNA will log into the SSO server via Kerberos. When the Forms connection fires off, it is from the Forms server, so Kerberos is not an option. Instead the Forms server will use a Resource Access Descriptor (RAD) to retrieve username/password/sid logon information from the OID server stored in the OID SSO account that your authenticated into via WNA
    If you are already using Portal & have users sign, then WNA is not needed & just go with the SSO for Forms.

Maybe you are looking for