Search in sources :

Example 31 with SneakyThrows

use of lombok.SneakyThrows in project cas by apereo.

the class RestSamlRegisteredServiceMetadataResolverTests method setup.

@Before
@SneakyThrows
public void setup() {
    final SamlMetadataDocument doc = new SamlMetadataDocument();
    doc.setId(1);
    doc.setName("SAML Document");
    doc.setSignature(null);
    doc.setValue(IOUtils.toString(new ClassPathResource("sp-metadata.xml").getInputStream(), StandardCharsets.UTF_8));
    final String data = MAPPER.writeValueAsString(doc);
    this.webServer = new MockWebServer(8078, new ByteArrayResource(data.getBytes(StandardCharsets.UTF_8), "REST Output"), MediaType.APPLICATION_XML_VALUE);
    this.webServer.start();
}
Also used : MockWebServer(org.apereo.cas.util.MockWebServer) SamlMetadataDocument(org.apereo.cas.support.saml.services.idp.metadata.SamlMetadataDocument) ByteArrayResource(org.springframework.core.io.ByteArrayResource) ClassPathResource(org.springframework.core.io.ClassPathResource) Before(org.junit.Before) SneakyThrows(lombok.SneakyThrows)

Example 32 with SneakyThrows

use of lombok.SneakyThrows in project cas by apereo.

the class AbstractSamlProfileHandlerController method constructServiceUrl.

/**
 * Construct service url string.
 *
 * @param request  the request
 * @param response the response
 * @param pair     the pair
 * @return the string
 * @throws SamlException the saml exception
 */
@SneakyThrows
protected String constructServiceUrl(final HttpServletRequest request, final HttpServletResponse response, final Pair<? extends SignableSAMLObject, MessageContext> pair) throws SamlException {
    final AuthnRequest authnRequest = AuthnRequest.class.cast(pair.getLeft());
    final MessageContext messageContext = pair.getRight();
    try (StringWriter writer = SamlUtils.transformSamlObject(this.configBean, authnRequest)) {
        final URLBuilder builder = new URLBuilder(this.callbackService.getId());
        builder.getQueryParams().add(new net.shibboleth.utilities.java.support.collection.Pair<>(SamlProtocolConstants.PARAMETER_ENTITY_ID, SamlIdPUtils.getIssuerFromSamlRequest(authnRequest)));
        final String samlRequest = EncodingUtils.encodeBase64(writer.toString().getBytes(StandardCharsets.UTF_8));
        builder.getQueryParams().add(new net.shibboleth.utilities.java.support.collection.Pair<>(SamlProtocolConstants.PARAMETER_SAML_REQUEST, samlRequest));
        builder.getQueryParams().add(new net.shibboleth.utilities.java.support.collection.Pair<>(SamlProtocolConstants.PARAMETER_SAML_RELAY_STATE, SAMLBindingSupport.getRelayState(messageContext)));
        final String url = builder.buildURL();
        LOGGER.trace("Built service callback url [{}]", url);
        return CommonUtils.constructServiceUrl(request, response, url, casProperties.getServer().getName(), CasProtocolConstants.PARAMETER_SERVICE, CasProtocolConstants.PARAMETER_TICKET, false);
    }
}
Also used : AuthnRequest(org.opensaml.saml.saml2.core.AuthnRequest) StringWriter(java.io.StringWriter) MessageContext(org.opensaml.messaging.context.MessageContext) URLBuilder(net.shibboleth.utilities.java.support.net.URLBuilder) SneakyThrows(lombok.SneakyThrows)

Example 33 with SneakyThrows

use of lombok.SneakyThrows in project cas by apereo.

the class BaseSamlResponseEncoder method encode.

/**
 * Encode.
 *
 * @param samlResponse the saml response
 * @param relayState   the relay state
 * @return the response
 * @throws SamlException the saml exception
 */
@SneakyThrows
public final Response encode(final Response samlResponse, final String relayState) throws SamlException {
    if (httpResponse != null) {
        final BaseSAML2MessageEncoder encoder = getMessageEncoderInstance();
        encoder.setHttpServletResponse(httpResponse);
        final MessageContext ctx = getEncoderMessageContext(samlResponse, relayState);
        encoder.setMessageContext(ctx);
        finalizeEncode(encoder, samlResponse, relayState);
    }
    return samlResponse;
}
Also used : BaseSAML2MessageEncoder(org.opensaml.saml.saml2.binding.encoding.impl.BaseSAML2MessageEncoder) MessageContext(org.opensaml.messaging.context.MessageContext) SneakyThrows(lombok.SneakyThrows)

Example 34 with SneakyThrows

use of lombok.SneakyThrows in project cas by apereo.

the class SamlObjectSignatureValidator method getSigningCredential.

@SneakyThrows
private Set<Credential> getSigningCredential(final RoleDescriptorResolver resolver, final RequestAbstractType profileRequest) {
    final MetadataCredentialResolver kekCredentialResolver = new MetadataCredentialResolver();
    final SignatureValidationConfiguration config = getSignatureValidationConfiguration();
    kekCredentialResolver.setRoleDescriptorResolver(resolver);
    kekCredentialResolver.setKeyInfoCredentialResolver(DefaultSecurityConfigurationBootstrap.buildBasicInlineKeyInfoCredentialResolver());
    kekCredentialResolver.initialize();
    final CriteriaSet criteriaSet = new CriteriaSet();
    criteriaSet.add(new SignatureValidationConfigurationCriterion(config));
    criteriaSet.add(new UsageCriterion(UsageType.SIGNING));
    buildEntityCriteriaForSigningCredential(profileRequest, criteriaSet);
    return Sets.newLinkedHashSet(kekCredentialResolver.resolve(criteriaSet));
}
Also used : UsageCriterion(org.opensaml.security.criteria.UsageCriterion) CriteriaSet(net.shibboleth.utilities.java.support.resolver.CriteriaSet) MetadataCredentialResolver(org.opensaml.saml.security.impl.MetadataCredentialResolver) BasicSignatureValidationConfiguration(org.opensaml.xmlsec.impl.BasicSignatureValidationConfiguration) SignatureValidationConfiguration(org.opensaml.xmlsec.SignatureValidationConfiguration) SignatureValidationConfigurationCriterion(org.opensaml.xmlsec.criterion.SignatureValidationConfigurationCriterion) SneakyThrows(lombok.SneakyThrows)

Example 35 with SneakyThrows

use of lombok.SneakyThrows in project anki-battle-showcase by adessoAG.

the class AnkiInitializer method connectToAnki.

@SneakyThrows
private void connectToAnki() {
    log.info("Connecting to Anki Gateway at 10.200.100.12...");
    gateway = new AnkiGateway("10.200.100.12", 5000);
    ankiVehicles = gateway.findVehicles();
    for (AnkiVehicle anki : ankiVehicles.subList(0, 1)) {
        myVehicle = new Vehicle();
        myVehicle.setAnkiReference(anki);
        anki.connect();
        anki.sendMessage(new SdkModeMessage());
        world.addBody(myVehicle);
    }
}
Also used : AnkiVehicle(de.adesso.anki.sdk.AnkiVehicle) AnkiVehicle(de.adesso.anki.sdk.AnkiVehicle) Vehicle(de.adesso.anki.battle.world.bodies.Vehicle) AnkiGateway(de.adesso.anki.sdk.AnkiGateway) 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