KeyInfo objects from scratch or for
 unmarshalling a KeyInfo object from a corresponding XML
 representation.
 Each instance of KeyInfoFactory supports a specific
 XML mechanism type. To create a KeyInfoFactory, call one of the
 static getInstance methods, passing in the XML
 mechanism type desired, for example:
 
   KeyInfoFactory factory = KeyInfoFactory.getInstance("DOM");
 The objects that this factory produces will be based
 on DOM and abide by the DOM interoperability requirements as defined in the
 DOM Mechanism Requirements.
 See the KeyInfoFactory section in the 
 Java Security Standard Algorithm Names Specification for a list of
 standard mechanism types.
 
KeyInfoFactory implementations are registered and loaded
 using the Provider mechanism.
 For example, a service provider that supports the
 DOM mechanism would be specified in the Provider subclass as:
 
     put("KeyInfoFactory.DOM", "org.example.DOMKeyInfoFactory");
 
 Also, the XMLStructures that are created by this factory
 may contain state specific to the KeyInfo and are not
 intended to be reusable.
 
An implementation MUST minimally support the default mechanism type: DOM.
Note that a caller must use the same KeyInfoFactory
 instance to create the XMLStructures of a particular
 KeyInfo object. The behavior is undefined if
 XMLStructures from different providers or different mechanism
 types are used together.
 
Concurrent Access
The static methods of this class are guaranteed to be thread-safe. Multiple threads may concurrently invoke the static methods defined in this class with no ill effects.
However, this is not true for the non-static methods defined by this
 class. Unless otherwise documented by a specific provider, threads that
 need to access a single KeyInfoFactory instance concurrently
 should synchronize amongst themselves and provide the necessary locking.
 Multiple threads each manipulating a different KeyInfoFactory
 instance need not synchronize.
- Since:
- 1.6
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedDefault constructor, for invocation by subclasses.
- 
Method SummaryModifier and TypeMethodDescriptionstatic KeyInfoFactoryReturns aKeyInfoFactorythat supports the default XML processing mechanism and representation type ("DOM").static KeyInfoFactorygetInstance(String mechanismType) Returns aKeyInfoFactorythat supports the specified XML processing mechanism and representation type (ex: "DOM").static KeyInfoFactorygetInstance(String mechanismType, String provider) Returns aKeyInfoFactorythat supports the requested XML processing mechanism and representation type (ex: "DOM"), as supplied by the specified provider.static KeyInfoFactorygetInstance(String mechanismType, Provider provider) Returns aKeyInfoFactorythat supports the requested XML processing mechanism and representation type (ex: "DOM"), as supplied by the specified provider.final StringReturns the type of the XML processing mechanism and representation supported by thisKeyInfoFactory(ex: "DOM")final ProviderReturns the provider of thisKeyInfoFactory.abstract URIDereferencerReturns a reference to theURIDereferencerthat is used by default to dereference URIs inRetrievalMethodobjects.abstract booleanisFeatureSupported(String feature) Indicates whether a specified feature is supported.abstract KeyInfonewKeyInfo(List<? extends XMLStructure> content) Creates aKeyInfocontaining the specified list of key information types.abstract KeyInfonewKeyInfo(List<? extends XMLStructure> content, String id) Creates aKeyInfocontaining the specified list of key information types and optional id.abstract KeyNamenewKeyName(String name) Creates aKeyNamefrom the specified name.abstract KeyValuenewKeyValue(PublicKey key) Creates aKeyValuefrom the specified public key.abstract PGPDatanewPGPData(byte[] keyId) Creates aPGPDatafrom the specified PGP public key identifier.abstract PGPDatanewPGPData(byte[] keyId, byte[] keyPacket, List<? extends XMLStructure> other) Creates aPGPDatafrom the specified PGP public key identifier, and optional key material packet and list of external elements.abstract PGPDatanewPGPData(byte[] keyPacket, List<? extends XMLStructure> other) Creates aPGPDatafrom the specified PGP key material packet and optional list of external elements.abstract RetrievalMethodnewRetrievalMethod(String uri) Creates aRetrievalMethodfrom the specified URI.abstract RetrievalMethodnewRetrievalMethod(String uri, String type, List<? extends Transform> transforms) Creates aRetrievalMethodfrom the specified parameters.abstract X509DatanewX509Data(List<?> content) Creates aX509Datacontaining the specified list of X.509 content.abstract X509IssuerSerialnewX509IssuerSerial(String issuerName, BigInteger serialNumber) Creates anX509IssuerSerialfrom the specified X.500 issuer distinguished name and serial number.abstract KeyInfounmarshalKeyInfo(XMLStructure xmlStructure) Unmarshals a newKeyInfoinstance from a mechanism-specificXMLStructure(ex:DOMStructure) instance.
- 
Constructor Details- 
KeyInfoFactoryprotected KeyInfoFactory()Default constructor, for invocation by subclasses.
 
