Método de elementos de proveedor() en Java con ejemplos

El método de elements() de la clase java.security.Provider se utiliza para devolver una enumeración de los valores en la tabla hash dada. 
Sintaxis: 
 

public Enumeration<Object> elements()

Valor devuelto: este método devuelve una enumeración de los valores en la tabla hash.
A continuación se muestran los ejemplos para ilustrar el método de elements() :
Ejemplo 1:
 

Java

// Java program to demonstrate
// elements() method
 
import java.security.*;
import java.util.*;
 
public class GFG1 {
    public static void main(String[] argv)
    {
        try {
            // creating the object of SecureRandom
            SecureRandom sr = SecureRandom.getInstance("SHA1PRNG");
 
            // getting the Provider of the SecureRandom sr
            // by using method getProvider()
            Provider provider = sr.getProvider();
 
            // printing the Provider
            System.out.println("Provider of the SHA1PRNG: " + provider);
 
            // Declaring the variable of Enumeration<Object> type
            Enumeration<Object> enume;
 
            // getting the enumeration of the values
            enume = provider.elements();
 
            // printing the enumerated value
            System.out.println("Enumeration of the values: \n");
 
            while (enume.hasMoreElements()) {
                System.out.println("Value is: " + enume.nextElement());
            }
        }
 
        catch (NoSuchAlgorithmException e) {
 
            System.out.println("Exception thrown : " + e);
        }
    }
}
Producción: 

Provider of the SHA1PRNG: SUN version 1.8
Enumeration of the values: 

Value is: SHA1withDSA
Value is: SHA1withDSA
Value is: SHA1withDSA
Value is: Software
Value is: sun.security.provider.JavaKeyStore$DualFormatJKS
Value is: SHA
Value is: sun.security.provider.SHA
Value is: sun.security.provider.JavaKeyStore$CaseExactJKS
Value is: Software
Value is: sun.security.provider.DSA$SHA256withDSA
Value is: SHA
Value is: SHA1withDSA
Value is: Software
Value is: Software
Value is: Software
Value is: sun.security.provider.DSA$RawDSA
Value is: X.509
Value is: java.security.interfaces.DSAPublicKey|java.security.interfaces.DSAPrivateKey
Value is: sun.security.provider.certpath.IndexedCollectionCertStore
Value is: sun.security.provider.Sun
Value is: SHA
Value is: SHA1withDSA
Value is: sun.security.provider.DomainKeyStore$DKS
Value is: Software
Value is: SHA256withDSA
Value is: SHA224withDSA
Value is: 1024
Value is: 1024
Value is: Software
Value is: sun.security.provider.DSAKeyFactory
Value is: sun.security.provider.ConfigFile$Spi
Value is: SHA1withDSA
Value is: SHA-224
Value is: DSA
Value is: Software
Value is: SHA-512
Value is: SHA-384
Value is: SHA-256
Value is: NONEwithDSA
Value is: SUN
Value is: DSA
Value is: RFC3280
Value is: sun.security.provider.PolicySpiFile
Value is: 2048
Value is: DSA
Value is: DSA
Value is: SHA1withDSA
Value is: DSA
Value is: sun.security.provider.SHA5$SHA384
Value is: sun.security.provider.SHA2$SHA224
Value is: Software
Value is: sun.security.provider.DSAParameterGenerator
Value is: java.security.interfaces.DSAPublicKey|java.security.interfaces.DSAPrivateKey
Value is: sun.security.provider.NativePRNG$Blocking
Value is: sun.security.provider.SHA5$SHA512
Value is: DSA
Value is: sun.security.provider.certpath.SunCertPathBuilder
Value is: SHA1withDSA
Value is: SHA-224
Value is: Software
Value is: SHA-512
Value is: 1.8
Value is: SHA-384
Value is: 2048
Value is: SHA-256
Value is: sun.security.provider.DSAParameters
Value is: java.security.interfaces.DSAPublicKey|java.security.interfaces.DSAPrivateKey
Value is: sun.security.provider.certpath.CollectionCertStore
Value is: Software
Value is: sun.security.provider.NativePRNG$NonBlocking
Value is: 2048
Value is: sun.security.provider.certpath.ldap.LDAPCertStore
Value is: sun.security.provider.X509Factory
Value is: SHA256withDSA
Value is: SHA224withDSA
Value is: sun.security.provider.NativePRNG
Value is: RFC2587
Value is: Software
Value is: Software
Value is: RFC3280
Value is: Software
Value is: sun.security.provider.DSA$SHA224withDSA
Value is: SHA1withDSA
Value is: sun.security.provider.certpath.PKIXCertPathValidator
Value is: SHA
Value is: 2048
Value is: sun.security.provider.SecureRandom
Value is: sun.security.provider.DSA$SHA1withDSA
Value is: DSA
Value is: Software
Value is: sun.security.provider.DSAKeyPairGenerator$Current
Value is: SUN (DSA key/parameter generation; DSA signing; SHA-1, MD5 digests; SecureRandom; X.509 certificates; JKS & DKS keystores; PKIX CertPathValidator; PKIX CertPathBuilder; LDAP, Collection CertStores, JavaPolicy Policy; JavaLoginConfig Configuration)
Value is: DSA
Value is: SHA1withDSA
Value is: sun.security.provider.MD5
Value is: SHA1withDSA
Value is: sun.security.provider.SHA2$SHA256
Value is: DSA
Value is: java.security.interfaces.DSAPublicKey|java.security.interfaces.DSAPrivateKey
Value is: sun.security.provider.MD2

 

