Search in sources :

Example 31 with Principal

use of org.apereo.cas.authentication.principal.Principal in project cas by apereo.

the class GrouperMultifactorAuthenticationPolicyEventResolver method resolveInternal.

@Override
public Set<Event> resolveInternal(final RequestContext context) {
    final RegisteredService service = resolveRegisteredServiceInRequestContext(context);
    final Authentication authentication = WebUtils.getAuthentication(context);
    if (StringUtils.isBlank(grouperField)) {
        LOGGER.debug("No group field is defined to process for Grouper multifactor trigger");
        return null;
    }
    if (authentication == null || service == null) {
        LOGGER.debug("No authentication or service is available to determine event for principal");
        return null;
    }
    final Principal principal = authentication.getPrincipal();
    final Collection<WsGetGroupsResult> results = GrouperFacade.getGroupsForSubjectId(principal.getId());
    if (results.isEmpty()) {
        LOGGER.debug("No groups could be found for [{}] to resolve events for MFA", principal);
        return null;
    }
    final Map<String, MultifactorAuthenticationProvider> providerMap = MultifactorAuthenticationUtils.getAvailableMultifactorAuthenticationProviders(this.applicationContext);
    if (providerMap == null || providerMap.isEmpty()) {
        LOGGER.error("No multifactor authentication providers are available in the application context");
        throw new AuthenticationException();
    }
    final GrouperGroupField groupField = GrouperGroupField.valueOf(grouperField);
    final Set<String> values = results.stream().map(wsGetGroupsResult -> Stream.of(wsGetGroupsResult.getWsGroups())).flatMap(Function.identity()).map(g -> GrouperFacade.getGrouperGroupAttribute(groupField, g)).collect(Collectors.toSet());
    final Optional<MultifactorAuthenticationProvider> providerFound = resolveProvider(providerMap, values);
    if (providerFound.isPresent()) {
        final MultifactorAuthenticationProvider provider = providerFound.get();
        if (provider.isAvailable(service)) {
            LOGGER.debug("Attempting to build event based on the authentication provider [{}] and service [{}]", provider, service.getName());
            final Event event = validateEventIdForMatchingTransitionInContext(provider.getId(), context, buildEventAttributeMap(authentication.getPrincipal(), service, provider));
            return CollectionUtils.wrapSet(event);
        }
        LOGGER.warn("Located multifactor provider [{}], yet the provider cannot be reached or verified", providerFound.get());
        return null;
    }
    LOGGER.debug("No multifactor provider could be found based on [{}]'s Grouper groups", principal.getId());
    return null;
}
Also used : CasConfigurationProperties(org.apereo.cas.configuration.CasConfigurationProperties) WsGetGroupsResult(edu.internet2.middleware.grouperClient.ws.beans.WsGetGroupsResult) MultifactorAuthenticationProviderSelector(org.apereo.cas.services.MultifactorAuthenticationProviderSelector) CentralAuthenticationService(org.apereo.cas.CentralAuthenticationService) TicketRegistrySupport(org.apereo.cas.ticket.registry.TicketRegistrySupport) RequestContext(org.springframework.webflow.execution.RequestContext) Function(java.util.function.Function) Authentication(org.apereo.cas.authentication.Authentication) Map(java.util.Map) CollectionUtils(org.apereo.cas.util.CollectionUtils) AuthenticationSystemSupport(org.apereo.cas.authentication.AuthenticationSystemSupport) GrouperFacade(org.apereo.cas.grouper.GrouperFacade) MultifactorAuthenticationUtils(org.apereo.cas.authentication.MultifactorAuthenticationUtils) CookieGenerator(org.springframework.web.util.CookieGenerator) ServicesManager(org.apereo.cas.services.ServicesManager) AuthenticationException(org.apereo.cas.authentication.AuthenticationException) MultifactorAuthenticationProvider(org.apereo.cas.services.MultifactorAuthenticationProvider) StringUtils(edu.internet2.middleware.grouperClientExt.org.apache.commons.lang3.StringUtils) GrouperGroupField(org.apereo.cas.grouper.GrouperGroupField) Audit(org.apereo.inspektr.audit.annotation.Audit) Collection(java.util.Collection) AuthenticationServiceSelectionPlan(org.apereo.cas.authentication.AuthenticationServiceSelectionPlan) Set(java.util.Set) Collectors(java.util.stream.Collectors) RegisteredService(org.apereo.cas.services.RegisteredService) BaseMultifactorAuthenticationProviderEventResolver(org.apereo.cas.web.flow.authentication.BaseMultifactorAuthenticationProviderEventResolver) Slf4j(lombok.extern.slf4j.Slf4j) Stream(java.util.stream.Stream) Optional(java.util.Optional) Principal(org.apereo.cas.authentication.principal.Principal) WebUtils(org.apereo.cas.web.support.WebUtils) Event(org.springframework.webflow.execution.Event) RegisteredService(org.apereo.cas.services.RegisteredService) AuthenticationException(org.apereo.cas.authentication.AuthenticationException) MultifactorAuthenticationProvider(org.apereo.cas.services.MultifactorAuthenticationProvider) WsGetGroupsResult(edu.internet2.middleware.grouperClient.ws.beans.WsGetGroupsResult) Authentication(org.apereo.cas.authentication.Authentication) GrouperGroupField(org.apereo.cas.grouper.GrouperGroupField) Event(org.springframework.webflow.execution.Event) Principal(org.apereo.cas.authentication.principal.Principal)

