use of org.pac4j.core.client.BaseClient in project cas by apereo.
the class DelegatedClientFactory method configureSamlClient.
/**
* Configure saml client.
*
* @param properties the properties
*/
protected void configureSamlClient(final Collection<BaseClient> properties) {
final AtomicInteger index = new AtomicInteger();
pac4jProperties.getSaml().stream().filter(saml -> StringUtils.isNotBlank(saml.getKeystorePath()) && StringUtils.isNotBlank(saml.getIdentityProviderMetadataPath()) && StringUtils.isNotBlank(saml.getServiceProviderEntityId()) && StringUtils.isNotBlank(saml.getServiceProviderMetadataPath())).forEach(saml -> {
final SAML2ClientConfiguration cfg = new SAML2ClientConfiguration(saml.getKeystorePath(), saml.getKeystorePassword(), saml.getPrivateKeyPassword(), saml.getIdentityProviderMetadataPath());
cfg.setMaximumAuthenticationLifetime(saml.getMaximumAuthenticationLifetime());
cfg.setServiceProviderEntityId(saml.getServiceProviderEntityId());
cfg.setServiceProviderMetadataPath(saml.getServiceProviderMetadataPath());
cfg.setDestinationBindingType(saml.getDestinationBinding());
cfg.setForceAuth(saml.isForceAuth());
cfg.setPassive(saml.isPassive());
cfg.setWantsAssertionsSigned(saml.isWantsAssertionsSigned());
cfg.setAttributeConsumingServiceIndex(saml.getAttributeConsumingServiceIndex());
if (saml.getAssertionConsumerServiceIndex() >= 0) {
cfg.setAssertionConsumerServiceIndex(saml.getAssertionConsumerServiceIndex());
}
if (StringUtils.isNotBlank(saml.getAuthnContextClassRef())) {
cfg.setComparisonType(saml.getAuthnContextComparisonType().toUpperCase());
cfg.setAuthnContextClassRef(saml.getAuthnContextClassRef());
}
if (StringUtils.isNotBlank(saml.getKeystoreAlias())) {
cfg.setKeystoreAlias(saml.getKeystoreAlias());
}
if (StringUtils.isNotBlank(saml.getNameIdPolicyFormat())) {
cfg.setNameIdPolicyFormat(saml.getNameIdPolicyFormat());
}
final SAML2Client client = new SAML2Client(cfg);
final int count = index.intValue();
if (StringUtils.isBlank(saml.getClientName())) {
client.setName(client.getClass().getSimpleName() + count);
}
configureClient(client, saml);
index.incrementAndGet();
LOGGER.debug("Created delegated client [{}]", client);
properties.add(client);
});
}
use of org.pac4j.core.client.BaseClient in project cas by apereo.
the class DelegatedClientAuthenticationAction method restoreAuthenticationRequestInContext.
private Service restoreAuthenticationRequestInContext(final RequestContext requestContext, final J2EContext webContext, final String clientName) {
delegatedSessionCookieManager.restore(webContext);
final BaseClient<Credentials, CommonProfile> client = (BaseClient<Credentials, CommonProfile>) this.clients.findClient(clientName);
final Service service = delegatedClientWebflowManager.retrieve(requestContext, webContext, client);
return service;
}
use of org.pac4j.core.client.BaseClient in project pac4j by pac4j.
the class DefaultCallbackLogic method renewSession.
protected void renewSession(final C context, final Config config) {
final SessionStore<C> sessionStore = context.getSessionStore();
if (sessionStore != null) {
final String oldSessionId = sessionStore.getOrCreateSessionId(context);
final boolean renewed = sessionStore.renewSession(context);
if (renewed) {
final String newSessionId = sessionStore.getOrCreateSessionId(context);
logger.debug("Renewing session: {} -> {}", oldSessionId, newSessionId);
final Clients clients = config.getClients();
if (clients != null) {
final List<Client> clientList = clients.getClients();
for (final Client client : clientList) {
final BaseClient baseClient = (BaseClient) client;
baseClient.notifySessionRenewal(oldSessionId, context);
}
}
} else {
logger.error("Unable to renew the session. The session store may not support this feature");
}
} else {
logger.error("No session store available for this web context");
}
}
Aggregations