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

org.infinispan.server.configuration.security.KerberosSecurityFactoryConfiguration Maven / Gradle / Ivy

There is a newer version: 15.1.0.Dev05
Show newest version
package org.infinispan.server.configuration.security;

import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import org.infinispan.commons.configuration.attributes.AttributeDefinition;
import org.infinispan.commons.configuration.attributes.AttributeSet;
import org.infinispan.commons.configuration.attributes.ConfigurationElement;
import org.infinispan.commons.util.TimeQuantity;
import org.infinispan.server.Server;
import org.infinispan.server.configuration.Attribute;
import org.infinispan.server.configuration.Element;
import org.wildfly.security.credential.source.CredentialSource;

/**
 * KerberosSecurityFactoryConfiguration.
 *
 * @author Tristan Tarrant
 * @since 10.1
 */
public class KerberosSecurityFactoryConfiguration extends ConfigurationElement {
   private static final String[] DEFAULT_MECHANISM_NAMES = new String[]{"KRB5", "SPNEGO"};

   static final AttributeDefinition PRINCIPAL = AttributeDefinition.builder(Attribute.PRINCIPAL, null, String.class).build();
   static final AttributeDefinition KEYTAB_PATH = AttributeDefinition.builder(Attribute.KEYTAB_PATH, null, String.class).build();
   static final AttributeDefinition RELATIVE_TO = AttributeDefinition.builder(Attribute.RELATIVE_TO, Server.INFINISPAN_SERVER_CONFIG_PATH, String.class).build();
   static final AttributeDefinition DEBUG = AttributeDefinition.builder(Attribute.DEBUG, false, Boolean.class).build();
   static final AttributeDefinition FAIL_CACHE = AttributeDefinition.builder(Attribute.FAIL_CACHE, 0l, Long.class).build();
   static final AttributeDefinition> MECHANISM_NAMES = AttributeDefinition.>builder(Attribute.MECHANISM_NAMES, new HashSet<>()).initializer(() -> new HashSet<>(Arrays.asList(DEFAULT_MECHANISM_NAMES))).build();
   static final AttributeDefinition> MECHANISM_OIDS = AttributeDefinition.>builder(Attribute.MECHANISM_OIDS, new HashSet<>()).initializer(HashSet::new).build();
   static final AttributeDefinition MINIMUM_REMAINING_LIFETIME = AttributeDefinition.builder(Attribute.MINIMUM_REMAINING_LIFETIME, TimeQuantity.valueOf(0)).build();
   static final AttributeDefinition OBTAIN_KERBEROS_TICKET = AttributeDefinition.builder(Attribute.OBTAIN_KERBEROS_TICKET, false, Boolean.class).build();
   static final AttributeDefinition> OPTIONS = AttributeDefinition.>builder("options", new HashMap<>()).initializer(HashMap::new).build();
   static final AttributeDefinition REQUEST_LIFETIME = AttributeDefinition.builder(Attribute.REQUEST_LIFETIME, TimeQuantity.valueOf(0)).build();
   static final AttributeDefinition REQUIRED = AttributeDefinition.builder(Attribute.REQUIRED, false, Boolean.class).build();
   static final AttributeDefinition SERVER = AttributeDefinition.builder(Attribute.SERVER, true, Boolean.class).build();
   static final AttributeDefinition WRAP_GSS_CREDENTIAL = AttributeDefinition.builder(Attribute.WRAP_GSS_CREDENTIAL, false, Boolean.class).build();

   static AttributeSet attributeDefinitionSet() {
      return new AttributeSet(KerberosSecurityFactoryConfiguration.class, PRINCIPAL, KEYTAB_PATH, RELATIVE_TO, DEBUG, FAIL_CACHE,
            MECHANISM_NAMES, MECHANISM_OIDS, MINIMUM_REMAINING_LIFETIME, OBTAIN_KERBEROS_TICKET, OPTIONS, REQUEST_LIFETIME,
            REQUIRED, SERVER, WRAP_GSS_CREDENTIAL);
   }

   private final CredentialSource credentialSource;

   KerberosSecurityFactoryConfiguration(AttributeSet attributes, CredentialSource credentialSource) {
      super(Element.KERBEROS, attributes);
      this.credentialSource = credentialSource;
   }

   public String getPrincipal() {
      return attributes.attribute(PRINCIPAL).get();
   }

   public CredentialSource getCredentialSource() {
      return credentialSource;
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy