模块  java.base
软件包  java.security

Class Signer

  • 实现的所有接口
    SerializablePrincipal

    @Deprecated(since="1.2",
                forRemoval=true)
    public abstract class Signer
    extends Identity
    Deprecated, for removal: This API element is subject to removal in a future version.
    This class is deprecated and subject to removal in a future version of Java SE. It has been replaced by java.security.KeyStore, the java.security.cert package, and java.security.Principal.
    此类用于表示也可以对数据进行数字签名的标识。

    签名者私钥的管理是一个重要而敏感的问题,应由子类根据其预期用途进行处理。

    从以下版本开始:
    1.1
    另请参见:
    IdentitySerialized Form
    • 构造方法详细信息

      • Signer

        protected Signer()
        Deprecated, for removal: This API element is subject to removal in a future version.
        创建签名者。 此构造函数应仅用于序列化。
      • Signer

        public Signer​(String name)
        Deprecated, for removal: This API element is subject to removal in a future version.
        创建具有指定标识名称的签名者。
        参数
        name - 身份名称。
      • Signer

        public Signer​(String name,
                      IdentityScope scope)
               throws KeyManagementException
        Deprecated, for removal: This API element is subject to removal in a future version.
        创建具有指定标识名称和范围的签名者。
        参数
        name - 身份名称。
        scope - 身份的范围。
        异常
        KeyManagementException - 如果范围中已存在具有相同名称的标识。
    • 方法详细信息

      • getPrivateKey

        public PrivateKey getPrivateKey()
        Deprecated, for removal: This API element is subject to removal in a future version.
        返回此签名者的私钥。

        首先,如果有安全管理器,其checkSecurityAccess方法被调用"getSignerPrivateKey"作为参数,看看它是否可以返回私钥。

        结果
        此签名者的私钥,如果尚未设置私钥,则返回null。
        异常
        SecurityException - 如果存在安全管理器且其 checkSecurityAccess方法不允许返回私钥。
        另请参见:
        SecurityManager.checkSecurityAccess(java.lang.String)
      • setKeyPair

        public final void setKeyPair​(KeyPair pair)
                              throws InvalidParameterException,
                                     KeyException
        Deprecated, for removal: This API element is subject to removal in a future version.
        设置此签名者的密钥对(公钥和私钥)。

        首先,如果有一个安全管理器,则调用其checkSecurityAccess方法,并以"setSignerKeyPair"作为其参数,以查看是否可以设置密钥对。

        参数
        pair - 初始化密钥对。
        异常
        InvalidParameterException - 如果密钥对未正确初始化。
        KeyException - 如果由于任何其他原因无法设置密钥对。
        SecurityException - 如果存在安全管理器且其 checkSecurityAccess方法不允许设置密钥对。
        另请参见:
        SecurityManager.checkSecurityAccess(java.lang.String)