Package org.jboss.errai.bus.server.api

Examples of org.jboss.errai.bus.server.api.ServerMessageBus


* @date: May 3, 2010
*/
class DefaultServices implements BootstrapExecution {

  public void execute(final BootstrapContext context) {
    final ServerMessageBus bus = context.getBus();

    /**
     * The standard ServerEchoService.
     */
    bus.subscribe(ErraiService.SERVER_ECHO_SERVICE, new MessageCallback() {
      public void callback(Message c) {
        MessageBuilder.createConversation(c)
            .subjectProvided().noErrorHandling()
            .sendNowWith(bus);
      }
View Full Code Here


* @date: May 3, 2010
*/
class DefaultServices implements BootstrapExecution {

  public void execute(final BootstrapContext context) {
    final ServerMessageBus bus = context.getBus();
    final boolean authenticationConfigured =
        context.getConfig().getResource(AuthenticationAdapter.class) != null;



    bus.subscribe(ErraiService.AUTHORIZATION_SVC_SUBJECT, new MessageCallback() {
      public void callback(Message message) {
        switch (SecurityCommands.valueOf(message.getCommandType())) {
          case AuthenticationScheme:
            if (authenticationConfigured) {

              /**
               * Respond with what credentials the authentication system requires.
               */
              //todo: we only support login/password for now

              createConversation(message)
                  .subjectProvided()
                  .command(SecurityCommands.AuthenticationScheme)
                  .with(SecurityParts.CredentialsRequired, "Name,Password")
                  .with(MessageParts.ReplyTo, ErraiService.AUTHORIZATION_SVC_SUBJECT)
                  .noErrorHandling().sendNowWith(bus);
            }
            else {
              createConversation(message)
                  .subjectProvided()
                  .command(SecurityCommands.AuthenticationNotRequired)
                  .noErrorHandling().sendNowWith(bus);
            }

            break;

          case AuthRequest:
            /**
             * Receive a challenge.
             */

            if (authenticationConfigured) {
              try {
                context.getConfig().getResource(AuthenticationAdapter.class)
                    .challenge(message);
              }
              catch (AuthenticationFailedException a) {
              }
            }
            break;

          case EndSession:
            if (authenticationConfigured) {
              context.getConfig().getResource(AuthenticationAdapter.class)
                  .endSession(message);
            }

            // reply in any case
            createConversation(message)
                .toSubject("LoginClient")
                .command(SecurityCommands.EndSession)
                .noErrorHandling()
                .sendNowWith(bus);

            break;
        }
      }
    });

    /**
     * The standard ServerEchoService.
     */
    bus.subscribe(ErraiService.SERVER_ECHO_SERVICE, new MessageCallback() {
      public void callback(Message c) {
        MessageBuilder.createConversation(c)
            .subjectProvided().noErrorHandling()
            .sendNowWith(bus);
      }
    });

    bus.subscribe(ErraiService.AUTHORIZATION_SERVICE, new MessageCallback() {
      public void callback(Message message) {
        AuthSubject subject = message.getResource(QueueSession.class, "Session")
            .getAttribute(AuthSubject.class, ErraiService.SESSION_AUTH_DATA);

        Message reply = MessageBuilder.createConversation(message).getMessage();
View Full Code Here

    DefaultTreeModel model = (DefaultTreeModel) serviceExplorer.getModel();

    if (messageBus instanceof ServerMessageBus) {
      // this is the serverside bus.
      ServerMessageBus smb = (ServerMessageBus) messageBus;
      Collection<MessageCallback> receivers = smb.getReceivers(currentlySelectedService);

      DefaultMutableTreeNode receiversNode = new DefaultMutableTreeNode("Receivers (" + receivers.size() + ")", true);

      for (MessageCallback mc : receivers) {
        receiversNode.add(new DefaultMutableTreeNode(mc.getClass().getName()));
View Full Code Here

    DefaultTreeModel model = (DefaultTreeModel) serviceExplorer.getModel();


    if (messageBus instanceof ServerMessageBus) {
      // this is the serverside bus.
      ServerMessageBus smb = (ServerMessageBus) messageBus;
      Collection<MessageCallback> receivers = smb.getReceivers(currentlySelectedService);

      DefaultMutableTreeNode receiversNode
              = new DefaultMutableTreeNode("Receivers (" + receivers.size() + ")", true);

      for (MessageCallback mc : receivers) {
View Full Code Here

*/
class DefaultServices implements BootstrapExecution
{
  public void execute(final BootstrapContext context)
  {
    final ServerMessageBus bus = context.getBus();
    final boolean authenticationConfigured =
        context.getConfig().getResource(AuthenticationAdapter.class) != null;

    bus.subscribe(ErraiService.AUTHORIZATION_SVC_SUBJECT, new MessageCallback() {
      public void callback(Message message) {
        switch (SecurityCommands.valueOf(message.getCommandType())) {
          case AuthenticationScheme:
            if (authenticationConfigured) {

              /**
               * Respond with what credentials the authentication system requires.
               */
              //todo: we only support login/password for now

              createConversation(message)
                  .subjectProvided()
                  .command(SecurityCommands.AuthenticationScheme)
                  .with(SecurityParts.CredentialsRequired, "Name,Password")
                  .with(MessageParts.ReplyTo, ErraiService.AUTHORIZATION_SVC_SUBJECT)
                  .noErrorHandling().sendNowWith(bus);
            } else {
              createConversation(message)
                  .subjectProvided()
                  .command(SecurityCommands.AuthenticationNotRequired)
                  .noErrorHandling().sendNowWith(bus);
            }

            break;

          case AuthRequest:
            /**
             * Receive a challenge.
             */

            if (authenticationConfigured) {
              try {
                context.getConfig().getResource(AuthenticationAdapter.class)
                    .challenge(message);
              }
              catch (AuthenticationFailedException a) {
              }
            }
            break;

          case EndSession:
            if (authenticationConfigured) {
              context.getConfig().getResource(AuthenticationAdapter.class)
                  .endSession(message);
            }

            // reply in any case
            createConversation(message)
                .toSubject("LoginClient")
                .command(SecurityCommands.EndSession)
                .noErrorHandling()
                .sendNowWith(bus);

            break;
        }
      }
    });

    /**
     * The standard ServerEchoService.
     */
    bus.subscribe("ServerEchoService", new MessageCallback() {
      public void callback(Message c) {
        MessageBuilder.createConversation(c)
            .subjectProvided().signalling().noErrorHandling()
            .sendNowWith(bus);
      }
    });

    bus.subscribe("AuthorizationService", new MessageCallback() {
      public void callback(Message message) {
        AuthSubject subject = message.getResource(QueueSession.class, "Session")
            .getAttribute(AuthSubject.class, ErraiService.SESSION_AUTH_DATA);

        Message reply = MessageBuilder.createConversation(message).getMessage();
View Full Code Here

TOP

Related Classes of org.jboss.errai.bus.server.api.ServerMessageBus

Copyright © 2018 www.massapicom. 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.