App Connect

App Connect

Join this online user group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
  • 1.  Accessing IBM ACE Vault credentials in Java Compute node

    Posted Tue January 28, 2025 03:51 PM

    I have made a vault using these commands:

    mqsivault test --vaultrc-store-key --vault-key myvaultkey --vaultrc-location /var/mqsi

    mqsivault test --create --vaultrc-location /var/mqsi

    mqsistart test --vault-key myvaultkey

    and then create creadentials of type ODBC on Node level and server level, using these commands 

    mqsicredentials test -e testeg --create --credential-name testdb --credential-type odbc --username test --password test

    mqsicredentials test  --create --credential-name testdbnode --credential-type odbc   --vault-key myvaultkey --username user1 --password user1

    I've verified my credentials using these commands:

    mqsicredentials test -e testeg --report --vault-key myvaultkey

    The credential name 'testdb' of type 'odbc' contains user name 'test' from provider 'servervault' and has the following properties defined: 'password', authentication type 'basic'.

    BIP15110I: The credential name 'testdbnode' of type 'odbc' contains user name 'user1' from provider 'nodevault' and has the following properties defined: 'password', authentication type 'basic'.

    Do these changes in server config file:

    Credentials:

      userRetrievableCredentialTypes: 'ALL' 

    and trying to access these credentials using this code

                                                     String username;

                                                     char[] password;

                                                      MbCredential myCred;

                                                      try {

                                                      myCred = MbCredential.getCredential("ODBC", "testdb ");

                                                      if(myCred == null) {

                                                                      throw new RuntimeException("Credentials not found");

                                                                      }

                                                     Map<Stringchar[]> credentialsProperties =  myCred.reloadAndRetrieveProperties();

                                                      if (credentialsProperties.containsKey(MbCredential.PASSWORD)) {

                                                                      password =credentialsProperties.get(MbCredential.PASSWORD);

                                                                      }

                                                      }catch(MbCredentialDeletedException cde) {

                                                      password = null;

                                                    }catch (MbException e) {

                                                                    throw new RuntimeException("Error during credetials lookup", e);

                                                    }

    But myCred is getting null value. Am i missing something?

    this is actually the same code as recommeded by IBM on this page:

    Accessing credentials from user Java code



    ------------------------------
    Saad
    ------------------------------


  • 2.  RE: Accessing IBM ACE Vault credentials in Java Compute node

    Posted Tue January 28, 2025 07:52 PM

    Hi Saad,

    I think from the steps you've listed what you've followed is 99% correct.

    I think why it's not working is down to this line of code:

      MbCredential.getCredential("ODBC", "testdb ");

    I believe the credential type needs to be lower case, so "odbc", which would be a doc defect for us to fix. Then it also looks like you have a space in the credential name after testdb and before the double quotes.

    Please can you try making those adjustments and see if the code then works.

    Thanks

    David



    ------------------------------
    David Coles
    App Connect Developer
    ------------------------------



  • 3.  RE: Accessing IBM ACE Vault credentials in Java Compute node

    Posted Wed January 29, 2025 03:00 PM

    Thanks David, it worked with :

    MbCredential.getCredential("odbc", "testdb");



    ------------------------------
    Saad Ahmed
    ------------------------------