Java Client/Console API Examples

Examples for accessing Secret Server using the Java API. (note that you must first install the Secret Server Java API to use these examples).

C# Sample Code:
http://updates.thycotic.net/secretserver/javaAPIexamples/JavaAPIconsolecaller.zip

Perl - Get Single Field Example:
# Sample script for getting the value of the 'Password' field for SecretId 8

#Change this value to match your desired Secret Id
my $secretid = 8;

my $fieldname = 'Password';
my $result = `java -jar secretserver-jconsole.jar -s $secretid $fieldname`;
my $exitCode = $?>>8; # non-zero if an error occurred
if($exitCode == 0)
{
    print $result;
}
else
{
    print "Error: $result";
}


Perl - Get Multiple Fields Example:
# Sample script for getting the values for the Username, password, and Notes fields on SecretId 8, separated by a semicolon

# Change this value to match your desired Secret Id
my $secretid = 8;
# Change this value to alter the string used to delimit field values returned by the Web Service.
my $separator = ';';
# Specify your desired fields here.
my @fields = qw(Username Password Notes);
my $fields = join(" ", @fields);

my $result = `java -jar secretserver-jconsole.jar -v $secretid $separator $fields`;
my $exitCode = $?>>8; # non-zero if an error occurred
if($exitCode == 0)
{
    print $result;
}
else
{
    print "Error: $result";
}

Article ID: 187, Created On: 10/19/2011, Modified: 4/16/2013

Feedback (0)