Class X509CertSupportNatives


  • public class X509CertSupportNatives
    extends java.lang.Object
    Mock implementation of the LLAPI: LLSEC_X509
    • Field Detail

      • J_UNKNOWN_ERROR

        protected static final int J_UNKNOWN_ERROR
        Unknown error
        See Also:
        Constant Field Values
      • J_X509_CERT_EXPIRED_ERROR

        protected static final int J_X509_CERT_EXPIRED_ERROR
        X509 certificate checkValidity error: expired
        See Also:
        Constant Field Values
      • J_X509_CERT_NOT_YET_VALID_ERROR

        protected static final int J_X509_CERT_NOT_YET_VALID_ERROR
        X509 certificate checkValidity error: not yet valid
        See Also:
        Constant Field Values
    • Constructor Detail

      • X509CertSupportNatives

        public X509CertSupportNatives()
    • Method Detail

      • parse

        public static int parse​(byte[] cert,
                                int off,
                                int len)
        Parses the given certificate to validate it and returns its encoded format type.
        Parameters:
        cert - the certificate buffer
        off - the offset in the buffer at which the certificate content starts
        len - the certificate content length
        Returns:
        the certificate encoded format type (0 if PEM format or 1 if DER format); J_CERT_PARSE_ERROR if the certificate is not valid or an error occurs.
      • getKeyData

        public static int getKeyData​(byte[] cert,
                                     int certLen)
                              throws ej.sni.NativeException
        Extracts the public key from the given certificate and registers it as a native resource.
        Parameters:
        cert - the certificate buffer
        certLen - the certificate content length
        Returns:
        the registered native resource id holding the certificate's public key.
        Throws:
        ej.sni.NativeException - on error.
      • verify

        public static int verify​(byte[] cert,
                                 int certLength,
                                 int nativeId)
                          throws ej.sni.NativeException
        Throws:
        ej.sni.NativeException
      • getX500PrincipalData

        public static int getX500PrincipalData​(byte[] cert,
                                               int certLen,
                                               byte[] principalData,
                                               int principalDataLength,
                                               boolean getIssuer)
                                        throws ej.sni.NativeException
        Throws:
        ej.sni.NativeException
      • nativeGetCloseKeyId

        public static int nativeGetCloseKeyId()
      • checkValidity

        public static int checkValidity​(byte[] cert,
                                        int certLen)
                                 throws ej.sni.NativeException
        Checks that the certificate is currently valid, i.e. the current time is within the specified validity period.
        Parameters:
        cert - the encoded certificate data
        certLen - encoded data length
        Returns:
        J_SEC_NO_ERROR on success, J_X509_CERT_EXPIRED_ERROR if certificate expired, J_X509_CERT_NOT_YET_VALID_ERROR if certificate is not yet valid
        Throws:
        ej.sni.NativeException - on error
      • newCertPathValidator

        public static int newCertPathValidator()
      • appendTrustedCertificate

        public static int appendTrustedCertificate​(int cpv,
                                                   byte[] x509)
      • expectForwardCertPath

        public static boolean expectForwardCertPath()
      • appendCertToPath

        public static int appendCertToPath​(int cpv,
                                           byte[] x509)
      • validateCertPath

        public static int validateCertPath​(int cpv)
                                    throws java.security.GeneralSecurityException
        Throws:
        java.security.GeneralSecurityException
      • closeCertPathValidator

        public static void closeCertPathValidator​(int cpv)