use of org.pac4j.core.http.callback.NoParameterCallbackUrlResolver in project cas by apereo.
the class DefaultDelegatedClientFactory method configureClient.
/**
* Sets client name.
*
* @param client the client
* @param props the props
*/
protected void configureClient(final IndirectClient client, final Pac4jBaseClientProperties props) {
val cname = props.getClientName();
if (StringUtils.isNotBlank(cname)) {
client.setName(cname);
} else {
val className = client.getClass().getSimpleName();
val genName = className.concat(RandomUtils.randomNumeric(2));
client.setName(genName);
LOGGER.warn("Client name for [{}] is set to a generated value of [{}]. " + "Consider defining an explicit name for the delegated provider", className, genName);
}
val customProperties = client.getCustomProperties();
customProperties.put(ClientCustomPropertyConstants.CLIENT_CUSTOM_PROPERTY_AUTO_REDIRECT_TYPE, props.getAutoRedirectType());
if (StringUtils.isNotBlank(props.getPrincipalAttributeId())) {
customProperties.put(ClientCustomPropertyConstants.CLIENT_CUSTOM_PROPERTY_PRINCIPAL_ATTRIBUTE_ID, props.getPrincipalAttributeId());
}
if (StringUtils.isNotBlank(props.getCssClass())) {
customProperties.put(ClientCustomPropertyConstants.CLIENT_CUSTOM_PROPERTY_CSS_CLASS, props.getCssClass());
}
if (StringUtils.isNotBlank(props.getDisplayName())) {
customProperties.put(ClientCustomPropertyConstants.CLIENT_CUSTOM_PROPERTY_AUTO_DISPLAY_NAME, props.getDisplayName());
}
val callbackUrl = StringUtils.defaultString(props.getCallbackUrl(), casProperties.getServer().getLoginUrl());
client.setCallbackUrl(callbackUrl);
switch(props.getCallbackUrlType()) {
case PATH_PARAMETER:
client.setCallbackUrlResolver(new PathParameterCallbackUrlResolver());
break;
case NONE:
client.setCallbackUrlResolver(new NoParameterCallbackUrlResolver());
break;
case QUERY_PARAMETER:
default:
client.setCallbackUrlResolver(new QueryParameterCallbackUrlResolver());
}
this.customizers.forEach(customizer -> customizer.customize(client));
if (!casProperties.getAuthn().getPac4j().getCore().isLazyInit()) {
client.init();
}
}
use of org.pac4j.core.http.callback.NoParameterCallbackUrlResolver in project druid by druid-io.
the class Pac4jAuthenticator method createPac4jConfig.
private Config createPac4jConfig(OIDCConfig oidcConfig) {
OidcConfiguration oidcConf = new OidcConfiguration();
oidcConf.setClientId(oidcConfig.getClientID());
oidcConf.setSecret(oidcConfig.getClientSecret().getPassword());
oidcConf.setDiscoveryURI(oidcConfig.getDiscoveryURI());
oidcConf.setExpireSessionWithToken(true);
oidcConf.setUseNonce(true);
oidcConf.setReadTimeout(Ints.checkedCast(pac4jCommonConfig.getReadTimeout().getMillis()));
oidcConf.setResourceRetriever(// ResourceRetriever is used to get Auth server configuration from "discoveryURI"
new CustomSSLResourceRetriever(pac4jCommonConfig.getReadTimeout().getMillis(), sslSocketFactory));
OidcClient oidcClient = new OidcClient(oidcConf);
oidcClient.setUrlResolver(new DefaultUrlResolver(true));
oidcClient.setCallbackUrlResolver(new NoParameterCallbackUrlResolver());
// This is used by OidcClient in various places to make HTTPrequests.
if (sslSocketFactory != null) {
HTTPRequest.setDefaultSSLSocketFactory(sslSocketFactory);
}
return new Config(Pac4jCallbackResource.SELF_URL, oidcClient);
}
use of org.pac4j.core.http.callback.NoParameterCallbackUrlResolver in project pac4j by pac4j.
the class ClientsTests method testAddClient.
@Test
public void testAddClient() {
final var facebookClient = newFacebookClient();
final var yahooClient = newYahooClient();
final var clients = new Clients(CALLBACK_URL, facebookClient);
clients.findAllClients();
final List<Client> list = new ArrayList<>();
list.add(facebookClient);
list.add(yahooClient);
clients.setClients(list);
clients.setCallbackUrlResolver(new NoParameterCallbackUrlResolver());
final var yclient = (IndirectClient) clients.findClient("YahooClient").get();
assertTrue(yclient.getCallbackUrlResolver() instanceof NoParameterCallbackUrlResolver);
final var fclient = (IndirectClient) clients.findClient("FacebookClient").get();
assertTrue(fclient.getCallbackUrlResolver() instanceof NoParameterCallbackUrlResolver);
}
Aggregations