Example #1
0
    def _Authenticate(self, error_func):
        self._ShowLoggingInMessage()

        try:
            credentials = base_client.GetOauthCredentials()
        except (RuntimeError, base_client.AuthenticationError) as e:
            error_func(unicode(e))
            return

        opener = base_client.BuildOauth2Opener(credentials)
        client_ = client.FileVaultClient(self.server_url, opener)

        try:
            client_.GetAndValidateMetadata()
        except base_client.MetadataError as e:
            error_func(unicode(e))
            return

        return client_
Example #2
0
def main(options):
    if options.login_type == 'oauth2':
        credentials = base_client.GetOauthCredentials()
        opener = base_client.BuildOauth2Opener(credentials)
    else:
        raise NotImplementedError('Unsupported login type: %s',
                                  options.login_type)

    c = client.LuksClient(options.server_url, opener)

    if options.mode == 'put':
        luks_passphrase = open(options.luks_passphrase_file,
                               'r').read().strip()
        data = {
            'hostname': options.hostname,
            'hdd_serial': options.hdd_serial,
            'platform_uuid': options.platform_uuid,
            'owner': options.username
        }
        c.UploadPassphrase(options.volume_uuid, luks_passphrase, data)
    if options.mode == 'get':
        print c.RetrieveSecret(options.volume_uuid)
def _GetOpener():
    credentials = base_client.GetOauthCredentials()
    opener = base_client.BuildOauth2Opener(credentials)
    return opener