// 2012-07-09 johnpfeiffer requires FileSystem
import java.io.IOException;
public class SSLKey
{
private static final String CLASSVERSION = "0.54";
private String sslkey;
SSLKey( )
{ sslkey = "";
}
SSLKey( String key ) throws IllegalArgumentException
{
if( key == null )
{
throw new IllegalArgumentException( "ERROR: key cannot be null" );
}
if( key.isEmpty() )
{
throw new IllegalArgumentException( "ERROR: key cannot be empty" );
}
sslkey = key.trim();
}
protected String getVersion()
{
return CLASSVERSION;
}
protected String get()
{ return sslkey;
}
/* TODO replace string test by java security or openssl test
protected boolean isValid( )
{
boolean result = false;
if( sslkey.startsWith( "-----BEGIN RSA PRIVATE KEY-----" ) )
{ result = true;
}
return result;
}
*/
protected void writeToFile( String pathFilename ) throws IllegalArgumentException, IOException
{
if( pathFilename == null )
{
throw new IllegalArgumentException( "ERROR: pathFilename cannot be null" );
}
if( pathFilename.isEmpty() )
{
throw new IllegalArgumentException( "ERROR: pathFilename cannot be empty" );
}
FileSystem fs = new FileSystem();
pathFilename = fs.convertFileSystemPath( pathFilename );
fs.writeStringToFile( sslkey , pathFilename );
}
} // end class