How to prevent multiple logins by using HttpBindingListener

Hi,
Can anyone tell me how do i actually use session to prevent multiple login from different machine? From my understanding, i need to use HttpBindingListener to valueBound and valueUnbound when user tries to login, but i encounter a problem is my session is always overwritten since i use setAttribute() method in servlet.
For instance i use username(aaa & bbb) to login in two different machine, my login is always overwritten if i use username bbb to login after username aaa. i know it is because setAttribute() method overwrite existing session data, so i would like to know what other method should i use to achieve what i want, tks.

Hi,
This is the logic for session :
Connect to db for verification, once verified, system return a UserBean and this UserBean will be set in ClientSecurityEngine
When this particular user has been successfully verified, a new session will be created
if(success)
    session = request.getSession();
    User user;
    synchronized(session)
    user = (User) session.getAttribute("user");                       
    if(user == null)
       user = new User(ClientSecurityEngine.getInstance().getUserBean().getUsername());
       session.setAttribute("user", user);
/* User class */
public class User implements HttpSessionBindingListener {
    private static Map<String, HttpSession> logins = Collections.synchronizedMap(new HashMap<String, HttpSession>());
    private String username;
    public User(String username) {
        this.username = username;       
    public String getUsername() {
        return username;
    @Override
    public void valueBound(HttpSessionBindingEvent event) {
        if (logins.containsKey(getUsername())) {
            HttpSession session = logins.remove(getUsername());
            if (session != null) {
                session.invalidate();
            logins.put(getUsername(), event.getSession());
        } else {
            logins.put(getUsername(), event.getSession());
    @Override
    public void valueUnbound(HttpSessionBindingEvent event) {
        logins.remove(getUsername());
}Edited by: EJP on 21/07/2011 14:22: added {noformat}{noformat} tags so we can actually read your code. Please use them.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Similar Messages

  • How to prevent re-login when switching in the application between different module in 6.1.1.1.11?

    How to prevent re-login when switching in the application between different module in 6.1.1.1.11?
    Please help me to figure out this or resolve this issue?

    Be sure to check that your Remoting Container service is running. If it is not, restart the service, and if it goes down again, check the event logs.
    Make sure that the AuthenticationBridgeService is enabled in your EnvironmentSettings.config, and the remoting container user is configured using the SetupAssistant.
    <RemotingContainer>
             <ConfigInfo configChildKey="key">
                   <add key="UserID" value="@@VAR:Prodika.RemotingContainer.SysUser@@" />
             </ConfigInfo>      
            <!-- Set the following services isActive flag to 'true' or 'false' -->
             <RemoteServices configChildKey="name">
                 <Service
                     name="AuthenticationBridgeService"
                     port="@@VAR:Prodika.AuthenticationBridge.Port@@"
                     isActive="true" />
    If the Remoting Container Service fails, please contact Support with details from the event logs.

  • How to avoid multiple LOGIN with same user in database.

    Hi All,
    Using database triggers how to control multiple logins of a pertiuclar user.
    thanks in advance

    Don't forget to activate the RESOURCE_LIMIT parameter, which default is FALSE :
    alter system set RESOURCE_LIMIT = true;
    Laurent, I had a similar problem some time ago : I didn't want to avoid multiple access, but only control who was doing what. That's because moving from Client/Server to Web the TERMINAL column in V$SESSION becomes useless.
    I tried your solution, but I had to give up with it, because in my Forms9i application some forms call Reports, which generate a new session.
    I decided to use DBMS_APPLICATION_INFO, and this is satisfactory for my requirements, but I'm interested to discover other solutions.
    P.S. with my solution I'm able to limit accesses, because in the CLIENT_INFO string I put, among other things, the
    application user, so I can control if an user is already connected. The problem is that existing applications have to be modified .....:-(

  • How can i design my application to prevent multiple login

    i need to develop a new application which want to prevent multiple user login. How can i do that? if i put all userid in a stack/arraylist and set it global, then set a filter to check the stack each time, is it ok, or have another better solution to do that. Thanks.

    Your client application needs to contain a unique Session identifier and the server application needs to keep a mapping of these Session identifiers against the User that is logged in.
    Then if another client app trys to log in with the same User ID and it is not the same as the current logged in Session identifier for that User, you can deny them access.
    Make sure the client app has a mechanism for logging out the current User/Session identifier, by way of a button or event.
    Events may go as follows:
    1. User A logs in
    2. Server app creates Session ID 1.
    3. Client app is assigned Session ID 1.
    4. Server app maps User A to Session ID 1.
    then later
    5. Different user tries to log in as User A.
    6. Server app checks for Session ID.
    7. No Session ID exists.
    8. Not the same user - go away (or other instruction)
    or
    5. Original User A (from point 1) logs in again.
    6. Server app checks for Session ID.
    7. Client app sends Session ID 1.
    8. Server app checks mapping of Session ID 1 to User A.
    9. Success, User A is the original user - please continue what you're doing.
    How you implement the storing of the Session ID on the Client app is dependant on the type of app your building - Cookies for web apps or encrypted files for GUI apps. The same applies for storing the mapping of the User to the Session but a database is the easist route to follow.
    Hope this helps.

  • How to prevent multiple users from updating the same data in coherence

    Hi,
    I have a Java Web Application and for data cache am using coherence 3.5. The same data maybe shared by multiple users which maybe in hundreds. Now how do I prevent multiple users from updating the same data in coherence i.e. is there something in coherence that will only allow one user a time to update. If one user is in a process of updating a data in coherence and some other user also tries to update then the second user should get an error.
    Thanks

    I have a question on the same line. How can I restrict someone from updating a cache value when I a process is already working on it. I tried locking the cache key but it does not stop other process to update it , it only does not allow other process to get lock on it.

  • Preventing Multiple Logins

    Is there a fairly simple way to prevent a user from having more than one concurrent login? I want to prevent the same user from logging in more than once by starting multiple telnet sessions or using multiple terminals.
    Thanks!

    Number 2 should happen naturally, AFAIK. As long as the session key is stored in a browser cookie (not given an expiration date in the future), closing the browser (that is, closing all open browser windows) should end the session. Of course, it will take a while to time out on the server. Also, if you've got three IE windows open and you close one of them, the cookie (and session) will remain.
    As far as the simultaneous multiple logins goes... You could just store a Set of "logged in users" in the servlet context, and then make sure that a user trying to log in is not a part of that set. I guess you'd have to use an HttpSessionBindingListener to remove them from the Set when their session times out or is forcefully invalidated.
    Of course, if you do that, you would run into problems when the following happened:
    (1) Logged-in user closes browser, losing temporary session key cookie.
    (2) User realizes they forgot something, opens a new browser window, and tries to log in.
    (3) Session still hasn't timed out on the server, so the user is denied login.
    My guess is that people would complain. I think the requirements are nearly impossible to do right. There's just no way to know for sure (on the server) whether a user still has their browser open at the other end, and so that leaves you open to the aformentioned problem if you try to prevent simultaneous logins of a single user.
    I could be wrong, though.

  • F110 - How to prevent multiple creation of DME file?

    Hello,
    I need to prevent multiple creation of DME file for the same Payment Run (after it has been created once).
    "Printout" bottom creates DME file and Payment Advice any time you trigger it.
    I'm searching for some User Exit / BAdi / Function that will help me to add ABAP code that will check if DME file has already been created.
    Thank You in Advance

    Hello,
    Please check if the flag "Create payment medium" is not flagged at the proposal and the payment run file.
    If it is flagged the payment file will be generated. Also when you press the print out button, the print program will be called and the system will try to created a new payment file.
    In order to avoid duplicated payments you should consider using the flag 'Payment Document Validation" in your print program.
    If the 'Payment Document Validation' parameter is not set ON, documents already processed for payment can be selected and paid again in a subsequent payment run, when posting terminations have occurred.
    Please refer to SAP Knowledge Base Article 1713825 in order to activate Payment Document Validation.
    Another option is to suppress  the"Create Payment Medium" flag at Proposal Run.
    In this case you should check the following information:
    Please restrict the activity 15 of object F_REGU_BUK in the user
    profile/role
    You may also refer to the available activities on this:
    - 02 Edit parameters
    - 03 Display parameters
    - 11 Execute proposal
    - 12 Edit proposal
    - 13 Display proposal
    - 14 Delete proposal
    - 15 Create payment medium proposal
    - 21 Execute payment run
    - 23 Display payment run
    - 24 Delete payment run payment data
    - 25 Create payment media of payment run
    - 26 Delete payment orders of payment run
    - 31 Print payment medium manually
    Kind Regards,
    Fernando Evangelista

  • How to avoid multiple if else using design patterns.

    Hi,
    Which design patterns is used to avoid lot of if else in our code . Say for example if the user press 1 the out put should be one, if he press 2 it should be two like this upto 10. So we need to include lot of if-else part. How to avoid the multiple if else using design patter for this scenario. I can't find the solution for this problem can you guys help me?.

    I'm too lazy to read a whole text book, but the first google link provides a code sample which made me laugh.
    http://www.refactoring.com/catalog/replaceConditionalWithPolymorphism.html
      double getSpeed() {
        switch (_type) {
          case EUROPEAN:
            return getBaseSpeed();
          case AFRICAN:
            return getBaseSpeed() - getLoadFactor() * _numberOfCoconuts;
          case NORWEGIAN_BLUE:
            return (_isNailed) ? 0 : getBaseSpeed(_voltage);
        throw new RuntimeException ("Should be unreachable");
      }My implementation of The Bridge Over The Parrot Shop
    package forums;
    import java.util.Random;
    abstract class Bird {
      private static final Random random = new Random();
      abstract double getAirSpeed();
      public double getBaseSpeed() {
        return randomDouble(18.96);
      protected static double randomDouble(double max) {
        return random.nextDouble() * max;
      protected static int randomInt(int max) {
        return random.nextInt(max);
    class EuropeanSwallow extends Bird {
      double getAirSpeed() {
        return getBaseSpeed();
    class AfricanSwallow extends Bird {
      private int _numberOfCoconuts;
      public AfricanSwallow() {
        this(randomInt(4));
      public AfricanSwallow(int numberOfCoconuts) {
        _numberOfCoconuts = numberOfCoconuts;
      double getAirSpeed() {
        return getBaseSpeed() - getLoadFactor() * _numberOfCoconuts;
      public double getLoadFactor() {
        return randomDouble(3.12);
    class NorwegianBlue extends Bird {
      private boolean _isNailed;
      private double _voltage;
      public NorwegianBlue() {
        this(randomInt(10)<2, randomDouble(12.0));
      public NorwegianBlue(boolean isNailed, double voltage) {
        _isNailed = isNailed;
        _voltage = voltage;
      double getAirSpeed() {
        return _isNailed ? 0 : getBaseSpeed(_voltage);
      double getBaseSpeed(double voltage) {
        return getBaseSpeed() * (1+(voltage/Math.PI));
    public class AirSpeedTest
      public static void main(String[] args)
        System.out.println("EUROPEAN: "+new EuropeanSwallow().getAirSpeed());
        System.out.println("AFRICAN: "+new AfricanSwallow().getAirSpeed());
        System.out.println("NORWEGIAN_BLUE: "+new NorwegianBlue().getAirSpeed());
    }... and the requisite background for the uninitiated [NORWEGIAN_BLUE|http://www.youtube.com/watch?v=4vuW6tQ0218] and [EUROPEAN v AFRICAN|http://www.youtube.com/watch?v=4b4bGAoVR7g].
    You have to know these things when you're a King you know.
    Cheers. Keith.

  • How to achieve multiple hirearcy structure using RBS feature in Project server 2013

    HI,
    How can we achieve multiple hirearcy structure using RBS feature in Project server 2013?
    The below is the screen shot of hirearcy.
    GM
    DGM
    AGM
    CM
    Officers
    There are different departments and one AM may handle 4 or more department. How to achieve this permission levels so that GM can see all departments officers created project, same with other levels
    Thanks,
    Sunitha

    Hi Sunitha,
    You could populate the RBS lookup table with 2 levels (department and sub department). Then configuring correctly your
    security categories based on the RBS, the resources in the 1st level (departments) will see projects from all theirs sub departments.
    Some more references:
    http://aboutmsproject.com/project-server-securitypart-1/
    http://ntrajkovski.com/2012/06/04/the-rbs-lookup-table-in-ms-project-server-2010/
    Hope this helps,
    Guillaume Rouyre, MBA, MVP, P-Seller |

  • How to create multiple ifs users using XML

    I used the following xml file to create a ifs user. But I don't know how to create multiple users using XML. Thanks for your help.
    <SimpleUser>
    <UserName>bill</UserName>
    <Password>bill</Password>
    <DirectoryUserDescription>Bill</DirectoryUserDescription>
    </SimpleUser>

    There are many good resources for Powershell tutorials. The MS help page for each cmdlet is usually a good place to start.
    The suggested answer is very good and easy to modify to your needs. The linked article provides good detail on creating your csv file. If you look at their sample csv, you will see the column for LicenseAgreement and UsageLocation. You can change the script
    to use the values from the csv instead of the same value for every user like so:
    -LicenseAssignment $_.LicenseAgreement -UsageLocation $_UsageLocation
    Basically, $_.<valuename> is the filled in by the value under the heading <valuename> in your csv file for the current user. 
    As for what msdivision, replace this with the correct domain name value for your organization. You can get the values for license SKUs from existing users by using the following:
    Connect-MsolService
    Get-MsolUser -UserPrincipalName <userprincipalname> |select Licenses

  • How to create multiple physical channels using DAQmx?

    Hi, I am new to Labview.
    Can anyone please help me on how to create multiple physical channels? I am following the LabVIEW examples in the NI example finder but they are only for acquiring signals from one channel.
    Actually, I am using the channels of an SCXI 1520 to measure voltage signals. And one more thing, in the NI Example Finder, they are sample codes there for setting the filter in SCXI 114x.
    Will this example work with an SCXI 1520, too?
    Thanks!

    There are many ways to read multiple channels in LabVIEW. First, if you look at that example that lets you set the filter setting on the 114x and you click on the 'Physical Channel Listbox' then click 'Browse' you can see that you can select multiple channels. After you select the channels and hit 'Ok' it will build a multiple channel string. This is one way to read multiple channels.
    Next, you can create a 'Task' in Measurement and Automation Explorer(MAX). When you create this task select all the channels that you need to read then back in LabVIEW simply select a 'DAQmx Task Name Constant' Select the task you just created and wire that to an Input of your first DAQ VI. If you do this you do not need to have a 'DAQmx Create Physical Channel' VI or create
    Task because it is already created in MAX.
    When looking at example VIs you can tell if a multi-channel read is acceptable by looking at the 'DAQmx Read' and if it says NChan that means it will do a multichannel read. There are tons of example programs that will display the multichannel read capabilities.
    This example may not work for the 1520 because the properties that are set could possibly be specific to the 142x. When using the 1520 though it is very likely that the properties will be very similar if not exact. You will simply put a DAQmx Channel property node on your block diagram and then look for the Lowpass filter settings properties that will most likely be in the same location. Now another way todo this without using a property node would be in MAX when you create a task set the filter settings from the Device tab in the task configure window.
    Let me know if you need anymore help with reguards to this issue! Have a great day!
    Allan S.
    National Instrument
    s
    Applications Engineering

  • How to prevent multiple submit (replay attack)?

    Hi there, I have managed to submit the form to the server side. However, is there any way to prevent the client side from keep submitting the form? I have heard of using random number, but I don't know what javascript code to place in the web page. Can anybody help, because I am stuck in the problem for quite a long time.
    Thanks,
    Rocky.

    r0ckytay89 wrote:
    Hi there, I have managed to submit the form to the server side. However, is there any way to prevent the client side from keep submitting the form? I have heard of using random number, but I don't know what javascript code to place in the web page. Can anybody help, because I am stuck in the problem for quite a long time.
    Thanks,
    Rocky.Well there are two ways of implementing this.
    1).Javascript Solutions (and mind you never always try disabling the submit button )
    [http://www.elated.com/articles/preventing-multiple-form-submits/]
    [http://www.web-source.net/web_development/form_submission.htm]
    2).Maintaining state of the form on server side and using a token for preventing mutiple submits.
    try to go through the solutions recommended in the below articles
    [http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=50&t=016689]
    [http://faq.javaranch.com/java/HowToPreventMultipleFormSubmits] (In struts)
    Or a more generalized solution is given in the article below
    [http://www.onjava.com/pub/a/onjava/2003/04/02/multiple_submits.html]
    Hope that might help :)
    REGARDS,
    RaHuL

  • How to create multiple Purchase Order  using the same document number?

    HI Friends,
    I m in a product which extracts data from SAP and stored in Access database.
    For that,while i extracting Purchase Order from the Demo Database (SBODemo_US)for OEC Computers,the same DocNum is used for several Purchase Order using Index Line numbers.
    eg:
    DocNum for Purchase Order1 -->3000   0 (Index)
      DocNum for Purchase Order2 -->3000   1 (Index)
        But i can't create multiple Purchase Order using same DocNum manually in SAP B1,Could anybody please help me <b>to create a Purchase Order using same DocumentNumber?</b>
    Thanks in Advance
    SooriyaKala.P

    Hi,
    The problem statement is not quite clear to me.
    As far as I understand your statement, I think you want to club multiple orders into one purchase order using the index incrementally.
    For this I think once you have created the first purchase order, open the purchase order in edit mode the second time and append the new line items.
    If I am getting you wrong please explain the problem statement in more detail.
    Regards,
    Rara.

  • How to prevent BIP login screen pop-up when opening  BIP report from Dashbo

    Hi
    My customer linked BI Publisher report on the Dashboard page by setting
    "Embedded Content" as "http://172.18.1.91:7001/xmlpserver/servlet/report".
    Customer could open Dashboard directly(just login Dashboard. no need to login BIP) until applied patch 13399232.
    After applied this patch,BIP login scrren pop-up everytime when opening dashboard.
    Customer's BIP is 10.1.3.4.
    Is there any way to prevent BIP login pop-up?
    I tested in my BIP 10.1.3.4 enviroment which patch 13399232 doesn't be applied in.
    I got the different behaviour with customer's.
    I have to login BIP everytime when I openning dashboard.
    The only difference between my setting with Customer's is that I added
    "Embedded Content" as http://jpdel1203.jp.oracle.com:7777/xmlpserver/~administrator/Test/Test.xdo (It's hostname not IP address)
    Is there sth i should set between BIP and dashboard ?
    Does anyone kindly advise it?
    Thank you in advance.
    Best Regards
    Liying

    Check your BIP integration with Analytics: BIP Admin integration with SAW. Ensure the user and password to proxy into BIP from BIEE is correct.
    regards
    Jorge

  • How to execute multiple SSH commands using Ganymed

    I try to use Ganymed SSH to send and receive commands to/from the SSH server.
    However Ganymed example shows only sending one single SSH command to the SSH server.
    Does anybody know how to send and receive multiple commands to/from SSH server?

    I tried many times and it did not work. Please help.
    The output is this :
    Last login: Tue Oct  6 23:05:10 2009 from 192.168.1.4
    /bin/ls -aldf -k[root@linux ~]# /bin/ls -aldf -kExit status : nullI enclose the
    import ch.ethz.ssh2.ChannelCondition;
    import ch.ethz.ssh2.Connection;
    import ch.ethz.ssh2.KnownHosts;
    import ch.ethz.ssh2.Session;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.io.OutputStreamWriter;
    public class TestClient01 implements Runnable {
        static final String knownHostPath = "~/.ssh/known_hosts";
        static final String idDSAPath = "~/.ssh/id_dsa";
        static final String idRSAPath = "~/.ssh/id_rsa";
        private String host = "192.168.1.2";
        private String username = "root";
        private String password = "1234567";
        private KnownHosts database = new KnownHosts();
        private OutputStreamWriter writer = null;
        private Connection conn = null;
        private Session sess = null;
        public void writeCommand(String s) {
            try {
                writer.write(s);
                writer.flush();
            } catch(Exception ex) {}
        public void close() {
            if (writer==null) return;
            try {
                writer.close();
                sess.close();
                conn.close();
            } catch(Exception ex) {}
            if (writer!=null) writer = null;
        public void run() {
            try {
                conn = new Connection(host);
                conn.connect();
                boolean isAuthenticated = conn.authenticateWithPassword(username, password);
                if (!isAuthenticated) throw new IOException("Authentication failed.");
                sess = conn.openSession();
                new Thread(new SyncPipe(sess.getStderr(), System.err)).start();
                new Thread(new SyncPipe(sess.getStdout(), System.out)).start();
                sess.requestPTY("bash");
                sess.startShell();
                writer = new OutputStreamWriter(sess.getStdin(), "utf-8");
                writeCommand("/bin/ls -al");
                writeCommand("df -k");
                sess.waitForCondition(ChannelCondition.CLOSED | ChannelCondition.EOF |
                        ChannelCondition.EXIT_STATUS, 10000);
                System.out.println("Exit status : " + sess.getExitStatus());
            } catch (Exception e) {
                e.printStackTrace(System.err);
                System.exit(2);
        public static void main(String[] args) throws Exception { new TestClient01().run();}
        class SyncPipe implements Runnable {
            String CVS_VERSION = "$Revision: 1.1 $ $Id: SyncPipe.java,v 1.1 2008-09-30 03:47:56 sabre Exp $ ";
            private final byte[] buffer_;
            private final OutputStream ostrm_;
            private final InputStream istrm_;
            private boolean closeAfterCopy_ = false;
            public SyncPipe(InputStream istrm, OutputStream ostrm) { this(istrm, ostrm, 4096);}
            public SyncPipe(InputStream istrm, OutputStream ostrm, int bufferSize) {
                if (istrm == null) throw new IllegalArgumentException("'istrm' cannot be null");
                if (ostrm == null) throw new IllegalArgumentException("'ostrm' cannot be null");
                if (bufferSize < 1024) throw new IllegalArgumentException("a buffer size less than 1024 makes little sense");
                istrm_ = istrm;
                ostrm_ = ostrm;
                buffer_ = new byte[bufferSize];
            public void handleException(IOException e) { e.printStackTrace();}
            public SyncPipe setCloseAfterCopy(boolean closeAfterCopy) {
                closeAfterCopy_ = closeAfterCopy;
                return this;
            public void run() {
                try {
                    for (int bytesRead = 0; (bytesRead = istrm_.read(buffer_)) != -1;)
                        ostrm_.write(buffer_, 0, bytesRead);
                    ostrm_.flush();
                    if (closeAfterCopy_) ostrm_.close();
                } catch (IOException e) { handleException(e);}
    }

Maybe you are looking for