Example 32 with Principal

use of org.apereo.cas.authentication.principal.Principal in project cas by apereo.

the class Saml2AttributeQueryProfileHandlerController method handlePostRequest.

/**
 * Handle post request.
 *
 * @param response the response
 * @param request  the request
 */
@PostMapping(path = SamlIdPConstants.ENDPOINT_SAML2_SOAP_ATTRIBUTE_QUERY)
protected void handlePostRequest(final HttpServletResponse response, final HttpServletRequest request) {
    final MessageContext ctx = decodeSoapRequest(request);
    final AttributeQuery query = (AttributeQuery) ctx.getMessage();
    try {
        final String issuer = query.getIssuer().getValue();
        final SamlRegisteredService service = verifySamlRegisteredService(issuer);
        final Optional<SamlRegisteredServiceServiceProviderMetadataFacade> adaptor = getSamlMetadataFacadeFor(service, query);
        if (!adaptor.isPresent()) {
            throw new UnauthorizedServiceException(UnauthorizedServiceException.CODE_UNAUTHZ_SERVICE, "Cannot find metadata linked to " + issuer);
        }
        final SamlRegisteredServiceServiceProviderMetadataFacade facade = adaptor.get();
        verifyAuthenticationContextSignature(ctx, request, query, facade);
        final Map<String, Object> attrs = new LinkedHashMap<>();
        if (query.getAttributes().isEmpty()) {
            final String id = this.samlAttributeQueryTicketFactory.createTicketIdFor(query.getSubject().getNameID().getValue());
            final SamlAttributeQueryTicket ticket = this.ticketRegistry.getTicket(id, SamlAttributeQueryTicket.class);
            final Authentication authentication = ticket.getTicketGrantingTicket().getAuthentication();
            final Principal principal = authentication.getPrincipal();
            final Map<String, Object> authnAttrs = authentication.getAttributes();
            final Map<String, Object> principalAttrs = principal.getAttributes();
            query.getAttributes().forEach(a -> {
                if (authnAttrs.containsKey(a.getName())) {
                    attrs.put(a.getName(), authnAttrs.get(a.getName()));
                } else if (principalAttrs.containsKey(a.getName())) {
                    attrs.put(a.getName(), principalAttrs.get(a.getName()));
                }
            });
        }
        final Assertion casAssertion = buildCasAssertion(issuer, service, attrs);
        this.responseBuilder.build(query, request, response, casAssertion, service, facade, SAMLConstants.SAML2_SOAP11_BINDING_URI);
    } catch (final Exception e) {
        LOGGER.error(e.getMessage(), e);
        request.setAttribute(SamlIdPConstants.REQUEST_ATTRIBUTE_ERROR, e.getMessage());
        samlFaultResponseBuilder.build(query, request, response, null, null, null, SAMLConstants.SAML2_SOAP11_BINDING_URI);
    }
}
Also used : SamlAttributeQueryTicket(org.apereo.cas.ticket.query.SamlAttributeQueryTicket) SamlRegisteredServiceServiceProviderMetadataFacade(org.apereo.cas.support.saml.services.idp.metadata.SamlRegisteredServiceServiceProviderMetadataFacade) Assertion(org.jasig.cas.client.validation.Assertion) UnauthorizedServiceException(org.apereo.cas.services.UnauthorizedServiceException) UnauthorizedServiceException(org.apereo.cas.services.UnauthorizedServiceException) LinkedHashMap(java.util.LinkedHashMap) AttributeQuery(org.opensaml.saml.saml2.core.AttributeQuery) Authentication(org.apereo.cas.authentication.Authentication) SamlRegisteredService(org.apereo.cas.support.saml.services.SamlRegisteredService) SAMLObject(org.opensaml.saml.common.SAMLObject) MessageContext(org.opensaml.messaging.context.MessageContext) Principal(org.apereo.cas.authentication.principal.Principal) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 33 with Principal

use of org.apereo.cas.authentication.principal.Principal in project cas by apereo.

the class OAuth20CasAuthenticationBuilder method build.

/**
 * Create an authentication from a user profile.
 *
 * @param profile           the given user profile
 * @param registeredService the registered service
 * @param context           the context
 * @param service           the service
 * @return the built authentication
 */
public Authentication build(final UserProfile profile, final OAuthRegisteredService registeredService, final J2EContext context, final Service service) {
    final Map<String, Object> profileAttributes = getPrincipalAttributesFromProfile(profile);
    final Principal newPrincipal = this.principalFactory.createPrincipal(profile.getId(), profileAttributes);
    LOGGER.debug("Created final principal [{}] after filtering attributes based on [{}]", newPrincipal, registeredService);
    final String authenticator = profile.getClass().getCanonicalName();
    final CredentialMetaData metadata = new BasicCredentialMetaData(new BasicIdentifiableCredential(profile.getId()));
    final AuthenticationHandlerExecutionResult handlerResult = new DefaultAuthenticationHandlerExecutionResult(authenticator, metadata, newPrincipal, new ArrayList<>());
    final Set<Object> scopes = CollectionUtils.toCollection(context.getRequest().getParameterValues(OAuth20Constants.SCOPE));
    final String state = StringUtils.defaultIfBlank(context.getRequestParameter(OAuth20Constants.STATE), StringUtils.EMPTY);
    final String nonce = StringUtils.defaultIfBlank(context.getRequestParameter(OAuth20Constants.NONCE), StringUtils.EMPTY);
    LOGGER.debug("OAuth [{}] is [{}], and [{}] is [{}]", OAuth20Constants.STATE, state, OAuth20Constants.NONCE, nonce);
    /*
         * pac4j UserProfile.getPermissions() and getRoles() returns UnmodifiableSet which Jackson Serializer
         * happily serializes to json but is unable to deserialize.
         * We have to of it to HashSet to avoid such problem
         */
    final AuthenticationBuilder bldr = DefaultAuthenticationBuilder.newInstance().addAttribute("permissions", new HashSet<>(profile.getPermissions())).addAttribute("roles", new HashSet<>(profile.getRoles())).addAttribute("scopes", scopes).addAttribute(OAuth20Constants.STATE, state).addAttribute(OAuth20Constants.NONCE, nonce).addCredential(metadata).setPrincipal(newPrincipal).setAuthenticationDate(ZonedDateTime.now()).addSuccess(profile.getClass().getCanonicalName(), handlerResult);
    collectionAuthenticationAttributesIfNecessary(profile, bldr);
    return bldr.build();
}
Also used : DefaultAuthenticationBuilder(org.apereo.cas.authentication.DefaultAuthenticationBuilder) AuthenticationBuilder(org.apereo.cas.authentication.AuthenticationBuilder) DefaultAuthenticationHandlerExecutionResult(org.apereo.cas.authentication.DefaultAuthenticationHandlerExecutionResult) BasicIdentifiableCredential(org.apereo.cas.authentication.BasicIdentifiableCredential) DefaultAuthenticationHandlerExecutionResult(org.apereo.cas.authentication.DefaultAuthenticationHandlerExecutionResult) AuthenticationHandlerExecutionResult(org.apereo.cas.authentication.AuthenticationHandlerExecutionResult) BasicCredentialMetaData(org.apereo.cas.authentication.BasicCredentialMetaData) CredentialMetaData(org.apereo.cas.authentication.CredentialMetaData) Principal(org.apereo.cas.authentication.principal.Principal) BasicCredentialMetaData(org.apereo.cas.authentication.BasicCredentialMetaData) HashSet(java.util.HashSet)

