How to set username in securityContext??

ADF Security uses SecurityContext to retrieve username and display page using roles of a particular user...... and we add users and application roles in jazn-data.xml
Actually my website created in adf doesn't have any login page..... It will receive user information from another website....
Now i want to display pages and their content based on user and their role....
Can u please tell me how to set Username in securityContext such that my website will work on the username retrieved from another website via token....
Please answer this question.....

This may help...
public String doLogin() {
String un = _username;
byte[] pw = _password.getBytes();
FacesContext ctx = FacesContext.getCurrentInstance();
HttpServletRequest request =
(HttpServletRequest)ctx.getExternalContext().getRequest();
try {
Subject subject =
Authentication.login(new URLCallbackHandler(un, pw));
weblogic.servlet.security.ServletAuthentication.runAs(subject,
request);
String loginUrl =
"/adfAuthentication?success_url=/faces/DashBoard";
HttpServletResponse response =
(HttpServletResponse)ctx.getExternalContext().getResponse();
sendForward(request, response, loginUrl);
} catch (FailedLoginException fle) {
FacesMessage msg =
new FacesMessage(FacesMessage.SEVERITY_ERROR, "Incorrect Username or Password",
"An incorrect Username or Password was specified");
ctx.addMessage(null, msg);
} catch (LoginException le) {private void reportUnexpectedLoginError(String errType, Exception e) {
        FacesMessage msg =
            new FacesMessage(FacesMessage.SEVERITY_ERROR, "Unexpected error during login",
                             "Unexpected error during login (" + errType +
                             "), please consult logs for detail");
        FacesContext.getCurrentInstance().addMessage(null, msg);
         e.printStackTrace();
reportUnexpectedLoginError("LoginException", le);
return null;3
private void reportUnexpectedLoginError(String errType, Exception e) {
FacesMessage msg =
new FacesMessage(FacesMessage.SEVERITY_ERROR, "Unexpected error during login",
"Unexpected error during login (" + errType +
"), please consult logs for detail");
FacesContext.getCurrentInstance().addMessage(null, msg);
e.printStackTrace();
Thanks,
CM.

Similar Messages

  • How to set username and password at line vty 0 4?

    hi guys,
    would like to know how i can set username and password so when i telnet to the router, i can login as username and password..?
    thks,
    ken

    Hi,
    for a simple telnet password with user name & password, find the steps below,
    aaa new-model
    username password
    line vty 0 4
    password
    login local
    if you wanted different types of users to login with different privilagez,do the following
    username privilege 15 password
    username privilege 5 password
    privilege exec level 15 conf t
    privilege exec level 5 show
    line vty 0 4
    password
    login local
    in the above statement "privilege exec level 15 "will have full access, "privilege exec level 5" will have the limited like "show" related
    hope this helps.
    rate this post if cleared.

  • How to set username and password when using Proxy class for SOCKS5?

    Hi all,
    I use the proxy class for SOCKS5, so need to set username and password, I don't find where can I set the value. whether the API support it.
    Thanks in advance!

    System.getProperties().put("proxySet", "true");That does nothing. Remove.
    System.getProperties().put("proxyHost", getProxyHost());
    System.getProperties().put("proxyPort", getProxyPort());You should be setting socks.proxyHost and socks.proxyPort here.
    System.setProperty("java.net.socks.username", getSOCKSUsername());
    System.setProperty("java.net.socks.password", getSOCKSPassword());
    Authenticator.setDefault(new ProxyAuth(getSOCKSUsername(), getSOCKSPassword()));You either need the first two lines or the third, not both. See the last link posted above.
    1. After I set the value, I connect internet by proxy, how the proxy server knows the values?Because Java tells it during the SOCKS handshake.
    2. In my app, I just set the values in the system properties, then JVM does remaining work? Remaining work is not concerned?Should be OK unless you have to connect to a different SOCKS proxy from the same JVM, but that kind of thing is problematic anyway due to the curious Authenticator design which is set globally, not per connection as you might expect.

  • How to set username and password before redirecting to a RESTful webservice

    I am a .Net developer who has developed a webservice used by my ColdFusion colleagues. They are using ColdFusion 9 but I'm not sure if they have incorporated any of the newer features of ColdFusion in their apps. Here is a snippet of how they have been invoking the webmethods:
    <cfscript>
                         ws = CreateObject("webservice", "#qTrim.webServiceName#");
                         ws.setUsername("#qTrim.trimAcct#");
                         ws.setPassword("#qTrim.trimpwd#");
                         wsString=ws.UploadFileCF("#qTrim.webserviceurl#","#objBinaryData#", "#qFiles.Filename#", "Document", "#MetaData#");
                </cfscript>
    As I understand things, the .setUsername and .setPassword correspond to the Windows credentials the CF Admin set when the URL of the .Net webservice was "registered" and given its "name" (for the CreateObject statement above). I have 4 webmethods that are all invoked in this manner and this SOAP protocol works adequately for us. Please note that this ColdFusion web app authenticates anonymous remote internet users by prompting for a username and password and compares them to an application database (i.e. Microsoft calls this "forms authentication"). Because only a few Windows domain accounts are authorized to call this .Net webservice, the above code always uses the same username/password constants and it all works.
    My question involves the newest webmethod added to the .Net webservice. It requires that callers must invoke it as a RESTful service which means it must be invoked by its URL. Here is a snippet of C# code that invokes it from an ASP.NET webclient:
                string r = txtRecordNumber.Text;
                string baseurl = "http://localhost/sdkTrimFileServiceASMX/FileService.asmx/DownloadFileCF?";
                StringBuilder url = new StringBuilder(baseurl);
                url.Append("trimURL="); url.Append(txtFakeURLParm.Text);
                url.Append("&");
                url.Append("TrimRecordNumber="); url.Append(txtRecordNumber.Text);
                Response.Redirect(url.ToString());
    I assume a ColdFusion script could easily build a full URL as above with appended querystring parameters and redirect. Is there some way for the CF code redirecting to a RESTful webservice (by way of its URL) to set the Username and Password to this Windows account mentioned above? When the DownloadFileCF webmethod is hit it must be with the credentials of this special Windows domain account. Can that be set by ColdFusion someway to mimic the result of the SOAP technique (the first snippet above).
    I hope my question is clear and someone can help me make suggestions to my ColdFusion colleagues. Thanks.

    Can you clarify what you mean by "establish a different Windows identity"?  Usually passing identity to a web site or service means adding something to the request's HTTP headers.  This could be a cookie in the case of .NET forms authentication or the "Authorization" header in the case of basic authentication.
    The SOAP web service invocation code you posted does use basic authentication, according to the CF docs "ColdFusion inserts the user name/password string in the authorization request header as a base64 binary encoded string, with a colon separating the user name and password. This method of passing the user name/password is compatible with the HTTP basic authentication mechanism used by web servers."
    http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec13a13 -7fe0.html
    If you need to mimic the SOAP techinque you should have basic authentication enabled for your REST service endpoints.
    If your authentication method is different then CF developers will need to add the appropriate HTTP headers to their service calls.  Note that calling a REST service from CF would probably be accomplished using the CFHTTP tag if the service is designed to be consumed by the CF server.

  • How to Set username in ADF from JAAS

    Greetings :
    I have an application that is mostly working. The problem is this. A user logs in using a JAAS module I wrote. As the principal I set their username. That works, I can display it on a jsp page or put it in session just fine. The problem is that when this user creates a new record there is a owner field that I want to default to this username. For example, I have a table mapped to adf data controls. Somewhere in the entity object (or wherever you think if you tell me differently) I would like to do something like :
    setOwner(request.getUserPrincipal().getName());
    the problem is, that I don't have the request object inside the create for example (obviously so and it most certaily shouldn't be accessible there).
    Can anyone tell me the best way to do this sort of thing?
    Thanks
    Troy

    You can look in help under:
    Enabling a Database Audit Trail in an Entity Object Definition
    This will give you the option to save created by, created date, modified by and modified date with the record. The username will be prefixed by the realm.
    You can get the username inside an application module via:
    String userId = getUserPrincipalName();

  • How to set username/password in OSB Business Service

    Hi
    I need to call thirt party http service that utilizes Http Basic authentication i.e. username / password. If I call the same service through Oracle SOA I can either
    put the username/password inside composite.xml but that way the password is visible. So have set the usrname/password insid the console.
    Now want to use OSB to call the sam service. Created business service but where do I add the username/password. Is there a plac inside sbconsole I can set the username password.
    Thanks

    You must a "Service Account" available in OSB and assosciate it with the Business service you invoke.

  • How to set username and role?

    From httpservelet request we can get user name using getUserPrincipal() and also can check whether user in role or not. To do this before the servlet is invoked some one has to set the UserName and Role in the request. who does this job? if i want to set them using my program what should i do? please guide me in this?

    Fine, here is the link to webapp security documentation:
    http://download.oracle.com/javaee/5/tutorial/doc/bncas.html
    Boring material, but nobody said that research was going to be a fun part of the software engineer's life - too bad it is a crucial part of the job. You can either take or completely ignore the message I'm hiding in there, that is your choice.

  • How to set Username and Password to a URLConnection?

    My applet is supposed to access a servlet that is only accessible when username and password are correct.
    I've made a URLConnection object to connect to the servlet, but the problem is that I don't know how to add the username and password details to this connection.
    Can anyone please help?
    Terry

    Does any one know how to do it?
    Please, it's quite urgent...
    And there's 10 DD as award if someone points me in the right direction, please help.

  • How to set userName from security context to Criteria in portlet

    Hi,
    From the portal application I have to get the logged in user and use the same user to filter the records in Portlet. I have to execute a view Criteria in portlet as a default method activity which takes logged in user as a input param.
    Is this achievable? Please let me know.
    Thanks in Advance
    Morgan.
    Edited by: Morgan Freeman on Aug 24, 2011 1:22 AM

    I have been doing some testing and there seems to be an issue with passing username to the portlet.
    Normally things like security.userName or portletrequest.getRemoteUser() should all work and they do work in webcenter PS2 but since JSR 286 this does not seem to work anymore.... ALthough the documentation of oracle states that is works but it doesn't :)
    A working workaround is to create a public render parameter (portlet parameter) and pass the username to that.
    I'll see if there is a configuration that we need to make in order for this to work.

  • How to set username and password for a tcode ?

    Dear Gurus,
              Greets..................
    Pls provide me solution for my scenario. My program is module pool program.It has been assigned by a Tcode.when the end user enter the tcode in command box,I should display a small screen with username and password(****).If username and password is correct,it should allow the end user to execute that particular tcode.If not i should display warning message that he is not eligible to access that program.
    Thanks & Regards.
    Raj

    Hi Raj,
    You can do this by creating a Login screen for the users and check the authentication of each user in PAI i.e. PROCESS AFTER INPUT.
    Store the user information in a database table and check the username and password when the user enters it.
    You can display password as *** also. For this double click on input box designed for password and goto Display tab. Select Invisible in the list and check it.
      CASE sy-ucomm.
        WHEN 'BACK'.
          LEAVE PROGRAM.
        WHEN <fcode for submit>.
          SELECT SINGLE uname pwd
           FROM <DB table>
           INTO (user, pass)
           WHERE username = user AND
                   password = passwd.
          IF sy-subrc = 0.
    <Go to next screen for further processing>
          ELSE.
    <Display Error message and exit>
          ENDIF.
      ENDCASE.
    Regards,
    Amit
    Message was edited by:
            Amit Kumar

  • How to set the file path dynamically based on sytem, username, and date

    Hi All,
    My requirement is upload the data into one  structure like xyz that is related to t.code MCSZ.
    file will be in  UNIx SERVER .
    PATH IS: /sapif
    file name is xy789 load .txt
    I have  to write code in one user-exit
    how can i set the file path for this.
    shall i put hard code file path?
    because i have to writecode in user-exit.
    plz tell me how to set the file path based ons syetem, username, date
    Thanks in advance
    Ram.A

    Concatenate the field SY-SYSID, SY-UNAME and SY-DATUM for the file path

  • How to set the username in PeopleEditor programmatically

    Hi ,
    How to set the user name in people picker entity programmatically.
    I have tried this:
    <sp:PeopleEditor ID="sppcustom" runat="server" AllowEmpty="false" MultiSelect="false" SelectionSet="User" />
    In the webpart cs code:
    PeopleEditor sppcustom = new PeopleEditor();
    sppcustom.CommaSeparatedAccounts = "domain" + "\\" + userFullname;
    The code is executing fine without error, however the username is not shown in the peopleeditor.
    When the name is added, i am getting the error "No exact match was found. Click the item(s) that did not resolve for more options.".
    However the username is a valid one. i tried the validate code also and the username was validated.
    How to fix this?
    Thanks

    You can set the display name of the particular user
    sppcustom.CommaSeparatedAccounts = userFullname.Name;
    if userFullname is SPUser 
    Gnanasekhar K

  • How to set  Oracle username to a column .

    Hi Everyone,
    i have a table with some columns for example: ROW_CREATED_BY,ROW_CHANGED_BY we have to set Oracle username in trigger
    i.e., i have a trigger
    create or replace
    TRIGGER "EMP_TRG" BEFORE INSERT OR UPDATE ON EMPLOYEE FOR EACH ROW
    BEGIN
    If inserting then
    if :new.ROW_CREATED_BY is NULL then
    :new.ROW_CREATED_BY := *?;*
    end if;
    END;
    we can make use of V$SESSION.USERNAME, how to set this in trigger
    can we write   :new.ROW_CREATED_BY      := V$SESSION.USERNAME;
    since i didnt have permission to acess V$SESSION table or any other approch to set Oracle username to a column
    Please NeedHelpFul

    The USER-Function gives you the name of the currently logged in user.
    Are you looking for this?
    http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions207.htm#sthref2462
    you could directly use it in your trigger like this:
    create or replace
    TRIGGER "EMP_TRG" BEFORE INSERT OR UPDATE ON EMPLOYEE FOR EACH ROW
    BEGIN
    If inserting then
    if :new.ROW_CREATED_BY is NULL then
    :new.ROW_CREATED_BY := USER;
    end if;
    END;

  • How set  UserName and Password for HTTP Basic Authentication for a servlet

    Hi..
    How set UserName and Password for HTTP Basic Authentication for a servlet in JBoss server?
    Using Tomcat i can do it .(By setting roles in web.xml, and user credintails in tomcat-user.xml).
    But i dont know how do it in JBOSS..
    I am using Netbeans and Eclipse IDEs.. Can we do it by using them also!?
    Thank u

    Hi Raj,
    You can do this by creating a Login screen for the users and check the authentication of each user in PAI i.e. PROCESS AFTER INPUT.
    Store the user information in a database table and check the username and password when the user enters it.
    You can display password as *** also. For this double click on input box designed for password and goto Display tab. Select Invisible in the list and check it.
      CASE sy-ucomm.
        WHEN 'BACK'.
          LEAVE PROGRAM.
        WHEN <fcode for submit>.
          SELECT SINGLE uname pwd
           FROM <DB table>
           INTO (user, pass)
           WHERE username = user AND
                   password = passwd.
          IF sy-subrc = 0.
    <Go to next screen for further processing>
          ELSE.
    <Display Error message and exit>
          ENDIF.
      ENDCASE.
    Regards,
    Amit
    Message was edited by:
            Amit Kumar

  • How to create a custom SecurityContext

    I download jaasdatabaseloginmodule-134915 and can use it to check username and password stored in DB. A table contain username and password such as username is jcooper and his password is welcome1.
    I use Jdeveloper 11.1.1.14 to open this project and create an ADF viewcontroller project. The viewcontroller project has login.jspx and welcome.jspx. I add security to this application. Login.jspx is the first page and welcome.jspx is the second page. If the user login, the welcome.jspx will be opened. After I set application->secure, if I run welcome.jspx, this page will be redirected to login.jspx.
    Then, I key in username and password. Java code in backingbean will check the user input with database table contents. If the username and passwork are correct, the jdeveloper log console will print out: User jcooper authenticated successfully
    However, ADFContext.getCurrent().getSecurityContext().isAuthenticated() is false and ADFContext.getCurrent().getSecurityContext().getUserName() is anonymous. Then, the page cannot redirect to welcome.jspx. In the welcome.jspx, I add : <af:commandButton text="Welcome #{securityContext.userName}" id="cb1"/>
    However, after redirecting, I cannot get username. It only shows anonymous.
    How to write a custom SecurityContext or use oracle's SecurityContext to set the status is authenticated. And then, redirectorying to next jspx page and shows current login user?. Could anyone paste the source code?
    I do not add user to jazn-data.xml due to username and password are stored in database. I do to not use weblogic SQL authentication because my boss wants to run this application not only on weblogic 10.3.4 but also on Tomcat, Jboss, or websphere. Can I do that?
    If anyone knows the tutorial or documents, please paste the whole web address.
    Thanks.

    Hi,
    when you security enable the application, adf-config is configured with oracle.adf.share.security.providers.jps.JpsSecurityContext. I would assume you have to extend this class to get your own context created. There is no documentation available I am aware of that covers this. So best is to file a Service Request with customer support to get the ADF Source code (if you have a support contract) and go from there.
    However, I am not sure there us a need for this as ADF Security delegates authentication to the container, which means that it is the container that provides the authenticated user information. For you this means that the login module should not be called by the application directly but configured as an authentication provider on the WLS server. This way the security context is provided for you. Programmatic authentication, which uses WLS authentication, is documented in the developer guide. Note that there is a SQL authentication provider already available in WLS so that you pobably dont have to use yours
    http://download.oracle.com/docs/cd/E17904_01/web.1111/b31974/adding_security.htm#BABDEICH
    http://download.oracle.com/docs/cd/E17904_01/web.1111/e13707/atn.htm
    Frank

Maybe you are looking for