use of org.pac4j.core.profile.AnonymousProfile in project pac4j by pac4j.
the class IsAuthenticatedAuthorizerTests method testAnonymousProfile.
@Test
public void testAnonymousProfile() {
profiles.add(new AnonymousProfile());
assertFalse(authorizer.isAuthorized(null, new MockSessionStore(), profiles));
}
use of org.pac4j.core.profile.AnonymousProfile in project pac4j by pac4j.
the class IsRememberedAuthorizerTests method testAnonymousProfileRedirectionUrl.
@Override
@Test
public void testAnonymousProfileRedirectionUrl() {
profiles.add(new AnonymousProfile());
((IsRememberedAuthorizer) authorizer).setRedirectionUrl(PAC4J_URL);
TestsHelper.expectException(() -> authorizer.isAuthorized(MockWebContext.create(), new MockSessionStore(), profiles), HttpAction.class, "Performing a 302 HTTP action");
}
use of org.pac4j.core.profile.AnonymousProfile in project pac4j by pac4j.
the class IsAnonymousAuthorizerTests method testAnonymousProfile.
@Test
public void testAnonymousProfile() {
profiles.add(new AnonymousProfile());
assertTrue(authorizer.isAuthorized(null, new MockSessionStore(), profiles));
}
use of org.pac4j.core.profile.AnonymousProfile in project pac4j by pac4j.
the class IsAnonymousAuthorizerTests method testAnonProfileTwoProfiles.
@Test
public void testAnonProfileTwoProfiles() {
profiles.add(new AnonymousProfile());
profiles.add(new CommonProfile());
assertFalse(authorizer.isAuthorized(null, new MockSessionStore(), profiles));
}
use of org.pac4j.core.profile.AnonymousProfile in project cas by apereo.
the class AccessTokenDeviceCodeResponseRequestExtractor method extract.
@Override
public AccessTokenRequestContext extract(final WebContext context) {
val clientId = OAuth20Utils.getRequestParameter(context, OAuth20Constants.CLIENT_ID).orElse(StringUtils.EMPTY);
LOGGER.debug("Locating OAuth registered service by client id [{}]", clientId);
val registeredService = OAuth20Utils.getRegisteredOAuthServiceByClientId(getOAuthConfigurationContext().getServicesManager(), clientId);
LOGGER.debug("Located OAuth registered service [{}]", registeredService);
val deviceCode = OAuth20Utils.getRequestParameter(context, OAuth20Constants.CODE).orElse(StringUtils.EMPTY);
val service = getOAuthConfigurationContext().getAuthenticationBuilder().buildService(registeredService, context, false);
LOGGER.debug("Authenticating the OAuth request indicated by [{}]", service);
val authentication = getOAuthConfigurationContext().getAuthenticationBuilder().build(new AnonymousProfile(), registeredService, context, service);
val audit = AuditableContext.builder().service(service).registeredService(registeredService).authentication(authentication).build();
val accessResult = getOAuthConfigurationContext().getRegisteredServiceAccessStrategyEnforcer().execute(audit);
accessResult.throwExceptionIfNeeded();
return AccessTokenRequestContext.builder().service(service).authentication(authentication).registeredService(registeredService).responseType(getResponseType()).grantType(getGrantType()).generateRefreshToken(registeredService != null && registeredService.isGenerateRefreshToken()).deviceCode(deviceCode).build();
}
Aggregations