- 
- 
Method Details- 
getInstanceReturns aKeyInfoFactorythat supports the specified XML processing mechanism and representation type (ex: "DOM").This method uses the standard JCA provider lookup mechanism to locate and instantiate a KeyInfoFactoryimplementation of the desired mechanism type. It traverses the list of registered securityProviders, starting with the most preferredProvider. A newKeyInfoFactoryobject from the firstProviderthat supports the specified mechanism is returned.Note that the list of registered providers may be retrieved via the Security.getProviders()method.- Implementation Note:
- The JDK Reference Implementation additionally uses the
 jdk.security.provider.preferredSecurityproperty to determine the preferred provider order for the specified algorithm. This may be different than the order of providers returned bySecurity.getProviders().
- Parameters:
- mechanismType- the type of the XML processing mechanism and representation. See the- KeyInfoFactorysection in the Java Security Standard Algorithm Names Specification for a list of standard mechanism types.
- Returns:
- a new KeyInfoFactory
- Throws:
- NullPointerException- if- mechanismTypeis- null
- NoSuchMechanismException- if no- Providersupports a- KeyInfoFactoryimplementation for the specified mechanism
- See Also:
 
- 
getInstanceReturns aKeyInfoFactorythat supports the requested XML processing mechanism and representation type (ex: "DOM"), as supplied by the specified provider. Note that the specifiedProviderobject does not have to be registered in the provider list.- Parameters:
- mechanismType- the type of the XML processing mechanism and representation. See the- KeyInfoFactorysection in the Java Security Standard Algorithm Names Specification for a list of standard mechanism types.
- provider- the- Providerobject
- Returns:
- a new KeyInfoFactory
- Throws:
- NullPointerException- if- mechanismTypeor- providerare- null
- NoSuchMechanismException- if a- KeyInfoFactoryimplementation for the specified mechanism is not available from the specified- Providerobject
- See Also:
 
- 
getInstancepublic static KeyInfoFactory getInstance(String mechanismType, String provider) throws NoSuchProviderException Returns aKeyInfoFactorythat supports the requested XML processing mechanism and representation type (ex: "DOM"), as supplied by the specified provider. The specified provider must be registered in the security provider list.Note that the list of registered providers may be retrieved via the Security.getProviders()method.- Parameters:
- mechanismType- the type of the XML processing mechanism and representation. See the- KeyInfoFactorysection in the Java Security Standard Algorithm Names Specification for a list of standard mechanism types.
- provider- the string name of the provider
- Returns:
- a new KeyInfoFactory
- Throws:
- NoSuchProviderException- if the specified provider is not registered in the security provider list
- NullPointerException- if- mechanismTypeor- providerare- null
- NoSuchMechanismException- if a- KeyInfoFactoryimplementation for the specified mechanism is not available from the specified provider
- See Also:
 
- 
getInstanceReturns aKeyInfoFactorythat supports the default XML processing mechanism and representation type ("DOM").This method uses the standard JCA provider lookup mechanism to locate and instantiate a KeyInfoFactoryimplementation of the default mechanism type. It traverses the list of registered securityProviders, starting with the most preferredProvider. A newKeyInfoFactoryobject from the firstProviderthat supports the DOM mechanism is returned.Note that the list of registered providers may be retrieved via the Security.getProviders()method.- Implementation Note:
- The JDK Reference Implementation additionally uses the
 jdk.security.provider.preferredSecurityproperty to determine the preferred provider order for the specified algorithm. This may be different than the order of providers returned bySecurity.getProviders().