Ejemplo 2: 
 

Java

// Java program to demonstrate
// elements() method
 
import java.security.*;
import java.util.*;
 
public class GFG1 {
    public static void main(String[] argv) throws Exception
    {
 
        try {
            // creating the object of  KeyPairGenerator
            KeyPairGenerator sr = KeyPairGenerator.getInstance("DSA", "SUN");
 
            // getting the Provider of the KeyPairGenerator sr
            // by using method getProvider()
            Provider provider = sr.getProvider();
 
            // printing the Provider
            System.out.println("Provider of the DSA, SUN: " + provider);
 
            // Declaring the variable of Enumeration<Object> type
            Enumeration<Object> enume;
 
            // getting the enumeration of the values
            enume = provider.elements();
 
            // printing the enumerated value
            System.out.println("enumeration of the values: \n");
            while (enume.hasMoreElements()) {
                System.out.println("Value is: " + enume.nextElement());
            }
        }
 
        catch (NoSuchAlgorithmException e) {
 
            System.out.println("Exception thrown : " + e);
        }
    }
}
Producción: 

Provider of the DSA, SUN: SUN version 1.8
enumeration of the values: 

Value is: SHA1withDSA
Value is: SHA1withDSA
Value is: SHA1withDSA
Value is: Software
Value is: sun.security.provider.JavaKeyStore$DualFormatJKS
Value is: SHA
Value is: sun.security.provider.SHA
Value is: sun.security.provider.JavaKeyStore$CaseExactJKS
Value is: Software
Value is: sun.security.provider.DSA$SHA256withDSA
Value is: SHA
Value is: SHA1withDSA
Value is: Software
Value is: Software
Value is: Software
Value is: sun.security.provider.DSA$RawDSA
Value is: X.509
Value is: java.security.interfaces.DSAPublicKey|java.security.interfaces.DSAPrivateKey
Value is: sun.security.provider.certpath.IndexedCollectionCertStore
Value is: sun.security.provider.Sun
Value is: SHA
Value is: SHA1withDSA
Value is: sun.security.provider.DomainKeyStore$DKS
Value is: Software
Value is: SHA256withDSA
Value is: SHA224withDSA
Value is: 1024
Value is: 1024
Value is: Software
Value is: sun.security.provider.DSAKeyFactory
Value is: sun.security.provider.ConfigFile$Spi
Value is: SHA1withDSA
Value is: SHA-224
Value is: DSA
Value is: Software
Value is: SHA-512
Value is: SHA-384
Value is: SHA-256
Value is: NONEwithDSA
Value is: SUN
Value is: DSA
Value is: RFC3280
Value is: sun.security.provider.PolicySpiFile
Value is: 2048
Value is: DSA
Value is: DSA
Value is: SHA1withDSA
Value is: DSA
Value is: sun.security.provider.SHA5$SHA384
Value is: sun.security.provider.SHA2$SHA224
Value is: Software
Value is: sun.security.provider.DSAParameterGenerator
Value is: java.security.interfaces.DSAPublicKey|java.security.interfaces.DSAPrivateKey
Value is: sun.security.provider.NativePRNG$Blocking
Value is: sun.security.provider.SHA5$SHA512
Value is: DSA
Value is: sun.security.provider.certpath.SunCertPathBuilder
Value is: SHA1withDSA
Value is: SHA-224
Value is: Software
Value is: SHA-512
Value is: 1.8
Value is: SHA-384
Value is: 2048
Value is: SHA-256
Value is: sun.security.provider.DSAParameters
Value is: java.security.interfaces.DSAPublicKey|java.security.interfaces.DSAPrivateKey
Value is: sun.security.provider.certpath.CollectionCertStore
Value is: Software
Value is: sun.security.provider.NativePRNG$NonBlocking
Value is: 2048
Value is: sun.security.provider.certpath.ldap.LDAPCertStore
Value is: sun.security.provider.X509Factory
Value is: SHA256withDSA
Value is: SHA224withDSA
Value is: sun.security.provider.NativePRNG
Value is: RFC2587
Value is: Software
Value is: Software
Value is: RFC3280
Value is: Software
Value is: sun.security.provider.DSA$SHA224withDSA
Value is: SHA1withDSA
Value is: sun.security.provider.certpath.PKIXCertPathValidator
Value is: SHA
Value is: 2048
Value is: sun.security.provider.SecureRandom
Value is: sun.security.provider.DSA$SHA1withDSA
Value is: DSA
Value is: Software
Value is: sun.security.provider.DSAKeyPairGenerator$Current
Value is: SUN (DSA key/parameter generation; DSA signing; SHA-1, MD5 digests; SecureRandom; X.509 certificates; JKS & DKS keystores; PKIX CertPathValidator; PKIX CertPathBuilder; LDAP, Collection CertStores, JavaPolicy Policy; JavaLoginConfig Configuration)
Value is: DSA
Value is: SHA1withDSA
Value is: sun.security.provider.MD5
Value is: SHA1withDSA
Value is: sun.security.provider.SHA2$SHA256
Value is: DSA
Value is: java.security.interfaces.DSAPublicKey|java.security.interfaces.DSAPrivateKey
Value is: sun.security.provider.MD2

 

Publicación traducida automáticamente

Artículo escrito por RohitPrasad3 y traducido por Barcelona Geeks. The original can be accessed here. Licence: CCBY-SA

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *