net.sourceforge.jsdp
Class Key

java.lang.Object
  extended by net.sourceforge.jsdp.Key
All Implemented Interfaces:
Serializable, Cloneable, Field

public class Key
extends Object
implements Field

A Key represents an <k=<field value> field contained in a SDP message.

A SDP message may be used to convey encryption keys, if transported over a secure and trusted channel. Key fields has the form: <method>:<key>, but the key value is optional. The following methods are defined:

Since:
0.1.2
Version:
1.0
Author:
Claudio Di Vita
See Also:
Serialized Form

Field Summary
static String BASE64
          The base64 encryption method modifier
static String CLEAR
          The clear encryption method modifier
protected  String key
          The encription key
protected  String method
          The encryption method
static String PROMPT
          The prompt encryption method modifier
static String URI
          The uri encryption method modifier
 
Fields inherited from interface net.sourceforge.jsdp.Field
ATTRIBUTE_FIELD, BANDWITH_FIELD, CONNECTION_FIELD, EMAIL_FIELD, END_OF_FIELD, INFORMATION_FIELD, KEY_FIELD, MEDIA_FIELD, ORIGIN_FIELD, PHONE_FIELD, REPEAT_TIME_FIELD, SESSION_NAME_FIELD, TIME_FIELD, TIMEZONE_FIELD, URI_FIELD, VERSION_FIELD
 
Constructor Summary
protected Key()
          Creates a new Key.
  Key(String method, String key)
          Creates a new Key.
 
Method Summary
 Object clone()
          Returns a clone of this field.
 String getKey()
          Returns the encryption key.
 String getMethod()
          Returns the encryption method.
 char getType()
          Returns the type character for the field.
 boolean hasKey()
          Determines if the method has an associated key.
static Key parse(String field)
          Parse an input string and constructs the equivalent key field.
 void setKey(String key)
          Sets the encryption key.
 void setMethod(String method)
          Sets the encryption method.
 String toString()
          Returns a string representation of the field.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BASE64

public static final String BASE64
The base64 encryption method modifier

See Also:
Constant Field Values

CLEAR

public static final String CLEAR
The clear encryption method modifier

See Also:
Constant Field Values

PROMPT

public static final String PROMPT
The prompt encryption method modifier

See Also:
Constant Field Values

URI

public static final String URI
The uri encryption method modifier

See Also:
Constant Field Values

method

protected String method
The encryption method


key

protected String key
The encription key

Constructor Detail

Key

protected Key()
Creates a new Key.


Key

public Key(String method,
           String key)
    throws SDPException
Creates a new Key.

Parameters:
method - the encryption method
key - the encryption key
Throws:
SDPException - if the encryption method is not allowed, or the encryption key is not valid for the specified method
Method Detail

parse

public static Key parse(String field)
                 throws SDPParseException
Parse an input string and constructs the equivalent key field.

Parameters:
field - the string to parse
Returns:
a new Key instance
Throws:
SDPParseException - if an error occurs while parsing

clone

public Object clone()
Returns a clone of this field.

Specified by:
clone in interface Field
Overrides:
clone in class Object
Returns:
a clone of this field

getKey

public String getKey()
Returns the encryption key.

Returns:
the encryption key.

getMethod

public String getMethod()
Returns the encryption method.

Returns:
the encryption method

getType

public char getType()
Returns the type character for the field.

Specified by:
getType in interface Field
Returns:
the field type character: k

hasKey

public boolean hasKey()
Determines if the method has an associated key.

Returns:
true if the method has an associated key, false otherwise

setKey

public void setKey(String key)
            throws SDPException
Sets the encryption key.

Parameters:
key - the encryption key to set
Throws:
SDPException - if the key is not valid

setMethod

public void setMethod(String method)
               throws SDPException
Sets the encryption method.

Parameters:
method - the encryption method to set
Throws:
SDPException - if the method is not allowed or null

toString

public String toString()
Returns a string representation of the field. The representation has one the following forms:

Specified by:
toString in interface Field
Overrides:
toString in class Object
Returns:
the string representation of the field


Copyright © 2004-2008. All Rights Reserved.