- Returns:
- a new KeyInfoFactory
- Throws:
- NoSuchMechanismException- if no- Providersupports a- KeyInfoFactoryimplementation for the DOM mechanism
- See Also:
 
- 
getMechanismTypeReturns the type of the XML processing mechanism and representation supported by thisKeyInfoFactory(ex: "DOM")- Returns:
- the XML processing mechanism type supported by this
    KeyInfoFactory
 
- 
getProviderReturns the provider of thisKeyInfoFactory.- Returns:
- the provider of this KeyInfoFactory
 
- 
newKeyInfoCreates aKeyInfocontaining the specified list of key information types.- Parameters:
- content- a list of one or more- XMLStructures representing key information types. The list is defensively copied to protect against subsequent modification.
- Returns:
- a KeyInfo
- Throws:
- NullPointerException- if- contentis- null
- IllegalArgumentException- if- contentis empty
- ClassCastException- if- contentcontains any entries that are not of type- XMLStructure
 
- 
newKeyInfoCreates aKeyInfocontaining the specified list of key information types and optional id. Theidparameter represents the value of an XMLIDattribute and is useful for referencing theKeyInfofrom other XML structures.- Parameters:
- content- a list of one or more- XMLStructures representing key information types. The list is defensively copied to protect against subsequent modification.
- id- the value of an XML- ID(may be- null)
- Returns:
- a KeyInfo
- Throws:
- NullPointerException- if- contentis- null
- IllegalArgumentException- if- contentis empty
- ClassCastException- if- contentcontains any entries that are not of type- XMLStructure
 
- 
newKeyNameCreates aKeyNamefrom the specified name.- Parameters:
- name- the name that identifies the key
- Returns:
- a KeyName
- Throws:
- NullPointerException- if- nameis- null
 
- 
newKeyValueCreates aKeyValuefrom the specified public key.- Parameters:
- key- the public key
- Returns:
- a KeyValue
- Throws:
- KeyException- if the- key's algorithm is not recognized or supported by this- KeyInfoFactory
- NullPointerException- if- keyis- null
 
- 
newPGPDataCreates aPGPDatafrom the specified PGP public key identifier.- Parameters:
- keyId- a PGP public key identifier as defined in RFC 2440, section 11.2. The array is cloned to protect against subsequent modification.
- Returns:
- a PGPData
- Throws:
- NullPointerException- if- keyIdis- null
- IllegalArgumentException- if the key id is not in the correct format
 
- 
newPGPDatapublic abstract PGPData newPGPData(byte[] keyId, byte[] keyPacket, List<? extends XMLStructure> other) Creates aPGPDatafrom the specified PGP public key identifier, and optional key material packet and list of external elements.- Parameters:
- keyId- a PGP public key identifier as defined in RFC 2440, section 11.2. The array is cloned to protect against subsequent modification.
- keyPacket- a PGP key material packet as defined in RFC 2440, section 5.5. The array is cloned to protect against subsequent modification. May be- null.
- other- a list of- XMLStructures representing elements from an external namespace. The list is defensively copied to protect against subsequent modification. May be- nullor empty.
- Returns:
- a PGPData
- Throws:
- NullPointerException- if- keyIdis- null
- IllegalArgumentException- if the- keyIdor- keyPacketis not in the correct format. For- keyPacket, the format of the packet header is checked and the tag is verified that it is of type key material. The contents and format of the packet body are not checked.
- ClassCastException- if- othercontains any entries that are not of type- XMLStructure
 
