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();
}
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);
}
}
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;
}
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));
}
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);
}
}
Aggregations