|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.opensaml.xml.security.keyinfo.KeyInfoHelper
public class KeyInfoHelper
Utility class for working with data inside a KeyInfo object. Methods are provided for converting the representation stored in the XMLTooling KeyInfo to Java java.security native types, and for storing these Java native types inside a KeyInfo.
Constructor Summary | |
---|---|
protected |
KeyInfoHelper()
Constructor. |
Method Summary | |
---|---|
static void |
addCertificate(KeyInfo keyInfo,
java.security.cert.X509Certificate cert)
Converts a native Java X509Certificate into the corresponding
XMLObject and stores it in a KeyInfo in the first X509Data element. |
static void |
addCRL(KeyInfo keyInfo,
java.security.cert.X509CRL crl)
Converts a native Java X509CRL into the corresponding XMLObject and stores it
in a KeyInfo in the first X509Data element. |
static void |
addKeyName(KeyInfo keyInfo,
java.lang.String keyNameValue)
Add a new KeyName value to a KeyInfo. |
static void |
addPublicKey(KeyInfo keyInfo,
java.security.PublicKey pk)
Converts a Java DSA or RSA public key into the corresponding XMLObject and stores it in a KeyInfo in a new KeyValue element. |
static DSAKeyValue |
buildDSAKeyValue(java.security.interfaces.DSAPublicKey dsaPubKey)
Builds a DSAKeyValue XMLObject from the Java security DSA public key type. |
protected static java.security.PublicKey |
buildKey(java.security.spec.KeySpec keySpec,
java.lang.String keyAlgorithm)
Generates a public key from the given key spec. |
static RSAKeyValue |
buildRSAKeyValue(java.security.interfaces.RSAPublicKey rsaPubKey)
Builds an RSAKeyValue XMLObject from the Java security RSA public key type. |
static X509Certificate |
buildX509Certificate(java.security.cert.X509Certificate cert)
Builds an X509Certificate XMLObject from a native
Java X509Certificate . |
static X509CRL |
buildX509CRL(java.security.cert.X509CRL crl)
Builds an X509CRL XMLObject from
a native Java X509CRL . |
static X509IssuerSerial |
buildX509IssuerSerial(java.lang.String issuerName,
java.math.BigInteger serialNumber)
Build an X509IssuerSerial containing a given issuer name and serial number. |
static X509SKI |
buildX509SKI(java.security.cert.X509Certificate javaCert)
Build an X509SKI containing the subject key identifier extension value contained within
a certificate. |
static X509SubjectName |
buildX509SubjectName(java.lang.String subjectName)
Build an X509SubjectName containing a given subject name. |
static java.math.BigInteger |
decodeBigIntegerFromCryptoBinary(java.lang.String base64Value)
Decode a base64-encoded ds:CryptoBinary value to a native Java BigInteger type. |
static java.lang.String |
encodeCryptoBinaryFromBigInteger(java.math.BigInteger bigInt)
Encode a native Java BigInteger type to a base64-encoded ds:CryptoBinary value. |
static java.security.cert.X509Certificate |
getCertificate(X509Certificate xmlCert)
Convert an X509Certificate into a native Java representation. |
static java.util.List<java.security.cert.X509Certificate> |
getCertificates(KeyInfo keyInfo)
Get a list of the Java X509Certificate within the given KeyInfo. |
static java.util.List<java.security.cert.X509Certificate> |
getCertificates(X509Data x509Data)
Get a list of the Java X509Certificate within the given X509Data . |
static java.security.cert.X509CRL |
getCRL(X509CRL xmlCRL)
Convert an X509CRL into a native Java representation. |
static java.util.List<java.security.cert.X509CRL> |
getCRLs(KeyInfo keyInfo)
Get a list of the Java X509CRL s within the given KeyInfo . |
static java.util.List<java.security.cert.X509CRL> |
getCRLs(X509Data x509Data)
Get a list of the Java X509CRL s within the given X509Data . |
static java.security.PublicKey |
getDSAKey(DSAKeyValue keyDescriptor)
Builds an DSA key from a DSAKeyValue element. |
static java.security.PublicKey |
getDSAKey(DSAKeyValue keyDescriptor,
java.security.interfaces.DSAParams dsaParams)
Builds a DSA key from an DSAKeyValue element and the supplied Java DSAParams ,
which supplies key material from a shared key family. |
static java.security.PublicKey |
getKey(KeyValue keyValue)
Extracts the DSA or RSA public key within the KeyValue . |
static java.util.List<java.lang.String> |
getKeyNames(KeyInfo keyInfo)
Get the set of key names inside the specified KeyInfo as a list of strings. |
static java.util.List<java.security.PublicKey> |
getPublicKeys(KeyInfo keyInfo)
Extracts all the public keys within the given KeyInfo 's KeyValue s. |
static java.security.PublicKey |
getRSAKey(RSAKeyValue keyDescriptor)
Builds an RSA key from an RSAKeyValue element. |
protected static java.security.cert.CertificateFactory |
getX509CertFactory()
Get the Java certificate factory singleton. |
static boolean |
hasCompleteDSAParams(DSAKeyValue keyDescriptor)
Check whether the specified DSAKeyValue element has the all optional DSA
values which can be shared amongst many keys in a DSA "key family", and
are presumed to be known from context. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected KeyInfoHelper()
Method Detail |
---|
public static java.util.List<java.lang.String> getKeyNames(KeyInfo keyInfo)
KeyInfo
as a list of strings.
keyInfo
- KeyInfo
to retrieve key names from
public static void addKeyName(KeyInfo keyInfo, java.lang.String keyNameValue)
KeyName
value to a KeyInfo.
keyInfo
- the KeyInfo to which to add the new valuekeyNameValue
- the new key name value to addpublic static java.util.List<java.security.cert.X509Certificate> getCertificates(KeyInfo keyInfo) throws java.security.cert.CertificateException
X509Certificate
within the given KeyInfo.
keyInfo
- key info to extract the certificates from
X509Certificate
s
java.security.cert.CertificateException
- thrown if there is a problem converting the
X509 data into X509Certificate
s.public static java.util.List<java.security.cert.X509Certificate> getCertificates(X509Data x509Data) throws java.security.cert.CertificateException
X509Certificate
within the given X509Data
.
x509Data
- X509Data
from which to extract the certificate
X509Certificate
s
java.security.cert.CertificateException
- thrown if there is a problem converting the
X509 data into X509Certificate
s.public static java.security.cert.X509Certificate getCertificate(X509Certificate xmlCert) throws java.security.cert.CertificateException
X509Certificate
into a native Java representation.
xmlCert
- an X509Certificate
X509Certificate
java.security.cert.CertificateException
- thrown if there is a problem converting the
X509 data into X509Certificate
s.public static java.util.List<java.security.cert.X509CRL> getCRLs(KeyInfo keyInfo) throws java.security.cert.CRLException
X509CRL
s within the given KeyInfo
.
keyInfo
- the KeyInfo
to extract the CRL's from
X509CRL
s
java.security.cert.CRLException
- thrown if there is a problem converting the
CRL data into X509CRL
spublic static java.util.List<java.security.cert.X509CRL> getCRLs(X509Data x509Data) throws java.security.cert.CRLException
X509CRL
s within the given X509Data
.
x509Data
- X509Data
to extract the CRLs from
X509CRL
s
java.security.cert.CRLException
- thrown if there is a problem converting the
CRL data into X509CRL
spublic static java.security.cert.X509CRL getCRL(X509CRL xmlCRL) throws java.security.cert.CRLException
X509CRL
into a native Java representation.
xmlCRL
- object to extract the CRL from
X509CRL
object
java.security.cert.CRLException
- thrown if there is a problem converting the
CRL data into X509CRL
spublic static void addCertificate(KeyInfo keyInfo, java.security.cert.X509Certificate cert) throws java.security.cert.CertificateEncodingException
X509Certificate
into the corresponding
XMLObject and stores it in a KeyInfo
in the first X509Data
element.
The X509Data element will be created if necessary.
keyInfo
- the KeyInfo
object into which to add the certificatecert
- the Java X509Certificate
to add
java.security.cert.CertificateEncodingException
- thrown when there is an error converting the Java
certificate representation to the XMLObject representationpublic static void addCRL(KeyInfo keyInfo, java.security.cert.X509CRL crl) throws java.security.cert.CRLException
X509CRL
into the corresponding XMLObject and stores it
in a KeyInfo
in the first X509Data
element. The X509Data element
will be created if necessary.
keyInfo
- the KeyInfo
object into which to add the CRLcrl
- the Java X509CRL
to add
java.security.cert.CRLException
- thrown when there is an error converting the Java
CRL representation to the XMLObject representationpublic static X509Certificate buildX509Certificate(java.security.cert.X509Certificate cert) throws java.security.cert.CertificateEncodingException
X509Certificate
XMLObject from a native
Java X509Certificate
.
cert
- the Java X509Certificate
to convert
X509Certificate
XMLObject
java.security.cert.CertificateEncodingException
- thrown when there is an error converting the Java
certificate representation to the XMLObject representationpublic static X509CRL buildX509CRL(java.security.cert.X509CRL crl) throws java.security.cert.CRLException
X509CRL
XMLObject from
a native Java X509CRL
.
crl
- the Java X509CRL
to convert
X509CRL
XMLObject
java.security.cert.CRLException
- thrown when there is an error converting the Java
CRL representation to the XMLObject representationpublic static X509SubjectName buildX509SubjectName(java.lang.String subjectName)
X509SubjectName
containing a given subject name.
subjectName
- the name content
public static X509IssuerSerial buildX509IssuerSerial(java.lang.String issuerName, java.math.BigInteger serialNumber)
X509IssuerSerial
containing a given issuer name and serial number.
issuerName
- the name contentserialNumber
- the serial number content
public static X509SKI buildX509SKI(java.security.cert.X509Certificate javaCert)
X509SKI
containing the subject key identifier extension value contained within
a certificate.
javaCert
- the Java X509Certificate from which to extract the subject key identifier value.
public static void addPublicKey(KeyInfo keyInfo, java.security.PublicKey pk) throws java.lang.IllegalArgumentException
KeyInfo
in a new KeyValue
element.
As input, only supports PublicKey
s which are instances of either
DSAPublicKey
or
RSAPublicKey
keyInfo
- the KeyInfo
element to which to add the keypk
- the native Java PublicKey
to add
java.lang.IllegalArgumentException
- thrown if an unsupported public key
type is passedpublic static RSAKeyValue buildRSAKeyValue(java.security.interfaces.RSAPublicKey rsaPubKey)
RSAKeyValue
XMLObject from the Java security RSA public key type.
rsaPubKey
- a native Java RSAPublicKey
RSAKeyValue
XMLObjectpublic static DSAKeyValue buildDSAKeyValue(java.security.interfaces.DSAPublicKey dsaPubKey)
DSAKeyValue
XMLObject from the Java security DSA public key type.
dsaPubKey
- a native Java DSAPublicKey
DSAKeyValue
XMLObjectpublic static java.util.List<java.security.PublicKey> getPublicKeys(KeyInfo keyInfo) throws java.security.KeyException
KeyInfo
's KeyValue
s. This method only
supports DSA and RSA key types.
keyInfo
- KeyInfo
to extract the keys out of
PublicKey
objects
java.security.KeyException
- thrown if the given key data can not be converted into PublicKey
public static java.security.PublicKey getKey(KeyValue keyValue) throws java.security.KeyException
KeyValue
.
keyValue
- the KeyValue
to extract the key from
Key
object
java.security.KeyException
- thrown if the given key data can not be converted into PublicKey
public static java.security.PublicKey getDSAKey(DSAKeyValue keyDescriptor) throws java.security.KeyException
DSAKeyValue
element. The element must contain values
for all required DSA public key parameters, including values for shared key family
values P, Q and G.
keyDescriptor
- the DSAKeyValue
key descriptor
DSAPublicKey
instance of PublicKey
java.security.KeyException
- thrown if the key algorithm is not supported by the JCE or the key spec does not
contain valid informationpublic static java.security.PublicKey getDSAKey(DSAKeyValue keyDescriptor, java.security.interfaces.DSAParams dsaParams) throws java.security.KeyException
DSAKeyValue
element and the supplied Java DSAParams
,
which supplies key material from a shared key family.
keyDescriptor
- the DSAKeyValue
key descriptordsaParams
- the DSAParams
DSA key family parameters
DSAPublicKey
instance of PublicKey
java.security.KeyException
- thrown if the key algorithm is not supported by the JCE or the key spec does not
contain valid informationpublic static boolean hasCompleteDSAParams(DSAKeyValue keyDescriptor)
DSAKeyValue
element has the all optional DSA
values which can be shared amongst many keys in a DSA "key family", and
are presumed to be known from context.
keyDescriptor
- the DSAKeyValue
element to check
public static java.security.PublicKey getRSAKey(RSAKeyValue keyDescriptor) throws java.security.KeyException
RSAKeyValue
element.
keyDescriptor
- the RSAKeyValue
key descriptor
RSAPublicKey
instance of PublicKey
java.security.KeyException
- thrown if the key algorithm is not supported by the JCE or the key spec does not
contain valid informationpublic static final java.math.BigInteger decodeBigIntegerFromCryptoBinary(java.lang.String base64Value)
base64Value
- base64-encoded CryptoBinary value
public static final java.lang.String encodeCryptoBinaryFromBigInteger(java.math.BigInteger bigInt)
bigInt
- the BigInteger value
protected static java.security.PublicKey buildKey(java.security.spec.KeySpec keySpec, java.lang.String keyAlgorithm) throws java.security.KeyException
keySpec
- KeySpec
specification for the keykeyAlgorithm
- key generation algorithm, only DSA and RSA supported
PublicKey
java.security.KeyException
- thrown if the key algorithm is not supported by the JCE or the key spec does not
contain valid informationprotected static java.security.cert.CertificateFactory getX509CertFactory() throws java.security.cert.CertificateException
CertificateFactory
the factory used to create X509 certificate objects
java.security.cert.CertificateException
- thrown if the factory can not be created
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |