Beispiel #1
0
 /**
  *
  * Finds the appropriate service implementation and creates instance of the
  * class that implements corresponding Service Provider Interface.
  *
  * @param algorithm
  * @param service
  * @param provider
  * @throws NoSuchAlgorithmException
  */
 public void getInstance(String algorithm, java.security.Provider provider,
                         Object param)
 {//throws NoSuchAlgorithmException {
     lock (this)
     {
         java.security.Provider.Service serv = null;
         if (algorithm == null)
         {
             throw new java.security.NoSuchAlgorithmException(serviceName + " , algorithm is null"); //$NON-NLS-1$
         }
         serv = provider.getService(serviceName, algorithm);
         if (serv == null)
         {
             throw new java.security.NoSuchAlgorithmException(serviceName + " " + algorithm + " implementation not found");
         }
         spi           = serv.newInstance(param);
         this.provider = provider;
     }
 }
Beispiel #2
0
        /**
         *
         * Finds the appropriate service implementation and creates instance of the
         * class that implements corresponding Service Provider Interface.
         *
         * @param algorithm
         * @param service
         * @throws NoSuchAlgorithmException
         */
        public void getInstance(String algorithm, Object param)
        {// throws NoSuchAlgorithmException {
            lock (this)
            {
                java.security.Provider.Service serv;

                if (algorithm == null)
                {
                    throw new java.security.NoSuchAlgorithmException("Null algorithm name"); //$NON-NLS-1$
                }
                Services.refresh();
                if (returnedService != null &&
                    Util.equalsIgnoreCase(algorithm, lastAlgorithm) &&
                    refreshNumber == Services.refreshNumber)
                {
                    serv = returnedService;
                }
                else
                {
                    if (Services.isEmpty())
                    {
                        throw new java.security.NoSuchAlgorithmException(serviceName + " " + algorithm + " implementation not found");
                    }
                    serv = Services.getService(new java.lang.StringBuilder(128)
                                               .append(serviceName).append(".").append( //$NON-NLS-1$
                                                   Util.toUpperCase(algorithm)).toString());
                    if (serv == null)
                    {
                        throw new java.security.NoSuchAlgorithmException(serviceName + " " + algorithm + " implementation not found");
                    }
                    returnedService = serv;
                    lastAlgorithm   = algorithm;
                    refreshNumber   = Services.refreshNumber;
                }
                spi           = serv.newInstance(param);
                this.provider = serv.getProvider();
            }
        }
Beispiel #3
0
        private static TransformService findInstance(String algorithm,
                                                     String mechanismType, java.security.Provider provider)
        {// throws NoSuchAlgorithmException {
            if (provider == null)
            {
                provider = getProvider("TransformService", algorithm,
                                       mechanismType);
            }
            java.security.Provider.Service ps = provider.getService("TransformService",
                                                                    algorithm);
            if (ps == null)
            {
                throw new java.security.NoSuchAlgorithmException("no such algorithm: " +
                                                                 algorithm + " for provider " +
                                                                 provider.getName());
            }
            TransformService ts = (TransformService)ps.newInstance(null);

            ts.algorithm = algorithm;
            ts.mechanism = mechanismType;
            ts.provider  = provider;
            return(ts);
        }
Beispiel #4
0
 private static KeyInfoFactory findInstance(String mechanismType,
                                            java.security.Provider provider)
 {
     if (provider == null)
     {
         provider = getProvider("KeyInfoFactory", mechanismType);
     }
     java.security.Provider.Service ps = provider.getService("KeyInfoFactory",
                                                             mechanismType);
     if (ps == null)
     {
         throw new NoSuchMechanismException("Cannot find " + mechanismType +
                                            " mechanism type");
     }
     try {
         KeyInfoFactory fac = (KeyInfoFactory)ps.newInstance(null);
         fac.mechanismType = mechanismType;
         fac.provider      = provider;
         return(fac);
     } catch (java.security.NoSuchAlgorithmException nsae) {
         throw new NoSuchMechanismException("Cannot find " + mechanismType +
                                            " mechanism type", nsae);
     }
 }