Beispiel #1
0
 public TestQueue(AMQShortString name) throws AMQException {
   super(
       name,
       false,
       new AMQShortString("test"),
       true,
       false,
       ApplicationRegistry.getInstance().getVirtualHostRegistry().getVirtualHost("test"),
       Collections.EMPTY_MAP);
   ApplicationRegistry.getInstance()
       .getVirtualHostRegistry()
       .getVirtualHost("test")
       .getQueueRegistry()
       .registerQueue(this);
 }
Beispiel #2
0
  public PrincipalDatabaseAuthenticationManager() {
    _logger.info("Initialising  PrincipalDatabase authentication manager.");

    Map<String, Class<? extends SaslServerFactory>> providerMap =
        new TreeMap<String, Class<? extends SaslServerFactory>>();

    initialiseAuthenticationMechanisms(
        providerMap, ApplicationRegistry.getInstance().getDatabaseManager().getDatabases());

    if (providerMap.size() > 0) {
      // Ensure we are used before the defaults
      if (Security.insertProviderAt(new JCAProvider(PROVIDER_NAME, providerMap), 1) == -1) {
        _logger.error(
            "Unable to load custom SASL providers. Qpid custom SASL authenticators unavailable.");
      } else {
        _logger.info("Additional SASL providers successfully registered.");
      }

    } else {
      _logger.warn("No additional SASL providers registered.");
    }
  }
Beispiel #3
0
  /**
   * @see org.apache.qpid.server.security.auth.manager.AuthenticationManager#authenticate(String,
   *     String)
   */
  @Override
  public AuthenticationResult authenticate(final String username, final String password) {
    final PrincipalDatabase db =
        ApplicationRegistry.getInstance()
            .getDatabaseManager()
            .getDatabases()
            .values()
            .iterator()
            .next();

    try {
      if (db.verifyPassword(username, password.toCharArray())) {
        final Subject subject = new Subject();
        subject.getPrincipals().add(new UsernamePrincipal(username));
        return new AuthenticationResult(subject);
      } else {
        return new AuthenticationResult(AuthenticationStatus.CONTINUE);
      }
    } catch (AccountNotFoundException e) {
      return new AuthenticationResult(AuthenticationStatus.CONTINUE);
    }
  }