Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
raviteja_satuluri
Contributor
Introduction

Here I am just explaining the Importance of Groovy script in the Real time scenarios when we are dealing with Cloud Integration.

Groovy scripting is an integral and important feature of SAP Cloud Platform Integration (CPI). The goals of this repository are: Providing templates when you are implementing a new script. Easily finding Groovy functions related to the CPI topic at hand. Minimizing search engine time for common tasks.

Business Requirement: How to access Credentials from Script

Accessing credentials from a script:

The user/password configured in a deployed credential can be accessed programmatically from a script
with the help of the getUserCredential api of the SecureStoreService class

Classes needed:
com.sap.it.api.securestore.SecureStoreService;
com.sap.it.api.securestore.UserCredential;

Method signature:
public UserCredential getUserCredential(String alias)

Sample Code:
Get a handle to the SecureStoreService service:
def service = ITApiFactory.getApi(SecureStoreService.class, null);

Retrieve the target value using:
def credential = service.getUserCredential("<Name of Credential that is deployed on
the tenant>").

Finally retrieve the username and password from the credential object:
String userName = credential.getUsername();
String password = new String(credential.getPassword());

 

The below code will print the retrieved user and password to the message payload (body).

 


 

Conclusion –


Hope this document will help to beginners to understand CPI concept of Groovy Script. Happy Learning 🙂

 


 

 

 
1 Comment
Labels in this area