iaik.security.ssl
Class SignatureAndHashAlgorithmList

java.lang.Object
  extended by iaik.security.ssl.SignatureAndHashAlgorithmList
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class SignatureAndHashAlgorithmList
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

Implements a list of TLS 1.2 SignatureAndHashAlgorithm elements as specified by RFC 5246.

A TLS 1.2 client/server may use the SignatureAndHashAlgorithm structure to announce the signature/hash algorithms it is able to support to the peer. The client, for instance, may send a SignatureAlgorithms extension with the ClientHello extension list to tell the server which SignatureAndHashAlgorithms the client can process to, e.g., verify the server certificates or, e.g., sign the CertificateVerify message.
The server, for instance, will specify a list of expected SignatureAndHashAlgorithms when sending the CertificateRequest message.

See Also:
SignatureAlgorithms, SignatureAndHashAlgorithm, Serialized Form

Field Summary
static int L_ALL
          Selection constant for a list with all supported signature algorithms.
static int L_DEFAULT
          Selection constant for a list with the default signature algorithms.
static int L_NONE
          Selection constant for an empty list.
 
Constructor Summary
SignatureAndHashAlgorithmList()
          Creates an empty signature algorithm list.
SignatureAndHashAlgorithmList(int which)
          Creates a new signature algorithm list with the contents determined by the selection value.
SignatureAndHashAlgorithmList(SignatureAndHashAlgorithm algorithm)
          Creates a new signature algorithm list with the specified algorithm as its only element.
SignatureAndHashAlgorithmList(SignatureAndHashAlgorithm[] algorithms)
          Creates a new signature algorithm list from the contents of the given array.
SignatureAndHashAlgorithmList(SignatureAndHashAlgorithmList algorithms)
          Creates a copy of the given signature algorithm list.
SignatureAndHashAlgorithmList(java.lang.String[] algorithms)
          Create a new SignatureAndHashAlgorithmList list from an array of SignatureAndHashAlgorithm names.
 
Method Summary
 void add(SignatureAndHashAlgorithm algorithm)
          Adds a signature algorithm to the end of this list.
 void add(SignatureAndHashAlgorithm[] algorithms)
          Adds all signature algorithms from an array to this list in order.
 void clear()
          Removes all elements from this list.
 java.lang.Object clone()
          Returns a clone of this signature algorithm list.
 boolean contains(SignatureAndHashAlgorithm algorithm)
          Checks if the given signature algorithm is an element of this list.
 void ensureAvailable()
          Make sure this list only contains signature algorithms that can actually be used.
 boolean equals(java.lang.Object obj)
          Checks if this SignatureAndHashAlgorithmList object is equal to the given object.
 SignatureAndHashAlgorithm get(int i)
          Returns the element at the given index.
static SignatureAndHashAlgorithmList getAll()
          Gets a list containing all supported signature algorithms.
static SignatureAndHashAlgorithmList getDefault()
          Gets a list containing the signature algorithms supported by default.
 int hashCode()
          Gets a hash code of this object.
 void intersectWith(SignatureAndHashAlgorithmList other)
          Computes the intersection of this list and another list.
 java.util.Iterator iterator()
          Return an Iterator for the elements of this list.
 void remove(SignatureAndHashAlgorithm algorithm)
          Removes a signature algorithm from this list.
 void remove(SignatureAndHashAlgorithm[] algorithms)
          Removes all signature algorithms from an array from this list.
 int size()
          Returns the number of elements in this list.
 SignatureAndHashAlgorithm[] toArray()
          Converts this list to an array of signature algorithms.
 java.lang.String toString()
          Returns a string representation of this list.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

L_NONE

public static final int L_NONE
Selection constant for an empty list.

See Also:
Constant Field Values

L_DEFAULT

public static final int L_DEFAULT
Selection constant for a list with the default signature algorithms.

See Also:
Constant Field Values

L_ALL

public static final int L_ALL
Selection constant for a list with all supported signature algorithms.

See Also:
Constant Field Values
Constructor Detail

SignatureAndHashAlgorithmList

public SignatureAndHashAlgorithmList()
Creates an empty signature algorithm list.


SignatureAndHashAlgorithmList

public SignatureAndHashAlgorithmList(int which)
Creates a new signature algorithm list with the contents determined by the selection value. It should be one of L_xxx values defined for this class. The resulting list will be sorted and only contain the signature algorithms that are available, i.e. can be used with the installed security provider.

Note that ensureAvailable() is automatically called on the created list.

Parameters:
which - the selection value deciding which type of list shall be created (L_NONE, L_DEFAULT, or L_ALL)
Throws:
IllegalParameterException - if the selection value is not one of

SignatureAndHashAlgorithmList

public SignatureAndHashAlgorithmList(SignatureAndHashAlgorithm algorithm)
Creates a new signature algorithm list with the specified algorithm as its only element.

Parameters:
algorithm - the signature algorithm

