use of org.pac4j.core.client.Clients in project pac4j by pac4j.
the class DefaultCallbackLogicTests method testCallback.
@Test
public void testCallback() {
final String originalSessionId = request.getSession().getId();
request.setParameter(Pac4jConstants.DEFAULT_CLIENT_NAME_PARAMETER, NAME);
final CommonProfile profile = new CommonProfile();
final IndirectClient indirectClient = new MockIndirectClient(NAME, null, new MockCredentials(), profile);
config.setClients(new Clients(CALLBACK_URL, indirectClient));
config.getClients().init();
call();
final HttpSession session = request.getSession();
final String newSessionId = session.getId();
final LinkedHashMap<String, CommonProfile> profiles = (LinkedHashMap<String, CommonProfile>) session.getAttribute(Pac4jConstants.USER_PROFILES);
assertTrue(profiles.containsValue(profile));
assertEquals(1, profiles.size());
assertNotEquals(newSessionId, originalSessionId);
assertEquals(302, response.getStatus());
assertEquals(Pac4jConstants.DEFAULT_URL_VALUE, response.getRedirectedUrl());
}
use of org.pac4j.core.client.Clients in project cas by apereo.
the class DelegatedClientAuthenticationHandlerTests method initialize.
@BeforeEach
public void initialize() {
this.fbClient = new FacebookClient();
val clients = new Clients(CALLBACK_URL, fbClient);
this.handler = new DelegatedClientAuthenticationHandler(StringUtils.EMPTY, 0, mock(ServicesManager.class), PrincipalFactoryUtils.newPrincipalFactory(), clients, DelegatedClientUserProfileProvisioner.noOp(), JEESessionStore.INSTANCE);
this.handler.setTypedIdUsed(true);
val credentials = new OAuth20Credentials(null);
this.clientCredential = new ClientCredential(credentials, fbClient.getName());
val mock = new ServletExternalContext(new MockServletContext(), new MockHttpServletRequest(), new MockHttpServletResponse());
ExternalContextHolder.setExternalContext(mock);
}
use of org.pac4j.core.client.Clients in project cas by apereo.
the class SamlIdentityProviderDiscoveryConfiguration method samlIdentityProviderEntityParser.
@Bean
@RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
@ConditionalOnMissingBean(name = "samlIdentityProviderEntityParser")
public Supplier<List<SamlIdentityProviderEntityParser>> samlIdentityProviderEntityParser(final CasConfigurationProperties casProperties, @Qualifier("builtClients") final Clients builtClients) {
val parsers = new ArrayList<SamlIdentityProviderEntityParser>();
val resource = casProperties.getAuthn().getPac4j().getSamlDiscovery().getResource();
resource.stream().filter(res -> res.getLocation() != null).forEach(Unchecked.consumer(res -> parsers.add(new SamlIdentityProviderEntityParser(res.getLocation()))));
builtClients.findAllClients().stream().filter(c -> c instanceof SAML2Client).map(SAML2Client.class::cast).forEach(c -> {
c.init();
val entity = new SamlIdentityProviderEntity();
entity.setEntityID(c.getIdentityProviderResolvedEntityId());
parsers.add(new SamlIdentityProviderEntityParser(entity));
});
return () -> parsers;
}
Aggregations