Mobile Tools for Java
Release 1.0

org.eclipse.mtj.core.signing
Class SignatureProperties

java.lang.Object
  extended by org.eclipse.mtj.core.signing.SignatureProperties
All Implemented Interfaces:
ISignatureProperties

public class SignatureProperties
extends Object
implements ISignatureProperties

This is a simple container class (bean) designed to hold the various project-specific properties relating to potential signing operations. It is used by the dialog class that allows the user to manipulate the settings, as well as the project properties persistence stuff.

Note: This class/interface is part of an interim API that is still under development and expected to change before reaching stability. It is being made available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken as the API evolves.


Field Summary
 
Fields inherited from interface org.eclipse.mtj.core.model.sign.ISignatureProperties
PASSMETHOD_IN_KEYRING, PASSMETHOD_IN_PROJECT, PASSMETHOD_PROMPT, PROJECT_RELATIVE_PREFIX
 
Constructor Summary
SignatureProperties()
          Standard constructor
 
Method Summary
 void clear()
          Resets the class to its default values
 void copy(ISignatureProperties other)
          Indicates whether or not the project is to be signed.
 String getAbsoluteKeyStorePath(IProject project)
          Returns the absolute file system path to the keystore file.
 String getKeyAlias()
          Returns the "alias" string identifying the key and certificate that will be used to sign the project.
 String getKeyPassword()
          Returns the key password, if passwords are being saved.
 String getKeyStoreDisplayPath()
          Returns the display string representing the keystore path.
 String getKeyStorePassword()
          Returns the password for the keystore file, if passwords are being saved.
 String getKeyStoreProvider()
          Returns the crypto provider string.
 String getKeyStoreType()
          Type of the keystore file.
 int getPasswordStorageMethod()
          Returns the password storage method.
 boolean getSignProject()
          Indicates whether or not the project is to be signed.
 boolean isKeyStorePathExternal()
          Indicates whether the keystore path is external to the project or project-relative.
 void setKeyAlias(String strValue)
          Sets the "alias" string identifying the key and certificate that will be used to sign the project.
 void setKeyPassword(String strValue)
          Sets the key password, if passwords are being saved.
 void setKeyStoreDisplayPath(String path)
          Sets the display string representing the keystore path.
 void setKeyStorePassword(String strValue)
          Sets the password for the keystore file.
 void setKeyStoreProvider(String strValue)
          Sets the crypto provider string.
 void setKeyStoreType(String strValue)
          Type of the keystore file.
 void setPasswordStorageMethod(int nMethod)
          Sets the password storage method.
 void setSignProject(boolean bValue)
          Indicates whether or not the project is to be signed.
static String toAbsolute(String path, IProject project)
          Converts a project-relative path into an absolute one, based on the location of the project containing the file.
static String toRelative(String path)
          Converts a basic project-relative path into the format that we recognize internally.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SignatureProperties

public SignatureProperties()
Standard constructor

Method Detail

copy

public void copy(ISignatureProperties other)
Indicates whether or not the project is to be signed.

Specified by:
copy in interface ISignatureProperties
Parameters:
other - ISignatureProperties object to be copied.

clear

public void clear()
Resets the class to its default values

Specified by:
clear in interface ISignatureProperties

getSignProject

public boolean getSignProject()
Indicates whether or not the project is to be signed.

Specified by:
getSignProject in interface ISignatureProperties
Returns:
true if the project is to be signed, false otherwise
See Also:
ISignatureProperties.setSignProject(boolean)

setSignProject

public void setSignProject(boolean bValue)
Indicates whether or not the project is to be signed.

Specified by:
setSignProject in interface ISignatureProperties
Parameters:
bValue - true if the project is to be signed, false otherwise.
See Also:
ISignatureProperties.getSignProject()

getPasswordStorageMethod

public int getPasswordStorageMethod()
Returns the password storage method.

Specified by:
getPasswordStorageMethod in interface ISignatureProperties
Returns:
One of PASSMETHOD_PROMPT, PASSMETHOD_IN_KEYRING or PASSMETHOD_IN_PROJECT.
See Also:
ISignatureProperties.setPasswordStorageMethod(int), ISignatureProperties.PASSMETHOD_IN_KEYRING, ISignatureProperties.PASSMETHOD_IN_PROJECT, ISignatureProperties.PASSMETHOD_PROMPT

setPasswordStorageMethod

public void setPasswordStorageMethod(int nMethod)
Sets the password storage method.

Specified by:
setPasswordStorageMethod in interface ISignatureProperties
Parameters:
nMethod - One of PASSMETHOD_PROMPT, PASSMETHOD_IN_KEYRING or
See Also:
ISignatureProperties.getPasswordStorageMethod(), ISignatureProperties.PASSMETHOD_IN_KEYRING, ISignatureProperties.PASSMETHOD_IN_PROJECT, ISignatureProperties.PASSMETHOD_PROMPT

getKeyStoreType

public String getKeyStoreType()
Type of the keystore file. null indicates the system standard type. This string is passed to KeyStore.getInstance as part of loading the keystore.

Specified by:
getKeyStoreType in interface ISignatureProperties
Returns:
String indicating keystore file type.
See Also:
KeyStore.getInstance(java.lang.String), KeyStore.getInstance(java.lang.String, java.lang.String)

setKeyStoreType

public void setKeyStoreType(String strValue)
Type of the keystore file. null indicates the system standard type. This string is passed to KeyStore.getInstance as part of loading the keystore.

Specified by:
setKeyStoreType in interface ISignatureProperties
Parameters:
strValue - KeyStore type string, or null to use the system default type.
See Also:
KeyStore.getInstance(java.lang.String), KeyStore.getInstance(java.lang.String, java.lang.String)

getKeyStoreProvider

public String getKeyStoreProvider()
Returns the crypto provider string. null indicates the system standard type. This string is passed to KeyStore.getInstance as part of loading the keystore.

Specified by:
getKeyStoreProvider in interface ISignatureProperties
Returns:
KeyStore provider string, or null to use the system default provider.
See Also:
KeyStore.getInstance(java.lang.String, java.lang.String)

setKeyStoreProvider

public void setKeyStoreProvider(String strValue)
Sets the crypto provider string. null indicates the system standard type.

Specified by:
setKeyStoreProvider in interface ISignatureProperties
Parameters:
strValue - KeyStore provider string, or null to use the system default provider.
See Also:
KeyStore.getInstance(java.lang.String, java.lang.String)

getKeyStorePassword

public String getKeyStorePassword()
Returns the password for the keystore file, if passwords are being saved.

Specified by:
getKeyStorePassword in interface ISignatureProperties
Returns:
String containing keystore password.
See Also:
ISignatureProperties.setKeyStorePassword(String)

setKeyStorePassword

public void setKeyStorePassword(String strValue)
Sets the password for the keystore file.

Specified by:
setKeyStorePassword in interface ISignatureProperties
Parameters:
strValue - String containing keystore password.
See Also:
ISignatureProperties.getKeyStorePassword()

getKeyAlias

public String getKeyAlias()
Returns the "alias" string identifying the key and certificate that will be used to sign the project.

Specified by:
getKeyAlias in interface ISignatureProperties
Returns:
String containing the alias identifying the key and certificate.
See Also:
ISignatureProperties.setKeyAlias(String)

setKeyAlias

public void setKeyAlias(String strValue)
Sets the "alias" string identifying the key and certificate that will be used to sign the project.

Specified by:
setKeyAlias in interface ISignatureProperties
Parameters:
strValue - String containing the alias identifying the key and certificate.
See Also:
ISignatureProperties.getKeyAlias()

getKeyPassword

public String getKeyPassword()
Returns the key password, if passwords are being saved. Will return null if passwords are not being saved.

Specified by:
getKeyPassword in interface ISignatureProperties
Returns:
String containing the key password.
See Also:
ISignatureProperties.setKeyPassword(String)

setKeyPassword

public void setKeyPassword(String strValue)
Sets the key password, if passwords are being saved. Ignored if passwords are not being saved.

Specified by:
setKeyPassword in interface ISignatureProperties
Parameters:
strValue - String containing the key password.
See Also:
ISignatureProperties.getKeyPassword()

getKeyStoreDisplayPath

public String getKeyStoreDisplayPath()
Returns the display string representing the keystore path. This may be an absolute path, or it may be a project-relative path. Relative paths are of the form "$/[Folder[/Folder...]]filename". Absolute paths have OS-dependent form.

Specified by:
getKeyStoreDisplayPath in interface ISignatureProperties
Returns:
String containing displayed path.
See Also:
isKeyStorePathExternal()

setKeyStoreDisplayPath

public void setKeyStoreDisplayPath(String path)
Sets the display string representing the keystore path. This may be an absolute path, or it may be a project-relative path.

Specified by:
setKeyStoreDisplayPath in interface ISignatureProperties
Parameters:
path - String containing displayed path.
See Also:
getKeyStoreDisplayPath()

getAbsoluteKeyStorePath

public String getAbsoluteKeyStorePath(IProject project)
                               throws CoreException
Returns the absolute file system path to the keystore file. The specified project instance is used to convert a project-relative path to an absolute path.

Specified by:
getAbsoluteKeyStorePath in interface ISignatureProperties
Parameters:
project - IProject to which this ISignatureProperties belongs.
Returns:
String containing absolute path to keystore file.
Throws:
CoreException
See Also:
ISignatureProperties.setKeyStoreDisplayPath(String)

isKeyStorePathExternal

public boolean isKeyStorePathExternal()
Indicates whether the keystore path is external to the project or project-relative.

Specified by:
isKeyStorePathExternal in interface ISignatureProperties
Returns:
true if the keystore path is external to the project, false if it's relative to the current project.
See Also:
ISignatureProperties.setKeyStoreDisplayPath(String)

toAbsolute

public static String toAbsolute(String path,
                                IProject project)
                         throws CoreException
Converts a project-relative path into an absolute one, based on the location of the project containing the file.

Parameters:
path - Relative path to be converted.
project - IProject instance containing the relative path.
Returns:
String containing the absolute path to the file.
Throws:
CoreException

toRelative

public static String toRelative(String path)
Converts a basic project-relative path into the format that we recognize internally. This is done by ensuring that the path string starts with our "relative prefix."

Parameters:
path - String containing the path to be converted.
Returns:
String with the converted value.

Mobile Tools for Java
Release 1.0