Class Identities


  • public final class Identities
    extends java.lang.Object
    This class consists exclusively of static methods used to create and operate on identity information.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static X509Identity newX509Identity​(java.lang.String mspId, java.security.cert.X509Certificate certificate, java.security.PrivateKey privateKey)
      Create a new identity using X.509 credentials.
      static X509Identity newX509Identity​(java.lang.String mspId, org.hyperledger.fabric.sdk.Enrollment enrollment)
      Create a new X.509 identity from an enrollment returned from a Certificate Authority.
      static java.security.PrivateKey readPrivateKey​(java.io.Reader pemReader)
      Read a PEM format private key.
      static java.security.PrivateKey readPrivateKey​(java.lang.String pem)
      Read a PEM format private key.
      static java.security.cert.X509Certificate readX509Certificate​(java.io.Reader pemReader)
      Read a PEM format X.509 certificate.
      static java.security.cert.X509Certificate readX509Certificate​(java.lang.String pem)
      Read a PEM format X.509 certificate.
      static java.lang.String toPemString​(java.security.cert.Certificate certificate)
      Converts the argument to a PEM format string.
      static java.lang.String toPemString​(java.security.PrivateKey privateKey)
      Converts the argument to a PKCS #8 PEM format string.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • newX509Identity

        public static X509Identity newX509Identity​(java.lang.String mspId,
                                                   java.security.cert.X509Certificate certificate,
                                                   java.security.PrivateKey privateKey)
        Create a new identity using X.509 credentials.
        Parameters:
        mspId - Member Services Provider identifier for the organization to which this identity belongs.
        certificate - An X.509 certificate.
        privateKey - Private key.
        Returns:
        An identity.
        Throws:
        java.lang.NullPointerException - if any of the arguments are null.
      • newX509Identity

        public static X509Identity newX509Identity​(java.lang.String mspId,
                                                   org.hyperledger.fabric.sdk.Enrollment enrollment)
                                            throws java.security.cert.CertificateException
        Create a new X.509 identity from an enrollment returned from a Certificate Authority.
        Parameters:
        mspId - Member Services Provider identifier.
        enrollment - Identity credentials.
        Returns:
        An identity.
        Throws:
        java.security.cert.CertificateException - if the certificate is invalid.
        java.lang.NullPointerException - if any of the arguments are null.
      • readX509Certificate

        public static java.security.cert.X509Certificate readX509Certificate​(java.lang.String pem)
                                                                      throws java.security.cert.CertificateException
        Read a PEM format X.509 certificate.
        Parameters:
        pem - PEM data.
        Returns:
        An X.509 certificate.
        Throws:
        java.security.cert.CertificateException - if the data is not valid X.509 certificate PEM.
      • readX509Certificate

        public static java.security.cert.X509Certificate readX509Certificate​(java.io.Reader pemReader)
                                                                      throws java.io.IOException,
                                                                             java.security.cert.CertificateException
        Read a PEM format X.509 certificate.
        Parameters:
        pemReader - Reader of PEM data.
        Returns:
        An X.509 certificate.
        Throws:
        java.io.IOException - if an error occurs reading data.
        java.security.cert.CertificateException - if the data is not valid X.509 certificate PEM.
      • readPrivateKey

        public static java.security.PrivateKey readPrivateKey​(java.lang.String pem)
                                                       throws java.security.InvalidKeyException
        Read a PEM format private key.
        Parameters:
        pem - PEM data.
        Returns:
        An X.509 certificate.
        Throws:
        java.security.InvalidKeyException - if the data is not valid private key PEM.
      • readPrivateKey

        public static java.security.PrivateKey readPrivateKey​(java.io.Reader pemReader)
                                                       throws java.io.IOException,
                                                              java.security.InvalidKeyException
        Read a PEM format private key.
        Parameters:
        pemReader - Reader of PEM data.
        Returns:
        A private key.
        Throws:
        java.io.IOException - if an error occurs reading data.
        java.security.InvalidKeyException - if the data is not valid private key PEM.
      • toPemString

        public static java.lang.String toPemString​(java.security.cert.Certificate certificate)
        Converts the argument to a PEM format string.
        Parameters:
        certificate - A certificate.
        Returns:
        A PEM format string.
      • toPemString

        public static java.lang.String toPemString​(java.security.PrivateKey privateKey)
        Converts the argument to a PKCS #8 PEM format string.
        Parameters:
        privateKey - A private key.
        Returns:
        A PEM format string.
        Throws:
        java.lang.IllegalArgumentException - if the argument can not be represented in PKCS #8 PEM format.