public abstract class KerberosOperationHandler extends Object
Modifier and Type | Field and Description |
---|---|
static String |
KERBEROS_ENV_AD_CREATE_ATTRIBUTES_TEMPLATE
Kerberos-env configuration property name: ad_create_attributes_template
|
static String |
KERBEROS_ENV_ADMIN_SERVER_HOST
Kerberos-env configuration property name: admin_server_host
|
static String |
KERBEROS_ENV_ENCRYPTION_TYPES
Kerberos-env configuration property name: encryption_types
|
static String |
KERBEROS_ENV_EXECUTABLE_SEARCH_PATHS
Kerberos-env configuration property name: executable_search_paths
|
static String |
KERBEROS_ENV_KADMIN_PRINCIPAL_NAME
Kerberos-env configuration property name: kadmin_principal_name
|
static String |
KERBEROS_ENV_KDC_CREATE_ATTRIBUTES
Kerberos-env configuration property name: kdc_create_attributes
|
static String |
KERBEROS_ENV_KDC_HOSTS
Kerberos-env configuration property name: kdc_hosts
|
static String |
KERBEROS_ENV_LDAP_URL
Kerberos-env configuration property name: ldap_url
|
static String |
KERBEROS_ENV_PRINCIPAL_CONTAINER_DN
Kerberos-env configuration property name: container_dn
|
static String |
KERBEROS_ENV_USER_PRINCIPAL_GROUP
Kerberos-env configuration property name: group
|
Constructor and Description |
---|
KerberosOperationHandler() |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes and cleans up any resources used by this KerberosOperationHandler
It is expected that this KerberosOperationHandler will not be used after this call.
|
protected DeconstructedPrincipal |
createDeconstructPrincipal(String principal)
Given a principal, attempt to create a new DeconstructedPrincipal
|
protected org.apache.directory.server.kerberos.shared.keytab.Keytab |
createKeytab(String principal,
String password,
Integer keyNumber)
Create a keytab using the specified principal and password.
|
protected boolean |
createKeytabFile(File sourceKeytabFile,
File destinationKeytabFile)
Create or append to a keytab file using keytab data from another keytab file.
|
boolean |
createKeytabFile(org.apache.directory.server.kerberos.shared.keytab.Keytab keytab,
File destinationKeytabFile)
Create or append to a keytab file using the specified Keytab
If the destination keytab file contains keytab data, that data will be merged with the new data
to create a composite set of keytab entries.
|
protected File |
createKeytabFile(String keytabData)
Given base64-encoded keytab data, decode the String to binary data and write it to a (temporary)
file.
|
protected boolean |
createKeytabFile(String principal,
String password,
Integer keyNumber,
File destinationKeytabFile)
Create or append to a keytab file using the specified principal and password.
|
abstract Integer |
createPrincipal(String principal,
String password,
boolean service)
Creates a new principal in a previously configured KDC
The implementation is specific to a particular type of KDC.
|
protected String |
escapeCharacters(String string,
Set<Character> charactersToEscape,
Character escapeCharacter)
Iterates through the characters in a string to escape special characters
|
protected ShellCommandUtil.Result |
executeCommand(String[] command)
Executes a shell command.
|
protected ShellCommandUtil.Result |
executeCommand(String[] command,
Map<String,String> envp,
ShellCommandUtil.InteractiveHandler interactiveHandler)
Executes a shell command.
|
protected ShellCommandUtil.Result |
executeCommand(String[] command,
ShellCommandUtil.InteractiveHandler interactiveHandler)
Executes a shell command.
|
PrincipalKeyCredential |
getAdministratorCredential()
Sets the KDC administrator credential.
|
String |
getDefaultRealm() |
protected String |
getExecutable(String executable)
Given the name of an executable, searches the configured executable search path for an executable
file with that name.
|
String[] |
getExecutableSearchPaths()
Gets the ordered array of search paths used to find Kerberos-related executables.
|
Set<org.apache.directory.shared.kerberos.codec.types.EncryptionType> |
getKeyEncryptionTypes()
Gets the encryption algorithms used to encrypt keys in keytab entries
|
boolean |
isOpen()
Test this KerberosOperationHandler to see whether is was previously open or not
|
protected org.apache.directory.server.kerberos.shared.keytab.Keytab |
mergeKeytabs(org.apache.directory.server.kerberos.shared.keytab.Keytab keytab,
org.apache.directory.server.kerberos.shared.keytab.Keytab updates)
Merge the keytab data from one keytab with the keytab data from a different keytab.
|
void |
open(PrincipalKeyCredential administratorCredential,
String defaultRealm,
Map<String,String> kerberosConfiguration)
Prepares and creates resources to be used by this KerberosOperationHandler.
|
abstract boolean |
principalExists(String principal,
boolean service)
Test to see if the specified principal exists in a previously configured KDC
The implementation is specific to a particular type of KDC.
|
protected org.apache.directory.server.kerberos.shared.keytab.Keytab |
readKeytabFile(File file)
Reads a file containing keytab data into a new Keytab
|
abstract boolean |
removePrincipal(String principal,
boolean service)
Removes an existing principal in a previously configured KDC
The implementation is specific to a particular type of KDC.
|
void |
setAdministratorCredential(PrincipalKeyCredential administratorCredential)
Sets the administrator credentials for this KerberosOperationHandler.
|
void |
setDefaultRealm(String defaultRealm) |
void |
setExecutableSearchPaths(String delimitedExecutableSearchPaths)
Sets the ordered array of search paths used to find Kerberos-related executables.
|
void |
setExecutableSearchPaths(String[] executableSearchPaths)
Sets the ordered array of search paths used to find Kerberos-related executables.
|
void |
setKeyEncryptionTypes(Set<org.apache.directory.shared.kerberos.codec.types.EncryptionType> keyEncryptionTypes)
Sets the encryption algorithms to use to encrypt keys in keytab entries
If set to
null the default set of ciphers will be used. |
void |
setOpen(boolean open)
Sets whether this KerberosOperationHandler is open or not.
|
abstract Integer |
setPrincipalPassword(String principal,
String password,
boolean service)
Updates the password for an existing principal in a previously configured KDC
The implementation is specific to a particular type of KDC.
|
boolean |
testAdministratorCredentials()
Tests to ensure the connection information and credentials allow for administrative
connectivity to the KDC
|
protected Set<org.apache.directory.shared.kerberos.codec.types.EncryptionType> |
translateEncryptionType(String name)
Given a cipher (or algorithm) name, attempts to translate it into an EncryptionType value.
|
protected Set<org.apache.directory.shared.kerberos.codec.types.EncryptionType> |
translateEncryptionTypes(String names,
String delimiter)
Given a delimited set of encryption type names, attempts to translate into a set of EncryptionType
values.
|
public static final String KERBEROS_ENV_LDAP_URL
public static final String KERBEROS_ENV_PRINCIPAL_CONTAINER_DN
public static final String KERBEROS_ENV_USER_PRINCIPAL_GROUP
public static final String KERBEROS_ENV_AD_CREATE_ATTRIBUTES_TEMPLATE
public static final String KERBEROS_ENV_KDC_CREATE_ATTRIBUTES
public static final String KERBEROS_ENV_ENCRYPTION_TYPES
public static final String KERBEROS_ENV_KDC_HOSTS
public static final String KERBEROS_ENV_ADMIN_SERVER_HOST
public static final String KERBEROS_ENV_KADMIN_PRINCIPAL_NAME
public static final String KERBEROS_ENV_EXECUTABLE_SEARCH_PATHS
public void open(PrincipalKeyCredential administratorCredential, String defaultRealm, Map<String,String> kerberosConfiguration) throws KerberosOperationException
administratorCredential
- a PrincipalKeyCredential containing the administrative credential
for the relevant KDCdefaultRealm
- a String declaring the default Kerberos realm (or domain)kerberosConfiguration
- a Map of key/value pairs containing data from the kerberos-env configuration setKerberosOperationException
public void close() throws KerberosOperationException
KerberosOperationException
public abstract boolean principalExists(String principal, boolean service) throws KerberosOperationException
principal
- a String containing the principal to testservice
- a boolean value indicating whether the principal is for a service or notKerberosOperationException
public abstract Integer createPrincipal(String principal, String password, boolean service) throws KerberosOperationException
principal
- a String containing the principal to addpassword
- a String containing the password to use when creating the principalservice
- a boolean value indicating whether the principal is to be created as a service principal or notKerberosOperationException
KerberosPrincipalAlreadyExistsException
- if the principal already existspublic abstract Integer setPrincipalPassword(String principal, String password, boolean service) throws KerberosOperationException
principal
- a String containing the principal to updatepassword
- a String containing the password to setservice
- a boolean value indicating whether the principal is for a service or notKerberosOperationException
KerberosPrincipalDoesNotExistException
- if the principal does not existpublic abstract boolean removePrincipal(String principal, boolean service) throws KerberosOperationException
principal
- a String containing the principal to removeservice
- a boolean value indicating whether the principal is for a service or notKerberosOperationException
public boolean testAdministratorCredentials() throws KerberosOperationException
KerberosOperationException
- if a failure occurs while testing the
administrator credentialsprotected org.apache.directory.server.kerberos.shared.keytab.Keytab createKeytab(String principal, String password, Integer keyNumber) throws KerberosOperationException
principal
- a String containing the principal to testpassword
- a String containing the password to use when creating the principalkeyNumber
- a Integer indicating the key number for the keytab entriesKerberosOperationException
protected boolean createKeytabFile(File sourceKeytabFile, File destinationKeytabFile) throws KerberosOperationException
sourceKeytabFile
- a File containing the absolute path to the file with the keytab data to storedestinationKeytabFile
- a File containing the absolute path to where the keytab data is to be storedKerberosOperationException
createKeytabFile(org.apache.directory.server.kerberos.shared.keytab.Keytab, java.io.File)
protected boolean createKeytabFile(String principal, String password, Integer keyNumber, File destinationKeytabFile) throws KerberosOperationException
principal
- a String containing the principal to testpassword
- a String containing the password to use when creating the principalkeyNumber
- an Integer declaring the relevant key number to use for the keytabs entriesdestinationKeytabFile
- a File containing the absolute path to where the keytab data is to be storedKerberosOperationException
createKeytabFile(org.apache.directory.server.kerberos.shared.keytab.Keytab, java.io.File)
public boolean createKeytabFile(org.apache.directory.server.kerberos.shared.keytab.Keytab keytab, File destinationKeytabFile) throws KerberosOperationException
keytab
- the Keytab containing the data to add to the keytab filedestinationKeytabFile
- a File containing the absolute path to where the keytab data is to be storedKerberosOperationException
protected org.apache.directory.server.kerberos.shared.keytab.Keytab mergeKeytabs(org.apache.directory.server.kerberos.shared.keytab.Keytab keytab, org.apache.directory.server.kerberos.shared.keytab.Keytab updates)
keytab
- a Keytab with the base keytab dataupdates
- a Keytab containing the updated keytab dataprotected org.apache.directory.server.kerberos.shared.keytab.Keytab readKeytabFile(File file)
file
- A File containing the path to the file from which to read keytab datapublic PrincipalKeyCredential getAdministratorCredential()
public void setAdministratorCredential(PrincipalKeyCredential administratorCredential) throws KerberosAdminAuthenticationException
PrincipalKeyCredential
is not null
, validates that the administrator
principal and values are not null
or empty. If the credential value does not
validate, then a KerberosAdminAuthenticationException
will be thrown.administratorCredential
- the KDC administrator credentialKerberosAdminAuthenticationException
- if the non-null Credential fails to contain
a non-empty principal and password values.public String getDefaultRealm()
public void setDefaultRealm(String defaultRealm)
public Set<org.apache.directory.shared.kerberos.codec.types.EncryptionType> getKeyEncryptionTypes()
public void setKeyEncryptionTypes(Set<org.apache.directory.shared.kerberos.codec.types.EncryptionType> keyEncryptionTypes)
null
the default set of ciphers will be used. See DEFAULT_CIPHERS
keyEncryptionTypes
- a Set of EncryptionKey values or null to indicate the default setpublic String[] getExecutableSearchPaths()
public void setExecutableSearchPaths(String[] executableSearchPaths)
executableSearchPaths
- an array of String values indicating an ordered list of filesystem paths to searchpublic void setExecutableSearchPaths(String delimitedExecutableSearchPaths)
delimitedExecutableSearchPaths
- a String containing a comma-delimited (ordered) list of filesystem paths to searchpublic boolean isOpen()
public void setOpen(boolean open)
open
- a boolean value indicating whether this KerberosOperationHandler was open (true) or not (false)protected File createKeytabFile(String keytabData) throws KerberosOperationException
keytabData
- a String containing base64-encoded keytab dataKerberosOperationException
protected ShellCommandUtil.Result executeCommand(String[] command, Map<String,String> envp, ShellCommandUtil.InteractiveHandler interactiveHandler) throws KerberosOperationException
org.apache.ambari.server.utils.ShellCommandUtil#runCommand(String[], Map)
command
- an array of String value representing the command and its argumentsenvp
- a map of string, string of environment variablesinteractiveHandler
- a handler to provide responses to queries from the command,
or null if no queries are expectedKerberosOperationException
protected ShellCommandUtil.Result executeCommand(String[] command) throws KerberosOperationException
ShellCommandUtil.runCommand(String[])
command
- an array of String value representing the command and its argumentsKerberosOperationException
executeCommand(String[], Map, ShellCommandUtil.InteractiveHandler)
protected ShellCommandUtil.Result executeCommand(String[] command, ShellCommandUtil.InteractiveHandler interactiveHandler) throws KerberosOperationException
ShellCommandUtil.runCommand(String[])
command
- an array of String value representing the command and its argumentsinteractiveHandler
- a handler to provide responses to queries from the command,
or null if no queries are expectedKerberosOperationException
executeCommand(String[], Map, ShellCommandUtil.InteractiveHandler)
protected DeconstructedPrincipal createDeconstructPrincipal(String principal) throws KerberosOperationException
principal
- a String containing the principal to deconstructKerberosOperationException
protected Set<org.apache.directory.shared.kerberos.codec.types.EncryptionType> translateEncryptionType(String name)
EncryptionType.UNKNOWN
is returned.name
- a String containing the name of the cipher to translateprotected Set<org.apache.directory.shared.kerberos.codec.types.EncryptionType> translateEncryptionTypes(String names, String delimiter) throws KerberosOperationException
names
- a String containing a delimited list of encryption type namesdelimiter
- a String declaring the delimiter to use to split names, if null, " " is used.KerberosOperationException
- When all the encryption type names are not supportedprotected String escapeCharacters(String string, Set<Character> charactersToEscape, Character escapeCharacter)
string
- the String to processcharactersToEscape
- a Set of characters declaring the special characters to escapeescapeCharacter
- a character to use for escapingprotected String getExecutable(String executable)
executable
- a String declaring the name of the executable to find within the search pathsetExecutableSearchPaths(String)
,
setExecutableSearchPaths(String[])
Copyright © 2022 Apache Software Foundation. All rights reserved.