jc

package
v0.0.0-...-7dc266a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 16, 2017 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientPrivateKey

type ClientPrivateKey struct {
	*rsa.PrivateKey
}

func LoadClientPrivateKeyFromFile

func LoadClientPrivateKeyFromFile(path string) (pk ClientPrivateKey, err error)

Loads a RSA private key from file, base64 decrypts the PEM, parses and returns an rsa.PrivateKey struct

func (*ClientPrivateKey) Sign

func (pk *ClientPrivateKey) Sign(data []byte) (signed []byte, err error)

SHA256 hashes an array of bytes and signs it with the current private key

func (*ClientPrivateKey) SignatureForRequest

func (pk *ClientPrivateKey) SignatureForRequest(time, httpMethod, httpUrl string) (signedBase64 string, err error)

Signs a request signature with the current private key

type ClientPrivateKeySigner

type ClientPrivateKeySigner interface {
	Sign(data []byte) ([]byte, error)
	SignatureForRequest(string, string, string) (string, error)
}

type SystemClient

type SystemClient struct {
	Config     map[string]interface{}
	ConfigPath string

	HttpClient    http.Client
	ClientKey     ClientPrivateKey
	ClientKeyPath string
	SystemKey     string
}

func NewSystemClient

func NewSystemClient(configPath, clientKeyPath string) (client SystemClient, err error)

Returns a new system client with the loaded configuration file + client key, ready to sign and send API requests

func (*SystemClient) AssociateGroup

func (c *SystemClient) AssociateGroup(groupId string) (result string, err error)

func (*SystemClient) Do

func (c *SystemClient) Do(endpoint, httpMethod, body string) (resp *http.Response, err error)

Sends an API request to the endpoint specified for the system key

func (*SystemClient) LoadConfig

func (c *SystemClient) LoadConfig() (err error)

Loads the jcagent.conf file from disk or wherever the systemClient is configured for

func (*SystemClient) LoadPrivateKey

func (c *SystemClient) LoadPrivateKey() (err error)

Loads the client.key file from disk or wherever the systemClient is configured for

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL