private void initializeNegotiator ( URI requestURI , SpnegoCredentials spnegoCredentials ) throws UnknownHostException , AuthenticationException , GSSException { // Initialize negotiator if ( spnegoNegotiator == null ) { // Determine host principal String servicePrincipal = spnegoCredentials . getServicePrincipalName ( ) ; if ( spnegoCredentials . getServicePrincipalName ( ) . contains ( HOSTNAME_PATTERN ) ) { String fqdn = getFQDN ( requestURI ) ; String [ ] components = spnegoCredentials . getServicePrincipalName ( ) . split ( "[/@]" ) ; if ( components . length != 3 || ! components [ 1 ] . equals ( HOSTNAME_PATTERN ) ) { throw new AuthenticationException ( "Malformed service principal name [" + spnegoCredentials . getServicePrincipalName ( ) + "]. To use host substitution, the principal must be of the format [serviceName/_HOST@REALM.NAME]." ) ; } servicePrincipal = components [ 0 ] + "/" + fqdn . toLowerCase ( ) + "@" + components [ 2 ] ; } User userInfo = spnegoCredentials . getUserProvider ( ) . getUser ( ) ; KerberosPrincipal principal = userInfo . getKerberosPrincipal ( ) ; if ( principal == null ) { throw new EsHadoopIllegalArgumentException ( "Could not locate Kerberos Principal on currently logged in user." ) ; } spnegoNegotiator = new SpnegoNegotiator ( principal . getName ( ) , servicePrincipal ) ; } }
Creates the negotiator if it is not yet created or does nothing if the negotiator is already initialized .