Module java.smartcardio Package javax.smartcardio

Class TerminalFactory

public final class TerminalFactory extends Object

卡片终端对象创建工厂,它允许应用程序这么做:
  • 通过调用该类中的一个静态工厂方法getDefault()或getInstance()获得一个TerminalFactory。
  • 通过调用terminals()方法,使用这个TerminalFactory对象访问cardterminal。

每个终端工厂都有一个类型,该类型指示它是如何实现的。当使用getInstance()方法获得实现并可以通过getType()方法检索时,必须指定它。

定义了以下标准类型名称:

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。

pc/sc

  调用主机平台的PC/SC智能卡堆栈的实现。实现不需要参数,并且在getInstance()调用中接受“null”作为参数。

None

  不提供任何卡片终端的实现。在不支持其他实现的平台上,getDefaultType()返回None, getDefault()返回None, TerminalFactory的实例不能通过调用getInstance()方法获得这种类型的工厂。

将来可能会定义其他标准类型。

 

注意:强烈建议通过getInstance()方法接受初始化参数的提供者实现尽可能使用Properties对象作为基于字符串键-值对的参数的表示。与每个提供者使用不同的提供者特定类作为参数相比,这允许应用程序更容易地与多个提供者进行互操作。

Since:1.6

See Also:

CardTerminalsProvider

方法概要

所有方法

返回类型

方法 描述
static TerminalFactory  getDefault​() 返回默认的TerminalFactory实例。
static String getDefaultType​() 获取默认的TerminalFactory类型。
static TerminalFactory getInstance​(String type, Object params) 返回使用指定参数初始化的指定类型的TerminalFactory。
static TerminalFactory getInstance​(String type, Object params,String provider) 返回使用指定参数初始化的指定类型的TerminalFactory。
static TerminalFactory getInstance​(String type, Object params,Provider provider) 返回使用指定参数初始化的指定类型的TerminalFactory。
Provider getProvider​() 返回TerminalFactory的提供程序。
String getType​() 返回TerminalFactory的类型。
CardTerminals terminals​() 返回一个封装此工厂支持的终端的新CardTerminals对象。
String toString​() 返回TerminalFactory的字符串表示形式。
方法继承自java.lang.Object类 cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

  方法详解:

getDefaultType

public static String getDefaultType​()

获取默认的TerminalFactory类型。

它的定义如下:初始化该类时,系统属性javax.smartcardio.TerminalFactory。DefaultType检查。如果设置了该类型,则通过调用getInstance(String,Object)方法来实例化该类型的TerminalFactory,方法将null作为params的值传递。如果调用成功,类型将成为默认类型,工厂将成为默认工厂。

如果没有设置系统属性,或者getInstance()调用由于任何原因失败,系统默认为实现特定的默认类型和TerminalFactory。 Returns: the default TerminalFactory type

getDefault

public static TerminalFactory getDefault​()

返回默认的TerminalFactory实例。有关更多信息,请参见getDefaultType()。

默认的TerminalFactory总是可用的。但是,根据实现的不同,它可能不提供任何终端。 Returns: the default TerminalFactory

getInstance

public static TerminalFactory getInstance​(String type, Object params) throws NoSuchAlgorithmException

返回使用指定参数初始化的指定类型的TerminalFactory。

此方法遍历已注册的安全提供程序列表,从最首选的提供程序开始。返回一个新的TerminalFactory对象,该对象封装了来自第一个支持指定类型的提供者的TerminalFactorySpi实现。 注意,注册提供者列表可以通过Security.getProviders()方法检索。 使用指定的parameters对象初始化TerminalFactory。所需参数的类型在不同类型之间可能有所不同 实现注意:JDK引用实现还使用了JDK .security.provider。首选安全性属性,以确定指定算法的首选提供程序顺序。这可能与Security.getProviders()返回的提供者的顺序不同。 参数: 类型:请求的TerminalFactory类型 参数的个数:传递给TerminalFactorySpi实现的参数,如果不需要参数,则为null Returns: a TerminalFactory of the specified type Throws: NullPointerException - if type is null NoSuchAlgorithmException - if no Provider supports a TerminalFactorySpi of the specified type

getInstance

public static TerminalFactory getInstance​(String type, Object params, String provider) throws NoSuchAlgorithmException, NoSuchProviderException

返回使用指定参数初始化的指定类型的TerminalFactory。

返回一个新的TerminalFactory对象,该对象封装了来自指定提供程序的TerminalFactorySpi实现。指定的提供程序必须在安全提供程序列表中注册。

注意,注册提供者列表可以通过Security.getProviders()方法检索。

使用指定的parameters对象初始化TerminalFactory。需要的参数类型在不同类型的终端工厂之间可能有所不同。

参数:

类型:请求的TerminalFactory类型

参数的个数:传递给TerminalFactorySpi实现的参数,如果不需要参数,则为null

提供者:提供程序名称

Returns:

a TerminalFactory of the specified type

Throws:

NullPointerException - if type is null

IllegalArgumentException - if provider is null or the empty String

NoSuchAlgorithmException - if a TerminalFactorySpi implementation of the specified type is not available from the specified provider

NoSuchAlgorithmException - if no TerminalFactory of the specified type could be found

NoSuchProviderException - if the specified provider could not be found

getInstance

public static TerminalFactory getInstance​(String type, Object params, Provider provider) throws NoSuchAlgorithmException

返回使用指定参数初始化的指定类型的TerminalFactory。

返回一个新的TerminalFactory对象,该对象封装了来自指定提供程序对象的TerminalFactorySpi实现。请注意,指定的提供程序对象不必在提供程序列表中注册。

使用指定的parameters对象初始化TerminalFactory。需要的参数类型在不同类型的终端工厂之间可能有所不同。

参数:

类型:请求的TerminalFactory类型

参数的个数:传递给TerminalFactorySpi实现的参数,如果不需要参数,则为null

提供者:提供程序名称

Returns:

a TerminalFactory of the specified type

Throws:

NullPointerException - if type is null

IllegalArgumentException - if provider is null

NoSuchAlgorithmException - if a TerminalFactorySpi implementation of the specified type is not available from the specified Provider

getProvider

public Provider getProvider​()

返回TerminalFactory实例。

Returns:

the provider of this TerminalFactory.

getType

public String getType​()

返回TerminalFactory的类型。这是在返回此对象的getInstance()方法中指定的值。

terminals

public CardTerminals terminals​()

返回一个封装此工厂支持的终端的新CardTerminals对象。有关如何共享和重用返回的对象,请参阅CardTerminals类的类注释。

Returns:

a new CardTerminals object encapsulating the terminals supported by this factory.

toString

public String toString​()

返回TerminalFactory的字符串表示形式。

Overrides:

toString in class Object

 

Returns:

a string representation of this TerminalFactory.

 

 

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