Skip to content

Commit

Permalink
polish
Browse files Browse the repository at this point in the history
  • Loading branch information
Bilal Al committed Aug 30, 2024
1 parent a96c19e commit 26389a7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package io.split.client.exceptions;

public class KerberosAuthException extends Exception {
public KerberosAuthException(String message) {
super(message);
}
public KerberosAuthException(String message, Throwable exception) {
super(message, exception);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package io.split.service;

import io.split.client.exceptions.KerberosAuthException;
import java.io.IOException;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.util.Map;
import java.util.Date;
import java.util.Set;
Expand Down Expand Up @@ -125,8 +128,7 @@ private Subject getContextSubject() {
* need to authenticate
* @return the HTTP Authorization header token
*/
private String buildAuthorizationHeader(String serverPrincipalName) throws LoginException
{
private String buildAuthorizationHeader(String serverPrincipalName) throws LoginException, PrivilegedActionException {
/*
* Get the principal from the Subject's private credentials and populate the
* client and server principal name for the GSS API
Expand Down Expand Up @@ -171,7 +173,7 @@ private String buildAuthorizationHeader(String serverPrincipalName) throws Login
* Subject.doAs() method. We do this in order to create a context of the user
* who has the service ticket and reuse this context for subsequent requests
*/
private static class CreateAuthorizationHeaderAction implements PrivilegedAction {
private static class CreateAuthorizationHeaderAction implements PrivilegedExceptionAction {
String clientPrincipalName;
String serverPrincipalName;

Expand All @@ -197,7 +199,7 @@ private String getNegotiateToken() {
* be set to true.
*/
@Override
public Object run() {
public Object run() throws KerberosAuthException {
try {
Oid krb5Mechanism = new Oid("1.2.840.113554.1.2.2");
Oid krb5PrincipalNameType = new Oid("1.2.840.113554.1.2.2.1");
Expand All @@ -218,7 +220,7 @@ public Object run() {
outputToken.append(new String(Base64.getEncoder().encode(outToken)));
context.dispose();
} catch (GSSException | IOException exception) {
throw new RuntimeException(exception.getMessage(), exception);
throw new KerberosAuthException(exception.getMessage(), exception);
}
return null;
}
Expand Down

0 comments on commit 26389a7

Please sign in to comment.