All Downloads are FREE. Search and download functionalities are using the official Maven repository.

pl.edu.icm.unity.oauth.client.config.OrcidProviderProperties Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (c) 2014 ICM Uniwersytet Warszawski All rights reserved.
 * See LICENCE.txt file for licensing information.
 */
package pl.edu.icm.unity.oauth.client.config;

import eu.unicore.util.configuration.ConfigurationException;
import pl.edu.icm.unity.engine.api.PKIManagement;
import pl.edu.icm.unity.oauth.client.UserProfileFetcher;
import pl.edu.icm.unity.oauth.client.profile.OrcidProfileFetcher;

import java.util.Properties;

/**
 * Preset configuration for Orcid OAuth provider.
 * This configuration is using a free API. For more complete authn, with user profile fetching 
 * an Orcid membership is required. This should work with customized configuration.
 * @author K. Benedyczak
 */
public class OrcidProviderProperties extends CustomProviderProperties
{

	public OrcidProviderProperties(Properties properties, String prefix, PKIManagement pkiManagement) 
			throws ConfigurationException
	{
		super(addDefaults(properties, prefix), prefix, pkiManagement);
	}
	
	private static Properties addDefaults(Properties properties, String prefix)
	{
		setIfUnset(properties, prefix + PROVIDER_NAME, "ORCID");
		setIfUnset(properties, prefix + PROVIDER_LOCATION, "https://orcid.org/oauth/authorize");
		setIfUnset(properties, prefix + ACCESS_TOKEN_ENDPOINT, "https://orcid.org/oauth/token");
		setIfUnset(properties, prefix + ICON_URL, "assets/img/external/orcid-small.png");
		setIfUnset(properties, prefix + PROFILE_ENDPOINT, "https://pub.orcid.org/v3.0/");
		setIfUnset(properties, prefix + SCOPES, "/authenticate");
		setIfUnset(properties, prefix + ADDITIONAL_AUTHZ_PARAMS + "1", "show_login=true");
		return properties;
	}

	@Override
	public UserProfileFetcher getUserAttributesResolver()
	{
		return new OrcidProfileFetcher();
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy