Examples of ConnectionManager


Examples of org.htmlparser.http.ConnectionManager

               
                code = httpClient.executeMethod(login);
                HttpState state = httpClient.getState();
               
                //copy all the cookies into the Parser cookie manager
        ConnectionManager cm = Parser.getConnectionManager();
                for (org.apache.commons.httpclient.Cookie cookie : state.getCookies()) {
                  if (cookie.getName().equals("NetflixShopperId")) {
                    shopperId = cookie.getValue();
                  }
            Cookie pCookie = new Cookie(cookie.getName(), cookie.getValue());
            pCookie.setDomain(cookie.getDomain());
            pCookie.setPath(cookie.getPath());
            cm.setCookie(pCookie, null);
                }
               
                String result = login.getResponseBodyAsString();
                login.releaseConnection();
               
View Full Code Here

Examples of org.jboss.as.domain.management.connections.ConnectionManager

            acb.setAuthorized(authenticationId.equals(authorizationId));

            return;
        }

        ConnectionManager connectionManager = this.connectionManager.getValue();
        String username = null;
        VerifyPasswordCallback verifyPasswordCallback = null;

        for (Callback current : callbacks) {
            if (current instanceof NameCallback) {
                username = ((NameCallback) current).getDefaultName();
            } else if (current instanceof RealmCallback) {
                // TODO - Nothing at the moment
            } else if (current instanceof VerifyPasswordCallback) {
                verifyPasswordCallback = (VerifyPasswordCallback) current;
            } else {
                throw new UnsupportedCallbackException(current);
            }
        }

        if (username == null || username.length() == 0) {
            throw MESSAGES.noUsername();
        }
        if (verifyPasswordCallback == null) {
            throw MESSAGES.noPassword();
        }

        InitialDirContext searchContext = null;
        InitialDirContext userContext = null;
        NamingEnumeration<SearchResult> searchEnumeration = null;
        try {
            // 1 - Obtain Connection to LDAP
            searchContext = (InitialDirContext) connectionManager.getConnection();
            // 2 - Search to identify the DN of the user connecting
            SearchControls searchControls = new SearchControls();
            if (recursive) {
                searchControls.setSearchScope(SearchControls.SUBTREE_SCOPE);
            } else {
                searchControls.setSearchScope(SearchControls.ONELEVEL_SCOPE);
            }
            searchControls.setReturningAttributes(new String[]{userDn});
            searchControls.setTimeLimit(searchTimeLimit);

            Object[] filterArguments = new Object[]{username};
            String filter = usernameAttribute != null ? "(" + usernameAttribute + "={0})" : advancedFilter;

            searchEnumeration = searchContext.search(baseDn, filter, filterArguments, searchControls);
            if (searchEnumeration.hasMore() == false) {
                throw MESSAGES.userNotFoundInDirectory(username);
            }

            String distinguishedUserDN = null;

            SearchResult result = searchEnumeration.next();
            Attributes attributes = result.getAttributes();
            if (attributes != null) {
                Attribute dn = attributes.get(userDn);
                if (dn != null) {
                    distinguishedUserDN = (String) dn.get();
                }
            }
            if (distinguishedUserDN == null) {
                if (result.isRelative() == true)
                    distinguishedUserDN = result.getName() + ("".equals(baseDn) ? "" : "," + baseDn);
                else
                    throw MESSAGES.nameNotFound(result.getName());
            }

            // 3 - Connect as user once their DN is identified
            userContext = (InitialDirContext) connectionManager.getConnection(distinguishedUserDN, verifyPasswordCallback.getPassword());
            if (userContext != null) {
                verifyPasswordCallback.setVerified(true);
            }

        } catch (Exception e) {
View Full Code Here

Examples of org.jboss.jca.core.connectionmanager.ConnectionManager

    */
   public boolean testConnection()
   {
      try
      {
         ConnectionManager cm = (ConnectionManager)getConnectionListenerFactory();
         ManagedConnectionFactory mcf = getManagedConnectionFactory();
      
         Subject subject = createSubject(cm.getSubjectFactory(), cm.getSecurityDomain(), mcf);
 
         if (subject != null)
            return internalTestConnection(subject);
      }
      catch (Throwable t)
View Full Code Here

Examples of org.jboss.jms.server.ConnectionManager

            // I need to do my own cleanup at ConnectionManager level.

            log.debug(this + " failed to handle callback", e);

            ServerConnectionEndpoint sce = sessionEndpoint.getConnectionEndpoint();
            ConnectionManager cm = sce.getServerPeer().getConnectionManager();

            cm.handleClientFailure(sce.getRemotingClientSessionID(), false);

            // we're practically cut, from connection down

            return null;
         }
View Full Code Here

Examples of org.jboss.jms.server.ConnectionManager

     
      CreateClientOnServerCommand command = new CreateClientOnServerCommand(cf, queue, true);
     
      String remotingSessionId = (String)remoteServer.executeCommand(command);
     
      ConnectionManager cm = localServer.getServerPeer().getConnectionManager();
           
      assertTrue(cm.containsRemotingSession(remotingSessionId));
     
      // Now we should have a client connection from the remote server to the local server
     
      remoteServer.kill();
      log.trace("killed remote server");
       
      // Wait for connection resources to be cleared up
      Thread.sleep(15000);
          
      // See if we still have a connection with this id
      assertTrue(cm.containsRemotingSession(remotingSessionId));
   }
View Full Code Here

Examples of org.jboss.jms.server.ConnectionManager

     
      CreateClientOnServerCommand command = new CreateClientOnServerCommand(cf, queue, true);
     
      String remotingSessionId = (String)remoteServer.executeCommand(command);
     
      ConnectionManager cm = localServer.getServerPeer().getConnectionManager();
           
      assertTrue(cm.containsRemotingSession(remotingSessionId));
     
      // Now we should have a client connection from the remote server to the local server
     
      remoteServer.kill();
      log.trace("killed remote server");
       
      // Wait for connection resources to be cleared up
      Thread.sleep(15000);
          
      // See if we still have a connection with this id
      assertFalse(cm.containsRemotingSession(remotingSessionId));
   }
View Full Code Here

Examples of org.jboss.jms.server.ConnectionManager

     
      CreateClientOnServerCommand command = new CreateClientOnServerCommand(cf, queue, true);
     
      String remotingSessionId = (String)remoteServer.executeCommand(command);
     
      ConnectionManager cm = localServer.getServerPeer().getConnectionManager();
           
      assertTrue(cm.containsRemotingSession(remotingSessionId));
     
      // Now we should have a client connection from the remote server to the local server
     
      remoteServer.kill();
      log.trace("killed remote server");
       
      // Wait for connection resources to be cleared up
      Thread.sleep(15000);
          
      // See if we still have a connection with this id
     
      //Connection state shouldn't have been cleared up by now
      assertTrue(cm.containsRemotingSession(remotingSessionId));
   }
View Full Code Here

Examples of org.jboss.jms.server.ConnectionManager

     
      CreateTwoClientOnServerCommand command = new CreateTwoClientOnServerCommand(cf, topic, true);
     
      String remotingSessionId[] = (String[])remoteServer.executeCommand(command);
     
      ConnectionManager cm = localServer.getServerPeer().getConnectionManager();
           
      log.info("server(0) = " + remotingSessionId[0]);
      log.info("server(1) = " + remotingSessionId[1]);
      log.info("we have = " + ((SimpleConnectionManager)cm).getClients().size() + " clients registered on SimpleconnectionManager");
     
      assertFalse(cm.containsRemotingSession(remotingSessionId[0]));
      assertTrue(cm.containsRemotingSession(remotingSessionId[1]));
     
      // Now we should have a client connection from the remote server to the local server
      remoteServer.kill();
      log.info("killed remote server");
       
      // Wait for connection resources to be cleared up
      Thread.sleep(25000);
          
      // See if we still have a connection with this id
     
      //Connection state should have been cleared up by now
      assertFalse(cm.containsRemotingSession(remotingSessionId[0]));
      assertFalse(cm.containsRemotingSession(remotingSessionId[1]));
     
      log.info("Servers = " + ((SimpleConnectionManager)cm).getClients().size());
     
      assertEquals(0,((SimpleConnectionManager)cm).getClients().size());
   }
View Full Code Here

Examples of org.jboss.jms.server.ConnectionManager

     
      CreateClientOnServerCommand command = new CreateClientOnServerCommand(cf, queue, true);
     
      String remotingSessionId = (String)remoteServer.executeCommand(command);
     
      ConnectionManager cm = localServer.getServerPeer().getConnectionManager();
           
      assertTrue(cm.containsRemotingSession(remotingSessionId));
     
      // Now we should have a client connection from the remote server to the local server
     
      remoteServer.kill();
      log.trace("killed remote server");
       
      // Wait for connection resources to be cleared up
      Thread.sleep(15000);
          
      // See if we still have a connection with this id
      assertTrue(cm.containsRemotingSession(remotingSessionId));
   }
View Full Code Here

Examples of org.jboss.jms.server.ConnectionManager

      // we need to disable exception listener otherwise it will clear up the connection itself
     
      ObjectName remoteConnectorName = ServiceContainer.REMOTING_OBJECT_NAME;
     
      ConnectionManager cm = localServer.getServerPeer().getConnectionManager();
     
      localServer.getServerPeer().getServer().
         invoke(remoteConnectorName,
                "removeConnectionListener",
                new Object[] {cm},
                new String[] {"org.jboss.remoting.ConnectionListener"});
      
      InitialContext ic = new InitialContext(InVMInitialContextFactory.getJNDIEnvironment());
     
      ConnectionFactory cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
     
      Queue queue = (Queue)ic.lookup("/queue/Queue");
     
      CreateHangingConsumerCommand command = new CreateHangingConsumerCommand(cf, queue);
     
      String remotingSessionId = (String)remoteServer.executeCommand(command);
     
      remoteServer.kill();
       
      // we have removed the exception listener so the server side resouces shouldn't be cleared up

      log.info("sleeping for 1 min ...");
      Thread.sleep(60000);
                
      assertTrue(cm.containsRemotingSession(remotingSessionId));
     
      // Now we send a message which should prompt delivery to the dead consumer causing
      // an exception which should cause connection cleanup
                 
      Connection conn = cf.createConnection();
     
      Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
       
      MessageProducer prod = sess.createProducer(queue);

      // sending just one message should be enough to trigger the failure and client smacking
      prod.send(sess.createMessage());

      log.info("sleeping for 45 secs ...");
      Thread.sleep(45000);
     
      assertFalse(cm.containsRemotingSession(remotingSessionId));

      // make sure the message is still in queue

      conn = cf.createConnection();
      conn.start();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.