Hi ,
Wanted to know if there is any way or exact I could use to fetch the values that are stored in saml based on runmodes
I have under
/apps/project/configuration/config.local
com.adobe.granite.auth.saml.SamlAuthenticationHandler-applicationName
from that i need to fetch logout url value .
The property is stored as logoutUrl
Now I need to get the value of this in the sightly code i.e in *.html file
Which I could use for href value
Could anyone provide inputs as how this could be resolved
Thanks
Solved! Go to Solution.
Views
Replies
Total Likes
@srinivas_chann1 You might be able to read OOTB config using configurationAdmin but again that's not recommended. The better approach would be to create a custom osgi config and a service to read this custom config.
Hi @srinivas_chann1 ,
You can define a new attribute in config for instance : logoutUrl, and you can getLogouUrl in model using the config service.
And in sightly you can use the model and get the url value in href using the model getter.
Thanks.
You can implement sling model and reference OSGI configs as as service and call the sling mode l in sightly with use class and implement getters and setters for the config values to access in the sightly html.
Thanks
Hope this helps!!
Hi @srinivas_chann1 ,
There are multiple ways to get this done:
1. You can create a service, read the values and return it to sling model and then get it into html. Reference URL: https://sourcedcode.com/blog/aem/aem-sling-model-injectors-annotations-reference-guide#OSGiService
2. You can directly read the values in JS and then pass it to html. Reference: https://gist.github.com/gabrielwalt/278f8cee870aac7ec619
Its not recommended to read OOTB config in another service. Here is an another community question which talks about this.
Hi,
Thanks for the response.
As this OOTB config not sure how to read this values in slightly code.
com.adobe.granite.auth.saml.SamlAuthenticationHandler-applicationName
For custom created config. I am already aware as
@ObjectClassDefinition(name = "config", description = "configuration")
public @interface ConfigurationProperties {}
@Component(configurationPolicy = ConfigurationPolicy.REQUIRE, immediate = true,
service = Configuration.class)
@Designate(ocd = ConfigurationProperties.class)
public class Configuration {}
@srinivas_chann1 You might be able to read OOTB config using configurationAdmin but again that's not recommended. The better approach would be to create a custom osgi config and a service to read this custom config.
You can try something like this
Configuration[] getConfigurations(String configId) throws IOException, InvalidSyntaxException {
return this.configurationAdmin.listConfigurations("(&(" + "oauth.config.id" + "="
+ configId + ")(" + "service.factoryPid" + "=" + "com.adobe.granite.auth.oauth.provider" + "))");
}
Change the oauth.config.id(property to match the specific configuration) and the oauth factory id with SAML configuration details
Configuration[] configurations = getConfigurations(configId);
if (configurations != null && configurations.length >= 1) {
String clientId=configurations[0].getProperties().get(Constants.OAUTH_CLIENT_ID).toString();
}
Regards
Albin I