Example 34 with Principal

use of org.apereo.cas.authentication.principal.Principal in project cas by apereo.

the class DefaultOAuth2UserProfileDataCreator method getAccessTokenAuthenticationPrincipal.

/**
 * Gets access token authentication principal.
 *
 * @param accessToken the access token
 * @param context     the context
 * @return the access token authentication principal
 */
protected Principal getAccessTokenAuthenticationPrincipal(final AccessToken accessToken, final J2EContext context) {
    final Service service = accessToken.getService();
    final RegisteredService registeredService = this.servicesManager.findServiceBy(service);
    final Principal currentPrincipal = accessToken.getAuthentication().getPrincipal();
    LOGGER.debug("Preparing user profile response based on CAS principal [{}]", currentPrincipal);
    final Principal principal = this.scopeToAttributesFilter.filter(accessToken.getService(), currentPrincipal, registeredService, context, accessToken);
    LOGGER.debug("Created CAS principal [{}] based on requested/authorized scopes", principal);
    return principal;
}
Also used : OAuthRegisteredService(org.apereo.cas.support.oauth.services.OAuthRegisteredService) RegisteredService(org.apereo.cas.services.RegisteredService) OAuthRegisteredService(org.apereo.cas.support.oauth.services.OAuthRegisteredService) RegisteredService(org.apereo.cas.services.RegisteredService) Service(org.apereo.cas.authentication.principal.Service) Principal(org.apereo.cas.authentication.principal.Principal)

Example 35 with Principal

use of org.apereo.cas.authentication.principal.Principal in project cas by apereo.

the class AbstractOAuth20Tests method internalVerifyClientOK.

protected Pair<String, String> internalVerifyClientOK(final RegisteredService service, final boolean refreshToken, final boolean json) throws Exception {
    final Principal principal = createPrincipal();
    final OAuthCode code = addCode(principal, service);
    final MockHttpServletRequest mockRequest = new MockHttpServletRequest(HttpMethod.GET.name(), CONTEXT + OAuth20Constants.ACCESS_TOKEN_URL);
    mockRequest.setParameter(OAuth20Constants.REDIRECT_URI, REDIRECT_URI);
    mockRequest.setParameter(OAuth20Constants.GRANT_TYPE, OAuth20GrantTypes.AUTHORIZATION_CODE.name().toLowerCase());
    final String auth = CLIENT_ID + ':' + CLIENT_SECRET;
    final String value = EncodingUtils.encodeBase64(auth.getBytes(StandardCharsets.UTF_8));
    mockRequest.addHeader(HttpConstants.AUTHORIZATION_HEADER, HttpConstants.BASIC_HEADER_PREFIX + value);
    mockRequest.setParameter(OAuth20Constants.CLIENT_ID, CLIENT_ID);
    mockRequest.setParameter(OAuth20Constants.CLIENT_SECRET, CLIENT_SECRET);
    mockRequest.setParameter(OAuth20Constants.CODE, code.getId());
    final MockHttpServletResponse mockResponse = new MockHttpServletResponse();
    requiresAuthenticationInterceptor.preHandle(mockRequest, mockResponse, null);
    oAuth20AccessTokenController.handleRequest(mockRequest, mockResponse);
    assertNull(this.ticketRegistry.getTicket(code.getId()));
    assertEquals(HttpStatus.SC_OK, mockResponse.getStatus());
    final String body = mockResponse.getContentAsString();
    final String accessTokenId;
    String refreshTokenId = null;
    if (json) {
        assertEquals(MediaType.APPLICATION_JSON_VALUE, mockResponse.getContentType());
        assertTrue(body.contains('"' + OAuth20Constants.ACCESS_TOKEN + "\":\"AT-"));
        final Map results = MAPPER.readValue(body, Map.class);
        if (refreshToken) {
            assertTrue(body.contains('"' + OAuth20Constants.REFRESH_TOKEN + "\":\"RT-"));
            refreshTokenId = results.get(OAuth20Constants.REFRESH_TOKEN).toString();
        }
        assertTrue(body.contains('"' + OAuth20Constants.EXPIRES_IN + "\":"));
        accessTokenId = results.get(OAuth20Constants.ACCESS_TOKEN).toString();
    } else {
        assertEquals(MediaType.TEXT_PLAIN_VALUE, mockResponse.getContentType());
        assertTrue(body.contains(OAuth20Constants.ACCESS_TOKEN + "=AT-"));
        if (refreshToken) {
            assertTrue(body.contains(OAuth20Constants.REFRESH_TOKEN + "=RT-"));
            refreshTokenId = Arrays.stream(body.split("&")).filter(f -> f.startsWith(OAuth20Constants.REFRESH_TOKEN)).map(f -> StringUtils.remove(f, OAuth20Constants.REFRESH_TOKEN + "=")).findFirst().get();
        }
        assertTrue(body.contains(OAuth20Constants.EXPIRES_IN + '='));
        accessTokenId = StringUtils.substringBetween(body, OAuth20Constants.ACCESS_TOKEN + '=', "&");
    }
    final AccessToken accessToken = this.ticketRegistry.getTicket(accessTokenId, AccessToken.class);
    assertEquals(principal, accessToken.getAuthentication().getPrincipal());
    final int timeLeft = getTimeLeft(body, refreshToken, json);
    assertTrue(timeLeft >= TIMEOUT - 10 - DELTA);
    return Pair.of(accessTokenId, refreshTokenId);
}
Also used : CasConfigurationProperties(org.apereo.cas.configuration.CasConfigurationProperties) Arrays(java.util.Arrays) ReturnAllAttributeReleasePolicy(org.apereo.cas.services.ReturnAllAttributeReleasePolicy) ZonedDateTime(java.time.ZonedDateTime) Autowired(org.springframework.beans.factory.annotation.Autowired) StringUtils(org.apache.commons.lang3.StringUtils) BasicIdentifiableCredential(org.apereo.cas.authentication.BasicIdentifiableCredential) CasCoreConfiguration(org.apereo.cas.config.CasCoreConfiguration) CasWebApplicationServiceFactoryConfiguration(org.apereo.cas.config.support.CasWebApplicationServiceFactoryConfiguration) Pair(org.apache.commons.lang3.tuple.Pair) OAuthCodeFactory(org.apereo.cas.ticket.code.OAuthCodeFactory) EnableConfigurationProperties(org.springframework.boot.context.properties.EnableConfigurationProperties) Map(java.util.Map) CasCoreWebConfiguration(org.apereo.cas.config.CasCoreWebConfiguration) OAuth20Constants(org.apereo.cas.support.oauth.OAuth20Constants) SecurityInterceptor(org.pac4j.springframework.web.SecurityInterceptor) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) CasCoreAuthenticationPolicyConfiguration(org.apereo.cas.config.CasCoreAuthenticationPolicyConfiguration) StandardCharsets(java.nio.charset.StandardCharsets) OAuth20AccessTokenEndpointController(org.apereo.cas.support.oauth.web.endpoints.OAuth20AccessTokenEndpointController) CasCookieConfiguration(org.apereo.cas.web.config.CasCookieConfiguration) Slf4j(lombok.extern.slf4j.Slf4j) CasCoreComponentSerializationConfiguration(org.apereo.cas.config.CasCoreComponentSerializationConfiguration) CasCoreTicketCatalogConfiguration(org.apereo.cas.config.CasCoreTicketCatalogConfiguration) Principal(org.apereo.cas.authentication.principal.Principal) EncodingUtils(org.apereo.cas.util.EncodingUtils) MockTicketGrantingTicket(org.apereo.cas.mock.MockTicketGrantingTicket) ComponentSerializationPlan(org.apereo.cas.ComponentSerializationPlan) RefreshTokenFactory(org.apereo.cas.ticket.refreshtoken.RefreshTokenFactory) CasCoreAuthenticationConfiguration(org.apereo.cas.config.CasCoreAuthenticationConfiguration) BasicCredentialMetaData(org.apereo.cas.authentication.BasicCredentialMetaData) RunWith(org.junit.runner.RunWith) WebApplicationServiceFactory(org.apereo.cas.authentication.principal.WebApplicationServiceFactory) EnableTransactionManagement(org.springframework.transaction.annotation.EnableTransactionManagement) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) CasOAuthAuthenticationServiceSelectionStrategyConfiguration(org.apereo.cas.config.CasOAuthAuthenticationServiceSelectionStrategyConfiguration) ArrayList(java.util.ArrayList) RefreshToken(org.apereo.cas.ticket.refreshtoken.RefreshToken) TicketRegistry(org.apereo.cas.ticket.registry.TicketRegistry) DefaultAuthenticationHandlerExecutionResult(org.apereo.cas.authentication.DefaultAuthenticationHandlerExecutionResult) RefreshAutoConfiguration(org.springframework.cloud.autoconfigure.RefreshAutoConfiguration) Authentication(org.apereo.cas.authentication.Authentication) ServicesManager(org.apereo.cas.services.ServicesManager) CasCoreUtilSerializationConfiguration(org.apereo.cas.config.CasCoreUtilSerializationConfiguration) CasCoreAuthenticationHandlersConfiguration(org.apereo.cas.config.CasCoreAuthenticationHandlersConfiguration) CasCoreServicesConfiguration(org.apereo.cas.config.CasCoreServicesConfiguration) EnvironmentConversionServiceInitializer(org.apereo.cas.config.support.EnvironmentConversionServiceInitializer) CasCoreServicesAuthenticationConfiguration(org.apereo.cas.config.CasCoreServicesAuthenticationConfiguration) CasCoreAuthenticationPrincipalConfiguration(org.apereo.cas.config.CasCoreAuthenticationPrincipalConfiguration) HttpMethod(org.springframework.http.HttpMethod) AuthenticationHandlerExecutionResult(org.apereo.cas.authentication.AuthenticationHandlerExecutionResult) RegisteredService(org.apereo.cas.services.RegisteredService) CasOAuthThrottleConfiguration(org.apereo.cas.config.CasOAuthThrottleConfiguration) ContextConfiguration(org.springframework.test.context.ContextConfiguration) CasCoreUtilConfiguration(org.apereo.cas.config.CasCoreUtilConfiguration) Assert(org.junit.Assert) DirtiesContext(org.springframework.test.annotation.DirtiesContext) DefaultAuthenticationBuilder(org.apereo.cas.authentication.DefaultAuthenticationBuilder) AopAutoConfiguration(org.springframework.boot.autoconfigure.aop.AopAutoConfiguration) HttpStatus(org.apache.http.HttpStatus) TestConfiguration(org.springframework.boot.test.context.TestConfiguration) AbstractRegisteredService(org.apereo.cas.services.AbstractRegisteredService) SchedulingUtils(org.apereo.cas.util.SchedulingUtils) OAuthCode(org.apereo.cas.ticket.code.OAuthCode) RegisteredServiceTestUtils(org.apereo.cas.services.RegisteredServiceTestUtils) CasCoreAuthenticationServiceSelectionStrategyConfiguration(org.apereo.cas.config.CasCoreAuthenticationServiceSelectionStrategyConfiguration) SpringRunner(org.springframework.test.context.junit4.SpringRunner) CredentialMetaData(org.apereo.cas.authentication.CredentialMetaData) CasCoreTicketIdGeneratorsConfiguration(org.apereo.cas.config.CasCoreTicketIdGeneratorsConfiguration) MediaType(org.springframework.http.MediaType) Collection(java.util.Collection) CasCoreLogoutConfiguration(org.apereo.cas.logout.config.CasCoreLogoutConfiguration) CasDefaultServiceTicketIdGeneratorsConfiguration(org.apereo.cas.config.CasDefaultServiceTicketIdGeneratorsConfiguration) List(java.util.List) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) ComponentSerializationPlanConfigurator(org.apereo.cas.ComponentSerializationPlanConfigurator) PostConstruct(javax.annotation.PostConstruct) CasCoreTicketsConfiguration(org.apereo.cas.config.CasCoreTicketsConfiguration) CasOAuthConfiguration(org.apereo.cas.config.CasOAuthConfiguration) CasPersonDirectoryConfiguration(org.apereo.cas.config.CasPersonDirectoryConfiguration) CasCoreAuthenticationSupportConfiguration(org.apereo.cas.config.CasCoreAuthenticationSupportConfiguration) MockServiceTicket(org.apereo.cas.mock.MockServiceTicket) EnableAspectJAutoProxy(org.springframework.context.annotation.EnableAspectJAutoProxy) HttpConstants(org.pac4j.core.context.HttpConstants) HashMap(java.util.HashMap) Qualifier(org.springframework.beans.factory.annotation.Qualifier) CasCoreAuthenticationMetadataConfiguration(org.apereo.cas.config.CasCoreAuthenticationMetadataConfiguration) AccessToken(org.apereo.cas.ticket.accesstoken.AccessToken) CasOAuthComponentSerializationConfiguration(org.apereo.cas.config.CasOAuthComponentSerializationConfiguration) CasCoreHttpConfiguration(org.apereo.cas.config.CasCoreHttpConfiguration) OAuth20GrantTypes(org.apereo.cas.support.oauth.OAuth20GrantTypes) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) OAuthRegisteredService(org.apereo.cas.support.oauth.services.OAuthRegisteredService) ApplicationContext(org.springframework.context.ApplicationContext) Service(org.apereo.cas.authentication.principal.Service) Bean(org.springframework.context.annotation.Bean) CoreAuthenticationTestUtils(org.apereo.cas.authentication.CoreAuthenticationTestUtils) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) AccessToken(org.apereo.cas.ticket.accesstoken.AccessToken) OAuthCode(org.apereo.cas.ticket.code.OAuthCode) Map(java.util.Map) HashMap(java.util.HashMap) Principal(org.apereo.cas.authentication.principal.Principal) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse)

Aggregations

Principal (org.apereo.cas.authentication.principal.Principal)114 HashMap (java.util.HashMap)33 RegisteredService (org.apereo.cas.services.RegisteredService)31 Test (org.junit.Test)29 Authentication (org.apereo.cas.authentication.Authentication)26 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)26 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)26 OAuthRegisteredService (org.apereo.cas.support.oauth.services.OAuthRegisteredService)25 Map (java.util.Map)23 Slf4j (lombok.extern.slf4j.Slf4j)23 lombok.val (lombok.val)19 List (java.util.List)15 StringUtils (org.apache.commons.lang3.StringUtils)15 OAuthCode (org.apereo.cas.ticket.code.OAuthCode)15 CollectionUtils (org.apereo.cas.util.CollectionUtils)15 ArrayList (java.util.ArrayList)14 Optional (java.util.Optional)14 Service (org.apereo.cas.authentication.principal.Service)14 Collection (java.util.Collection)11 Collectors (java.util.stream.Collectors)10