Search in sources :

Example 11 with SneakyThrows

use of lombok.SneakyThrows in project cas by apereo.

the class WSFederationValidateRequestController method redirectToIdentityProvider.

@SneakyThrows
private void redirectToIdentityProvider(final WSFederationRequest fedRequest, final HttpServletResponse response, final HttpServletRequest request, final WSFederationRegisteredService service) {
    final String serviceUrl = constructServiceUrl(request, response, fedRequest);
    LOGGER.debug("Created service url [{}] mapped to [{}]", serviceUrl, service);
    final boolean renew = shouldRenewAuthentication(fedRequest, request);
    final String initialUrl = CommonUtils.constructRedirectUrl(casProperties.getServer().getLoginUrl(), CasProtocolConstants.PARAMETER_SERVICE, serviceUrl, renew, false);
    LOGGER.debug("Redirecting authN request to [{}]", initialUrl);
    final AuthenticationRedirectStrategy authenticationRedirectStrategy = new DefaultAuthenticationRedirectStrategy();
    authenticationRedirectStrategy.redirect(request, response, initialUrl);
}
Also used : DefaultAuthenticationRedirectStrategy(org.jasig.cas.client.authentication.DefaultAuthenticationRedirectStrategy) DefaultAuthenticationRedirectStrategy(org.jasig.cas.client.authentication.DefaultAuthenticationRedirectStrategy) AuthenticationRedirectStrategy(org.jasig.cas.client.authentication.AuthenticationRedirectStrategy) SneakyThrows(lombok.SneakyThrows)

Example 12 with SneakyThrows

use of lombok.SneakyThrows in project instagram-java-scraper by postaddictme.

the class ModelMapper method getUnmarshaller.

@SneakyThrows
protected Unmarshaller getUnmarshaller(String mappingFile) {
    Map<String, Object> properties = new HashMap<>();
    properties.put(JAXBContextProperties.OXM_METADATA_SOURCE, mappingFile);
    properties.put(JAXBContextProperties.MEDIA_TYPE, MediaType.APPLICATION_JSON);
    ClassLoader classLoader = Thread.currentThread().getContextClassLoader() == null ? Account.class.getClassLoader() : Thread.currentThread().getContextClassLoader();
    JAXBContext jaxbContext = DynamicJAXBContextFactory.createContextFromOXM(classLoader, properties);
    Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
    unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, MediaType.APPLICATION_JSON);
    return unmarshaller;
}
Also used : HashMap(java.util.HashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) JAXBContext(javax.xml.bind.JAXBContext) Unmarshaller(javax.xml.bind.Unmarshaller) SneakyThrows(lombok.SneakyThrows)

Example 13 with SneakyThrows

use of lombok.SneakyThrows in project cas by apereo.

the class DynamoDbTicketRegistryConfiguration method amazonDynamoDbClient.

@RefreshScope
@Bean
@SneakyThrows
public AmazonDynamoDB amazonDynamoDbClient() {
    final DynamoDbTicketRegistryProperties dynamoDbProperties = casProperties.getTicket().getRegistry().getDynamoDb();
    final AmazonDynamoDbClientFactory factory = new AmazonDynamoDbClientFactory();
    return factory.createAmazonDynamoDb(dynamoDbProperties);
}
Also used : AmazonDynamoDbClientFactory(org.apereo.cas.dynamodb.AmazonDynamoDbClientFactory) DynamoDbTicketRegistryProperties(org.apereo.cas.configuration.model.support.dynamodb.DynamoDbTicketRegistryProperties) RefreshScope(org.springframework.cloud.context.config.annotation.RefreshScope) SneakyThrows(lombok.SneakyThrows) Bean(org.springframework.context.annotation.Bean)

Example 14 with SneakyThrows

use of lombok.SneakyThrows in project cas by apereo.

the class AbstractCasWebflowEventResolver method validateEventIdForMatchingTransitionInContext.

