use of org.hisp.dhis.security.oidc.DhisOidcClientRegistration in project dhis2-core by dhis2.
the class GoogleProvider method parse.
public static DhisOidcClientRegistration parse(Properties config) {
Objects.requireNonNull(config, "DhisConfigurationProvider is missing!");
Map<String, Set<String>> allKeysByProvider = GenericOidcProviderConfigParser.extractKeysGroupByProvider(config);
// Skip parsing if there is no keys matching REGISTRATION_ID
if (!allKeysByProvider.containsKey(REGISTRATION_ID) || allKeysByProvider.get(REGISTRATION_ID).isEmpty()) {
return null;
}
Set<String> googleKeys = allKeysByProvider.get(REGISTRATION_ID);
Map<String, Map<String, String>> externalClientConfigs = GenericOidcProviderConfigParser.getAllExternalClients(config, REGISTRATION_ID, googleKeys);
ClientRegistration clientRegistration = buildClientRegistration(config);
if (clientRegistration == null) {
return null;
}
return DhisOidcClientRegistration.builder().clientRegistration(clientRegistration).mappingClaimKey(StringUtils.firstNonBlank(config.getProperty(OIDC_PROVIDER_GOOGLE_MAPPING_CLAIM.getKey()), "email")).loginIcon("../oidc/btn_google_light_normal_ios.svg").loginIconPadding("0px 0px").loginText("login_with_google").externalClients(externalClientConfigs).build();
}
use of org.hisp.dhis.security.oidc.DhisOidcClientRegistration in project dhis2-core by dhis2.
the class LoginAction method addRegisteredProviders.
private void addRegisteredProviders() {
List<Map<String, String>> providers = new ArrayList<>();
Set<String> allRegistrationIds = repository.getAllRegistrationId();
for (String registrationId : allRegistrationIds) {
DhisOidcClientRegistration clientRegistration = repository.getDhisOidcClientRegistration(registrationId);
providers.add(ImmutableMap.of("id", registrationId, "icon", clientRegistration.getLoginIcon(), "iconPadding", clientRegistration.getLoginIconPadding(), "loginText", clientRegistration.getLoginText()));
}
if (!providers.isEmpty()) {
oidcConfig.put("providers", providers);
}
}
Aggregations