SignatureAndHashAlgorithmList

public SignatureAndHashAlgorithmList(SignatureAndHashAlgorithm[] algorithms)
Creates a new signature algorithm list from the contents of the given array. If a signature algorithm occurs multiple times in the array only the first occurrence is used.

Parameters:
algorithms - the array of signature algorithms

SignatureAndHashAlgorithmList

public SignatureAndHashAlgorithmList(SignatureAndHashAlgorithmList algorithms)
Creates a copy of the given signature algorithm list.

Parameters:
algorithms - the algorithm list to be copied

SignatureAndHashAlgorithmList

public SignatureAndHashAlgorithmList(java.lang.String[] algorithms)
                              throws java.lang.IllegalArgumentException
Create a new SignatureAndHashAlgorithmList list from an array of SignatureAndHashAlgorithm names. If a SignatureAndHashAlgorithm occurs multiple times in the array only the first occurrence is used.

Parameters:
algorithms - the SignatureAndHashAlgorithm names
Throws:
java.lang.IllegalArgumentException - if the list of algorithm names refers a SignatureAndHashAlgorithm that is not supported
Method Detail

getDefault

public static final SignatureAndHashAlgorithmList getDefault()
Gets a list containing the signature algorithms supported by default. Contains the following algorithms (if supported by the installed SecurityProvider):

Returns:
a list containing the default algorithms supported by the installed SecurityProvider

getAll

public static final SignatureAndHashAlgorithmList getAll()
Gets a list containing all supported signature algorithms. Contains all signature and hash algorithms specified by TLS 1.2 (RFC 5246), if supported by the installed SecurityProvider):

Returns:
a list containing all signature algorithms supported by the installed SecurityProvider

add

public void add(SignatureAndHashAlgorithm algorithm)
Adds a signature algorithm to the end of this list. If it is already contained in the list the call is ignored.

Parameters:
algorithm - the algorithm to be added

remove

public void remove(SignatureAndHashAlgorithm algorithm)
Removes a signature algorithm from this list. If it is not contained in the list the call is ignored.

Parameters:
algorithm - the algorithm to be removed

contains

public boolean contains(SignatureAndHashAlgorithm algorithm)
Checks if the given signature algorithm is an element of this list.

Parameters:
algorithm - the algorithm to be checked
Returns:
true if the algorithm is included, false if it is not included

add

public void add(SignatureAndHashAlgorithm[] algorithms)
Adds all signature algorithms from an array to this list in order.

Parameters:
algorithms - the signature algorithms to be added

remove

public void remove(SignatureAndHashAlgorithm[] algorithms)
Removes all signature algorithms from an array from this list.

Parameters:
algorithms - the algorithms to be removed

clear

public void clear()
Removes all elements from this list.


toArray

public SignatureAndHashAlgorithm[] toArray()
Converts this list to an array of signature algorithms.

Returns:
an array containing all signature algorithms of this list

size

public int size()
Returns the number of elements in this list.

Returns:
the size of this list

get

public SignatureAndHashAlgorithm get(int i)
                              throws java.lang.IndexOutOfBoundsException
Returns the element at the given index. An IndexOutOfBoundsException is thrown if the index is invalid.

Parameters:
i - the index of the requested element
Returns:
the element at index i
Throws:
java.lang.IndexOutOfBoundsException - if the index

iterator

public java.util.Iterator iterator()
Return an Iterator for the elements of this list.

Returns:
an Iterator for stepping through the elements of this list

ensureAvailable

public void ensureAvailable()
Make sure this list only contains signature algorithms that can actually be used. This method disables all signature algorithms for which SignatureAndHashAlgorithm#isAvailable() returns false.

See Also:
SignatureAndHashAlgorithm.isAvailable()

intersectWith

public void intersectWith(SignatureAndHashAlgorithmList other)
Computes the intersection of this list and another list. This list is modified to only contain signature algorithms enabled in both this and other.

Parameters:
other - the other list

hashCode

public int hashCode()
Gets a hash code of this object.

Overrides:
hashCode in class java.lang.Object
Returns:
a hash code of this object

equals

public boolean equals(java.lang.Object obj)
Checks if this SignatureAndHashAlgorithmList object is equal to the given object.

Two SignatureAndHashAlgorithmList object are treated as equal if they contain the same SignatureAndHashAlgorithm objects (same number and same order).

Overrides:
equals in class java.lang.Object
Returns:
true if this SignatureAndHashAlgorithmList object is equal to the given object, false if it is not equal to it

clone

public java.lang.Object clone()
Returns a clone of this signature algorithm list.

Overrides:
clone in class java.lang.Object
Returns:
the clone of this list

toString

public java.lang.String toString()
Returns a string representation of this list.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of this list

This Javadoc may contain text parts from text parts from IETF Internet Standard specifications (see copyright note).

iSaSiLk 5.104, (c) 2002 IAIK, (c) 2003 - 2015 SIC