0 Replies Latest reply on May 16, 2013 10:28 AM by adfasdfasdfhjasdfhasddfhasdfaj

    createTopicConnection - username, password

    adfasdfasdfhjasdfhasddfhasdfaj

      Hello,

       

      i'm using JMS to distribute messages. All worked fine (subscribing, receiving) but when i receive a message and i call a service-method i got an AuthenticationException because i'm logged in as anonymous (all services are secured).

       

      Ok, so i need to login myself... i think there are two possibilities... just do a login before i call the service out of the onMessage-method or to create the topicConnection with username and password. But both failed...

       

      The programm always says something like unable to validate user: <username>. Here the exception:

      2013-05-16 15:12:42,699 ERROR  [org.hornetq.core.protocol.core.impl.HornetQPacketHandler] Failed to create session : HornetQException[errorCode=105 message=Unable to validate user: backoffice]

          at org.hornetq.core.security.impl.SecurityStoreImpl.authenticate(SecurityStoreImpl.java:147)

          at org.hornetq.core.server.impl.HornetQServerImpl.createSession(HornetQServerImpl.java:858)

          at org.hornetq.core.protocol.core.impl.HornetQPacketHandler.handleCreateSession(HornetQPacketHandler.java:187)

          at org.hornetq.core.protocol.core.impl.HornetQPacketHandler.handlePacket(HornetQPacketHandler.java:85)

          at org.hornetq.core.protocol.core.impl.ChannelImpl.handlePacket(ChannelImpl.java:508)

          at org.hornetq.core.protocol.core.impl.RemotingConnectionImpl.doBufferReceived(RemotingConnectionImpl.java:556)

          at org.hornetq.core.protocol.core.impl.RemotingConnectionImpl.bufferReceived(RemotingConnectionImpl.java:517)

          at org.hornetq.core.remoting.server.impl.RemotingServiceImpl$DelegatingBufferHandler.bufferReceived(RemotingServiceImpl.java:534)

          at org.hornetq.core.remoting.impl.invm.InVMConnection$1.run(InVMConnection.java:169)

          at org.hornetq.utils.OrderedExecutorFactory$OrderedExecutor$1.run(OrderedExecutorFactory.java:100)

          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)

          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)

          at java.lang.Thread.run(Thread.java:722)

       

      I don't know where jBoss is looking for the user, because the user exists (in the database) and the remote login from the clients works with this user.

       

      Here the source of the creating of the connection to jms:

       

      public void start(InitialContext iniCtx) throws NamingException, JMSException {

              Object tmp = iniCtx.lookup("ConnectionFactory");

              TopicConnectionFactory tcf = (TopicConnectionFactory) tmp;

              tConn = tcf.createTopicConnection(USERNAME, PASSWORD);

              //tConn = tcf.createTopicConnection();

              tConn.setClientID(this.getClass().getName());

              topic = (Topic) iniCtx.lookup(getTopicName());

       

              tSession = tConn.createTopicSession(false, TopicSession.AUTO_ACKNOWLEDGE);

              // subscriber = tSession.createDurableSubscriber(topic, getSubscriptionName(), getJMSTypeString(), false);

              subscriber = tSession.createSubscriber(topic, getJMSTypeString(), true);

              subscriber.setMessageListener(this);

              tConn.start();

      }

       

      Here the login variant, but doesn't work either:

       

      protected void login() throws LoginException {

              LoginContext loginContext = new LoginContext("backofficexyz", new MyLoginCallBackHandler());

              loginContext.login();

          }

       

      private class BemaLoginCallBackHandler implements CallbackHandler {

             

          @Override

          public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {

              for (int i = 0; i < callbacks.length; i++) {

                  if (callbacks[i] instanceof TextOutputCallback) {

                      TextOutputCallback toc = (TextOutputCallback) callbacks[i];

                      switch (toc.getMessageType()) {

                      case TextOutputCallback.INFORMATION:

                          logger.info(toc.getMessage());

                          break;

                      case TextOutputCallback.ERROR:

                          logger.error(toc.getMessage());

                          break;

                      case TextOutputCallback.WARNING:

                          logger.warn(toc.getMessage());

                          break;

                      default:

                          throw new IOException("Unsupported message type: " + toc.getMessageType());

                      }

                  } else if (callbacks[i] instanceof NameCallback) {

                      NameCallback nc = (NameCallback) callbacks[i];

                      nc.setName(USERNAME);

                  } else if (callbacks[i] instanceof PasswordCallback) {

                      PasswordCallback pc = (PasswordCallback) callbacks[i];

                      pc.setPassword(PASSWORD.toCharArray());

                  } else {

                      throw new UnsupportedCallbackException(callbacks[i], "Unrecognized Callback");

                  }

              }

          }

      }

       

      Anybody an idea? JBoss Version is jBoss 7.1.4