forked from opensearch-project/OpenSearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e8528ba
commit 07f92c4
Showing
3 changed files
with
89 additions
and
8 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
...cs/src/main/java/org/opensearch/repositories/gcs/GoogleApplicationDefaultCredentials.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.repositories.gcs; | ||
|
||
import com.google.auth.oauth2.GoogleCredentials; | ||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
|
||
import java.io.IOException; | ||
|
||
public class GoogleApplicationDefaultCredentials { | ||
private static final Logger logger = LogManager.getLogger(GoogleApplicationDefaultCredentials.class); | ||
|
||
public GoogleCredentials getApplicationDefaultCredentials() { | ||
GoogleCredentials credentials = null; | ||
try { | ||
credentials = SocketAccess.doPrivilegedIOException(GoogleCredentials::getApplicationDefault); | ||
} catch (IOException e) { | ||
logger.error("Failed to retrieve \"Application Default Credentials\""); | ||
} | ||
return credentials; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters