org.keycloak.services.resources.admin

## Class ClientAttributeCertificateResource

- java.lang.Object
- - org.keycloak.services.resources.admin.ClientAttributeCertificateResource

-     public class ClientAttributeCertificateResource
      extends Object

  Version:
    $Revision: 1 $
  Author:
    Bill Burke

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected AdminEventBuilder` | `adminEvent`
    `protected String` | `attributePrefix`
    `protected String` | `certificateAttribute`
    `protected ClientModel` | `client`
    `static String` | `PRIVATE_KEY`
    `protected String` | `privateAttribute`
    `protected RealmModel` | `realm`
    `protected KeycloakSession` | `session`
    `static String` | `X509CERTIFICATE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ClientAttributeCertificateResource(RealmModel realm, RealmAuth auth, ClientModel client, KeycloakSession session, String attributePrefix, AdminEventBuilder adminEvent)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `CertificateRepresentation` | `generate()` Generate a new certificate with new key pair
    `byte[]` | `generateAndGetKeystore(KeyStoreConfig config)` Generate a new keypair and certificate, and get the private key file Generates a keypair and certificate and serves the private key in a specified keystore format.
    `CertificateRepresentation` | `getKeyInfo()` Get key info
    `byte[]` | `getKeystore(KeyStoreConfig config)` Get a keystore file for the client, containing private key and public certificate
    `CertificateRepresentation` | `uploadJks(javax.ws.rs.core.UriInfo uriInfo, org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput input)` Upload certificate and eventually private key
    `CertificateRepresentation` | `uploadJksCertificate(javax.ws.rs.core.UriInfo uriInfo, org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput input)` Upload only certificate, not private key

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### PRIVATE_KEY

          public static final String PRIVATE_KEY

      See Also:
        Constant Field Values

    - #### X509CERTIFICATE

          public static final String X509CERTIFICATE

      See Also:
        Constant Field Values

    - #### realm

          protected RealmModel realm

    - #### client

          protected ClientModel client

    - #### session

          protected KeycloakSession session

    - #### adminEvent

          protected AdminEventBuilder adminEvent

    - #### attributePrefix

          protected String attributePrefix

    - #### privateAttribute

          protected String privateAttribute

    - #### certificateAttribute

          protected String certificateAttribute

  - ### Constructor Detail

    - #### ClientAttributeCertificateResource

          public ClientAttributeCertificateResource(RealmModel realm,
                                                    RealmAuth auth,
                                                    ClientModel client,
                                                    KeycloakSession session,
                                                    String attributePrefix,
                                                    AdminEventBuilder adminEvent)

  - ### Method Detail

    - #### getKeyInfo

          @GET
           @Produces(value="application/json")
          public CertificateRepresentation getKeyInfo()

      Get key info
      Returns:

    - #### generate

          @POST
           @Path(value="generate")
           @Produces(value="application/json")
          public CertificateRepresentation generate()

      Generate a new certificate with new key pair
      Returns:

    - #### uploadJks

          @POST
           @Path(value="upload")
           @Consumes(value="multipart/form-data")
           @Produces(value="application/json")
          public CertificateRepresentation uploadJks(@Context
                                                                                                                                                               javax.ws.rs.core.UriInfo uriInfo,
                                                                                                                                                               org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput input)
                                                                                                                                                        throws IOException

      Upload certificate and eventually private key
      Parameters:
        `uriInfo` -
        `input` -
      Returns:
      Throws:
        `IOException`

    - #### uploadJksCertificate

          @POST
           @Path(value="upload-certificate")
           @Consumes(value="multipart/form-data")
           @Produces(value="application/json")
          public CertificateRepresentation uploadJksCertificate(@Context
                                                                                                                                                                                      javax.ws.rs.core.UriInfo uriInfo,
                                                                                                                                                                                      org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput input)
                                                                                                                                                                               throws IOException

      Upload only certificate, not private key
      Parameters:
        `uriInfo` -
        `input` -
      Returns:
        information extracted from uploaded certificate - not necessarily the new state of certificate on the server
      Throws:
        `IOException`

    - #### getKeystore

          @POST
           @Path(value="/download")
           @Produces(value="application/octet-stream")
           @Consumes(value="application/json")
          public byte[] getKeystore(KeyStoreConfig config)

      Get a keystore file for the client, containing private key and public certificate
      Parameters:
        `config` - Keystore configuration as JSON
      Returns:

    - #### generateAndGetKeystore

          @POST
           @Path(value="/generate-and-download")
           @Produces(value="application/octet-stream")
           @Consumes(value="application/json")
          public byte[] generateAndGetKeystore(KeyStoreConfig config)

      Generate a new keypair and certificate, and get the private key file Generates a keypair and certificate and serves the private key in a specified keystore format. Only generated public certificate is saved in Keycloak DB - the private key is not.
      Parameters:
        `config` - Keystore configuration as JSON
      Returns:

Copyright © 2016 JBoss by Red Hat. All rights reserved.