@@ -21,6 +21,7 @@ public class BitwardenAccess implements KeychainAccessProvider {
2121 private BitwardenClient bitwardenClient ;
2222 private final String accessToken ;
2323 private UUID organizationId = null ;
24+ private final String stateFile ;
2425 private boolean isSupported = false ;
2526 private final String boID ;
2627 private final String apiUrl = "https://api.bitwarden.com" ;
@@ -30,14 +31,15 @@ public class BitwardenAccess implements KeychainAccessProvider {
3031 public BitwardenAccess () {
3132 this .accessToken = System .getenv ("BITWARDEN_ACCESS_TOKEN" );
3233 this .boID = System .getenv ("BITWARDEN_ORGANIZATION_ID" );
34+ this .stateFile = System .getenv ("BITWARDEN_STATE_FILE" );
3335
3436 if (isEnvVarValid (accessToken ) && isEnvVarValid (boID )) {
3537 try {
3638 this .organizationId = UUID .fromString (boID );
3739 this .bitwardenSettings .setApiUrl (apiUrl );
3840 this .bitwardenSettings .setIdentityUrl (identityUrl );
3941 this .bitwardenClient = new BitwardenClient (bitwardenSettings );
40- this .bitwardenClient .accessTokenLogin ( accessToken );
42+ this .bitwardenClient .auth (). loginAccessToken ( accessToken , stateFile );
4143 this .isSupported = true ;
4244
4345 } catch (BitwardenClientException | IllegalArgumentException e ) {
@@ -56,17 +58,17 @@ public BitwardenAccess() {
5658 public boolean isLocked () { return false ; }
5759
5860 @ Override
59- public void storePassphrase (String vault , CharSequence password ) throws KeychainAccessException {
60- storePassphrase (vault , "Vault" , password );
61+ public void storePassphrase (String vault , String displayName , CharSequence password ) throws KeychainAccessException {
62+ storePassphrase (vault , displayName , password , false );
6163 }
6264
6365 @ Override
64- public void storePassphrase (String vault , String name , CharSequence password ) throws KeychainAccessException {
66+ public void storePassphrase (String vault , String name , CharSequence password , boolean requireOsAuthentication ) throws KeychainAccessException {
6567 try {
6668 var projectId = getprojectId ();
6769 var secret = getSecret (vault );
6870 if (secret .isEmpty ()) {
69- bitwardenClient .secrets ().create (vault , password .toString (), "Password for vault: " + name , organizationId , new UUID []{ projectId });
71+ bitwardenClient .secrets ().create (organizationId , vault , password .toString (), "Password for vault: " + name , new UUID []{ projectId });
7072 }
7173 LOG .debug ("Passphrase successfully stored" );
7274 } catch (BitwardenClientException | IllegalArgumentException e ) {
@@ -119,7 +121,7 @@ public void changePassphrase(String vault, String name, CharSequence password) t
119121 LOG .debug ("Passphrase not found" );
120122 } else {
121123 LOG .debug ("Passphrase found and updated" );
122- bitwardenClient .secrets ().update (secret .get ().getID (), vault , password .toString (), "Password for vault: " + name , organizationId , new UUID []{ projectId });
124+ bitwardenClient .secrets ().update (organizationId , secret .get ().getID (), vault , password .toString (), "Password for vault: " + name , new UUID []{ projectId });
123125 }
124126 } catch (BitwardenClientException | IllegalArgumentException e ) {
125127 throw new KeychainAccessException ("Updating the passphrase failed" , e );
0 commit comments