enrollment

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const Limit10KiB = 10 * 1024

Variables

View Source
var ErrAlreadyEnrolled = errors.New("already enrolled")

Functions

func HTTPErrors

func HTTPErrors(r *http.Response) error

HTTPErrors reports an HTTP error for a non-200 HTTP response. The first 10KiB of the body is read for non-200 response. For a 200 response nil is returned. Caller is responsible for closing response body.

func ReplaceIdentityRandom

func ReplaceIdentityRandom(e *Enrollment) error

ReplaceIdentityRandom changes the certificate private key to a random certificate and key.

Types

type Enrollment

type Enrollment struct {
	// contains filtered or unexported fields
}

Enrollment emulates an MDM enrollment. Currently it mostly emulates device channel enrollments.

func NewFromCheckins

func NewFromCheckins(doer protocol.Doer, serverURL, checkInURL, authenticatePath, tokenUpdatePath string) (*Enrollment, error)

NewFromCheckins loads device information from authenticate and tokenupdate files on disk.

func NewRandomDeviceEnrollment

func NewRandomDeviceEnrollment(doer protocol.Doer, topic, serverURL, checkInURL string) (*Enrollment, error)

NewRandomDeviceEnrollment creates a new randomly identified MDM enrollment.

func (*Enrollment) DoAuthenticate

func (e *Enrollment) DoAuthenticate(ctx context.Context) error

DoAuthenticate sends an Authenticate check-in message to the MDM server.

func (*Enrollment) DoEnroll

func (e *Enrollment) DoEnroll(ctx context.Context) error

DoEnroll enrolls (or re-enrolls) this enrollment into MDM. Authenticate and TokenUpdate check-in messages are sent via the transport to the MDM server.

func (*Enrollment) DoEscrowBootstrapToken

func (e *Enrollment) DoEscrowBootstrapToken(ctx context.Context, token []byte) error

DoEscrowBootstrapToken sends the Bootstrap Token to the MDM server.

func (*Enrollment) DoGetBootstrapToken

func (e *Enrollment) DoGetBootstrapToken(ctx context.Context) (*mdm.BootstrapToken, error)

DoGetBootstrapToken retrieves the Bootstrap Token from the MDM erver.

func (*Enrollment) DoReportAndFetch

func (e *Enrollment) DoReportAndFetch(ctx context.Context, report io.Reader) (*http.Response, error)

DoReportAndFetch sends report to the MDM server. Any new command delivered will be in the response. The caller is responsible for closing the response body.

func (*Enrollment) DoTokenUpdate

func (e *Enrollment) DoTokenUpdate(ctx context.Context) error

DoTokenUpdate sends a TokenUpdate check-in message to the MDM server. A new random push token is generated for the device.

func (*Enrollment) EnrollID

func (e *Enrollment) EnrollID() *mdm.EnrollID

EnrollID returns the NanoMDM enroll ID.

func (*Enrollment) GenAuthenticate

func (e *Enrollment) GenAuthenticate() (io.Reader, error)

GenAuthenticate creates an XML Plist Authenticate check-in message.

func (*Enrollment) GenTokenUpdate

func (e *Enrollment) GenTokenUpdate() (io.Reader, error)

GenTokenUpdate creates an XML Plist TokenUpdate check-in message.

func (*Enrollment) GetEnrollment

func (e *Enrollment) GetEnrollment() *mdm.Enrollment

GetEnrollment returns the enrollment identifier data.

func (*Enrollment) GetIdentity

GetIdentity supplies the identity certificate and key of this enrollment.

func (*Enrollment) GetPush

func (e *Enrollment) GetPush() *mdm.Push

GetPush returns the enrollment push info data.

func (*Enrollment) ID

func (e *Enrollment) ID() string

ID returns the NanoMDM "normalized" enrollment ID.

func (*Enrollment) NewMDMRequest

func (e *Enrollment) NewMDMRequest(ctx context.Context) *mdm.Request

type HTTPError

type HTTPError struct {
	Body       []byte
	Status     string
	StatusCode int
}

HTTPError contains the body and status details.

func NewHTTPError

func NewHTTPError(response *http.Response, body []byte) *HTTPError

func (*HTTPError) Error

func (e *HTTPError) Error() (err string)

Error returns strings for HTTP errors that may include body and status.

type Transport

type Transport interface {
	// DoCheckIn performs an HTTP MDM check-in to the CheckInURL (or ServerURL).
	// The caller is responsible for closing the response body.
	DoCheckIn(context.Context, io.Reader) (*http.Response, error)

	// DoReportResultsAndFetchNext sends an HTTP MDM report-results-and-retrieve-next-command request to the ServerURL.
	// The caller is responsible for closing the response body.
	DoReportResultsAndFetchNext(ctx context.Context, report io.Reader) (*http.Response, error)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