Skip to content

Commit d4ea440

Browse files
authored
[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
1 parent f0b3667 commit d4ea440

File tree

3 files changed

+14
-16
lines changed

3 files changed

+14
-16
lines changed

x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/kerberos/KerberosTestCase.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public void tearDownMiniKdc() throws IOException, PrivilegedActionException {
133133
* @param dir Directory where the key tab would be created.
134134
* @param princNames principal names to be created
135135
* @return {@link Path} to key tab file.
136-
* @throws Exception
136+
* @throws Exception thrown if principal or keytab could not be created
137137
*/
138138
protected Path createPrincipalKeyTab(final Path dir, final String... princNames) throws Exception {
139139
final Path path = dir.resolve(randomAlphaOfLength(10) + ".keytab");
@@ -146,7 +146,7 @@ protected Path createPrincipalKeyTab(final Path dir, final String... princNames)
146146
*
147147
* @param principalName Principal name
148148
* @param password Password
149-
* @throws Exception
149+
* @throws Exception thrown if principal could not be created
150150
*/
151151
protected void createPrincipal(final String principalName, final char[] password) throws Exception {
152152
simpleKdcLdapServer.createPrincipal(principalName, new String(password));
@@ -168,8 +168,8 @@ protected String principalName(final String user) {
168168
* @param subject {@link Subject}
169169
* @param action {@link PrivilegedExceptionAction} action for performing inside
170170
* Subject.doAs
171-
* @return <T> Type of value as returned by PrivilegedAction
172-
* @throws PrivilegedActionException
171+
* @return T Type of value as returned by PrivilegedAction
172+
* @throws PrivilegedActionException when privileged action threw exception
173173
*/
174174
static <T> T doAsWrapper(final Subject subject, final PrivilegedExceptionAction<T> action) throws PrivilegedActionException {
175175
return AccessController.doPrivileged((PrivilegedExceptionAction<T>) () -> Subject.doAs(subject, action));
@@ -181,7 +181,7 @@ static <T> T doAsWrapper(final Subject subject, final PrivilegedExceptionAction<
181181
* @param keytabPath {@link Path} to keytab file.
182182
* @param content Content for keytab
183183
* @return key tab path
184-
* @throws IOException
184+
* @throws IOException if I/O error occurs while writing keytab file
185185
*/
186186
public static Path writeKeyTab(final Path keytabPath, final String content) throws IOException {
187187
try (BufferedWriter bufferedWriter = Files.newBufferedWriter(keytabPath, StandardCharsets.US_ASCII)) {

x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/kerberos/SimpleKdcLdapServer.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public class SimpleKdcLdapServer {
6666
* @param orgName Org name for base dn
6767
* @param domainName domain name for base dn
6868
* @param ldiff for ldap directory.
69-
* @throws Exception
69+
* @throws Exception when KDC or Ldap server initialization fails
7070
*/
7171
public SimpleKdcLdapServer(final Path workDir, final String orgName, final String domainName, final Path ldiff) throws Exception {
7272
this.workDir = workDir;
@@ -194,7 +194,7 @@ public synchronized void createPrincipal(final Path keytabFile, final String...
194194
/**
195195
* Stop Simple Kdc Server
196196
*
197-
* @throws PrivilegedActionException
197+
* @throws PrivilegedActionException when privileged action threw exception
198198
*/
199199
public synchronized void stop() throws PrivilegedActionException {
200200
AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {

x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/kerberos/SpnegoClient.java

+7-9
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import org.elasticsearch.common.SuppressForbidden;
1212
import org.elasticsearch.common.logging.ESLoggerFactory;
1313
import org.elasticsearch.common.settings.SecureString;
14-
import org.elasticsearch.common.settings.Settings;
1514
import org.elasticsearch.xpack.security.authc.kerberos.KerberosTicketValidator;
1615
import org.ietf.jgss.GSSContext;
1716
import org.ietf.jgss.GSSCredential;
@@ -67,8 +66,8 @@ class SpnegoClient implements AutoCloseable {
6766
* @param password password for client
6867
* @param servicePrincipalName Service principal name with whom this client
6968
* interacts with.
70-
* @throws PrivilegedActionException
71-
* @throws GSSException
69+
* @throws PrivilegedActionException when privileged action threw exception
70+
* @throws GSSException thrown when GSS API error occurs
7271
*/
7372
SpnegoClient(final String userPrincipalName, final SecureString password, final String servicePrincipalName)
7473
throws PrivilegedActionException, GSSException {
@@ -99,7 +98,7 @@ class SpnegoClient implements AutoCloseable {
9998
* base64 encoded token to be sent to server.
10099
*
101100
* @return Base64 encoded token
102-
* @throws PrivilegedActionException
101+
* @throws PrivilegedActionException when privileged action threw exception
103102
*/
104103
String getBase64EncodedTokenForSpnegoHeader() throws PrivilegedActionException {
105104
final byte[] outToken = KerberosTestCase.doAsWrapper(loginContext.getSubject(),
@@ -114,7 +113,7 @@ String getBase64EncodedTokenForSpnegoHeader() throws PrivilegedActionException {
114113
* gss negotiation
115114
* @return Base64 encoded token to be sent to server. May return {@code null} if
116115
* nothing to be sent.
117-
* @throws PrivilegedActionException
116+
* @throws PrivilegedActionException when privileged action threw exception
118117
*/
119118
String handleResponse(final String base64Token) throws PrivilegedActionException {
120119
if (gssContext.isEstablished()) {
@@ -160,10 +159,9 @@ boolean isEstablished() {
160159
*
161160
* @param principal Principal name
162161
* @param password {@link SecureString}
163-
* @param settings {@link Settings}
164162
* @return authenticated {@link LoginContext} instance. Note: This needs to be
165163
* closed {@link LoginContext#logout()} after usage.
166-
* @throws LoginException
164+
* @throws LoginException thrown if problem with login configuration or when login fails
167165
*/
168166
private static LoginContext loginUsingPassword(final String principal, final SecureString password) throws LoginException {
169167
final Set<Principal> principals = Collections.singleton(new KerberosPrincipal(principal));
@@ -182,8 +180,8 @@ private static LoginContext loginUsingPassword(final String principal, final Sec
182180
* Instead of an additional file setting as we do not want the options to be
183181
* customizable we are constructing it in memory.
184182
* <p>
185-
* As we are uing this instead of jaas.conf, this requires refresh of
186-
* {@link Configuration} and reqires appropriate security permissions to do so.
183+
* As we are using this instead of jaas.conf, this requires refresh of
184+
* {@link Configuration} and requires appropriate security permissions to do so.
187185
*/
188186
static class PasswordJaasConf extends Configuration {
189187
private final String principal;

0 commit comments

Comments
 (0)