Source

HealthVault-jython / HealthVault / util.py

Full commit
''' setup functions '''

from config import *

def setup_keyStore(filename, alias, password):
    from com.microsoft.hsg import DefaultPrivateKeyStore
    keyStore = DefaultPrivateKeyStore()
    keyStore.filename = filename
    keyStore.alias = alias
    keyStore.password = password
    return keyStore

def setup_authenticator(keyStore, appId):
    from com.microsoft.hsg import ApplicationAuthenticator, DefaultSharedSecret
    authenticator = ApplicationAuthenticator()
    authenticator.sharedSecretGenerator = DefaultSharedSecret()
    authenticator.keyStore = keyStore
    authenticator.appId = appId
    return authenticator

def setup_transport(url = HV_URL):
    from com.microsoft.hsg import URLConnectionTransport
    import java.net.URL
    transport = URLConnectionTransport()
    transport.url = java.net.URL(url)
    return transport

def setup_connection(transport, authenticator):
    from com.microsoft.hsg import Connection
    connection = Connection()
    connection.transport = transport
    connection.authenticator = authenticator
    return connection

def setup_request(connection):
    from com.microsoft.hsg.methods.jaxb import SimpleRequestTemplate
    return SimpleRequestTemplate(connection)