switch (checkType.type) { case CheckType.TYPE_READ: { readCache.add(dest); break; } case CheckType.TYPE_WRITE: { writeCache.add(dest); break; } case CheckType.TYPE_CREATE: { createCache.add(dest); break; } default: { throw new IllegalArgumentException("Invalid checkType:" + checkType); } }
   private void check(Destination dest, CheckType checkType, ServerConnectionEndpoint conn)      throws JMSSecurityException   {      if (trace) { log.trace("checking access permissions to " + dest); }      JBossDestination jbd = (JBossDestination)dest;      boolean isQueue = jbd.isQueue();      String name = jbd.getName();      SecurityManager sm = conn.getSecurityManager();      SecurityMetadata securityMetadata = sm.getSecurityMetadata(isQueue, name);      if (securityMetadata == null)      {         throw new JMSSecurityException("No security configuration avaliable for " + name);      }      // Authenticate      sm.authenticate(conn.getUsername(), conn.getPassword());      // Authorize      Set principals = checkType == CheckType.READ ? securityMetadata.getReadPrincipals() :                       checkType == CheckType.WRITE ? securityMetadata.getWritePrincipals() :                       securityMetadata.getCreatePrincipals();                             if (!sm.authorize(conn.getUsername(), principals))      {         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);                              }   }