public class KerberosHelperImpl extends Object implements KerberosHelper
Modifier and Type | Class and Description |
---|---|
static class |
KerberosHelperImpl.SupportedCustomOperation |
KerberosHelper.Command<T,A>, KerberosHelper.KerberosDescriptorType
Modifier and Type | Field and Description |
---|---|
static String |
BASE_LOG_DIR |
static String |
CHECK_KEYTABS |
static String |
REMOVE_KEYTAB |
static String |
SET_KEYTAB |
ALLOW_RETRY, AMBARI_SERVER_HOST_NAME, AMBARI_SERVER_KERBEROS_IDENTITY_NAME, CASE_INSENSITIVE_USERNAME_RULES, CLUSTER_HOST_INFO, CREATE_AMBARI_PRINCIPAL, DEFAULT_REALM, DIRECTIVE_COMPONENTS, DIRECTIVE_CONFIG_UPDATE_POLICY, DIRECTIVE_FORCE_TOGGLE_KERBEROS, DIRECTIVE_HOSTS, DIRECTIVE_IGNORE_CONFIGS, DIRECTIVE_MANAGE_KERBEROS_IDENTITIES, DIRECTIVE_REGENERATE_KEYTABS, INCLUDE_ALL_COMPONENTS_IN_AUTH_TO_LOCAL_RULES, KDC_ADMINISTRATOR_CREDENTIAL_ALIAS, KDC_TYPE, KERBEROS_ENV, MANAGE_AUTH_TO_LOCAL_RULES, MANAGE_IDENTITIES, PRECONFIGURE_SERVICES, SECURITY_ENABLED_CONFIG_TYPE, SECURITY_ENABLED_PROPERTY_NAME
Constructor and Description |
---|
KerberosHelperImpl() |
Modifier and Type | Method and Description |
---|---|
int |
addIdentities(KerberosIdentityDataFileWriter kerberosIdentityDataFileWriter,
Collection<KerberosIdentityDescriptor> identities,
Collection<String> identityFilter,
String hostname,
Long hostId,
String serviceName,
String componentName,
Map<String,Map<String,String>> kerberosConfigurations,
Map<String,Map<String,String>> configurations,
Map<String,ResolvedKerberosKeytab> resolvedKeytabs,
String realm)
Adds identities to the KerberosIdentityDataFileWriter.
|
Map<String,Map<String,String>> |
applyStackAdvisorUpdates(Cluster cluster,
Set<String> services,
Map<String,Map<String,String>> existingConfigurations,
Map<String,Map<String,String>> kerberosConfigurations,
Map<String,Set<String>> propertiesToIgnore,
Map<String,Set<String>> propertiesToRemove,
boolean kerberosEnabled)
Invokes the Stack Advisor to help determine relevant configuration changes when enabling or
disabling Kerberos.
|
Map<String,Map<String,String>> |
calculateConfigurations(Cluster cluster,
String hostname,
KerberosDescriptor kerberosDescriptor,
boolean includePreconfigureData,
boolean calculateClusterHostInfo)
Calculates the map of configurations relative to the cluster and host.
|
void |
configureServices(Cluster cluster,
Map<String,Collection<String>> serviceFilter)
Updates the relevant configurations for the components specified in the service filter.
|
boolean |
createAmbariIdentities(Map<String,String> kerberosEnvProperties)
Determines if the Ambari identities should be created when enabling Kerberos.
|
void |
createResolvedKeytab(ResolvedKerberosKeytab resolvedKerberosKeytab)
Creates and saves underlying
KerberosPrincipalEntity ,
KerberosKeytabEntity entities
in JPA storage. |
File |
createTemporaryDirectory()
Creates a temporary directory within the system temporary directory
The resulting directory is to be removed by the caller when desired.
|
protected File |
createTemporaryFile()
Creates a temporary file within the system temporary directory
The resulting file is to be removed by the caller when desired.
|
RequestStageContainer |
createTestIdentity(Cluster cluster,
Map<String,String> commandParamsStage,
RequestStageContainer requestStageContainer)
Create a unique identity to use for testing the general Kerberos configuration.
|
void |
deleteIdentities(Cluster cluster,
List<Component> components,
Set<String> identities)
Deletes the kerberos identities of the given component, even if the component is already deleted.
|
RequestStageContainer |
deleteIdentities(Cluster cluster,
Map<String,? extends Collection<String>> serviceComponentFilter,
Set<String> hostFilter,
Collection<String> identityFilter,
RequestStageContainer requestStageContainer,
Boolean manageIdentities)
Deletes the set of filtered principals and keytabs from the cluster.
|
RequestStageContainer |
deleteTestIdentity(Cluster cluster,
Map<String,String> commandParamsStage,
RequestStageContainer requestStageContainer)
Deletes the unique identity to use for testing the general Kerberos configuration.
|
boolean |
ensureHeadlessIdentities(Cluster cluster,
Map<String,Map<String,String>> existingConfigurations,
Set<String> services)
Ensures that the relevant headless (or user) Kerberos identities are created and cached.
|
RequestStageContainer |
ensureIdentities(Cluster cluster,
Map<String,? extends Collection<String>> serviceComponentFilter,
Set<String> hostFilter,
Collection<String> identityFilter,
Set<String> hostsToForceKerberosOperations,
RequestStageContainer requestStageContainer,
Boolean manageIdentities)
Ensures the set of filtered principals and keytabs exist on the cluster.
|
RequestStageContainer |
executeCustomOperations(Cluster cluster,
Map<String,String> requestProperties,
RequestStageContainer requestStageContainer,
Boolean manageIdentities)
Used to execute custom security operations which are sent as directives in URI
|
Map<String,Collection<KerberosIdentityDescriptor>> |
getActiveIdentities(String clusterName,
String hostName,
String serviceName,
String componentName,
boolean replaceHostNames,
Map<String,Map<String,Map<String,String>>> hostConfigurations,
KerberosDescriptor kerberosDescriptor)
Returns the active identities for the named cluster.
|
List<KerberosIdentityDescriptor> |
getAmbariServerIdentities(KerberosDescriptor kerberosDescriptor)
Gets the Ambari server Kerberos identities found in the Kerberos descriptor.
|
protected File |
getConfiguredTemporaryDirectory()
Gets the configured temporary directory.
|
boolean |
getForceToggleKerberosDirective(Map<String,String> requestProperties)
Retrieves the value of the force_toggle_kerberos directive from the request properties,
if it exists.
|
Set<String> |
getHostsWithValidKerberosClient(Cluster cluster) |
Map<String,Map<String,String>> |
getIdentityConfigurations(List<KerberosIdentityDescriptor> identityDescriptors)
Given a list of KerberosIdentityDescriptors, returns a Map fo configuration types to property
names and values.
|
PrincipalKeyCredential |
getKDCAdministratorCredentials(String clusterName)
Gets the previously stored KDC administrator credential.
|
KerberosDescriptor |
getKerberosDescriptor(Cluster cluster,
boolean includePreconfigureData)
Builds a composite Kerberos descriptor using the default Kerberos descriptor and a user-specified
Kerberos descriptor, if it exists.
|
KerberosDescriptor |
getKerberosDescriptor(KerberosHelper.KerberosDescriptorType kerberosDescriptorType,
Cluster cluster,
boolean evaluateWhenClauses,
Collection<String> additionalServices,
boolean includePreconfigureData)
Gets the requested Kerberos descriptor.
|
KerberosDescriptor |
getKerberosDescriptor(KerberosHelper.KerberosDescriptorType kerberosDescriptorType,
Cluster cluster,
StackId stackId,
boolean includePreconfigureData)
Gets the Kerberos descriptor for the requested stack.
|
KerberosDetails |
getKerberosDetails(Cluster cluster,
Boolean manageIdentities)
Gathers the Kerberos-related data from configurations and stores it in a new KerberosDetails
instance.
|
Boolean |
getManageIdentitiesDirective(Map<String,String> requestProperties)
Retrieves the value of the manage_kerberos_identities directive from the request properties,
if it exists.
|
List<ServiceComponentHost> |
getServiceComponentHostsToProcess(Cluster cluster,
KerberosDescriptor kerberosDescriptor,
Map<String,? extends Collection<String>> serviceComponentFilter,
Collection<String> hostFilter) |
Map<String,Map<String,String>> |
getServiceConfigurationUpdates(Cluster cluster,
Map<String,Map<String,String>> existingConfigurations,
Map<String,Set<String>> installedServices,
Map<String,Collection<String>> serviceFilter,
Set<String> previouslyExistingServices,
boolean kerberosEnabled,
boolean applyStackAdvisorUpdates)
Returns the updates configurations that are expected when the given set of services are configured
for Kerberos.
|
boolean |
isClusterKerberosEnabled(Cluster cluster)
Determine if a cluster has kerberos enabled.
|
Map<String,Map<String,String>> |
mergeConfigurations(Map<String,Map<String,String>> configurations,
Map<String,KerberosConfigurationDescriptor> updates,
Map<String,Map<String,String>> replacements,
Set<String> configurationTypeFilter)
Merges configurations from a Map of configuration updates into a main configurations Map.
|
static Map<String,Set<String>> |
parseComponentFilter(Map<String,String> requestProperties)
Parsing 'Kerberos/components' property to get list of components for 'regenerate_keytabs' request.
|
static Set<String> |
parseHostFilter(Map<String,String> requestProperties)
Parsing 'Kerberos/hosts' property to get list of hosts for 'regenerate_keytabs' request.
|
Map<String,Map<String,String>> |
processPreconfiguredServiceConfigurations(Map<String,Map<String,String>> configurations,
Map<String,Map<String,String>> replacements,
Cluster cluster,
KerberosDescriptor kerberosDescriptor)
Determines which services, not currently installed, should be preconfigured to aid in reducing
the number of service restarts when new services are added to a cluster where Kerberos is enabled.
|
void |
removeStaleKeytabs(Collection<ResolvedKerberosKeytab> expectedKeytabs)
Removes existent persisted keytabs if they are not in
expectedKeytabs collection. |
void |
setAuthToLocalRules(Cluster cluster,
KerberosDescriptor kerberosDescriptor,
String realm,
Map<String,Set<String>> installedServices,
Map<String,Map<String,String>> existingConfigurations,
Map<String,Map<String,String>> kerberosConfigurations,
boolean includePreconfigureData)
Sets the relevant auth-to-local rule configuration properties using the services installed on
the cluster and their relevant Kerberos descriptors to determine the rules to be created.
|
boolean |
shouldExecuteCustomOperations(SecurityType requestSecurityType,
Map<String,String> requestProperties)
Tests the request properties to check for directives that need to be acted upon
It is required that the SecurityType from the request is either KERBEROS or NONE and that at
least one directive in the requestProperties map is supported.
|
RequestStageContainer |
toggleKerberos(Cluster cluster,
SecurityType securityType,
RequestStageContainer requestStageContainer,
Boolean manageIdentities)
Toggles Kerberos security to enable it or remove it depending on the state of the cluster.
|
Map<String,Set<String>> |
translateConfigurationSpecifications(Collection<String> configurationSpecifications)
Translates a collection of configuration specifications (
config-type/property-name )
to a map of configuration types to a set of property names. |
void |
validateKDCCredentials(Cluster cluster)
Validate the KDC admin credentials.
|
public static final String BASE_LOG_DIR
public static final String CHECK_KEYTABS
public static final String SET_KEYTAB
public static final String REMOVE_KEYTAB
public RequestStageContainer toggleKerberos(Cluster cluster, SecurityType securityType, RequestStageContainer requestStageContainer, Boolean manageIdentities) throws org.apache.ambari.server.AmbariException, KerberosOperationException
KerberosHelper
toggleKerberos
in interface KerberosHelper
cluster
- the relevant ClustersecurityType
- the SecurityType to handle; this value is expected to be either
SecurityType.KERBEROS or SecurityType.NONErequestStageContainer
- a RequestStageContainer to place generated stages, if needed -
if null a new RequestStageContainer will be created.manageIdentities
- a Boolean value indicating how to override the configured behavior
of managing Kerberos identities; if null the configured behavior
will not be overriddenorg.apache.ambari.server.AmbariException
KerberosInvalidConfigurationException
- if an issue occurs trying to get the
Kerberos-specific configuration detailsKerberosOperationException
public RequestStageContainer executeCustomOperations(Cluster cluster, Map<String,String> requestProperties, RequestStageContainer requestStageContainer, Boolean manageIdentities) throws org.apache.ambari.server.AmbariException, KerberosOperationException
KerberosHelper
executeCustomOperations
in interface KerberosHelper
cluster
- the relevant ClusterrequestProperties
- this structure is expected to hold already supported and validated directives
for the 'Cluster' resource. See ClusterResourceDefinition#getUpdateDirectivesrequestStageContainer
- a RequestStageContainer to place generated stages, if needed -
if null a new RequestStageContainer will be created.manageIdentities
- a Boolean value indicating how to override the configured behavior
of managing Kerberos identities; if null the configured behavior
will not be overriddenorg.apache.ambari.server.AmbariException
KerberosOperationException
KerberosInvalidConfigurationException
- if an issue occurs trying to get the
Kerberos-specific configuration detailspublic static Set<String> parseHostFilter(Map<String,String> requestProperties)
requestProperties
- public static Map<String,Set<String>> parseComponentFilter(Map<String,String> requestProperties)
requestProperties
- public RequestStageContainer ensureIdentities(Cluster cluster, Map<String,? extends Collection<String>> serviceComponentFilter, Set<String> hostFilter, Collection<String> identityFilter, Set<String> hostsToForceKerberosOperations, RequestStageContainer requestStageContainer, Boolean manageIdentities) throws org.apache.ambari.server.AmbariException, KerberosOperationException
KerberosHelper
ensureIdentities
in interface KerberosHelper
cluster
- the relevant ClusterserviceComponentFilter
- a Map of service names to component names indicating the
relevant set of services and components - if null, no
filter is relevant; if empty, the filter indicates no
relevant services or componentshostFilter
- a set of hostname indicating the set of hosts to process -
if null, no filter is relevant; if empty, the filter
indicates no relevant hostsidentityFilter
- a Collection of identity names indicating the relevant
identities - if null, no filter is relevant; if empty,
the filter indicates no relevant identitieshostsToForceKerberosOperations
- a set of host names on which it is expected that the
Kerberos client is or will be in the INSTALLED state by
the time the operations targeted for them are to be
executed - if empty or null, this no hosts will be
"forced"requestStageContainer
- a RequestStageContainer to place generated stages, if
needed - if null a new RequestStageContainer will be
created.manageIdentities
- a Boolean value indicating how to override the configured behavior
of managing Kerberos identities; if null the configured behavior
will not be overriddenorg.apache.ambari.server.AmbariException
KerberosOperationException
KerberosInvalidConfigurationException
- if an issue occurs trying to get the
Kerberos-specific configuration detailspublic RequestStageContainer deleteIdentities(Cluster cluster, Map<String,? extends Collection<String>> serviceComponentFilter, Set<String> hostFilter, Collection<String> identityFilter, RequestStageContainer requestStageContainer, Boolean manageIdentities) throws org.apache.ambari.server.AmbariException, KerberosOperationException
KerberosHelper
deleteIdentities
in interface KerberosHelper
cluster
- the relevant ClusterserviceComponentFilter
- a Map of service names to component names indicating the relevant
set of services and components - if null, no filter is relevant;
if empty, the filter indicates no relevant services or componentshostFilter
- a set of hostname indicating the set of hosts to process -
if null, no filter is relevant; if empty, the filter
indicates no relevant hostsidentityFilter
- a Collection of identity names indicating the relevant identities -
if null, no filter is relevant; if empty, the filter indicates no
relevant identitiesrequestStageContainer
- a RequestStageContainer to place generated stages, if needed -
if null a new RequestStageContainer will be created.manageIdentities
- a Boolean value indicating how to override the configured behavior
of managing Kerberos identities; if null the configured behavior
will not be overriddenorg.apache.ambari.server.AmbariException
KerberosOperationException
KerberosInvalidConfigurationException
- if an issue occurs trying to get the
Kerberos-specific configuration detailspublic void deleteIdentities(Cluster cluster, List<Component> components, Set<String> identities) throws org.apache.ambari.server.AmbariException, KerberosOperationException
deleteIdentities
in interface KerberosHelper
org.apache.ambari.server.AmbariException
KerberosOperationException
public void configureServices(Cluster cluster, Map<String,Collection<String>> serviceFilter) throws org.apache.ambari.server.AmbariException, KerberosInvalidConfigurationException
KerberosHelper
null
is passed in as the service filter, all installed services and components
will be affected. If an empty map is passed in, no services or components will be affected.
If the relevant services and components have Kerberos descriptors, configuration values from
the descriptors are used to update the relevant configuration sets.configureServices
in interface KerberosHelper
cluster
- the relevant ClusterserviceFilter
- a Map of service names to component names indicating the
relevant set of services and components - if null, no
filter is relevant; if empty, the filter indicates no
relevant services or componentsorg.apache.ambari.server.AmbariException
KerberosInvalidConfigurationException
public Map<String,Map<String,String>> getServiceConfigurationUpdates(Cluster cluster, Map<String,Map<String,String>> existingConfigurations, Map<String,Set<String>> installedServices, Map<String,Collection<String>> serviceFilter, Set<String> previouslyExistingServices, boolean kerberosEnabled, boolean applyStackAdvisorUpdates) throws KerberosInvalidConfigurationException, org.apache.ambari.server.AmbariException
KerberosHelper
getServiceConfigurationUpdates
in interface KerberosHelper
cluster
- the clusterexistingConfigurations
- the cluster's existing configurationsinstalledServices
- the map of services and relevant components to processserviceFilter
- a Map of service names to component names indicating the
relevant set of services and components - if null, no
filter is relevant; if empty, the filter indicates no
relevant services or componentspreviouslyExistingServices
- a set of previously existing service names - null or a subset of installedServiceskerberosEnabled
- true if kerberos is (to be) enabled; otherwise falseapplyStackAdvisorUpdates
- true to invoke the stack advisor to validate property updates;
false to skipKerberosInvalidConfigurationException
- if an issue occurs trying to get the
Kerberos-specific configuration detailsorg.apache.ambari.server.AmbariException
public Map<String,Map<String,String>> applyStackAdvisorUpdates(Cluster cluster, Set<String> services, Map<String,Map<String,String>> existingConfigurations, Map<String,Map<String,String>> kerberosConfigurations, Map<String,Set<String>> propertiesToIgnore, Map<String,Set<String>> propertiesToRemove, boolean kerberosEnabled) throws org.apache.ambari.server.AmbariException
KerberosHelper
applyStackAdvisorUpdates
in interface KerberosHelper
cluster
- a clusterservices
- a set of services that are being configured to enabled or disable KerberosexistingConfigurations
- the cluster's existing configurationskerberosConfigurations
- the configuration updates to makepropertiesToIgnore
- the configuration properties that should be ignored when applying recommendationspropertiesToRemove
- the configuration properties that must be removed from cluster config are inserted
into this map in case if provided (not null) and kerberosEnabledkerberosEnabled
- true if kerberos is (to be) enabled; otherwise falseorg.apache.ambari.server.AmbariException
public boolean ensureHeadlessIdentities(Cluster cluster, Map<String,Map<String,String>> existingConfigurations, Set<String> services) throws KerberosInvalidConfigurationException, org.apache.ambari.server.AmbariException
KerberosHelper
ensureHeadlessIdentities
in interface KerberosHelper
cluster
- the clusterexistingConfigurations
- the cluster's existing configurationsservices
- the set of services to processKerberosInvalidConfigurationException
- if an issue occurs trying to get the
Kerberos-specific configuration detailsorg.apache.ambari.server.AmbariException
public RequestStageContainer createTestIdentity(Cluster cluster, Map<String,String> commandParamsStage, RequestStageContainer requestStageContainer) throws KerberosOperationException, org.apache.ambari.server.AmbariException
KerberosHelper
createTestIdentity
in interface KerberosHelper
cluster
- the relevant ClustercommandParamsStage
- the command parameters map that will be sent to the agent side commandrequestStageContainer
- a RequestStageContainer to place generated stages, if needed -
if null a new RequestStageContainer will be created.KerberosOperationException
org.apache.ambari.server.AmbariException
public RequestStageContainer deleteTestIdentity(Cluster cluster, Map<String,String> commandParamsStage, RequestStageContainer requestStageContainer) throws KerberosOperationException, org.apache.ambari.server.AmbariException
KerberosHelper
deleteTestIdentity
in interface KerberosHelper
cluster
- the relevant ClustercommandParamsStage
- the command parameters map that will be sent to the agent side commandrequestStageContainer
- a RequestStageContainer to place generated stages, if needed -
if null a new RequestStageContainer will be created.KerberosOperationException
org.apache.ambari.server.AmbariException
public void validateKDCCredentials(Cluster cluster) throws KerberosMissingAdminCredentialsException, KerberosAdminAuthenticationException, KerberosInvalidConfigurationException, org.apache.ambari.server.AmbariException
KerberosHelper
validateKDCCredentials
in interface KerberosHelper
cluster
- associated clusterorg.apache.ambari.server.AmbariException
- if any other error occurs while trying to validate the credentialsKerberosMissingAdminCredentialsException
KerberosAdminAuthenticationException
KerberosInvalidConfigurationException
public void setAuthToLocalRules(Cluster cluster, KerberosDescriptor kerberosDescriptor, String realm, Map<String,Set<String>> installedServices, Map<String,Map<String,String>> existingConfigurations, Map<String,Map<String,String>> kerberosConfigurations, boolean includePreconfigureData) throws org.apache.ambari.server.AmbariException
KerberosHelper
setAuthToLocalRules
in interface KerberosHelper
cluster
- cluster instancekerberosDescriptor
- the current Kerberos descriptorrealm
- the default realminstalledServices
- the map of services and relevant components to processexistingConfigurations
- a map of the current configurationskerberosConfigurations
- a map of the configurations to update, this where the generated
auth-to-local values will be storedincludePreconfigureData
- true
to include the preconfigure data; false
otherwiseorg.apache.ambari.server.AmbariException
public List<ServiceComponentHost> getServiceComponentHostsToProcess(Cluster cluster, KerberosDescriptor kerberosDescriptor, Map<String,? extends Collection<String>> serviceComponentFilter, Collection<String> hostFilter) throws org.apache.ambari.server.AmbariException
getServiceComponentHostsToProcess
in interface KerberosHelper
cluster
- the clusterkerberosDescriptor
- the current Kerberos descriptorserviceComponentFilter
- a Map of service names to component names indicating the
relevant set of services and components - if null, no
filter is relevant; if empty, the filter indicates no
relevant services or componentshostFilter
- a set of hostname indicating the set of hosts to process -
if null, no filter is relevant; if empty, the filter
indicates no relevant hostsorg.apache.ambari.server.AmbariException
public Set<String> getHostsWithValidKerberosClient(Cluster cluster) throws org.apache.ambari.server.AmbariException
getHostsWithValidKerberosClient
in interface KerberosHelper
org.apache.ambari.server.AmbariException
public KerberosDescriptor getKerberosDescriptor(Cluster cluster, boolean includePreconfigureData) throws org.apache.ambari.server.AmbariException
KerberosHelper
stacks/:stackName/versions/:version/artifacts/kerberos_descriptor
endpoint
The user-specified Kerberos descriptor was registered to the
cluster/:clusterName/artifacts/kerberos_descriptor
endpoint.
If the user-specified Kerberos descriptor exists, it is used to update the default Kerberos
descriptor and the composite is returned. If not, the default cluster descriptor is returned
as-is.getKerberosDescriptor
in interface KerberosHelper
cluster
- cluster instanceincludePreconfigureData
- true
to include the preconfigure data; false
otherwiseorg.apache.ambari.server.AmbariException
- if unable to obtain the descriptorKerberosHelper.getKerberosDescriptor(KerberosDescriptorType, Cluster, boolean, Collection, boolean)
public KerberosDescriptor getKerberosDescriptor(KerberosHelper.KerberosDescriptorType kerberosDescriptorType, Cluster cluster, boolean evaluateWhenClauses, Collection<String> additionalServices, boolean includePreconfigureData) throws org.apache.ambari.server.AmbariException
KerberosHelper
One of the following Kerberos descriptors will be returned - with or without pruning identity
definitions based on the evaluation of their when
clauses:
KerberosHelper.KerberosDescriptorType.STACK
KerberosHelper.KerberosDescriptorType.USER
KerberosHelper.KerberosDescriptorType.COMPOSITE
KerberosHelper.getKerberosDescriptor(Cluster, boolean)
getKerberosDescriptor
in interface KerberosHelper
kerberosDescriptorType
- the type of Kerberos descriptor to retrieve - see KerberosHelper.KerberosDescriptorType
cluster
- the relevant ClusterevaluateWhenClauses
- true to evaluate Kerberos identity when
clauses and
prune if necessary; false otherwise.additionalServices
- an optional collection of service names declaring additional
services to add to the set of currently installed services to use
while evaluating when
clausesincludePreconfigureData
- true
to include the preconfigure data; false
otherwiseorg.apache.ambari.server.AmbariException
public KerberosDescriptor getKerberosDescriptor(KerberosHelper.KerberosDescriptorType kerberosDescriptorType, Cluster cluster, StackId stackId, boolean includePreconfigureData) throws org.apache.ambari.server.AmbariException
KerberosHelper
One of the following Kerberos descriptors will be returned:
KerberosHelper.KerberosDescriptorType.STACK
KerberosHelper.KerberosDescriptorType.USER
KerberosHelper.KerberosDescriptorType.COMPOSITE
KerberosHelper.getKerberosDescriptor(Cluster, boolean)
getKerberosDescriptor
in interface KerberosHelper
kerberosDescriptorType
- the type of Kerberos descriptor to retrieve - see KerberosHelper.KerberosDescriptorType
cluster
- the relevant ClusterstackId
- the relevant stack id, used for COMPOSITE
or STACK
Kerberos descriptor requestsincludePreconfigureData
- true
to include the preconfigure data; false
otherwiseorg.apache.ambari.server.AmbariException
public Map<String,Map<String,String>> mergeConfigurations(Map<String,Map<String,String>> configurations, Map<String,KerberosConfigurationDescriptor> updates, Map<String,Map<String,String>> replacements, Set<String> configurationTypeFilter) throws org.apache.ambari.server.AmbariException
KerberosHelper
Each property in the updates Map is processed to replace variables using the replacement Map, unless it has been filtered out using an optionally supplied configuration type filter (configurationTypeFilter).
SeeVariableReplacementHelper.replaceVariables(String, java.util.Map)
for information on variable replacement.mergeConfigurations
in interface KerberosHelper
configurations
- a Map of existing configurations (updated in-place)updates
- a Map of configuration updatesreplacements
- a Map of (grouped) replacement valuesconfigurationTypeFilter
- a Set of config types to filter from the map of updates;
null
indicate no filterorg.apache.ambari.server.AmbariException
- if an issue occurspublic Map<String,Map<String,String>> processPreconfiguredServiceConfigurations(Map<String,Map<String,String>> configurations, Map<String,Map<String,String>> replacements, Cluster cluster, KerberosDescriptor kerberosDescriptor) throws org.apache.ambari.server.AmbariException
KerberosHelper
processPreconfiguredServiceConfigurations
in interface KerberosHelper
configurations
- a Map of existing configurations (updated in-place)replacements
- a Map of (grouped) replacement valuescluster
- the clusterkerberosDescriptor
- the Kerberos Descriptororg.apache.ambari.server.AmbariException
- if an issue occurspublic int addIdentities(KerberosIdentityDataFileWriter kerberosIdentityDataFileWriter, Collection<KerberosIdentityDescriptor> identities, Collection<String> identityFilter, String hostname, Long hostId, String serviceName, String componentName, Map<String,Map<String,String>> kerberosConfigurations, Map<String,Map<String,String>> configurations, Map<String,ResolvedKerberosKeytab> resolvedKeytabs, String realm) throws IOException
KerberosHelper
addIdentities
in interface KerberosHelper
kerberosIdentityDataFileWriter
- a KerberosIdentityDataFileWriter to use for storing identity
recordsidentities
- a List of KerberosIdentityDescriptors to add to the data
fileidentityFilter
- a Collection of identity names indicating the relevant identities -
if null, no filter is relevant; if empty, the filter indicates no
relevant identitieshostname
- the relevant hostnameserviceName
- the relevant service namecomponentName
- the relevant component namekerberosConfigurations
- a map of the configurations to update with identity-specific
valuesconfigurations
- a Map of configurations to use a replacements for variables
in identity fieldsIOException
- if an error occurs while writing a record to the data filepublic Map<String,Map<String,String>> calculateConfigurations(Cluster cluster, String hostname, KerberosDescriptor kerberosDescriptor, boolean includePreconfigureData, boolean calculateClusterHostInfo) throws org.apache.ambari.server.AmbariException
KerberosHelper
ExecutionCommandWrapper.getExecutionCommand()
calculateConfigurations
in interface KerberosHelper
cluster
- the relevant Clusterhostname
- the relevant hostnamekerberosDescriptor
- a map of general Kerberos descriptor propertiesincludePreconfigureData
- true
to include the preconfigure data; otherwise falseorg.apache.ambari.server.AmbariException
public Map<String,Collection<KerberosIdentityDescriptor>> getActiveIdentities(String clusterName, String hostName, String serviceName, String componentName, boolean replaceHostNames, Map<String,Map<String,Map<String,String>>> hostConfigurations, KerberosDescriptor kerberosDescriptor) throws org.apache.ambari.server.AmbariException
KerberosHelper
null
value for any of these filters indicates no filter for that parameter.
The return values are grouped by host and optionally _HOST
in
principals will be replaced with the relevant hostname if specified to do
so.getActiveIdentities
in interface KerberosHelper
clusterName
- the name of the relevant cluster (mandatory)hostName
- the name of a host for which to find results, null indicates all
hostsserviceName
- the name of a service for which to find results, null indicates
all servicescomponentName
- the name of a component for which to find results, null indicates
all componentsreplaceHostNames
- if true, _HOST in principals will be replace with the relevant
host namehostConfigurations
- a mapping of hostname to configurations for that host. Fetching
this ahead of time for every host in the cluster will ensure that
this method doesn't need to do it inside of a loop. If
null
or empty, then this method will do the lookup itself,
at considerable cost.kerberosDescriptor
- the kerberos descriptor to use when looking up identities. If
null
, then this method will deserialize the descriptor
inside of a loop at considerable cost.org.apache.ambari.server.AmbariException
- if an error occurs processing the cluster's active identitiespublic List<KerberosIdentityDescriptor> getAmbariServerIdentities(KerberosDescriptor kerberosDescriptor) throws org.apache.ambari.server.AmbariException
KerberosHelper
getAmbariServerIdentities
in interface KerberosHelper
kerberosDescriptor
- the kerberos descriptororg.apache.ambari.server.AmbariException
public boolean createAmbariIdentities(Map<String,String> kerberosEnvProperties)
KerberosHelper
If kerberos-env/create_ambari_principal is not set to false the identity should be calculated.
createAmbariIdentities
in interface KerberosHelper
kerberosEnvProperties
- the kerberos-env configuration propertiespublic PrincipalKeyCredential getKDCAdministratorCredentials(String clusterName) throws org.apache.ambari.server.AmbariException
getKDCAdministratorCredentials
in interface KerberosHelper
clusterName
- the name of the relevant clusterorg.apache.ambari.server.AmbariException
- if an error occurs while retrieving the credentialspublic void createResolvedKeytab(ResolvedKerberosKeytab resolvedKerberosKeytab)
KerberosPrincipalEntity
,
KerberosKeytabEntity
entities
in JPA storage.
This method has to be very, very careful WRT how and when it merges
bidirectional associations.For larger cluster, merging the
KerberosKeytabEntity
and KerberosPrincipalEntity
even when
a KerberosKeytabPrincipalEntity
will result in major performance
problems.
createResolvedKeytab
in interface KerberosHelper
resolvedKerberosKeytab
- kerberos keytab to be persistedpublic void removeStaleKeytabs(Collection<ResolvedKerberosKeytab> expectedKeytabs)
KerberosHelper
expectedKeytabs
collection.removeStaleKeytabs
in interface KerberosHelper
expectedKeytabs
- collection to compare existent keytabspublic Map<String,Set<String>> translateConfigurationSpecifications(Collection<String> configurationSpecifications)
KerberosHelper
config-type/property-name
)
to a map of configuration types to a set of property names.
For example:
translateConfigurationSpecifications
in interface KerberosHelper
configurationSpecifications
- a collection of configuration specifications (config-type/property-name
)public KerberosDetails getKerberosDetails(Cluster cluster, Boolean manageIdentities) throws KerberosInvalidConfigurationException, org.apache.ambari.server.AmbariException
getKerberosDetails
in interface KerberosHelper
cluster
- the relevant ClustermanageIdentities
- a Boolean value indicating how to override the configured behavior
of managing Kerberos identities; if null the configured behavior
will not be overriddenorg.apache.ambari.server.AmbariException
KerberosInvalidConfigurationException
public File createTemporaryDirectory() throws org.apache.ambari.server.AmbariException
createTemporaryDirectory
in interface KerberosHelper
org.apache.ambari.server.AmbariException
- if a new temporary directory cannot be createdprotected File createTemporaryFile() throws org.apache.ambari.server.AmbariException
org.apache.ambari.server.AmbariException
- if a new temporary directory cannot be createdprotected File getConfiguredTemporaryDirectory() throws IOException
IOException
public boolean isClusterKerberosEnabled(Cluster cluster)
KerberosHelper
isClusterKerberosEnabled
in interface KerberosHelper
cluster
- cluster to testpublic boolean shouldExecuteCustomOperations(SecurityType requestSecurityType, Map<String,String> requestProperties)
KerberosHelper
shouldExecuteCustomOperations
in interface KerberosHelper
requestSecurityType
- the SecurityType from the requestrequestProperties
- A Map of request directives and their valuespublic Boolean getManageIdentitiesDirective(Map<String,String> requestProperties)
KerberosHelper
getManageIdentitiesDirective
in interface KerberosHelper
requestProperties
- a map of the request property name/value pairspublic boolean getForceToggleKerberosDirective(Map<String,String> requestProperties)
KerberosHelper
false
is
returned.
If force_toggle_kerberos does exists in the map of request properties and is equal to "true",
then true
is returned; otherwise false
is returned.getForceToggleKerberosDirective
in interface KerberosHelper
requestProperties
- a map of the request property name/value pairspublic Map<String,Map<String,String>> getIdentityConfigurations(List<KerberosIdentityDescriptor> identityDescriptors)
KerberosHelper
getIdentityConfigurations
in interface KerberosHelper
identityDescriptors
- a List of KerberosIdentityDescriptor from which to retrieve configurationsCopyright © 2022 Apache Software Foundation. All rights reserved.