Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Not Answered
Replies
2 replies
Subscribers
5 subscribers
Views
1703 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
Plug-Ins
Smart Service is using deprecated API
natasav
over 7 years ago
Hi ,
we have some smart service that is used to unlock document, part of some KC, that were lock more that 2 hours. We did a health check using available action on the forum and we find out following remark about it:
Document Unlocker (documentunlocker) references deprecated Appian APIs
[deprecated] com.appiancorp.suiteapi.common.ServiceLocator.getAdministratorServiceContext()
I am not the one that design this plugin, so I need help. Could you give me an suggestion how to replace that API with some support API and make still useful for the Appian platform?
OriginalPostID-230186
Discussion posts and replies are publicly visible
Parents
0
chetany
A Score Level 1
over 7 years ago
I would suggest to create secure credentials store with a username(this can avoid hardcoding the username in the plugin code. The plugin code then does not have to store the username in the Java code anywhere). The username field of the secure store should contain the username of a user who is authorized to perform the API call. Most of the times, it is a user with systems admin credentials. Then read the username in plugin code dynamically. Then, use ServiceContextFactory.getServiceContext(username);
eg:
String username = null;
try {
Map<String, String> securedValues = scs.getSystemSecuredValues(EXTERNAL_KEY) ;
username = securedValues.get(USERNAME_FIELD);
} catch (InsufficientPrivilegesException | ObjectNotFoundException e) {
LOG.error("Could not get the Secure credentials key");
e.printStackTrace();
}
ServiceContext sc_userContext = ServiceContextFactory.getServiceContext(username);
This way, you do not need to hardcode the username in the plugin code anywhere.
Only caveat is that you need to create the secure credentials store on every new environment that you need to deploy the plugin on. Also, when you create the secure credential store with some external key name, you need to specify the plugins which should be allowed access to that credential store.
You can read about the Secure Credential Store here:
forum.appian.com/.../Secure_Credentials_Store.html
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
Reply
0
chetany
A Score Level 1
over 7 years ago
I would suggest to create secure credentials store with a username(this can avoid hardcoding the username in the plugin code. The plugin code then does not have to store the username in the Java code anywhere). The username field of the secure store should contain the username of a user who is authorized to perform the API call. Most of the times, it is a user with systems admin credentials. Then read the username in plugin code dynamically. Then, use ServiceContextFactory.getServiceContext(username);
eg:
String username = null;
try {
Map<String, String> securedValues = scs.getSystemSecuredValues(EXTERNAL_KEY) ;
username = securedValues.get(USERNAME_FIELD);
} catch (InsufficientPrivilegesException | ObjectNotFoundException e) {
LOG.error("Could not get the Secure credentials key");
e.printStackTrace();
}
ServiceContext sc_userContext = ServiceContextFactory.getServiceContext(username);
This way, you do not need to hardcode the username in the plugin code anywhere.
Only caveat is that you need to create the secure credentials store on every new environment that you need to deploy the plugin on. Also, when you create the secure credential store with some external key name, you need to specify the plugins which should be allowed access to that credential store.
You can read about the Secure Credential Store here:
forum.appian.com/.../Secure_Credentials_Store.html
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
Children
No Data