use of org.keycloak.protocol.saml.SamlClient in project keycloak by keycloak.
the class ModAuthMellonClientInstallation method generateInstallation.
@Override
public Response generateInstallation(KeycloakSession session, RealmModel realm, ClientModel client, URI serverBaseUri) {
SamlClient samlClient = new SamlClient(client);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ZipOutputStream zip = new ZipOutputStream(baos);
String idpDescriptor = SamlService.getIDPMetadataDescriptor(session.getContext().getUri(), session, realm);
String spDescriptor = SamlSPDescriptorClientInstallation.getSPDescriptorForClient(client);
String clientDirName = client.getClientId().replace('/', '_').replace(' ', '_');
try {
zip.putNextEntry(new ZipEntry(clientDirName + "/idp-metadata.xml"));
zip.write(idpDescriptor.getBytes());
zip.closeEntry();
zip.putNextEntry(new ZipEntry(clientDirName + "/sp-metadata.xml"));
zip.write(spDescriptor.getBytes());
zip.closeEntry();
if (samlClient.requiresClientSignature()) {
if (samlClient.getClientSigningPrivateKey() != null) {
zip.putNextEntry(new ZipEntry(clientDirName + "/client-private-key.pem"));
zip.write(samlClient.getClientSigningPrivateKey().getBytes());
zip.closeEntry();
}
if (samlClient.getClientSigningCertificate() != null) {
zip.putNextEntry(new ZipEntry(clientDirName + "/client-cert.pem"));
zip.write(samlClient.getClientSigningCertificate().getBytes());
zip.closeEntry();
}
}
zip.close();
baos.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
return Response.ok(baos.toByteArray(), getMediaType()).build();
}
use of org.keycloak.protocol.saml.SamlClient in project keycloak by keycloak.
the class KeycloakSamlClientInstallation method generateInstallation.
@Override
public Response generateInstallation(KeycloakSession session, RealmModel realm, ClientModel client, URI baseUri) {
SamlClient samlClient = new SamlClient(client);
StringBuilder buffer = new StringBuilder();
buffer.append("<keycloak-saml-adapter>\n");
baseXml(session, realm, client, baseUri, samlClient, buffer);
buffer.append("</keycloak-saml-adapter>\n");
return Response.ok(buffer.toString(), MediaType.TEXT_PLAIN_TYPE).build();
}
Aggregations