/**
 * Validate event for transition.
 *
 * @param eventId    the event id
 * @param context    the context
 * @param attributes the attributes
 * @return the event
 */
@SneakyThrows
protected Event validateEventIdForMatchingTransitionInContext(final String eventId, final RequestContext context, final Map<String, Object> attributes) {
    final AttributeMap<Object> attributesMap = new LocalAttributeMap<>(attributes);
    final Event event = new Event(this, eventId, attributesMap);
    LOGGER.debug("Resulting event id is [{}]. Locating transitions in the context for that event id...", event.getId());
    final TransitionDefinition def = context.getMatchingTransition(event.getId());
    if (def == null) {
        LOGGER.warn("Transition definition cannot be found for event [{}]", event.getId());
        throw new AuthenticationException();
    }
    LOGGER.debug("Found matching transition [{}] with target [{}] for event [{}] with attributes [{}].", def.getId(), def.getTargetStateId(), event.getId(), event.getAttributes());
    return event;
}
Also used : LocalAttributeMap(org.springframework.webflow.core.collection.LocalAttributeMap) AuthenticationException(org.apereo.cas.authentication.AuthenticationException) Event(org.springframework.webflow.execution.Event) TransitionDefinition(org.springframework.webflow.definition.TransitionDefinition) SneakyThrows(lombok.SneakyThrows)

Example 15 with SneakyThrows

use of lombok.SneakyThrows in project cas by apereo.

the class RegisteredServiceMultifactorAuthenticationPolicyEventResolver method resolveEventPerAuthenticationProvider.

/**
 * Resolve event per authentication provider event.
 *
 * @param principal the principal
 * @param context   the context
 * @param service   the service
 * @return the event
 */
@SneakyThrows
protected Set<Event> resolveEventPerAuthenticationProvider(final Principal principal, final RequestContext context, final RegisteredService service) {
    final Collection<MultifactorAuthenticationProvider> providers = flattenProviders(getAuthenticationProviderForService(service));
    if (providers != null && !providers.isEmpty()) {
        final MultifactorAuthenticationProvider provider = this.multifactorAuthenticationProviderSelector.resolve(providers, service, principal);
        LOGGER.debug("Selected multifactor authentication provider for this transaction is [{}]", provider);
        if (!provider.isAvailable(service)) {
            LOGGER.warn("Multifactor authentication provider [{}] could not be verified/reached.", provider);
            return null;
        }
        final String identifier = provider.getId();
        LOGGER.debug("Attempting to build an event based on the authentication provider [{}] and service [{}]", provider, service.getName());
        final Event event = validateEventIdForMatchingTransitionInContext(identifier, context, buildEventAttributeMap(principal, service, provider));
        return CollectionUtils.wrapSet(event);
    }
    LOGGER.debug("No multifactor authentication providers could be located for [{}]", service);
    return null;
}
Also used : Event(org.springframework.webflow.execution.Event) MultifactorAuthenticationProvider(org.apereo.cas.services.MultifactorAuthenticationProvider) SneakyThrows(lombok.SneakyThrows)

Aggregations

SneakyThrows (lombok.SneakyThrows)592 lombok.val (lombok.val)292 Test (org.junit.Test)66 ArrayList (java.util.ArrayList)59 HashMap (java.util.HashMap)51 List (java.util.List)42 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)33 LinkedHashMap (java.util.LinkedHashMap)29 File (java.io.File)27 Collectors (java.util.stream.Collectors)25 Path (java.nio.file.Path)24 IOException (java.io.IOException)23 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)22 URL (java.net.URL)20 Slf4j (lombok.extern.slf4j.Slf4j)20 InputStream (java.io.InputStream)19 Map (java.util.Map)19 Cleanup (lombok.Cleanup)17 FishingActivityQuery (eu.europa.ec.fisheries.ers.service.search.FishingActivityQuery)16 SearchFilter (eu.europa.ec.fisheries.uvms.activity.model.schemas.SearchFilter)16