[Kerberos] Add missing javadocs (#32469)

This commit adds missing javadocs and fixes few where
the build failed when using JDK 11 for compilation.

Closes#32461
This commit is contained in:
Yogesh Gaikwad 2018-07-31 11:18:08 +10:00 committed by GitHub
parent f0b36679ec
commit d4ea440e37
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 16 deletions

View File

@ -133,7 +133,7 @@ public abstract class KerberosTestCase extends ESTestCase {
* @param dir Directory where the key tab would be created.
* @param princNames principal names to be created
* @return {@link Path} to key tab file.
* @throws Exception
* @throws Exception thrown if principal or keytab could not be created
*/
protected Path createPrincipalKeyTab(final Path dir, final String... princNames) throws Exception {
final Path path = dir.resolve(randomAlphaOfLength(10) + ".keytab");
@ -146,7 +146,7 @@ public abstract class KerberosTestCase extends ESTestCase {
*
* @param principalName Principal name
* @param password Password
* @throws Exception
* @throws Exception thrown if principal could not be created
*/
protected void createPrincipal(final String principalName, final char[] password) throws Exception {
simpleKdcLdapServer.createPrincipal(principalName, new String(password));
@ -168,8 +168,8 @@ public abstract class KerberosTestCase extends ESTestCase {
* @param subject {@link Subject}
* @param action {@link PrivilegedExceptionAction} action for performing inside
* Subject.doAs
* @return <T> Type of value as returned by PrivilegedAction
* @throws PrivilegedActionException
* @return T Type of value as returned by PrivilegedAction
* @throws PrivilegedActionException when privileged action threw exception
*/
static <T> T doAsWrapper(final Subject subject, final PrivilegedExceptionAction<T> action) throws PrivilegedActionException {
return AccessController.doPrivileged((PrivilegedExceptionAction<T>) () -> Subject.doAs(subject, action));
@ -181,7 +181,7 @@ public abstract class KerberosTestCase extends ESTestCase {
* @param keytabPath {@link Path} to keytab file.
* @param content Content for keytab
* @return key tab path
* @throws IOException
* @throws IOException if I/O error occurs while writing keytab file
*/
public static Path writeKeyTab(final Path keytabPath, final String content) throws IOException {
try (BufferedWriter bufferedWriter = Files.newBufferedWriter(keytabPath, StandardCharsets.US_ASCII)) {

View File

@ -66,7 +66,7 @@ public class SimpleKdcLdapServer {
* @param orgName Org name for base dn
* @param domainName domain name for base dn
* @param ldiff for ldap directory.
* @throws Exception
* @throws Exception when KDC or Ldap server initialization fails
*/
public SimpleKdcLdapServer(final Path workDir, final String orgName, final String domainName, final Path ldiff) throws Exception {
this.workDir = workDir;
@ -194,7 +194,7 @@ public class SimpleKdcLdapServer {
/**
* Stop Simple Kdc Server
*
* @throws PrivilegedActionException
* @throws PrivilegedActionException when privileged action threw exception
*/
public synchronized void stop() throws PrivilegedActionException {
AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {

View File

@ -11,7 +11,6 @@ import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.common.SuppressForbidden;
import org.elasticsearch.common.logging.ESLoggerFactory;
import org.elasticsearch.common.settings.SecureString;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.xpack.security.authc.kerberos.KerberosTicketValidator;
import org.ietf.jgss.GSSContext;
import org.ietf.jgss.GSSCredential;
@ -67,8 +66,8 @@ class SpnegoClient implements AutoCloseable {
* @param password password for client
* @param servicePrincipalName Service principal name with whom this client
* interacts with.
* @throws PrivilegedActionException
* @throws GSSException
* @throws PrivilegedActionException when privileged action threw exception
* @throws GSSException thrown when GSS API error occurs
*/
SpnegoClient(final String userPrincipalName, final SecureString password, final String servicePrincipalName)
throws PrivilegedActionException, GSSException {
@ -99,7 +98,7 @@ class SpnegoClient implements AutoCloseable {
* base64 encoded token to be sent to server.
*
* @return Base64 encoded token
* @throws PrivilegedActionException
* @throws PrivilegedActionException when privileged action threw exception
*/
String getBase64EncodedTokenForSpnegoHeader() throws PrivilegedActionException {
final byte[] outToken = KerberosTestCase.doAsWrapper(loginContext.getSubject(),
@ -114,7 +113,7 @@ class SpnegoClient implements AutoCloseable {
* gss negotiation
* @return Base64 encoded token to be sent to server. May return {@code null} if
* nothing to be sent.
* @throws PrivilegedActionException
* @throws PrivilegedActionException when privileged action threw exception
*/
String handleResponse(final String base64Token) throws PrivilegedActionException {
if (gssContext.isEstablished()) {
@ -160,10 +159,9 @@ class SpnegoClient implements AutoCloseable {
*
* @param principal Principal name
* @param password {@link SecureString}
* @param settings {@link Settings}
* @return authenticated {@link LoginContext} instance. Note: This needs to be
* closed {@link LoginContext#logout()} after usage.
* @throws LoginException
* @throws LoginException thrown if problem with login configuration or when login fails
*/
private static LoginContext loginUsingPassword(final String principal, final SecureString password) throws LoginException {
final Set<Principal> principals = Collections.singleton(new KerberosPrincipal(principal));
@ -182,8 +180,8 @@ class SpnegoClient implements AutoCloseable {
* Instead of an additional file setting as we do not want the options to be
* customizable we are constructing it in memory.
* <p>
* As we are uing this instead of jaas.conf, this requires refresh of
* {@link Configuration} and reqires appropriate security permissions to do so.
* As we are using this instead of jaas.conf, this requires refresh of
* {@link Configuration} and requires appropriate security permissions to do so.
*/
static class PasswordJaasConf extends Configuration {
private final String principal;