- 
newPGPDataCreates aPGPDatafrom the specified PGP key material packet and optional list of external elements.- Parameters:
- keyPacket- a PGP key material packet as defined in RFC 2440, section 5.5. The array is cloned to protect against subsequent modification.
- other- a list of- XMLStructures representing elements from an external namespace. The list is defensively copied to protect against subsequent modification. May be- nullor empty.
- Returns:
- a PGPData
- Throws:
- NullPointerException- if- keyPacketis- null
- IllegalArgumentException- if- keyPacketis not in the correct format. For- keyPacket, the format of the packet header is checked and the tag is verified that it is of type key material. The contents and format of the packet body are not checked.
- ClassCastException- if- othercontains any entries that are not of type- XMLStructure
 
- 
newRetrievalMethodCreates aRetrievalMethodfrom the specified URI.- Parameters:
- uri- the URI that identifies the- KeyInfoinformation to be retrieved
- Returns:
- a RetrievalMethod
- Throws:
- NullPointerException- if- uriis- null
- IllegalArgumentException- if- uriis not RFC 2396 compliant
 
- 
newRetrievalMethodpublic abstract RetrievalMethod newRetrievalMethod(String uri, String type, List<? extends Transform> transforms) Creates aRetrievalMethodfrom the specified parameters.- Parameters:
- uri- the URI that identifies the- KeyInfoinformation to be retrieved
- type- a URI that identifies the type of- KeyInfoinformation to be retrieved (may be- null)
- transforms- a list of- Transforms. The list is defensively copied to protect against subsequent modification. May be- nullor empty.
- Returns:
- a RetrievalMethod
- Throws:
- NullPointerException- if- uriis- null
- IllegalArgumentException- if- uriis not RFC 2396 compliant
- ClassCastException- if- transformscontains any entries that are not of type- Transform
 
- 
newX509DataCreates aX509Datacontaining the specified list of X.509 content.- Parameters:
- content- a list of one or more X.509 content types. Valid types are- String(subject names),- byte[](subject key ids),- X509Certificate,- X509CRL, or- XMLStructure(- X509IssuerSerialobjects or elements from an external namespace). Subject names are distinguished names in RFC 2253 String format. Implementations MUST support the attribute type keywords defined in RFC 2253 (CN, L, ST, O, OU, C, STREET, DC and UID). Implementations MAY support additional keywords. The list is defensively copied to protect against subsequent modification.
- Returns:
- a X509Data
- Throws:
- NullPointerException- if- contentis- null
- IllegalArgumentException- if- contentis empty, or if a subject name is not RFC 2253 compliant or one of the attribute type keywords is not recognized.
- ClassCastException- if- contentcontains any entries that are not of one of the valid types mentioned above
 
- 
newX509IssuerSerialCreates anX509IssuerSerialfrom the specified X.500 issuer distinguished name and serial number.- Parameters:
- issuerName- the issuer's distinguished name in RFC 2253 String format. Implementations MUST support the attribute type keywords defined in RFC 2253 (CN, L, ST, O, OU, C, STREET, DC and UID). Implementations MAY support additional keywords.
- serialNumber- the serial number
- Returns:
- an X509IssuerSerial
- Throws:
- NullPointerException- if- issuerNameor- serialNumberare- null
- IllegalArgumentException- if the issuer name is not RFC 2253 compliant or one of the attribute type keywords is not recognized.
 
- 
isFeatureSupportedIndicates whether a specified feature is supported.- Parameters:
- feature- the feature name (as an absolute URI)
- Returns:
- trueif the specified feature is supported,- falseotherwise
- Throws:
- NullPointerException- if- featureis- null
 
- 
getURIDereferencerReturns a reference to theURIDereferencerthat is used by default to dereference URIs inRetrievalMethodobjects.- Returns:
- a reference to the default URIDereferencer
 
- 
unmarshalKeyInfoUnmarshals a newKeyInfoinstance from a mechanism-specificXMLStructure(ex:DOMStructure) instance.- Parameters:
- xmlStructure- a mechanism-specific XML structure from which to unmarshal the keyinfo from
- Returns:
- the KeyInfo
- Throws:
- NullPointerException- if- xmlStructureis- null
- ClassCastException- if the type of- xmlStructureis inappropriate for this factory
- MarshalException- if an unrecoverable exception occurs during unmarshalling
 
 
-