Package java.security

Examples of java.security.Provider


    return c.getSignature().getBytes();
  }

    public String getSigAlgName()
  {
    Provider  prov = Security.getProvider("BC");
    String    algName = prov.getProperty("Alg.Alias.Signature." + this.getSigAlgOID());

    if ( algName != null )
    {
      return algName;
    }
View Full Code Here


    }

    static Provider getProvider(String provider)
        throws NoSuchProviderException
    {
        Provider prov = Security.getProvider(provider);

        if (prov == null)
        {
            throw new NoSuchProviderException("Provider " + provider + " not found");
        }
View Full Code Here

     * return a more "meaningful" representation for the signature algorithm used in
     * the certficate.
     */
    public String getSigAlgName()
    {
        Provider    prov = Security.getProvider("BC");
        String      algName = prov.getProperty("Alg.Alias.Signature." + this.getSigAlgOID());

        if (algName != null)
        {
            return algName;
        }
View Full Code Here

  }

  static private void testDigest() {
    try {
      MessageDigest md = MessageDigest.getInstance("MD5");
      Provider p = md.getProvider();
      Set<Provider.Service> services = p.getServices();
      for (Provider.Service service : services) {
        System.out.println("Service="+service);
      }
    } catch (NoSuchAlgorithmException e) {
      e.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
View Full Code Here

    *
    * @return the provider
    */
   public static Provider getJSSEProvider()
   {
      Provider obj = null;
      ClassLoader tcl = Thread.currentThread().getContextClassLoader();
      Class clazz;
      try
      {
         clazz = tcl.loadClass(jsseProviderClassName);
View Full Code Here

         n = reqdProviders.getLength();
         //int providersLoaded = 0;

         for (int i = 0; i < n; i++)
         {
            Provider provider;
            Node reqdProvider = reqdProviders.item(i);

            String providerName;
            String providerClass;
            int requestedPosition = 0;

            if (Node.ELEMENT_NODE == reqdProvider.getNodeType())
            {
               Element prov = (Element) reqdProvider;
               if (prov.hasAttribute("class"))
               {
                  providerClass = prov.getAttribute("class");
               }
               else
               {
                  log.warn("A provider element must, at the very least, have a class attribute: " + prov);
                  continue;
               }

               try
               {
                  provider = (Provider) Class.forName(providerClass).newInstance();
               }
               catch (InstantiationException e1)
               {
                  log.warn("Unable to instantiate an instance of the JCE Provider class " + providerClass, e1);
                  continue;
               }
               catch (IllegalAccessException e1)
               {
                  log.warn("No permission to access the JCE Provider class " + providerClass, e1);
                  continue;
               }
               catch (ClassNotFoundException e1)
               {
                  log.warn("Could not find the JCE Provider class " + providerClass, e1);
                  continue;
               }
               catch (ClassCastException e1)
               {
                  log.warn("The Class " + providerClass + " is not a java.security.Provider");
                  continue;
               }

               providerName = provider.getName();

               if (prov.hasAttribute("position"))
               {
                  try
                  {
View Full Code Here

    addedJSSEProvider = false;
    try {
      new URL("https://www.https.test");
    } catch (MalformedURLException e) {
      // Install the default JSSE security provider
      Provider provider = SecurityProviderUtil.getJSSEProvider();
      log.debug("Adding " + provider.getName());

      addedJSSEProvider = Security.addProvider(provider) != -1;
      if (addedJSSEProvider) {
        log.debug("Added " + provider.getName());
      }

      addedHttpsHandler = false;
      // Install the JSSE https handler if it has not already been added
      String protocolHandler = SecurityProviderUtil
View Full Code Here

               ClassLoader loader = getContextClassLoader();
               Class<?> clazz = loader.loadClass(keyStoreProvider);
               Class<?>[] ctorSig = {String.class};
               Constructor<?> ctor = clazz.getConstructor(ctorSig);
               Object[] ctorArgs = {keyStoreProviderArgument};
               Provider provider = (Provider) ctor.newInstance(ctorArgs);
               keyStore = KeyStore.getInstance(keyStoreType, provider);
            }
            else
               keyStore = KeyStore.getInstance(keyStoreType, keyStoreProvider);
         }
         else
            keyStore = KeyStore.getInstance(keyStoreType);
         InputStream is = null;
         if ((!"PKCS11".equalsIgnoreCase(keyStoreType) || !"PKCS11IMPLKS".equalsIgnoreCase(keyStoreType)) && keyStoreURL != null)
         {
            is = keyStoreURL.openStream();
         }
         keyStore.load(is, keyStorePass);
         if (keyStoreAlias != null && !keyStore.isKeyEntry(keyStoreAlias))
         {
            throw new IOException("Cannot find key entry with alias " + keyStoreAlias + " in the keyStore");
         }
      }
      if (trustStorePass != null)
      {
         if (trustStoreType == null)
            trustStoreType = KeyStore.getDefaultType();
         if (trustStoreProvider != null)
         {
            if (trustStoreProviderArgument != null)
            {
               ClassLoader loader = getContextClassLoader();
               Class<?> clazz = loader.loadClass(trustStoreProvider);
               Class<?>[] ctorSig = {String.class};
               Constructor<?> ctor = clazz.getConstructor(ctorSig);
               Object[] ctorArgs = {trustStoreProviderArgument};
               Provider provider = (Provider) ctor.newInstance(ctorArgs);
               trustStore = KeyStore.getInstance(trustStoreType, provider);
            }
            else
               trustStore = KeyStore.getInstance(trustStoreType, trustStoreProvider);
         }
View Full Code Here

    }
  }

  protected void stopService() throws Exception {
    if (addedJSSEProvider) {
      Provider provider = SecurityProviderUtil.getJSSEProvider();
      String name = provider.getName();
      log.debug("Removing " + name);
      Security.removeProvider(name);
    }

    if (addedHttpsHandler == true) {
View Full Code Here

               ClassLoader loader = Thread.currentThread().getContextClassLoader();
               Class clazz = loader.loadClass(keyStoreProvider);
               Class[] ctorSig = {String.class};
               Constructor ctor = clazz.getConstructor(ctorSig);
               Object[] ctorArgs = {keyStoreProviderArgument};
               Provider provider = (Provider) ctor.newInstance(ctorArgs);
               keyStore = KeyStore.getInstance(keyStoreType, provider);
            }
            else
               keyStore = KeyStore.getInstance(keyStoreType, keyStoreProvider);
         }
         else
            keyStore = KeyStore.getInstance(keyStoreType);
         InputStream is = null;
         if ((!"PKCS11".equalsIgnoreCase(keyStoreType) || !"PKCS11IMPLKS".equalsIgnoreCase(keyStoreType)) && keyStoreURL != null)
         {
            is = keyStoreURL.openStream();
         }
         keyStore.load(is, keyStorePassword);
         if (keyStoreAlias != null && !keyStore.isKeyEntry(keyStoreAlias))
         {
            throw new IOException("Cannot find key entry with alias " + keyStoreAlias + " in the keyStore");
         }
         String algorithm = null;
         if (keyMgrFactoryAlgorithm != null)
            algorithm = keyMgrFactoryAlgorithm;
         else
            algorithm = KeyManagerFactory.getDefaultAlgorithm();
         if (keyMgrFactoryProvider != null)
            keyMgr = KeyManagerFactory.getInstance(algorithm, keyMgrFactoryProvider);
         else
            keyMgr = KeyManagerFactory.getInstance(algorithm);
         keyMgr.init(keyStore, keyStorePassword);
         if (keyStoreAlias != null)
         {
            KeyManager[] keyManagers = keyMgr.getKeyManagers();
            for (int i = 0; i < keyManagers.length; i++)
            {
               keyManagers[i] = new SecurityKeyManager((X509KeyManager) keyManagers[i], keyStoreAlias, clientAlias);
            }
         }
      }
      if (trustStorePassword != null)
      {
         if (trustStoreProvider != null)
         {
            if (trustStoreProviderArgument != null)
            {
               ClassLoader loader = Thread.currentThread().getContextClassLoader();
               Class clazz = loader.loadClass(trustStoreProvider);
               Class[] ctorSig = {String.class};
               Constructor ctor = clazz.getConstructor(ctorSig);
               Object[] ctorArgs = {trustStoreProviderArgument};
               Provider provider = (Provider) ctor.newInstance(ctorArgs);
               trustStore = KeyStore.getInstance(trustStoreType, provider);
            }
            else
               trustStore = KeyStore.getInstance(trustStoreType, trustStoreProvider);
         }
View Full Code Here

TOP

Related Classes of java.security.Provider

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.