FileDocCategorySizeDatePackage
Engine.javaAPI DocAndroid 1.5 API4434Wed May 06 22:41:06 BST 2009org.apache.harmony.security.fortress

Engine

public class Engine extends Object
This class implements common functionality for all engine classes

Fields Summary
private String
serviceName
private Provider$Service
returnedService
private String
lastAlgorithm
private int
refreshNumber
public Provider
provider
Provider
public Object
spi
SPI instance
public static SecurityAccess
door
Access to package visible api in java.security
Constructors Summary
public Engine(String service)
Creates a Engine object

param
service

        this.serviceName = service;
    
Methods Summary
public synchronized voidgetInstance(java.lang.String algorithm, java.lang.Object param)
Finds the appropriate service implementation and creates instance of the class that implements corresponding Service Provider Interface.

param
algorithm
param
service
throws
NoSuchAlgorithmException

        Provider.Service serv;

        if (algorithm == null) {
            throw new NoSuchAlgorithmException(Messages.getString("security.149")); //$NON-NLS-1$
        }
        Services.refresh();
        if (returnedService != null
                && algorithm.equalsIgnoreCase(lastAlgorithm)
                && refreshNumber == Services.refreshNumber) {
            serv = returnedService;
        } else {
            if (Services.isEmpty()) {
                throw new NoSuchAlgorithmException(Messages.getString("security.14A", //$NON-NLS-1$
                        serviceName, algorithm));
            }
            serv = Services.getService(new StringBuffer(128)
                    .append(serviceName).append(".").append( //$NON-NLS-1$
                            algorithm.toUpperCase()).toString());
            if (serv == null) {
                throw new NoSuchAlgorithmException(Messages.getString("security.14A", //$NON-NLS-1$
                        serviceName, algorithm));
            }
            returnedService = serv;
            lastAlgorithm = algorithm;
            refreshNumber = Services.refreshNumber;
        }
        spi = serv.newInstance(param);
        this.provider = serv.getProvider();
    
public synchronized voidgetInstance(java.lang.String algorithm, java.security.Provider provider, java.lang.Object param)
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


        Provider.Service serv = null;
        if (algorithm == null) {
            throw new NoSuchAlgorithmException(
                    Messages.getString("security.14B", serviceName)); //$NON-NLS-1$
        }
        serv = provider.getService(serviceName, algorithm);
        if (serv == null) {
            throw new NoSuchAlgorithmException(Messages.getString("security.14A", //$NON-NLS-1$
                    serviceName, algorithm));
        }
        spi = serv.newInstance(param);
        this.provider = provider;