Skip to content

Commit

Permalink
Reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-dheyman committed Dec 10, 2024
1 parent c391329 commit 556f476
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions src/main/java/net/snowflake/client/core/SessionUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,9 @@ private static AuthenticatorType getAuthenticator(SFLoginInput loginInput) {
} else if (loginInput.getAuthenticator().equalsIgnoreCase(AuthenticatorType.OAUTH.name())) {
// OAuth access code Authentication
return AuthenticatorType.OAUTH;
} else if (loginInput.getAuthenticator().equalsIgnoreCase(AuthenticatorType.PROGRAMMATIC_ACCESS_TOKEN.name())) {
} else if (loginInput
.getAuthenticator()
.equalsIgnoreCase(AuthenticatorType.PROGRAMMATIC_ACCESS_TOKEN.name())) {
return AuthenticatorType.PROGRAMMATIC_ACCESS_TOKEN;
} else if (loginInput
.getAuthenticator()
Expand Down Expand Up @@ -292,17 +294,18 @@ static SFLoginOutput openSession(
}

final AuthenticatorType authenticator = getAuthenticator(loginInput);
if (authenticator.equals(AuthenticatorType.OAUTH) || authenticator.equals(AuthenticatorType.PROGRAMMATIC_ACCESS_TOKEN)) {
// OAUTH and PAT needs either token or password
AssertUtil.assertTrue(
loginInput.getToken() != null || loginInput.getPassword() != null,
"missing token or password for opening session");
} else {
// OAuth does not require a username
AssertUtil.assertTrue(
loginInput.getUserName() != null, "missing user name for opening session");
}
if (authenticator.equals(AuthenticatorType.EXTERNALBROWSER)) {
if (authenticator.equals(AuthenticatorType.OAUTH)
|| authenticator.equals(AuthenticatorType.PROGRAMMATIC_ACCESS_TOKEN)) {
// OAUTH and PAT needs either token or password
AssertUtil.assertTrue(
loginInput.getToken() != null || loginInput.getPassword() != null,
"missing token or password for opening session");
} else {
// OAuth does not require a username
AssertUtil.assertTrue(
loginInput.getUserName() != null, "missing user name for opening session");
}
if (authenticator.equals(AuthenticatorType.EXTERNALBROWSER)) {
if ((Constants.getOS() == Constants.OS.MAC || Constants.getOS() == Constants.OS.WINDOWS)
&& loginInput.isEnableClientStoreTemporaryCredential()) {
// force to set the flag for Mac/Windows users
Expand Down Expand Up @@ -508,7 +511,8 @@ private static SFLoginOutput newSession(
}
} else if (authenticatorType == AuthenticatorType.OKTA) {
data.put(ClientAuthnParameter.RAW_SAML_RESPONSE.name(), tokenOrSamlResponse);
} else if (authenticatorType == AuthenticatorType.OAUTH || authenticatorType == AuthenticatorType.PROGRAMMATIC_ACCESS_TOKEN) {
} else if (authenticatorType == AuthenticatorType.OAUTH
|| authenticatorType == AuthenticatorType.PROGRAMMATIC_ACCESS_TOKEN) {
data.put(ClientAuthnParameter.AUTHENTICATOR.name(), authenticatorType.name());

// Fix for HikariCP refresh token issue:SNOW-533673.
Expand Down

0 comments on commit 556f476

Please sign in to comment.