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.


#Applicationintegration
#App Connect
#AppConnect
 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
    ------------------------------



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

    Posted 7 days ago

    First of all, thank you very much for expressing your concern. After reading the entire post, consulting the official IBM documentation, and conducting tests, I have noticed that the command [ mqsivault test --create --vaultrc-location /var/mqsi ] does not work, falls short or It appears to be a confusion of purposes, as it returns a syntax error [ BIP8102E: An invalid or incorrectly formatted badge has been provided.The command will not result in any action; the badge or badge argument is in the wrong format.Correct the command and resend it. ]. I do not know if, at the time of your publication, the syntax was required for that version of the application.

    On the other hand, complementing what David Coles mentioned, I have noticed that the documentation continues to refer to "ODBC" and not "odbc."

    https://www.ibm.com/docs/en/app-connect/12.0.x?topic=java-accessing-credentials-from-user-code

    I am leaving my question here, hoping that at some point it will be seen and you can share your comments with me, so that if any other colleague needs to do the same, they can move forward without any surprises.

    If you think I have omitted something or am incorrect, please let me know.

    Thanks and best regards



    ------------------------------
    Axel Reyes
    ------------------------------