Package javax.jms

Examples of javax.jms.JMSSecurityException


      SecurityStore sm = conn.getSecurityManager();
      SecurityMetadata securityMetadata = sm.getSecurityMetadata(isQueue, name);

      if (securityMetadata == null)
      {
         throw new JMSSecurityException("No security configuration avaliable for " + name);
      }

      // Authenticate. Successful autentication will place a new SubjectContext on thread local,
      // which will be used in the authorization process. However, we need to make sure we clean up
      // thread local immediately after we used the information, otherwise some other people
      // security my be screwed up, on account of thread local security stack being corrupted.
     
      sm.authenticate(conn.getUsername(), conn.getPassword());

      // Authorize
      Set principals = checkType == CheckType.READ ? securityMetadata.getReadPrincipals() :
                       checkType == CheckType.WRITE ? securityMetadata.getWritePrincipals() :
                       securityMetadata.getCreatePrincipals();
      try
      {
         if (!sm.authorize(conn.getUsername(), principals, checkType))
         {
            String msg = "User: " + conn.getUsername() +
               " is not authorized to " +
               (checkType == CheckType.READ ? "read from" :
                  checkType == CheckType.WRITE ? "write to" : "create durable sub on") +
               " destination " + name;

            throw new JMSSecurityException(msg);
         }
      }
      finally
      {
         // pop the Messaging SecurityContext, it did its job
View Full Code Here


         SecurityActions.pushSubjectContext(principal, passwordChars, subject);
         return subject;
      }
      else
      {
         throw new JMSSecurityException("User " + user + " is NOT authenticated");
      }
   }
View Full Code Here

        if (userName != null) {
            principal = new BasicPrincipal(userName, password);
        }
        try {
            if (!_authenticator.authenticate(principal)) {
                throw new JMSSecurityException("Failed to authenticate user: " +
                                               userName);
            }
        } catch (ResourceException exception) {
            _log.error(exception, exception);
            throw new JMSSecurityException("Failed to authenticate user "
                                           + userName);
        }

        ServerConnectionImpl result = null;
        synchronized (_connections) {
View Full Code Here

        if (username != null) {
            principal = new BasicPrincipal(username, password);
        }
        try {
            if (!_authenticator.authenticate(principal)) {
                throw new JMSSecurityException("Failed to authenticate user " +
                                               username);
            }
        } catch (ResourceException exception) {
            _log.error(exception, exception);
            throw new JMSSecurityException("Failed to authenticate user "
                                           + username);
        }

        return _factory.create();
    }
View Full Code Here

            if (_orb == null) {
                _orb = SharedORB.getInstance();
            }
            registry = _orb.getRegistry(properties);
        } catch (AccessException exception) {
            JMSSecurityException error = new JMSSecurityException(
                    exception.getMessage());
            error.setLinkedException(exception);
            throw error;
        } catch (RemoteException exception) {
            JMSException error = new JMSException(
                    "Failed to get registry service for URL: " + _serverURI);
            error.setLinkedException(exception);
            throw error;
        }

        try {
            factory = (ServerConnectionFactory) registry.lookup("server");
        } catch (NotBoundException exception) {
            throw new JMSException(
                    "Server is not bound in the registry for URL: "
                    + _serverURI);
        } catch (RemoteException exception) {
            JMSException error = new JMSException(
                    "Failed to lookup OpenJMS server for URL: " + _serverURI);
            error.setLinkedException(exception);
            throw error;
        }
        try {
            _orb.addCallerListener(_serverURI, this);
        } catch (RemoteException exception) {
            JMSException error = new JMSException(
                    "Failed to register for disconnection notification for "
                    + "URL: " + _serverURI);
            error.setLinkedException(exception);
            throw error;
        }

        if (registry instanceof Proxy) {
            ((Proxy) registry).disposeProxy();
View Full Code Here

   
    if (dest instanceof TemporaryQueue) {
      Connection tempQCnx = ((TemporaryQueue) dest).getCnx();

      if (tempQCnx == null || ! tempQCnx.equals(sess.getConnection()))
        throw new JMSSecurityException("Forbidden consumer on this temporary destination.");
    }
    else if (dest instanceof TemporaryTopic) {
      Connection tempTCnx = ((TemporaryTopic) dest).getCnx();
   
      if (tempTCnx == null || ! tempTCnx.equals(sess.getConnection()))
        throw new JMSSecurityException("Forbidden consumer on this temporary destination.");
    }

    try {
      ClientSelector.checks(selector);
    } catch (org.objectweb.joram.shared.excepts.SelectorException sE) {
View Full Code Here

          Integer result = (Integer) resp.getReturnValue().getValue();

          // The returned value is either the key of the connection, or -1
          // if the user is invalid:
          if (result.intValue() == -1) {
            throw new JMSSecurityException("Can't open the connection with"
                                           + " the server on host "
                                           + factParams.getHost()
                                           + " and port "
                                           + factParams.getPort()
                                           + ": invalid user identification.");
View Full Code Here

   */
  public static JMSException buildJmsException(MomExceptionReply excReply) {
    JMSException jmsExc = null;
    int excType = excReply.getType();
    if (excType == MomExceptionReply.AccessException) {
      jmsExc = new JMSSecurityException(excReply.getMessage());
    } else if (excType == MomExceptionReply.DestinationException) {
      jmsExc = new InvalidDestinationException(excReply.getMessage());
    } else {
      jmsExc = new JMSException(excReply.getMessage());
    }
View Full Code Here

   * @exception IllegalStateException  If the connection is closed or broken.
   * @exception JMSException  If the request fails for any other reason.
   */
  public void delete() throws JMSException {
    if (cnx == null)
      throw new JMSSecurityException("Forbidden call as this TemporaryQueue does not belong to this connection.");

    if (logger.isLoggable(BasicLevel.DEBUG))
      logger.log(BasicLevel.DEBUG, "--- " + this + ": deleting...");

    // Checking the connection's subscribers:
View Full Code Here

         case QUEUE_EXISTS:
            je = new InvalidDestinationException(me.getMessage());
            break;

         case SECURITY_EXCEPTION:
            je = new JMSSecurityException(me.getMessage());
            break;

         case UNSUPPORTED_PACKET:
            je = new javax.jms.IllegalStateException(me.getMessage());
            break;
View Full Code Here

TOP

Related Classes of javax.jms.JMSSecurityException

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.