All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.infinispan.hotrod.configuration.AuthenticationConfiguration Maven / Gradle / Ivy

There is a newer version: 14.0.32.Final
Show newest version
package org.infinispan.hotrod.configuration;

import static org.infinispan.commons.configuration.attributes.CollectionAttributeCopier.collectionCopier;

import java.util.HashMap;
import java.util.Map;

import javax.security.auth.Subject;
import javax.security.auth.callback.CallbackHandler;

import org.infinispan.commons.configuration.attributes.AttributeDefinition;
import org.infinispan.commons.configuration.attributes.AttributeSet;
import org.infinispan.commons.configuration.attributes.ConfigurationElement;

/**
 * AuthenticationConfiguration.
 *
 * @since 14.0
 */
public class AuthenticationConfiguration extends ConfigurationElement {
   static final AttributeDefinition ENABLED = AttributeDefinition.builder("use-auth", false, Boolean.class).build();
   static final AttributeDefinition CALLBACK_HANDLER = AttributeDefinition.builder("callback-handler", null, CallbackHandler.class).build();
   static final AttributeDefinition CLIENT_SUBJECT = AttributeDefinition.builder("client-subject", null, Subject.class).build();
   static final AttributeDefinition SASL_MECHANISM = AttributeDefinition.builder("sasl-mechanism", "SCRAM-SHA-512", String.class).build();
   static final AttributeDefinition> SASL_PROPERTIES = AttributeDefinition.builder("sasl-properties", null, (Class>) (Class) Map.class)
         .copier(collectionCopier())
         .initializer(HashMap::new).immutable().build();
   static final AttributeDefinition SERVER_NAME = AttributeDefinition.builder("server-name", "infinispan", String.class).build();

   static AttributeSet attributeDefinitionSet() {
      return new AttributeSet(AuthenticationConfiguration.class, ENABLED, CALLBACK_HANDLER, CLIENT_SUBJECT, SASL_MECHANISM, SASL_PROPERTIES, SERVER_NAME);
   }

   AuthenticationConfiguration(AttributeSet attributes) {
      super("authentication", attributes);
   }

   public CallbackHandler callbackHandler() {
      return attributes.attribute(CALLBACK_HANDLER).get();
   }

   public boolean enabled() {
      return attributes.attribute(ENABLED).get();
   }

   public String saslMechanism() {
      return attributes.attribute(SASL_MECHANISM).get();
   }

   public Map saslProperties() {
      return attributes.attribute(SASL_PROPERTIES).get();
   }

   public String serverName() {
      return attributes.attribute(SERVER_NAME).get();
   }

   public Subject clientSubject() {
      return attributes.attribute(CLIENT_SUBJECT).get();
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy