Class OxAuthCryptoProvider


  • public class OxAuthCryptoProvider
    extends AbstractCryptoProvider
    Version:
    April 25, 2022
    Author:
    Javier Rojas Blum, Yuriy Movchan, Sergey Manoylo
    • Field Detail

      • LOG

        protected static final org.apache.log4j.Logger LOG
    • Constructor Detail

      • OxAuthCryptoProvider

        public OxAuthCryptoProvider()
                             throws java.lang.Exception
        Throws:
        java.lang.Exception
      • OxAuthCryptoProvider

        public OxAuthCryptoProvider​(java.lang.String keyStoreFile,
                                    java.lang.String keyStoreSecret,
                                    java.lang.String dnName)
                             throws java.lang.Exception
        Throws:
        java.lang.Exception
      • OxAuthCryptoProvider

        public OxAuthCryptoProvider​(java.lang.String keyStoreFile,
                                    java.lang.String keyStoreSecret,
                                    java.lang.String dnName,
                                    boolean rejectNoneAlg)
                             throws java.lang.Exception
        Throws:
        java.lang.Exception
      • OxAuthCryptoProvider

        public OxAuthCryptoProvider​(java.lang.String keyStoreFile,
                                    java.lang.String keyStoreSecret,
                                    java.lang.String dnName,
                                    boolean rejectNoneAlg,
                                    KeySelectionStrategy keySelectionStrategy)
                             throws java.lang.Exception
        Throws:
        java.lang.Exception
    • Method Detail

      • load

        public void load​(java.lang.String keyStoreSecret)
      • getKeyStoreFile

        public java.lang.String getKeyStoreFile()
      • getKeyStoreSecret

        public java.lang.String getKeyStoreSecret()
      • getDnName

        public java.lang.String getDnName()
      • generateKey

        public org.json.JSONObject generateKey​(Algorithm algorithm,
                                               java.lang.Long expirationTime,
                                               Use use)
                                        throws java.lang.Exception
        Specified by:
        generateKey in class AbstractCryptoProvider
        Throws:
        java.lang.Exception
      • generateKey

        public org.json.JSONObject generateKey​(Algorithm algorithm,
                                               java.lang.Long expirationTime,
                                               Use use,
                                               int keyLength)
                                        throws java.lang.Exception
        Specified by:
        generateKey in class AbstractCryptoProvider
        Throws:
        java.lang.Exception
      • getAliasByAlgorithmForDeletion

        public java.lang.String getAliasByAlgorithmForDeletion​(Algorithm algorithm,
                                                               java.lang.String newAlias,
                                                               Use use)
                                                        throws java.security.KeyStoreException
        Throws:
        java.security.KeyStoreException
      • sign

        public java.lang.String sign​(java.lang.String signingInput,
                                     java.lang.String alias,
                                     java.lang.String sharedSecret,
                                     SignatureAlgorithm signatureAlgorithm)
                              throws java.lang.Exception
        Specified by:
        sign in class AbstractCryptoProvider
        Throws:
        java.lang.Exception
      • verifySignature

        public boolean verifySignature​(java.lang.String signingInput,
                                       java.lang.String encodedSignature,
                                       java.lang.String alias,
                                       org.json.JSONObject jwks,
                                       java.lang.String sharedSecret,
                                       SignatureAlgorithm signatureAlgorithm)
                                throws java.lang.Exception
        Specified by:
        verifySignature in class AbstractCryptoProvider
        Throws:
        java.lang.Exception
      • deleteKey

        public boolean deleteKey​(java.lang.String alias)
                          throws java.lang.Exception
        Specified by:
        deleteKey in class AbstractCryptoProvider
        Throws:
        java.lang.Exception
      • getPublicKey

        public java.security.PublicKey getPublicKey​(java.lang.String alias)
      • getPrivateKey

        public java.security.PrivateKey getPrivateKey​(java.lang.String alias)
                                               throws java.security.UnrecoverableKeyException,
                                                      java.security.NoSuchAlgorithmException,
                                                      java.security.KeyStoreException
        Specified by:
        getPrivateKey in class AbstractCryptoProvider
        Throws:
        java.security.UnrecoverableKeyException
        java.security.NoSuchAlgorithmException
        java.security.KeyStoreException
      • generateV3Certificate

        public java.security.cert.X509Certificate generateV3Certificate​(java.security.KeyPair keyPair,
                                                                        java.lang.String issuer,
                                                                        java.lang.String signatureAlgorithm,
                                                                        java.lang.Long expirationTime)
                                                                 throws org.bouncycastle.cert.CertIOException,
                                                                        org.bouncycastle.operator.OperatorCreationException,
                                                                        java.security.cert.CertificateException
        Throws:
        org.bouncycastle.cert.CertIOException
        org.bouncycastle.operator.OperatorCreationException
        java.security.cert.CertificateException
      • getSignatureAlgorithm

        public SignatureAlgorithm getSignatureAlgorithm​(java.lang.String alias)
                                                 throws java.security.KeyStoreException
        Throws:
        java.security.KeyStoreException
      • getKeyStore

        public java.security.KeyStore getKeyStore()
      • checkExtension

        public static boolean checkExtension​(java.lang.String extension,
                                             org.gluu.util.security.SecurityProviderUtility.SecurityModeType securityMode)
        Checks, if SecurityModeType value correspondent to the keystorage extension value
        Parameters:
        extension - extension value
        securityMode - SecurityModeType value
        Returns:
        boolean result