# Before running this comman, you must log in top the MFT console and set
# the PGP Keystore passwords
#
# Requires setting pgp private key password as welcome1 in the MFT console
# 'Administration -> Keystores -> PGP Keystore -> PGP Private Key Password'
# 'Administration -> Keystores -> PGP Keystore -> PGP Private Key Password'

#help('all')
#help('mft')
#listCallouts()

# Retrieve working directory (run script from sam directory as the key files)
import os
DIR  = os.getcwd()
print DIR

# Build and display fully qualified key files
FILE1 = os.path.join(DIR, 'test_pgp_private.asc')
FILE2 = os.path.join(DIR, 'test_pgp_public.asc')
print FILE1
print FILE2

# Connect to MFT WebLogic Server
connect("weblogic", "welcome1", "t3://localhost:7601")

# List any keys stored (should be empty on the first run)
listCSFKeyAliases('PGP', 'PRIVATE')
listCSFKeyAliases('PGP', 'PUBLIC')

# Delete any old keys stored (should fail on the first run)
deleteCSFKey('PGP', 'PRIVATE', 'SamplePrivateAlias')
deleteCSFKey('PGP', 'PUBLIC', 'SamplePublicAlias')

# Import new PGP keys stored
importCSFKey('PGP', 'PRIVATE', 'SamplePrivateAlias', FILE1)
importCSFKey('PGP', 'PUBLIC', 'SamplePublicAlias', FILE2)

# List new PGP keys stored
listCSFKeyAliases('PGP', 'PRIVATE')
listCSFKeyAliases('PGP', 'PUBLIC')

# Disconnect from WebLogic
exit()
