use of org.springframework.core.io.InputStreamSource in project cas by apereo.
the class X509CredentialFactory method fromRequestBody.
@Override
public Credential fromRequestBody(final MultiValueMap<String, String> requestBody) {
final String cert = requestBody.getFirst(CERTIFICATE);
LOGGER.trace("cert: {}", cert);
if (cert == null) {
LOGGER.debug("cert is null fallback to username/passwd");
return super.fromRequestBody(requestBody);
}
final InputStream is = new ByteArrayInputStream(cert.getBytes());
final InputStreamSource iso = new InputStreamResource(is);
final X509Certificate certificate = CertUtils.readCertificate(iso);
final X509CertificateCredential credential = new X509CertificateCredential(new X509Certificate[] { certificate });
credential.setCertificate(certificate);
return credential;
}
Aggregations