Saml configuration values in sightly for aem6.5 | Adobe Higher Education
Skip to main content
srinivas_chann1
Level 7
January 26, 2022
Répondu

Saml configuration values in sightly for aem6.5

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

 

Ce sujet a été fermé aux réponses.
Meilleure réponse par JeevanRaj

@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.

5 commentaires

milind_bachani
Adobe Employee
Adobe Employee
January 26, 2022

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.

Anny0505
Community Advisor
Community Advisor
January 26, 2022

@srinivas_chann1 ,

 

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!!

Anish-Sinha
Adobe Employee
Adobe Employee
January 26, 2022

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

 

JeevanRaj
Community Advisor
Community Advisor
January 27, 2022

Hi @srinivas_chann1 

 

Its not recommended to read OOTB config in another service. Here is an another community question which talks about this.

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/correct-way-to-read-osgi-configuration/m-p/287975

 

srinivas_chann1
Level 7
January 27, 2022

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 {}
JeevanRaj
Community Advisor
JeevanRajCommunity AdvisorRéponse
Community Advisor
January 27, 2022

@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.

Community Advisor
January 27, 2022

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

www.albinsblog.com