diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index a09bd3a8..00000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,27 +0,0 @@ -version: 2 -jobs: - build-go1.11: - docker: - - image: golang:1.11 - - image: postgres:9.6 - environment: - POSTGRES_DB: micromdm - POSTGRES_USER: micromdm - POSTGRES_PASSWORD: micromdm - - working_directory: /go/src/github.com/micromdm/micromdm - steps: &steps - - checkout - - run: apt-get update -y && apt-get install postgresql-client -y - - run: make deps - - run: GO111MODULE=on go install github.com/pressly/goose/cmd/goose - - run: make db-reset-test - - run: make db-migrate-test - - run: make test - - run: make - -workflows: - version: 2 - build: - jobs: - - build-go1.11 diff --git a/.github/ISSUE_TEMPLATE b/.github/ISSUE_TEMPLATE deleted file mode 100644 index ebb563eb..00000000 --- a/.github/ISSUE_TEMPLATE +++ /dev/null @@ -1,13 +0,0 @@ - - -### What version of `micromdm` are you using? - -### What `micromdm` command did you run? - -### What did you expect to see? - -### What did you see instead? diff --git a/.gitignore b/.gitignore index 2f8d222b..5b16a669 100644 --- a/.gitignore +++ b/.gitignore @@ -1,13 +1,4 @@ -vendor/ build/ *.zip *.DS_Store .vscode/ - -cmd/mdmctl/mdmdctl -cmd/micromdm/micromdm - -tools/ngrok/config_root -tools/ngrok/filerepo -tools/ngrok/env -mdm-files/ diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 1c2ef4d1..00000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,142 +0,0 @@ -## [v1.7.1](https://github.com/micromdm/micromdm/compare/v1.6.0...v1.7.1) April, 2020 - -* Replace un-maintained UUID dependency #665 - -## [v1.7.0](https://github.com/micromdm/micromdm/compare/v1.6.0...v1.7.0-alpha) March, 2020 - -### Reliability, scalability, security, and usability improvements: - -* Add device DEP status to API response (#617) -* CLI improvements (#618, #620, #621) -* Support new values for AccountConfiguration (#627) -* Fix issue where DEP watcher would stop permanently for transient network issues (#582, #632) -* Workaround issue where a newly added DEP token would not be used after a restart (#546, #633) -* Fix bug with applying an empty blueprint (#615, #634) -* Add `-no-command-history` flag to disable saving of command history (#640). This works around a race-condition/scalability issue with device records (#556). -* Add dynamic SCEP challenges (#642). Require dynamic SCEP challenges for certificate issuance with `-use-dynamic-challenge` and (only recommended for testing) generate them in enrollment profiles with `-gen-dynamic-challenge`. -* Add MDM commands to enable and disable remote desktop (#651) -* SCEP payload key names were corrected (#652) - -Thanks to our contributors for this release: @grahamgilbert, @n8felton, @tomaswallentinus - -## [v1.6.0](https://github.com/micromdm/micromdm/compare/v1.5.0...v1.6.0) August 14, 2019 - -### Go security update along with updates: - -* Add `erase_device` tools script -* Add assign profile endpoint (#611) -* Add support for User Enrollment (#597) -* Add support for Signing Profiles (#602) -* Add support for setting APNS message expiration (#609) -* Update `mdmctl remove devices -serial` flag to be plural (now `-serials`) (#621) - -Thanks to our contributors for this release: @WardsParadox, @n8felton - -## [v1.5.0](https://github.com/micromdm/micromdm/compare/v1.4.0...v1.5.0) June 15 2019 - -* Fix DEP token update issue (#513, #510) -* Refactor certificate verification and implement UDID-cert authentication (#358, #429) -* Cleanup DEP library and integrate into main project (#504, #505) -* Add API endpoint to retrieve APNS certificate (#503) -* Remove deprecated `-apns` flags from server startup (#528) -* Move API calls to list endpoints from HTTP GET to HTTP POST (#522, #523, #524, #525, #526) -* Add support for the ApplicationConfiguration Setting (#521) -* Add support for the ActivationLockBypassCode Command (#578) -* Allow SCEP client validity to be adjusted via server startup flag (#577) -* Fix bug in mdmctl server saving, switch config when saving automatically (#565, #566) -* Do not send DeviceConfigured automatically when there are no blueprints (#586) -* Set acknowledge time when moving command to completed queue (#581) -* Serialize PurchaseMethod when value is 0. (#592) - -Thanks to our contributors for this release: @discentem, @nkllkc, @arubdesu, @bdemetris, @Lepidopteron, @joncrain, @emman27, @jenjac, @daniellockard, and @0xflotus - -## [v1.4.0](https://github.com/micromdm/micromdm/compare/v1.3.1...v1.4.0) September 6 2018 - -### Stability Improvements - -* Handle DEP INVALID_CURSOR response (#497) -* Use config for block push (#479, #480) -* No longer store SCEP CA on disk or include in enrollment profile (#490) -* Further SCEP fixes (#492, #493) -* Base64 fixes for API CLI tools (#477) -* `mdmctl apply block` now works with self-signed certs (#480) -* Add API CLI tool for dep sync (#481) -* DeviceInformation command API example support query strings (#469) -* Allow setting curl options in environment variable (#455) -* Fix URL params decoding. (#467) -* Reorganize/refactor server init (#458) -* Allow supplying additional `curl` options in API CLI tools (#455) - -Thanks to our contributors for this release: @erikng, @gerardkok, @knightsc, @marpaia, and @ochimo! - -## [v1.3.1](https://github.com/micromdm/micromdm/compare/v1.3.0...v1.3.1) July 10 2018 - -* Update base container to Alpine 3.7 (#437) -* Fix bugs in SCEP enrollment (#451) -* Fix issue with APNS timeouts -- Issue #215 (#446) -* Add device_information and security_info commands with curl API (#448) -* Add support for InstallEnterpriseApplication command (#452) - -## [v1.3.0](https://github.com/micromdm/micromdm/compare/v1.2.0...v1.3.0) - -### Auto-assigner - -* Reorganize/refactor MDM, device, webhook services. #423, #424, #425, #426, #427 -* Do not allow `mdmctl config set` without args. #421 -* Fix for multiple UDID records. #422 -* Added/refactored logging. #405, #425 -* Added `-homepage` switch. #420 -* Warn about deprecated APNS switches. #412 -* Disallow bad TLS configuration with `-tls=false`. #414 -* Refactored MDM types. #341, #415 -* Added DEP auto-assigner feature. #405 -* Fixed bug with authentication error messages. #411 -* Added support for querying devices by serial(s). #363 -* Added support for triggering a DEP sync via API. #404 -* Added support for mdmcert.download directly to `mdmctl` #401 -* Reject network MDM user attempts until we add support. #379 -* Warn when starting without an API key. #396 -* Added tools and documentation for ngrok, curl, and APIs. #392 -* Fix issue with MDM command `AvailableOSUpdates` parsing. #368 -* Validate APNs Push Certificate Topic. #373 -* `mdmctl` now outputs to stdout vs. stderr. #360 -* Added common HTTP library `httputil`. #350 -* Added project Code of Conduct. #334 -* Refactored services (mostly for HA). #348, #349, #351, #352, #353, #354, #355, #359 -* Reorganized project layout. #333, #335, #336, #338, #340, #347 -* Added support for version API. #327 -* Added command response webhook feature. #315 -* Added support for supplied `depsim` URL. #318 -* Added Dockerfile. #316 - -## [v1.2.0](https://github.com/micromdm/micromdm/compare/v1.1.0...v1.2.0) October 31 2017 - -### User Profiles - -* Added support for modifying the default enrollment profile. -* Added support for user level profiles. -* Added support for AccountConfiguration during DEP Enrollment. Specified in blueprints -* Addes support for multiple server configs in `mdmctl`. -* Added `mdmctl mdmcert upload` command which uploads/replaces the servers push certificate. -* Incorporated certhelper into mdmctl. See `mdmctl mdmcert -h` -* Added ENV variables for sensitive flags: `MICROMDM_APNS_KEY_PASSWORD`,`MICROMDM_API_KEY` -* Removed the `-redir-addr` flag. Redirect to HTTPS is only enabled when the 443 port is used. - -## [v1.1.0](https://github.com/micromdm/micromdm/compare/v1.0.0...v1.1.0) June 05 2017 - -### YVR! - -* Import and sign pkgs, generate appmanifest on import. -* Support syncing devices from DEP when token is added. -* Option to include SSL certificates in DEP profile template (-anchor and -use-server-cert) #107 -* /push and /v1/commands API endpoints require API authentication #157 -* Add `mdmctl` binary for interacting with the server over API. #127 -* Save DEP cursor for use after restart. #109 -* Add `-examples` flag to micromdm serve. #119 -* Add HTTP logger (with apache format) for all endpoints. #85 -* Serve a basic homepage at `/`. #113 -* Decrypt armored private keys if the `-apns-password` flag is specified by the user. #105 -* Improved command queue handling of NotNow and other responses. #96 -* Fixed bug that allowed for duplicate device records on re-enrollment. #125 -* Fixed data race in pubsub package. #97 -* Fixed bug that would cause PushInfo Token for the device to be replaced by one for the user. #90 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a9c16eee..fff71e62 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,67 +1,12 @@ -# Contributing +When contributing to this repository, please first discuss the change you wish to make by opening an issue. -Welcome! If you're looking to help, this document is a great place to start! +Please note we have a [code of conduct](./CODE_OF_CONDUCT.md), please follow it in all your interactions with the project. +## Go resources -## Finding things that need help +MicroMDM is written using the Go programming language. Many changes to MicroMDM are added by newcomers to Go. Below are a few resources for learning Go. -Here's a few places to get started and find out what's outstanding. - -- Read through the [MDM Protocol Reference](https://developer.apple.com/library/content/documentation/Miscellaneous/Reference/MobileDeviceManagementProtocolRef/3-MDM_Protocol/MDM_Protocol.html) on the Apple website. Having a deeper understanding of MDM can help with designing features and uncovering bugs. -- Follow the [Quickstart](https://github.com/micromdm/micromdm/wiki/Quickstart) guide and make edits if something doesn't look or work right. -- If you run into a problem that you're not sure how to fix, file a bug in [the issue tracker](https://github.com/micromdm/micromdm/issues) -- Browse through the open issues in [the issue tracker](https://github.com/micromdm/micromdm/issues). We try to tag issues as [**beginner friendly**](https://github.com/micromdm/micromdm/issues?q=is%3Aissue+is%3Aopen+label%3Abeginner-friendly) where appropriate. -- See something that others might benefit from? Considering updating or writing a [wiki page](https://github.com/micromdm/micromdm/wiki). - -## Building the project - -To build MicroMDM from source, you will need [Go 1.11](https://golang.org/dl/) or later installed. - -``` -git clone git@github.com:micromdm/micromdm && cd micromdm -make deps -make - -# run -./build/darwin/micromdm -h -./build/darwin/mdmctl -h -``` - -## Git workflow -``` -username=groob -# add your remote/upstream -git remote add $username git@github.com:groob/micromdm.git - -# update from origin/main -git pull --rebase - -# create a branch -git checkout -b my_feature - -# push changes from my_feature to your fork. -# -u, --set-upstream set upstream for git pull/status -git push -u $username -``` - - -## Go Resources - -A few helpful resources for getting started with Go: - -* [Writing, building, installing, and testing Go code](https://www.youtube.com/watch?v=XCsL89YtqCs) -* [Resources for new Go programmers](http://dave.cheney.net/resources-for-new-go-programmers) -* [How I start](https://howistart.org/posts/go/1) -* [How to write Go code](https://golang.org/doc/code.html) - -## Important libraries and frameworks - -MicroMDM is built using a few popular Go packages outside the standard libraries. It might be worth checking them out. - -- [Go Kit](https://github.com/go-kit/kit#go-kit------) is a set of Go libraries used by MicroMDM to provide [logging](https://github.com/go-kit/kit/tree/master/log), and abstractions for building HTTP services. Its [examples](https://gokit.io/examples/) page is a good place to start. -- [BoltDB](https://github.com/boltdb/bolt#getting-started) is a key/value database used to provide persistant storage for many components of MicroMDM. -- [gorilla/mux](http://www.gorillatoolkit.org/pkg/mux) is used to provide routing for http handlers. - -## Other resources - -Also see [Contributing wiki page](https://github.com/micromdm/micromdm/wiki/Contributing) which has some additional notes on running, troubleshooting, and developing with MicroMDM. +- [Getting Started](https://learn.go.dev) +- [How to Write Go Code](https://golang.org/doc/code.html) +- [Go by Example](https://gobyexample.com) +- [Resources for new Go programmers](https://dave.cheney.net/resources-for-new-go-programmers) diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 42b4c503..00000000 --- a/Dockerfile +++ /dev/null @@ -1,24 +0,0 @@ -FROM golang:latest as builder - -WORKDIR /go/src/github.com/micromdm/micromdm/ - -ENV CGO_ENABLED=0 \ - GOARCH=amd64 \ - GOOS=linux - -COPY . . - -RUN make deps -RUN make - - -FROM alpine:latest - -RUN apk --update add ca-certificates - -COPY --from=builder /go/src/github.com/micromdm/micromdm/build/linux/micromdm /usr/bin/ -COPY --from=builder /go/src/github.com/micromdm/micromdm/build/linux/mdmctl /usr/bin/ - -EXPOSE 80 443 -VOLUME ["/var/db/micromdm"] -CMD ["micromdm", "serve"] diff --git a/Makefile b/Makefile deleted file mode 100644 index 37e874b5..00000000 --- a/Makefile +++ /dev/null @@ -1,148 +0,0 @@ -all: build - -.PHONY: build - -ifeq ($(GOPATH),) - PATH := $(HOME)/go/bin:$(PATH) -else - PATH := $(GOPATH)/bin:$(PATH) -endif - -export GO111MODULE=on - -#Specify a minimum version for macos otherwise notarization will fail -CGO_LDFLAGS=-mmacosx-version-min=10.12 - -VERSION = $(shell git describe --tags --always --dirty) -BRANCH = $(shell git rev-parse --abbrev-ref HEAD) -REVISION = $(shell git rev-parse HEAD) -REVSHORT = $(shell git rev-parse --short HEAD) -USER = $(shell whoami) -GOVERSION = $(shell go version | awk '{print $$3}') -NOW = $(shell date -u +"%Y-%m-%dT%H:%M:%SZ") -SHELL = /bin/sh - -ifndef ($(DOCKER_IMAGE_NAME)) - DOCKER_IMAGE_NAME = micromdm/micromdm -endif -DOCKER_IMAGE_TAG = $(shell echo ${VERSION} | sed 's/^v//') - -ifneq ($(OS), Windows_NT) - CURRENT_PLATFORM = linux - ifeq ($(shell uname), Darwin) - SHELL := /bin/sh - CURRENT_PLATFORM = darwin - endif -else - CURRENT_PLATFORM = windows -endif - -ifeq ($(PG_HOST),) -PG_HOST := localhost -endif - -BUILD_VERSION = "\ - -X github.com/micromdm/go4/version.appName=${APP_NAME} \ - -X github.com/micromdm/go4/version.version=${VERSION} \ - -X github.com/micromdm/go4/version.branch=${BRANCH} \ - -X github.com/micromdm/go4/version.buildUser=${USER} \ - -X github.com/micromdm/go4/version.buildDate=${NOW} \ - -X github.com/micromdm/go4/version.revision=${REVISION} \ - -X github.com/micromdm/go4/version.goVersion=${GOVERSION} \ - -X github.com/micromdm/micromdm/dep.version=${VERSION}" - -gomodcheck: - @go help mod > /dev/null || (@echo micromdm requires Go version 1.11 or higher && exit 1) - -deps: gomodcheck - @go mod download - -test: - go test -cover -race ./... - -build: micromdm mdmctl - -clean: - rm -rf build/ - rm -f *.zip - -.pre-build: - mkdir -p build/darwin - mkdir -p build/linux - -install-local: \ - install-mdmctl \ - install-micromdm - -.pre-mdmctl: - $(eval APP_NAME = mdmctl) - -mdmctl: .pre-build .pre-mdmctl - go build -o build/$(CURRENT_PLATFORM)/mdmctl -ldflags ${BUILD_VERSION} ./cmd/mdmctl - -xp-mdmctl: .pre-build .pre-mdmctl - GOOS=darwin go build -o build/darwin/mdmctl -ldflags ${BUILD_VERSION} ./cmd/mdmctl - GOOS=linux CGO_ENABLED=0 go build -o build/linux/mdmctl -ldflags ${BUILD_VERSION} ./cmd/mdmctl - -install-mdmctl: .pre-mdmctl - go install -ldflags ${BUILD_VERSION} ./cmd/mdmctl - -APP_NAME = micromdm - -.pre-micromdm: - $(eval APP_NAME = micromdm) - -micromdm: .pre-build .pre-micromdm - go build -o build/$(CURRENT_PLATFORM)/micromdm -ldflags ${BUILD_VERSION} ./cmd/micromdm - -install-micromdm: .pre-micromdm - go install -ldflags ${BUILD_VERSION} ./cmd/micromdm - -xp-micromdm: .pre-build .pre-micromdm - GOOS=darwin go build -o build/darwin/micromdm -ldflags ${BUILD_VERSION} ./cmd/micromdm - GOOS=linux CGO_ENABLED=0 go build -o build/linux/micromdm -ldflags ${BUILD_VERSION} ./cmd/micromdm - -release-zip: xp-micromdm xp-mdmctl - zip -r micromdm_${VERSION}.zip build/ - -docker-build: - GOOS=linux CGO_ENABLED=0 go build -o build/linux/micromdm -ldflags ${BUILD_VERSION} ./cmd/micromdm - docker build -t ${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG} . - -docker-tag: docker-build - docker tag ${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG} ${DOCKER_IMAGE_NAME}:latest - -ngrok: - @./tools/ngrok/screen - -docker-compose: - docker-compose -f docker-compose-dev.yaml up -d - -db-psql-test: - $(call psql_db,micromdm_test) - -db-psql: - $(call psql_db,micromdm) - -define psql_db - PGPASSWORD=micromdm psql --host=${PG_HOST} --port=5432 --username=micromdm --dbname=$(1) -endef - -db-reset-test: - $(call psql_exec,'DROP DATABASE IF EXISTS micromdm_test;') - $(call psql_exec,'CREATE DATABASE micromdm_test;') - -define psql_exec - PGPASSWORD=micromdm psql --host=${PG_HOST} --port=5432 --username=micromdm -c $(1) -endef - -db-migrate-test: - $(call goose_up,micromdm_test) - -db-migrate: - $(call goose_up,micromdm) - -define goose_up - cd ./pg/migrations && goose postgres "host=${PG_HOST} port=5432 user=micromdm dbname=$(1) password=micromdm sslmode=disable" up -endef - diff --git a/cmd/mdmctl/apply.go b/cmd/mdmctl/apply.go deleted file mode 100644 index c881e4d2..00000000 --- a/cmd/mdmctl/apply.go +++ /dev/null @@ -1,379 +0,0 @@ -package main - -import ( - "context" - "crypto" - "crypto/x509" - "encoding/json" - "encoding/pem" - "flag" - "fmt" - "io/ioutil" - "net/http" - "net/url" - "os" - "path/filepath" - "strings" - - "github.com/go-kit/kit/log" - "github.com/google/uuid" - "github.com/pkg/errors" - "golang.org/x/crypto/pkcs12" - - "github.com/micromdm/micromdm/pkg/crypto/profileutil" - "github.com/micromdm/micromdm/platform/blueprint" - "github.com/micromdm/micromdm/platform/profile" -) - -type applyCommand struct { - config *ServerConfig - *remoteServices -} - -func (cmd *applyCommand) setup() error { - cfg, err := LoadServerConfig() - if err != nil { - return err - } - cmd.config = cfg - logger := log.NewLogfmtLogger(os.Stderr) - remote, err := setupClient(logger) - if err != nil { - return err - } - cmd.remoteServices = remote - return nil -} - -func (cmd *applyCommand) Run(args []string) error { - if len(args) < 1 { - cmd.Usage() - os.Exit(1) - } - if err := cmd.setup(); err != nil { - return err - } - var run func([]string) error - switch strings.ToLower(args[0]) { - case "blueprints": - run = cmd.applyBlueprint - case "dep-tokens": - run = cmd.applyDEPTokens - case "dep-profiles": - run = cmd.applyDEPProfile - case "profiles": - run = cmd.applyProfile - case "app": - run = cmd.applyApp - case "block": - run = cmd.applyBlock - case "users": - run = cmd.applyUser - case "dep-autoassigner": - run = cmd.applyDEPAutoAssigner - default: - cmd.Usage() - os.Exit(1) - } - return run(args[1:]) -} - -func (cmd *applyCommand) Usage() error { - const applyUsage = ` -Apply a resource. - -Valid resource types: - - * blueprints - * profiles - * users - * dep-tokens - * dep-profiles - * dep-autoassigner - * app - * block - -Examples: - # Apply a Blueprint. - mdmctl apply blueprints -f /path/to/blueprint.json - - # Apply a DEP Profile. - mdmctl apply dep-profiles -f /path/to/dep-profile.json - -` - fmt.Println(applyUsage) - return nil -} - -func (cmd *applyCommand) applyBlueprint(args []string) error { - flagset := flag.NewFlagSet("blueprints", flag.ExitOnError) - var ( - flBlueprintPath = flagset.String("f", "", "filename of blueprint JSON to apply") - flTemplate = flagset.Bool("template", false, "print a new blueprint template") - ) - flagset.Usage = usageFor(flagset, "mdmctl apply blueprints [flags]") - if err := flagset.Parse(args); err != nil { - return err - } - - if *flTemplate { - newBlueprint := &blueprint.Blueprint{ - Name: "exampleName", - UUID: uuid.New().String(), - ApplicationURLs: []string{cmd.config.ServerURL + "repo/exampleAppManifest.plist"}, - ProfileIdentifiers: []string{"com.example.my.profile"}, - UserUUID: []string{"your-admin-account-uuid"}, - ApplyAt: []string{"Enroll"}, - } - - enc := json.NewEncoder(os.Stdout) - enc.SetIndent("", " ") - if err := enc.Encode(newBlueprint); err != nil { - return errors.Wrap(err, "encode blueprint template") - } - return nil - } - - if *flBlueprintPath == "" { - flagset.Usage() - return errors.New("bad input: must provide -f or -template flag") - } - - if *flBlueprintPath != "" { - jsonBytes, err := readBytesFromPath(*flBlueprintPath) - if err != nil { - return err - } - var blpt blueprint.Blueprint - err = json.Unmarshal(jsonBytes, &blpt) - if err != nil { - return err - } - - // validate the blueprint account rules - if len(blpt.UserUUID) == 0 && (blpt.SkipPrimarySetupAccountCreation || blpt.SetPrimarySetupAccountAsRegularUser) { - return errors.New("SkipPrimarySetupAccountCreation and SetPrimarySetupAccountAsRegularUser can only be true if there is an account in the UserUUID array.") - } - - ctx := context.Background() - err = cmd.blueprintsvc.ApplyBlueprint(ctx, &blpt) - if err != nil { - return err - } - fmt.Println("applied blueprint", *flBlueprintPath) - return nil - } - - return nil -} - -func (cmd *applyCommand) applyDEPTokens(args []string) error { - flagset := flag.NewFlagSet("dep-tokens", flag.ExitOnError) - var ( - flTokenPath = flagset.String( - "import", - filepath.Join(defaultmdmctlFilesPath, "DEPOAuthToken.json"), - "Filename of p7m encrypted token file (downloaded from DEP portal)") - ) - - flagset.Usage = usageFor(flagset, "mdmctl apply dep-tokens [flags]") - if err := flagset.Parse(args); err != nil { - return err - } - - if *flTokenPath == "" { - return errors.New("must provide -import-token parameter") - } - if _, err := os.Stat(*flTokenPath); os.IsNotExist(err) { - return err - } - p7mBytes, err := ioutil.ReadFile(*flTokenPath) - if err != nil { - return err - } - ctx := context.Background() - err = cmd.configsvc.ApplyDEPToken(ctx, p7mBytes) - if err != nil { - return err - } - fmt.Println("imported DEP token") - return nil -} - -func (cmd *applyCommand) applyBlock(args []string) error { - flagset := flag.NewFlagSet("block", flag.ExitOnError) - var ( - flUDID = flagset.String("udid", "", "UDID of a device to block.") - ) - flagset.Usage = usageFor(flagset, "mdmctl apply block [flags]") - if err := flagset.Parse(args); err != nil { - return err - } - if *flUDID == "" { - flagset.Usage() - return errors.New("bad input: must provide a device UDID to block.") - } - if err := cmd.blocksvc.BlockDevice(context.Background(), *flUDID); err != nil { - return err - } - - // trigger a push - u, err := url.Parse(cmd.config.ServerURL) - if err != nil { - fmt.Println(err) - return nil - } - u.Path = "/push/" + url.QueryEscape(*flUDID) - req, err := http.NewRequest("GET", u.String(), nil) - if err != nil { - fmt.Println(err) - return nil - } - req.SetBasicAuth("micromdm", cmd.config.APIToken) - skipVerifyHTTPClient(cmd.config.SkipVerify).Do(req) - return nil -} - -func loadSigningKey(keyPass, keyPath, certPath string) (crypto.PrivateKey, *x509.Certificate, error) { - certData, err := ioutil.ReadFile(certPath) - if err != nil { - return nil, nil, err - } - - isP12 := filepath.Ext(certPath) == ".p12" - if isP12 { - pkey, cert, err := pkcs12.Decode(certData, keyPass) - return pkey, cert, errors.Wrap(err, "decode p12 contents") - } - - keyData, err := ioutil.ReadFile(keyPath) - if err != nil { - return nil, nil, errors.Wrap(err, "read key from file") - } - - keyDataBlock, _ := pem.Decode(keyData) - if keyDataBlock == nil { - return nil, nil, errors.Errorf("invalid PEM data for private key %s", keyPath) - } - var pemKeyData []byte - if x509.IsEncryptedPEMBlock(keyDataBlock) { - b, err := x509.DecryptPEMBlock(keyDataBlock, []byte(keyPass)) - if err != nil { - return nil, nil, fmt.Errorf("decrypting DES private key %s", err) - } - pemKeyData = b - } else { - pemKeyData = keyDataBlock.Bytes - } - - priv, err := x509.ParsePKCS1PrivateKey(pemKeyData) - if err != nil { - return nil, nil, errors.Wrap(err, "parse private key") - } - - pub, _ := pem.Decode(certData) - if pub == nil { - return nil, nil, errors.Errorf("invalid PEM data for certificate %q", certPath) - } - - cert, err := x509.ParseCertificate(pub.Bytes) - if err != nil { - return nil, nil, errors.Wrap(err, "parse PEM certificate data") - } - - return priv, cert, nil -} - -func (cmd *applyCommand) applyProfile(args []string) error { - flagset := flag.NewFlagSet("profiles", flag.ExitOnError) - var ( - flProfilePath = flagset.String("f", "", "Path to profile payload.") - flSign = flagset.Bool("sign", false, "Sign the profile. Requires key and certificate path.") - flOut = flagset.String("out", "", "Output path for signed profile(optional).") - flKeyPass = flagset.String("password", "", "Password to encrypt/read the signing key(optional) or p12 file.") - flKeyPath = flagset.String("private-key", "", "Path to the signing private key. Don't use with p12 file.") - flCertPath = flagset.String("cert", "", "Path to the signing certificate or p12 file.") - ) - flagset.Usage = func() { - fmt.Fprintf(os.Stderr, "%s\n", - `Upload profiles to the server. - -Uploaded profiles can also be specified in a blueprint, which will be applied on device enrollment. -This command can also be used to replace the enrollment profile. -Profiles can be signed before upload. - -Examples - - # Upload a mobileconfig - mdmctl apply profiles -f /path/to/profile.mobileconfig - - # Sign and upload - mdmctl apply profiles -f /path/to/profile.mobileconfig -private-key key.pem -cert certificate.pem -password secret -sign - - # Sign and save to local directory instead of uploading - # Use "-out -" print the output to stdout instead of a file. - mdmctl apply profiles -f /path/to/profile.mobileconfig -private-key key.pem -cert certificate.pem -password secret -sign -out signed.mobileconfig - -`) - usageFor(flagset, "mdmctl apply profiles [flags]")() - } - if err := flagset.Parse(args); err != nil { - return err - } - if *flProfilePath == "" { - flagset.Usage() - return errors.New("bad input: must provide -f parameter. use - for stdin") - } - profileBytes, err := readBytesFromPath(*flProfilePath) - if err != nil { - return err - } - - if *flSign { - priv, pub, err := loadSigningKey(*flKeyPass, *flKeyPath, *flCertPath) - if err != nil { - return errors.Wrap(err, "loading signing certificate and private key") - } - signed, err := profileutil.Sign(priv, pub, profileBytes) - if err != nil { - return errors.Wrap(err, "signing profile with the specified key") - } - - if *flOut == "-" { // print to stdout and return - _, err = os.Stdout.Write(signed) - return err - } else if *flOut != "" { // write to file and return - return ioutil.WriteFile(*flOut, signed, 0644) - } - - profileBytes = signed - } - - // TODO: to consider just uploading the Mobileconfig data (without a - // Profile struct and doing init server side) - var p profile.Profile - p.Mobileconfig = profileBytes - p.Identifier, err = p.Mobileconfig.GetPayloadIdentifier() - if err != nil { - return err - } - - ctx := context.Background() - err = cmd.profilesvc.ApplyProfile(ctx, &p) - if err != nil { - return err - } - - fmt.Printf("applied profile id %s from %s\n", p.Identifier, *flProfilePath) - return nil -} - -func readBytesFromPath(path string) ([]byte, error) { - if path == "-" { - return ioutil.ReadAll(os.Stdin) - } - if _, err := os.Stat(path); os.IsNotExist(err) { - return nil, err - } - return ioutil.ReadFile(path) -} diff --git a/cmd/mdmctl/apply_app.go b/cmd/mdmctl/apply_app.go deleted file mode 100644 index 94e1e63e..00000000 --- a/cmd/mdmctl/apply_app.go +++ /dev/null @@ -1,205 +0,0 @@ -package main - -import ( - "bytes" - "compress/zlib" - "context" - "encoding/binary" - "flag" - "fmt" - "io/ioutil" - "log" - "net/url" - "os" - "path" - "path/filepath" - "strings" - - "github.com/groob/plist" - "github.com/pkg/errors" - - "github.com/micromdm/micromdm/mdm/appmanifest" -) - -func (cmd *applyCommand) applyApp(args []string) error { - flagset := flag.NewFlagSet("app", flag.ExitOnError) - var ( - flPkgPath = flagset.String("pkg", "", "path to a distribution pkg.") - flPkgURL = flagset.String("pkg-url", "", "use custom pkg url") - flAppManifest = flagset.String("manifest", "-", `path to an app manifest. optional, - will be created if file does not exist.`) - - flHashSize = flagset.Int64("md5size", appmanifest.DefaultMD5Size, "md5 hash size in bytes (optional)") - flSign = flagset.String("sign", "", "sign package before importing, requires specifying a product ID (optional)") - flUpload = flagset.Bool("upload", false, "upload package and/or manifest to micromdm repository.") - ) - flagset.Usage = usageFor(flagset, "mdmctl apply app [flags]") - if err := flagset.Parse(args); err != nil { - return err - } - - pkgurl := *flPkgURL - if pkgurl == "" { - su, err := cmd.serverRepoURL() - if err != nil { - return err - } - pkgurl = pkgURL(su, *flPkgPath) - } - - pkg := *flPkgPath - signed, err := checkSignature(pkg) - if err != nil { - return err - } - - distribution, err := checkDistribution(*flPkgPath) - if err != nil { - return err - } - if !distribution { - fmt.Println(` -[WARNING] The package you're importing is not a macOS distribution package. MDM requires distribution packages. -You can turn a flat package to a distribution one with the productbuild command: - -productbuild --package someFlatPkg.pkg myNewPkg.pkg - -Please rebuild the package and re-run the command. - - `) - } - - if !signed { - if *flSign == "" { - flagset.Usage() - return errors.New(`MDM packages must be signed. Provide signed package or Developer ID with -sign flag`) - } - outpath := filepath.Join(os.TempDir(), filepath.Base(*flPkgPath)) - if err := signPackage(*flPkgPath, outpath, *flSign); err != nil { - return err - } - pkg = outpath // use signed package to create the manifest - } - - // open pkg file - f, err := os.Open(pkg) - if err != nil { - return err - } - defer f.Close() - - opts := []appmanifest.Option{appmanifest.WithMD5Size(*flHashSize)} - manifest, err := appmanifest.Create(&appFile{f}, pkgurl, opts...) - if err != nil { - return errors.Wrap(err, "creating manifest") - } - - var buf bytes.Buffer - enc := plist.NewEncoder(&buf) - enc.Indent(" ") - if err := enc.Encode(manifest); err != nil { - return err - } - - if *flUpload { - // we read the file to generate the appmanifest, so we need to seek to the beginning of the file again. - if _, err := f.Seek(0, 0); err != nil { - return errors.Wrap(err, "reset pkg file reader") - } - err := cmd.appsvc.UploadApp(context.TODO(), nameMannifest(f.Name()), &buf, filepath.Base(f.Name()), f) - if err != nil { - return err - } - } - - switch *flAppManifest { - case "": - case "-": - _, err := os.Stdout.Write(buf.Bytes()) - return err - default: - return ioutil.WriteFile(*flAppManifest, buf.Bytes(), 0644) - } - - return nil -} - -func nameMannifest(pkgName string) string { - trimmed := strings.TrimSuffix(filepath.Base(pkgName), filepath.Ext(pkgName)) - return trimmed + ".plist" -} - -func checkDistribution(pkgPath string) (bool, error) { - const ( - xarHeaderMagic = 0x78617221 - xarHeaderSize = 28 - ) - - f, err := os.Open(pkgPath) - if err != nil { - return false, err - } - defer f.Close() - - hdr := make([]byte, xarHeaderSize) - _, err = f.ReadAt(hdr, 0) - if err != nil { - return false, err - } - tocLenZlib := binary.BigEndian.Uint64(hdr[8:16]) - ztoc := make([]byte, tocLenZlib) - _, err = f.ReadAt(ztoc, xarHeaderSize) - if err != nil { - return false, err - } - - br := bytes.NewBuffer(ztoc) - zr, err := zlib.NewReader(br) - if err != nil { - return false, err - } - toc, err := ioutil.ReadAll(zr) - if err != nil { - return false, err - } - return bytes.Contains(toc, []byte(`Distribution`)), nil -} - -func (cmd *applyCommand) serverRepoURL() (string, error) { - return repoURL(cmd.config.ServerURL) -} - -func pkgURL(repoURL, pkgPath string) string { - u, _ := url.Parse(repoURL) - newPath := path.Join(u.Path, filepath.Base(pkgPath)) - u.Path = newPath - return u.String() -} - -func repoURL(server string) (string, error) { - serverURL, err := url.Parse(server) - if err != nil { - return "", err - } - serverURL.Path = "/repo" - return serverURL.String(), nil -} - -// replaces .pkg with .plist -func manifestURL(repoURL, pkgPath string) string { - pu := pkgURL(repoURL, pkgPath) - trimmed := strings.TrimSuffix(pu, path.Ext(pu)) - return trimmed + ".plist" -} - -type appFile struct { - *os.File -} - -func (af *appFile) Size() int64 { - info, err := af.Stat() - if err != nil { - log.Fatal(err) - } - return info.Size() -} diff --git a/cmd/mdmctl/apply_app_test.go b/cmd/mdmctl/apply_app_test.go deleted file mode 100644 index ab2b09c0..00000000 --- a/cmd/mdmctl/apply_app_test.go +++ /dev/null @@ -1,15 +0,0 @@ -package main - -import ( - "testing" -) - -func TestPkgURL(t *testing.T) { - baseURL := "https://mdm.acme.co/repo" - pkgPath := "/Users/user/Desktop/dep_pkg-foo_1.1.pkg" - u := pkgURL(baseURL, pkgPath) - if have, want := u, "https://mdm.acme.co/repo/dep_pkg-foo_1.1.pkg"; have != want { - t.Errorf("have %s, want %s", have, want) - } - -} diff --git a/cmd/mdmctl/apply_dep_autoassigner.go b/cmd/mdmctl/apply_dep_autoassigner.go deleted file mode 100644 index ac13d573..00000000 --- a/cmd/mdmctl/apply_dep_autoassigner.go +++ /dev/null @@ -1,37 +0,0 @@ -package main - -import ( - "context" - "flag" - "fmt" - - "github.com/micromdm/micromdm/platform/dep/sync" - "github.com/pkg/errors" -) - -func (cmd *applyCommand) applyDEPAutoAssigner(args []string) error { - flagset := flag.NewFlagSet("dep-autoassigner", flag.ExitOnError) - var ( - flFilter = flagset.String("filter", "*", "filter string (only '*' supported right now)") - flProfileUUID = flagset.String("uuid", "", "DEP profile UUID to set") - ) - flagset.Usage = usageFor(flagset, "mdmctl apply dep-autoassigner [flags]") - if err := flagset.Parse(args); err != nil { - return err - } - - if *flFilter == "" || *flProfileUUID == "" { - return errors.New("bad input: must provide both -filter and -uuid") - } - - assigner := sync.AutoAssigner{*flFilter, *flProfileUUID} - - err := cmd.depsyncsvc.ApplyAutoAssigner(context.TODO(), &assigner) - if err != nil { - return err - } - - fmt.Printf("saved auto-assign filter '%s' to DEP profile UUID '%s'\n", assigner.Filter, assigner.ProfileUUID) - fmt.Println("newly added DEP devices will be auto-assigned to the above profile UUID") - return nil -} diff --git a/cmd/mdmctl/apply_dep_profile.go b/cmd/mdmctl/apply_dep_profile.go deleted file mode 100644 index 82c0f874..00000000 --- a/cmd/mdmctl/apply_dep_profile.go +++ /dev/null @@ -1,152 +0,0 @@ -package main - -import ( - "context" - "crypto/tls" - "crypto/x509" - "encoding/json" - "flag" - "fmt" - "net/url" - "os" - - "github.com/pkg/errors" - - "github.com/micromdm/micromdm/dep" - "github.com/micromdm/micromdm/pkg/crypto" - "github.com/micromdm/micromdm/platform/dep/sync" -) - -func certificatesFromURL(serverURL string, insecure bool) ([]*x509.Certificate, error) { - urlParsed, err := url.Parse(serverURL) - if err != nil { - return nil, err - } - addr := urlParsed.Host - if urlParsed.Port() == "" { - addr += ":443" - } - conn, err := tls.Dial("tcp", addr, &tls.Config{InsecureSkipVerify: insecure}) - if err != nil { - return nil, err - } - defer conn.Close() - return conn.ConnectionState().PeerCertificates, nil -} - -func (cmd *applyCommand) applyDEPProfile(args []string) error { - flagset := flag.NewFlagSet("dep-profiles", flag.ExitOnError) - var ( - flProfilePath = flagset.String("f", "", "filename of DEP profile to apply") - flTemplate = flagset.Bool("template", false, "print a JSON example of a DEP profile") - flAnchorFile = flagset.String("anchor", "", "filename of PEM cert(s) to add to anchor certs in template") - flUseServer = flagset.Bool("use-server-cert", false, "use the server cert(s) to add to anchor certs in template") - flFilter = flagset.String("filter", "", "set the auto-assign filter to for the defined profile") - ) - flagset.Usage = usageFor(flagset, "mdmctl apply dep-profiles [flags]") - if err := flagset.Parse(args); err != nil { - return err - } - - if *flTemplate { - var anchorCerts []*x509.Certificate - if *flAnchorFile != "" { - certs, err := crypto.ReadPEMCertificatesFile(*flAnchorFile) - if err != nil { - return err - } - anchorCerts = append(anchorCerts, certs...) - } - if *flUseServer { - certs, err := certificatesFromURL(cmd.config.ServerURL, cmd.config.SkipVerify) - if err != nil { - return err - } - anchorCerts = append(anchorCerts, certs...) - } - return printDEPProfileTemplate(anchorCerts) - } - - if *flProfilePath == "" { - flagset.Usage() - return errors.New("bad input: must provide -f or -template parameter ") - } - - var output *os.File - { - if *flProfilePath == "-" { - output = os.Stdin - } else { - var err error - output, err = os.Open(*flProfilePath) - if err != nil { - return err - } - defer output.Close() - } - } - - var profile dep.Profile - if err := json.NewDecoder(output).Decode(&profile); err != nil { - return errors.Wrap(err, "decode DEP Profile JSON") - } - - resp, err := cmd.depsvc.DefineProfile(context.TODO(), &profile) - if err != nil { - return errors.Wrap(err, "define dep profile") - } - - // TODO: it would be nice to encode back a profile that save the - // UUID for future reference. - fmt.Printf("Defined DEP Profile with UUID %s\n", resp.ProfileUUID) - - if *flFilter != "" { - assigner := sync.AutoAssigner{*flFilter, resp.ProfileUUID} - err := cmd.depsyncsvc.ApplyAutoAssigner(context.TODO(), &assigner) - if err != nil { - return errors.Wrap(err, "set auto-assigner") - } - fmt.Printf("Saved auto-assign filter '%s' for this DEP profile\n", *flFilter) - } - - return nil -} - -func printDEPProfileTemplate(anchorCerts []*x509.Certificate) error { - var anchorCertStr string = "[]" - - // convert certificates into base64 encoded strings - // json.Marshal does this for us for byte[] arrays - if len(anchorCerts) > 0 { - var certs [][]byte - for _, cert := range anchorCerts { - certs = append(certs, cert.Raw) - } - jsonBytes, err := json.Marshal(certs) - if err != nil { - return nil - } - anchorCertStr = string(jsonBytes) - } - - resp := fmt.Sprintf(`{ - "profile_name": "(Required) Human readable name", - "url": "https://mymdm.example.org/mdm/enroll", - "allow_pairing": true, - "is_supervised": false, - "is_multi_user": false, - "is_mandatory": false, - "await_device_configured": false, - "is_mdm_removable": true, - "support_phone_number": "(Optional) +1 408 555 1010", - "support_email_address": "(Optional) support@example.com", - "org_magic": "(Optional)", - "anchor_certs": %s, - "supervising_host_certs": [], - "skip_setup_items": ["AppleID", "Android"], - "department": "(Optional) support@example.com", - "devices": ["SERIAL1","SERIAL2"] -}`, anchorCertStr) - fmt.Println(resp) - return nil -} diff --git a/cmd/mdmctl/apply_user.go b/cmd/mdmctl/apply_user.go deleted file mode 100644 index e67ea0e7..00000000 --- a/cmd/mdmctl/apply_user.go +++ /dev/null @@ -1,95 +0,0 @@ -package main - -import ( - "context" - "encoding/json" - "flag" - "fmt" - "io/ioutil" - "os" - - "github.com/groob/plist" - "github.com/pkg/errors" - - "github.com/micromdm/micromdm/pkg/crypto/password" - "github.com/micromdm/micromdm/platform/user" -) - -func (cmd *applyCommand) applyUser(args []string) error { - flagset := flag.NewFlagSet("users", flag.ExitOnError) - var ( - flUserManifest = flagset.String("f", "", "Path to user manifest") - flTemplate = flagset.Bool("template", false, "Print a JSON example of a user manifest.") - flPassword = flagset.String("password", "", "Password of the user. Only required when creating a new user.") - ) - flagset.Usage = usageFor(flagset, "mdmctl apply users [flags]") - if err := flagset.Parse(args); err != nil { - return err - } - - if *flTemplate { - printUserTemplate() - return nil - } - - manifestData, err := ioutil.ReadFile(*flUserManifest) - if err != nil { - return errors.Wrap(err, "read user manifest file") - } - - var manifest user.User - if err := json.Unmarshal(manifestData, &manifest); err != nil { - return errors.Wrap(err, "unmarshal user manifest") - } - - if manifest.UUID == "" && *flPassword == "" { - return errors.New("password argument must be provided when creating a user") - } - - if *flPassword != "" { - salted, err := password.SaltedSHA512PBKDF2(*flPassword) - if err != nil { - return errors.Wrap(err, "salting plaintext password") - } - hashDict := struct { - SaltedSHA512PBKDF2 password.SaltedSHA512PBKDF2Dictionary `plist:"SALTED-SHA512-PBKDF2"` - }{ - SaltedSHA512PBKDF2: salted, - } - hashPlist, err := plist.Marshal(hashDict) - if err != nil { - return errors.Wrap(err, "marshal salted password to plist") - } - manifest.PasswordHash = hashPlist - } - - usr, err := cmd.usersvc.ApplyUser(context.TODO(), manifest) - if err != nil { - return errors.Wrap(err, "apply user with mdmctl") - } - - f, err := os.OpenFile(*flUserManifest, os.O_RDWR, os.ModeAppend) - if err != nil { - return errors.Wrapf(err, "open user manifest %s", *flUserManifest) - } - defer f.Close() - - enc := json.NewEncoder(f) - enc.SetIndent("", " ") - if err := enc.Encode(usr); err != nil { - return errors.Wrap(err, "encode user manifest") - } - return nil - -} - -func printUserTemplate() { - jsn := ` -{ - "user_shortname": "", - "user_longname": "", - "hidden": false -} -` - fmt.Println(jsn) -} diff --git a/cmd/mdmctl/config.go b/cmd/mdmctl/config.go deleted file mode 100644 index 4cdc341c..00000000 --- a/cmd/mdmctl/config.go +++ /dev/null @@ -1,320 +0,0 @@ -package main - -import ( - "encoding/json" - "flag" - "fmt" - "io/ioutil" - "log" - "net/url" - "os" - "os/user" - "path/filepath" - "strings" - - "crypto/tls" - "net/http" - - "github.com/pkg/errors" -) - -type configCommand struct { - config *ClientConfig -} - -// skipVerifyHTTPClient returns an *http.Client with InsecureSkipVerify set -// to true for its TLS config. This allows self-signed SSL certificates. -func skipVerifyHTTPClient(skipVerify bool) *http.Client { - if skipVerify { - tlsConfig := &tls.Config{InsecureSkipVerify: true} - transport := &http.Transport{TLSClientConfig: tlsConfig} - return &http.Client{Transport: transport} - } - return http.DefaultClient -} - -func (cmd *configCommand) Run(args []string) error { - if len(args) < 1 { - cmd.Usage() - os.Exit(1) - } - - if strings.ToLower(args[0]) != "migrate" { - checkForOldConfig() - } - - var run func([]string) error - switch strings.ToLower(args[0]) { - case "migrate": - run = migrateCmd - case "set": - run = setCmd - case "switch": - run = switchCmd - case "print": - printConfig() - return nil - default: - cmd.Usage() - os.Exit(1) - } - - return run(args[1:]) -} - -func printConfig() { - path, err := clientConfigPath() - if err != nil { - log.Fatal(err) - } - cfgData, err := ioutil.ReadFile(path) - if err != nil { - log.Fatal(err) - } - fmt.Println(string(cfgData)) -} - -func (cmd *configCommand) Usage() error { - const help = ` -mdmctl config print -mdmctl config set -h -mdmctl config switch -h -` - fmt.Println(help) - return nil -} - -func checkForOldConfig() error { - configPath, err := namedClientConfigPath("default.json") - if err != nil { - return err - } - if _, err := os.Stat(configPath); !os.IsNotExist(err) { - fmt.Println("Found old style config. You must migrate it to continue") - fmt.Println("Run `mdmctl config migrate -name=myconfig`") - os.Exit(1) - } - return nil -} -func migrateServerConfig(configName string) error { - configPath, err := namedClientConfigPath("default.json") - if err != nil { - return err - } - cfgData, err := ioutil.ReadFile(configPath) - if err != nil { - return err - } - var serverCfg *ServerConfig - err = json.Unmarshal(cfgData, &serverCfg) - if err != nil { - return errors.Wrapf(err, "failed to unmarshal %s", configPath) - } - if err = saveServerConfig(serverCfg, configName); err != nil { - return err - } - if err = os.Remove(configPath); err != nil { - return err - } - err = switchServerConfig(configName) - if err != nil { - err = fmt.Errorf("Failed to set %s as active config", configName) - if err != nil { - return errors.Wrapf(err, "Failed to set %s as active config", configName) - } - } - fmt.Println("Successfully migrated old config.") - return nil -} - -func setCmd(args []string) error { - flagset := flag.NewFlagSet("set", flag.ExitOnError) - var ( - flName = flagset.String("name", "", "name of the server") - flToken = flagset.String("api-token", "", "api token to connect to micromdm server") - flServerURL = flagset.String("server-url", "", "server url of micromdm server") - flSkipVerify = flagset.Bool("skip-verify", false, "skip verification of server certificate (insecure)") - ) - - flagset.Usage = usageFor(flagset, "mdmctl config set [flags]") - if err := flagset.Parse(args); err != nil { - return err - } - - if flagset.NFlag() == 0 { - flagset.Usage() - os.Exit(1) - } - - cfg := new(ServerConfig) - - if *flToken == "" { - return errors.New("bad input: api-token must be provided.") - } - cfg.APIToken = *flToken - - validatedURL, err := validateServerURL(*flServerURL) - if err != nil { - return err - } - cfg.ServerURL = validatedURL - - cfg.SkipVerify = *flSkipVerify - - err = saveServerConfig(cfg, *flName) - if err != nil { - return err - } - return switchServerConfig(*flName) -} - -func switchCmd(args []string) error { - flagset := flag.NewFlagSet("switch", flag.ExitOnError) - var ( - flName = flagset.String("name", "", "name of the server to switch to") - ) - - flagset.Usage = usageFor(flagset, "mdmctl config switch [flags]") - if err := flagset.Parse(args); err != nil { - return err - } - - return switchServerConfig(*flName) -} -func migrateCmd(args []string) error { - flagset := flag.NewFlagSet("migrate", flag.ExitOnError) - var ( - flName = flagset.String("name", "", "name of the server to switch to") - ) - - if err := flagset.Parse(args); err != nil { - return err - } - - return migrateServerConfig(*flName) -} - -func validateServerURL(serverURL string) (string, error) { - if serverURL == "" { - return serverURL, errors.New("bad input: server-url must be provided.") - } - - if !(strings.HasPrefix(serverURL, "http") || - strings.HasPrefix(serverURL, "https")) { - serverURL = "https://" + serverURL - } - u, err := url.Parse(serverURL) - if err != nil { - return "", err - } - u.Path = "/" - serverURL = u.String() - - return serverURL, nil -} - -func clientConfigPath() (string, error) { - configPath, err := namedClientConfigPath("servers.json") - if err != nil { - return "", err - } - return configPath, err -} - -func namedClientConfigPath(fileName string) (string, error) { - usr, err := user.Current() - if err != nil { - return "", err - } - return filepath.Join(usr.HomeDir, ".micromdm", fileName), err -} - -func saveClientConfig(clientCfg *ClientConfig) error { - configPath, err := clientConfigPath() - if err != nil { - return err - } - if _, err := os.Stat(filepath.Dir(configPath)); os.IsNotExist(err) { - if err := os.MkdirAll(filepath.Dir(configPath), 0777); err != nil { - return err - } - } - f, err := os.OpenFile(configPath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600) - if err != nil { - return err - } - defer f.Close() - enc := json.NewEncoder(f) - enc.SetIndent("", " ") - return enc.Encode(clientCfg) -} - -func saveServerConfig(cfg *ServerConfig, name string) error { - clientCfg, err := loadClientConfig() - if err != nil { - if os.IsNotExist(errors.Cause(err)) { - clientCfg = new(ClientConfig) - clientCfg.Servers = make(map[string]ServerConfig) - } else { - return err - } - } - if cfg == nil { - cfg = new(ServerConfig) - } - clientCfg.Servers[name] = *cfg - return saveClientConfig(clientCfg) -} - -func switchServerConfig(name string) error { - clientCfg, err := loadClientConfig() - if err != nil { - return err - } - if _, ok := clientCfg.Servers[name]; !ok { - return fmt.Errorf("no server named \"%s\" found", name) - } - clientCfg.Active = name - return saveClientConfig(clientCfg) -} - -func loadClientConfig() (*ClientConfig, error) { - path, err := clientConfigPath() - if err != nil { - return nil, err - } - cfgData, err := ioutil.ReadFile(path) - if err != nil { - return nil, errors.Wrap(err, "unable to load default config file") - } - var cfg ClientConfig - err = json.Unmarshal(cfgData, &cfg) - if err != nil { - return nil, fmt.Errorf("failed to unmarshal %s : %s", path, err) - } - if cfg.Servers == nil { - cfg.Servers = map[string]ServerConfig{} - } - return &cfg, nil -} - -func LoadServerConfig() (*ServerConfig, error) { - cfg, err := loadClientConfig() - if err != nil { - return nil, err - } - var serverCfg ServerConfig - serverCfg = cfg.Servers[cfg.Active] - return &serverCfg, nil -} - -type ClientConfig struct { - Active string `json:"active"` - Servers map[string]ServerConfig `json:"servers"` -} - -type ServerConfig struct { - APIToken string `json:"api_token"` - ServerURL string `json:"server_url"` - SkipVerify bool `json:"skip_verify"` -} diff --git a/cmd/mdmctl/config_test.go b/cmd/mdmctl/config_test.go deleted file mode 100644 index 720438e9..00000000 --- a/cmd/mdmctl/config_test.go +++ /dev/null @@ -1,41 +0,0 @@ -package main - -import "testing" - -func TestValidateServerURL(t *testing.T) { - - tests := []struct { - name string - input string - expected string - }{ - { - name: "http", - input: "http://localhost:8000", - expected: "http://localhost:8000/", - }, - { - name: "https", - input: "https://localhost:8000", - expected: "https://localhost:8000/", - }, - { - name: "trailing_slash", - input: "https://localhost:8000/", - expected: "https://localhost:8000/", - }, - { - name: "no_prefix", - input: "localhost:8000", - expected: "https://localhost:8000/", - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - actualURL, _ := validateServerURL(tt.input) - if have, want := actualURL, tt.expected; have != want { - t.Errorf("have %s, want %s", have, want) - } - }) - } -} diff --git a/cmd/mdmctl/get.go b/cmd/mdmctl/get.go deleted file mode 100644 index a06a9d95..00000000 --- a/cmd/mdmctl/get.go +++ /dev/null @@ -1,366 +0,0 @@ -package main - -import ( - "context" - "crypto/x509" - "encoding/json" - "flag" - "fmt" - "os" - "path/filepath" - "strings" - "text/tabwriter" - - "github.com/go-kit/kit/log" - "github.com/micromdm/micromdm/pkg/crypto" - "github.com/micromdm/micromdm/platform/blueprint" - "github.com/micromdm/micromdm/platform/device" - "github.com/micromdm/micromdm/platform/profile" - "github.com/pkg/errors" -) - -type getCommand struct { - config *ServerConfig - *remoteServices -} - -func (cmd *getCommand) setup() error { - cfg, err := LoadServerConfig() - if err != nil { - return err - } - cmd.config = cfg - logger := log.NewLogfmtLogger(os.Stderr) - - remote, err := setupClient(logger) - if err != nil { - return err - } - cmd.remoteServices = remote - return nil -} - -func (cmd *getCommand) Run(args []string) error { - if len(args) < 1 { - cmd.Usage() - os.Exit(1) - } - - if err := cmd.setup(); err != nil { - return err - } - - var run func([]string) error - switch strings.ToLower(args[0]) { - case "dev", "device", "devices": - run = cmd.getDevices - case "dep-devices": - run = cmd.getDEPDevices - case "dep-account": - run = cmd.getDEPAccount - case "dep-profiles": - run = cmd.getDEPProfiles - case "dep-tokens": - run = cmd.getDepTokens - case "blueprints": - run = cmd.getBlueprints - case "profiles": - run = cmd.getProfiles - case "users": - run = cmd.getUsers - case "apps": - run = cmd.getApps - case "dep-autoassigners": - run = cmd.getDEPAutoAssigners - default: - cmd.Usage() - os.Exit(1) - } - - return run(args[1:]) -} - -func (cmd *getCommand) Usage() error { - const getUsage = ` -Display one or many resources. - -Valid resource types: - - * devices - * blueprints - * dep-tokens - * dep-devices - * dep-account - * dep-profiles - * dep-autoassigners - * users - * profiles - * apps - -Examples: - # Get a list of devices - mdmctl get devices - - # Get a device by serial (TODO implement filtering) - mdmctl get devices -serials=C02ABCDEF -` - fmt.Println(getUsage) - return nil -} - -type devicesTableOutput struct{ w *tabwriter.Writer } - -func (out *devicesTableOutput) BasicHeader() { - fmt.Fprintf(out.w, "UDID\tSerialNumber\tEnrollmentStatus\tLastSeen\n") -} - -func (out *devicesTableOutput) BasicFooter() { - out.w.Flush() -} - -func (cmd *getCommand) getDevices(args []string) error { - flagset := flag.NewFlagSet("devices", flag.ExitOnError) - var ( - flFilterSerials = flagset.String("serials", "", "device serial, optionally comma-separated") - ) - flagset.Usage = usageFor(flagset, "mdmctl get devices [flags]") - if err := flagset.Parse(args); err != nil { - return err - } - w := tabwriter.NewWriter(os.Stdout, 0, 4, 2, ' ', 0) - out := &devicesTableOutput{w} - out.BasicHeader() - defer out.BasicFooter() - ctx := context.Background() - - // convert string to []string in case a filter serial is defined - // nil serials will return all serials from the database - var flFilterSerialsSlice []string - if *flFilterSerials != "" { - flFilterSerialsSlice = strings.Split(*flFilterSerials, ",") - } - - devices, err := cmd.devicesvc.ListDevices(ctx, device.ListDevicesOption{FilterSerial: flFilterSerialsSlice}) - if err != nil { - return err - } - for _, d := range devices { - fmt.Fprintf(out.w, "%s\t%s\t%v\t%s\n", d.UDID, d.SerialNumber, d.EnrollmentStatus, d.LastSeen) - } - return nil -} - -const defaultmdmctlFilesPath = "mdm-files" - -func (cmd *getCommand) getDepTokens(args []string) error { - flagset := flag.NewFlagSet("dep-tokens", flag.ExitOnError) - var ( - flFullCK = flagset.Bool("v", false, "Display full ConsumerKey in summary list") - flPublicKeyPath = flagset.String( - "export-public-key", - filepath.Join(defaultmdmctlFilesPath, "DEPPublicKey"), - "Filename of public key to write (to be uploaded to deploy.apple.com)", - ) - flTokenPath = flagset.String( - "export-token", - filepath.Join(defaultmdmctlFilesPath, "DEPOAuthToken.json"), - "Filename to save decrypted oauth token (JSON)") - ) - flagset.Usage = usageFor(flagset, "mdmctl get dep-tokens [flags]") - if err := flagset.Parse(args); err != nil { - return err - } - - w := tabwriter.NewWriter(os.Stdout, 0, 4, 2, ' ', 0) - fmt.Fprintf(w, "ConsumerKey\tAccessTokenExpiry\n") - ctx := context.Background() - tokens, certBytes, err := cmd.configsvc.GetDEPTokens(ctx) - if err != nil { - return err - } - var ckTrimmed string - for _, t := range tokens { - if len(t.ConsumerKey) > 40 && !*flFullCK { - ckTrimmed = t.ConsumerKey[0:39] + "…" - } else { - ckTrimmed = t.ConsumerKey - } - fmt.Fprintf(w, "%s\t%s\n", ckTrimmed, t.AccessTokenExpiry.String()) - } - w.Flush() - - if *flPublicKeyPath != "" && certBytes != nil { - - if err := os.MkdirAll(filepath.Dir(*flPublicKeyPath), 0755); err != nil { - return errors.Wrapf(err, "create directory %s", filepath.Dir(*flPublicKeyPath)) - } - - cert, err := x509.ParseCertificate(certBytes) - if err != nil { - return err - } - err = crypto.WritePEMCertificateFile(cert, *flPublicKeyPath) - if err != nil { - return err - } - fmt.Printf("\nWrote DEP public key to: %s\n", *flPublicKeyPath) - } - - if *flTokenPath != "" && len(tokens) > 0 { - t := tokens[0] - - if err := os.MkdirAll(filepath.Dir(*flTokenPath), 0755); err != nil { - return errors.Wrapf(err, "create directory %s", filepath.Dir(*flTokenPath)) - } - - tokenFile, err := os.Create(*flTokenPath) - if err != nil { - return err - } - defer tokenFile.Close() - - err = json.NewEncoder(tokenFile).Encode(t) - if err != nil { - return err - } - - fmt.Printf("\nWrote DEP token JSON to: %s\n", *flTokenPath) - if len(tokens) > 1 { - fmt.Println("WARNING: more than one DEP token returned; only saved first") - } - } - - return nil -} - -func (cmd *getCommand) getBlueprints(args []string) error { - flagset := flag.NewFlagSet("blueprints", flag.ExitOnError) - var ( - flBlueprintName = flagset.String("name", "", "name of blueprint") - flJSONName = flagset.String("f", "-", "filename of JSON to save to") - ) - flagset.Usage = usageFor(flagset, "mdmctl get blueprints [flags]") - if err := flagset.Parse(args); err != nil { - return err - } - - ctx := context.Background() - blueprints, err := cmd.blueprintsvc.GetBlueprints(ctx, blueprint.GetBlueprintsOption{FilterName: *flBlueprintName}) - if err != nil { - return err - } - - if *flBlueprintName == "" || len(blueprints) < 1 { - w := tabwriter.NewWriter(os.Stdout, 0, 4, 2, ' ', 0) - fmt.Fprintf(w, "Name\tUUID\tManifests\tProfiles\tApply At\n") - for _, bp := range blueprints { - var applyAtStr string - if len(bp.ApplyAt) > 0 { - applyAtStr = strings.Join(bp.ApplyAt, ",") - } else { - applyAtStr = "(None)" - } - fmt.Fprintf( - w, - "%s\t%s\t%d\t%d\t%s\n", - bp.Name, - bp.UUID, - len(bp.ApplicationURLs), - len(bp.ProfileIdentifiers), - applyAtStr, - ) - } - w.Flush() - } else if *flJSONName != "" { - bp := blueprints[0] - - var output *os.File - { - if *flJSONName == "-" { - output = os.Stdout - } else { - var err error - output, err = os.Create(*flJSONName) - if err != nil { - return err - } - defer output.Close() - } - } - - enc := json.NewEncoder(output) - enc.SetIndent("", " ") - err = enc.Encode(bp) - if err != nil { - return err - } - - if *flJSONName != "-" { - fmt.Printf("wrote blueprint %s to: %s\n", *flBlueprintName, *flJSONName) - if len(blueprints) > 1 { - fmt.Println("WARNING: more than one Blueprint returned; only saved first") - } - } - } - - return nil -} - -func (cmd *getCommand) getProfiles(args []string) error { - flagset := flag.NewFlagSet("profiles", flag.ExitOnError) - var ( - flProfilePath = flagset.String("f", "-", "filename of profile to write") - flIdentifier = flagset.String("id", "", "profile Identifier") - ) - flagset.Usage = usageFor(flagset, "mdmctl get blueprints [flags]") - if err := flagset.Parse(args); err != nil { - return err - } - - ctx := context.Background() - profiles, err := cmd.profilesvc.GetProfiles(ctx, profile.GetProfilesOption{Identifier: *flIdentifier}) - if err != nil { - return err - } - - if *flIdentifier == "" || len(profiles) < 1 { - w := tabwriter.NewWriter(os.Stdout, 0, 4, 2, ' ', 0) - fmt.Fprintf(w, "Identifier\tLength\n") - for _, p := range profiles { - fmt.Fprintf( - w, - "%s\t%d\n", - p.Identifier, - len(p.Mobileconfig), - ) - } - w.Flush() - } else if *flProfilePath != "" { - p := profiles[0] - - var output *os.File - { - if *flProfilePath == "-" { - output = os.Stdout - } else { - var err error - output, err = os.Create(*flProfilePath) - if err != nil { - return err - } - defer output.Close() - } - } - _, err = output.Write([]byte(p.Mobileconfig)) - if err != nil { - return err - } - if *flProfilePath != "-" { - fmt.Printf("wrote profile id %s to: %s\n", p.Identifier, *flProfilePath) - if len(profiles) > 1 { - fmt.Println("WARNING: more than one Profile returned; only saved first") - } - } - } - return nil -} diff --git a/cmd/mdmctl/get_app.go b/cmd/mdmctl/get_app.go deleted file mode 100644 index 744305f6..00000000 --- a/cmd/mdmctl/get_app.go +++ /dev/null @@ -1,62 +0,0 @@ -package main - -import ( - "context" - "flag" - "fmt" - "io/ioutil" - "os" - "text/tabwriter" - - "github.com/micromdm/micromdm/platform/appstore" -) - -type appsTableOutput struct{ w *tabwriter.Writer } - -func (out *appsTableOutput) BasicHeader() { - fmt.Fprintf(out.w, "Name\tManifestURL\n") -} - -func (out *appsTableOutput) BasicFooter() { - out.w.Flush() -} - -func (cmd *getCommand) getApps(args []string) error { - flagset := flag.NewFlagSet("apps", flag.ExitOnError) - var ( - flNameFilter = flagset.String("name", "", "specify the name of the app to get full details") - flOutputPath = flagset.String("f", "-", "path to save file to. defaults to stdout.") - ) - flagset.Usage = usageFor(flagset, "mdmctl get apps [flags]") - if err := flagset.Parse(args); err != nil { - return err - } - ctx := context.Background() - apps, err := cmd.appsvc.ListApplications(ctx, appstore.ListAppsOption{ - FilterName: []string{*flNameFilter}, - }) - if err != nil { - return err - } - if *flNameFilter != "" && (len(apps) != 0) { - payload := apps[0].Payload - if *flOutputPath == "-" { - fmt.Println(string(payload)) - return nil - } - return ioutil.WriteFile(*flOutputPath, payload, 0644) - } - rURL, err := repoURL(cmd.config.ServerURL) - if err != nil { - return err - } - w := tabwriter.NewWriter(os.Stdout, 0, 4, 2, ' ', 0) - out := appsTableOutput{w} - out.BasicHeader() - defer out.BasicFooter() - for _, a := range apps { - manifestURL := rURL + "/" + a.Name - fmt.Fprintf(out.w, "%s\t%s\n", a.Name, manifestURL) - } - return nil -} diff --git a/cmd/mdmctl/get_dep_account.go b/cmd/mdmctl/get_dep_account.go deleted file mode 100644 index ef3a38f3..00000000 --- a/cmd/mdmctl/get_dep_account.go +++ /dev/null @@ -1,38 +0,0 @@ -package main - -import ( - "context" - "flag" - "fmt" - "os" - "text/tabwriter" -) - -type depaccountTableOutput struct{ w *tabwriter.Writer } - -func (out *depaccountTableOutput) BasicHeader() { - fmt.Fprintf(out.w, "OrgName\tOrgPhone\tOrgEmail\tServerName\n") -} - -func (out *depaccountTableOutput) BasicFooter() { - out.w.Flush() -} - -func (cmd *getCommand) getDEPAccount(args []string) error { - flagset := flag.NewFlagSet("dep-account", flag.ExitOnError) - flagset.Usage = usageFor(flagset, "mdmctl get dep-account [flags]") - if err := flagset.Parse(args); err != nil { - return err - } - w := tabwriter.NewWriter(os.Stdout, 0, 4, 2, ' ', 0) - out := &depaccountTableOutput{w} - out.BasicHeader() - defer out.BasicFooter() - ctx := context.Background() - resp, err := cmd.depsvc.GetAccountInfo(ctx) - if err != nil { - return err - } - fmt.Fprintf(out.w, "%s\t%s\t%s\t%s\n", resp.OrgName, resp.OrgPhone, resp.OrgEmail, resp.ServerName) - return nil -} diff --git a/cmd/mdmctl/get_dep_autoassigner.go b/cmd/mdmctl/get_dep_autoassigner.go deleted file mode 100644 index bcf2ecf1..00000000 --- a/cmd/mdmctl/get_dep_autoassigner.go +++ /dev/null @@ -1,31 +0,0 @@ -package main - -import ( - "context" - "flag" - "fmt" - "os" - "text/tabwriter" -) - -func (cmd *getCommand) getDEPAutoAssigners(args []string) error { - flagset := flag.NewFlagSet("dep-autoassigner", flag.ExitOnError) - flagset.Usage = usageFor(flagset, "mdmctl get dep-autoassigner [flags]") - if err := flagset.Parse(args); err != nil { - return err - } - - assigners, err := cmd.depsyncsvc.GetAutoAssigners(context.TODO()) - if err != nil { - return err - } - - w := tabwriter.NewWriter(os.Stdout, 0, 4, 2, ' ', 0) - fmt.Fprintf(w, "Filter\tDEP Profile UUID\n") - for _, a := range assigners { - fmt.Fprintf(w, "%s\t%s\n", a.Filter, a.ProfileUUID) - } - w.Flush() - - return nil -} diff --git a/cmd/mdmctl/get_dep_devices.go b/cmd/mdmctl/get_dep_devices.go deleted file mode 100644 index a12f03a1..00000000 --- a/cmd/mdmctl/get_dep_devices.go +++ /dev/null @@ -1,48 +0,0 @@ -package main - -import ( - "context" - "errors" - "flag" - "fmt" - "os" - "strings" - "text/tabwriter" -) - -type depDevicesTableOutput struct{ w *tabwriter.Writer } - -func (out *depDevicesTableOutput) BasicHeader() { - fmt.Fprintf(out.w, "SerialNumber\tModel\tDeviceFamily\tProfileStatus\tProfileUUID\n") -} - -func (out *depDevicesTableOutput) BasicFooter() { - out.w.Flush() -} - -func (cmd *getCommand) getDEPDevices(args []string) error { - flagset := flag.NewFlagSet("dep-devices", flag.ExitOnError) - flSerials := flagset.String("serials", "", "device serial, optionally comma-separated") - flagset.Usage = usageFor(flagset, "mdmctl get dep-devices [flags]") - if err := flagset.Parse(args); err != nil { - return err - } - if *flSerials == "" { - flagset.Usage() - return errors.New("bad input: must provide a comma-separated list of DEP serials") - } - w := tabwriter.NewWriter(os.Stdout, 0, 4, 2, ' ', 0) - out := &depDevicesTableOutput{w} - out.BasicHeader() - defer out.BasicFooter() - ctx := context.Background() - serials := strings.Split(*flSerials, ",") - resp, err := cmd.depsvc.GetDeviceDetails(ctx, serials) - if err != nil { - return err - } - for _, d := range resp.Devices { - fmt.Fprintf(out.w, "%s\t%s\t%s\t%s\t%s\n", d.SerialNumber, d.Model, d.DeviceFamily, d.ProfileStatus, d.ProfileUUID) - } - return nil -} diff --git a/cmd/mdmctl/get_dep_profiles.go b/cmd/mdmctl/get_dep_profiles.go deleted file mode 100644 index 246c5ca4..00000000 --- a/cmd/mdmctl/get_dep_profiles.go +++ /dev/null @@ -1,96 +0,0 @@ -package main - -import ( - "context" - "encoding/json" - "flag" - "fmt" - "os" - "strings" - "text/tabwriter" -) - -type depProfilesTableOutput struct{ w *tabwriter.Writer } - -func (out *depProfilesTableOutput) BasicHeader() { - fmt.Fprintf(out.w, "Name\tMandatory\tRemovable\tAwaitConfigured\tSkippedItems\n") -} - -func (out *depProfilesTableOutput) BasicFooter() { - out.w.Flush() -} - -const noUUIDText = `The DEP API does not support listing profiles. -A UUID flag must be specified. To get currently assigned profile UUIDs run - mdmctl get dep-devices -serials=serial1,serial2,serial3 -The output of the dep-devices response will contain the profile UUIDs. -` - -func (cmd *getCommand) getDEPProfiles(args []string) error { - flagset := flag.NewFlagSet("dep-profiles", flag.ExitOnError) - var ( - flProfilePath = flagset.String("f", "", "filename of DEP profile to apply") - flUUID = flagset.String("uuid", "", "DEP Profile UUID(required)") - ) - flagset.Usage = usageFor(flagset, "mdmctl get dep-profiles [flags]") - if err := flagset.Parse(args); err != nil { - return err - } - - if *flUUID == "" { - fmt.Println(noUUIDText) - flagset.Usage() - os.Exit(1) - } - - ctx := context.Background() - resp, err := cmd.depsvc.FetchProfile(ctx, *flUUID) - if err != nil { - return err - } - - if *flProfilePath == "" { - w := tabwriter.NewWriter(os.Stdout, 0, 4, 2, ' ', 0) - out := &depProfilesTableOutput{w} - out.BasicHeader() - defer out.BasicFooter() - - fmt.Fprintf(out.w, "%s\t%v\t%v\t%v\t%s\n", - resp.ProfileName, - resp.IsMandatory, - resp.IsMDMRemovable, - resp.AwaitDeviceConfigured, - strings.Join(resp.SkipSetupItems, ","), - ) - } else { - var output *os.File - { - if *flProfilePath == "-" { - output = os.Stdout - } else { - var err error - output, err = os.Create(*flProfilePath) - if err != nil { - return err - } - defer output.Close() - } - } - - // TODO: perhaps we want to store the raw DEP profile for storage - // as we may have problems with default/non-default values getting - // omitted in the marshalled JSON - enc := json.NewEncoder(output) - enc.SetIndent("", " ") - err = enc.Encode(resp) - if err != nil { - return err - } - - if *flProfilePath != "-" { - fmt.Printf("wrote DEP profile %s to: %s\n", *flUUID, *flProfilePath) - } - } - - return nil -} diff --git a/cmd/mdmctl/get_users.go b/cmd/mdmctl/get_users.go deleted file mode 100644 index 8a4f1b4c..00000000 --- a/cmd/mdmctl/get_users.go +++ /dev/null @@ -1,46 +0,0 @@ -package main - -import ( - "context" - "flag" - "fmt" - "os" - "text/tabwriter" - - "github.com/micromdm/micromdm/platform/user" - "github.com/pkg/errors" -) - -type usersTableOutput struct{ w *tabwriter.Writer } - -func (out *usersTableOutput) BasicHeader() { - fmt.Fprintf(out.w, "UUID\tUDID\tUserID\tUserShortName\tUserLongName\n") -} - -func (out *usersTableOutput) BasicFooter() { - out.w.Flush() -} - -func (cmd *getCommand) getUsers(args []string) error { - flagset := flag.NewFlagSet("users", flag.ExitOnError) - flagset.Usage = usageFor(flagset, "mdmctl get users [flags]") - if err := flagset.Parse(args); err != nil { - return err - } - - w := tabwriter.NewWriter(os.Stdout, 0, 4, 2, ' ', 0) - out := &usersTableOutput{w} - out.BasicHeader() - defer out.BasicFooter() - - users, err := cmd.usersvc.ListUsers(context.TODO(), user.ListUsersOption{}) - if err != nil { - return errors.Wrap(err, "list users") - } - - for _, u := range users { - fmt.Fprintf(out.w, "%s\t%s\t%s\t%v\t%s\n", u.UUID, u.UDID, u.UserID, u.UserShortname, u.UserLongname) - } - - return nil -} diff --git a/cmd/mdmctl/mdmcert.download.go b/cmd/mdmctl/mdmcert.download.go deleted file mode 100644 index 6e71129d..00000000 --- a/cmd/mdmctl/mdmcert.download.go +++ /dev/null @@ -1,284 +0,0 @@ -package main - -import ( - "bytes" - "crypto/rand" - "crypto/rsa" - "encoding/base64" - "encoding/hex" - "encoding/json" - "encoding/pem" - "flag" - "fmt" - "io/ioutil" - "net/http" - "os" - - "github.com/fullsailor/pkcs7" - "github.com/go-kit/kit/log" - "github.com/micromdm/micromdm/pkg/crypto" - "github.com/micromdm/micromdm/pkg/crypto/mdmcertutil" - "github.com/pkg/errors" -) - -const ( - mdmcertRequestURL = "https://mdmcert.download/api/v1/signrequest" - // see - // https://github.com/jessepeterson/commandment/blob/1352b51ba6697260d1111eccc3a5a0b5b9af60d0/commandment/mdmcert.py#L23-L28 - mdmcertAPIKey = "f847aea2ba06b41264d587b229e2712c89b1490a1208b7ff1aafab5bb40d47bc" -) - -// format of a signing request to mdmcert.download -type signRequest struct { - CSR string `json:"csr"` // base64 encoded PEM CSR - Email string `json:"email"` - Key string `json:"key"` // server key from above - Encrypt string `json:"encrypt"` // mdmcert pki cert -} - -type mdmcertDownloadCommand struct { - *remoteServices -} - -func (cmd *mdmcertDownloadCommand) setup() error { - logger := log.NewLogfmtLogger(os.Stderr) - remote, err := setupClient(logger) - if err != nil { - return err - } - cmd.remoteServices = remote - return nil -} - -func (cmd *mdmcertDownloadCommand) Usage() error { - const usageText = ` -Request new MDM Push Certificate from https://mdmcert.download -This utility helps obtain an MDM Push Certificate using the service -at mdmcert.download. - -First we'll generate the initial request (which also generates a private key): - - mdmctl mdmcert.download -new -email=cool.mdm.admin@example.org - -This will output the private key into the file mdmcert.download.key. -Then, after you check your email and download the request file you just -need to decrypt the push certificate request: - - mdmctl mdmcert.download -decrypt=~/Downloads/mdm_signed_request.20171122_094910_220.plist.b64.p7 - -This will output the push certificate request to mdmcert.download.req. -Upload this file to https://identity.apple.com and download the signed -certificate. Then use the 'mdmctl mdmcert upload' command to upload it, -(and the above private key) into MicroMDM. - -` - fmt.Println(usageText) - return nil - -} - -func (cmd *mdmcertDownloadCommand) Run(args []string) error { - flagset := flag.NewFlagSet("mdmcert.download", flag.ExitOnError) - flagset.Usage = usageFor(flagset, "mdmctl mdmcert.download [flags]") - var ( - flNew = flagset.Bool("new", false, "Generates a new privkey and uploads new MDM request") - flDecrypt = flagset.String("decrypt", "", "Decrypts and mdmcert.download push certificate request") - flEmail = flagset.String("email", "", "Email address to use in mdmcert request & CSR Subject") - flCountry = flagset.String("country", "US", "Two letter country code for the CSR Subject (example: US).") - flCN = flagset.String("cn", "mdm-push", "CommonName for the CSR Subject.") - flCertPath = flagset.String("pki-cert", "mdmcert.download.pki.crt", "Path for generated MDMCert pki exchange certificate") - flKeyPath = flagset.String("pki-private-key", "mdmcert.download.pki.key", "Path for generated MDMCert pki exchange private key") - flPKeyPass = flagset.String("pki-password", "", "Password to encrypt/read the RSA key.") - flCCSRPath = flagset.String("push-csr", "mdmcert.download.push.csr", "Path for generated Push Certificate CSR") - flCReqPath = flagset.String("push-req", "mdmcert.download.push.req", "Path for generated Push Certificate Request") - flCKeyPath = flagset.String("push-private-key", "mdmcert.download.push.key", "Path to the generated Push Cert private key") - flCPKeyPass = flagset.String("push-password", "", "Password to encrypt/read the push RSA key.") - ) - - if err := flagset.Parse(args); err != nil { - cmd.Usage() - return err - } - - // neither flag was used - if !*flNew && *flDecrypt == "" { - cmd.Usage() - return errors.New("bad input: must either use -new or -decrypt") - } - - // both flags used - if *flNew && (*flDecrypt != "") { - // cmd.Usage() - return errors.New("bad input: can't use both -new and -decrypt") - } - - if *flNew { - if *flEmail == "" { - return errors.New("bad input: must provide -email") - } - - paths := []string{*flCertPath, *flKeyPath, *flCCSRPath, *flCKeyPath} - for _, path := range paths { - if _, err := os.Stat(path); err == nil { - return fmt.Errorf("file already exists: %s", path) - } - } - - pkiKey, pkiCert, err := crypto.SimpleSelfSignedRSAKeypair("mdmcert.download", 365) - if err != nil { - return errors.Wrap(err, "could not create PKI keypair") - } - - pemBlock := &pem.Block{ - Type: "CERTIFICATE", - Headers: nil, - Bytes: pkiCert.Raw, - } - pemPkiCert := pem.EncodeToMemory(pemBlock) - - if err := crypto.WritePEMCertificateFile(pkiCert, *flCertPath); err != nil { - return errors.Wrap(err, "could not write PKI cert") - } - - if *flPKeyPass != "" { - err = crypto.WriteEncryptedPEMRSAKeyFile(pkiKey, []byte(*flPKeyPass), *flKeyPath) - } else { - err = crypto.WritePEMRSAKeyFile(pkiKey, *flKeyPath) - } - if err != nil { - return errors.Wrap(err, "could not write private key") - } - - pushKey, err := rsa.GenerateKey(rand.Reader, 2048) - if err != nil { - return errors.Wrap(err, "could not generate push private key") - } - - if *flCPKeyPass != "" { - err = crypto.WriteEncryptedPEMRSAKeyFile(pushKey, []byte(*flCPKeyPass), *flCKeyPath) - } else { - err = crypto.WritePEMRSAKeyFile(pushKey, *flCKeyPath) - } - if err != nil { - return errors.Wrap(err, "could not write push private key") - } - - derBytes, err := mdmcertutil.NewCSR(pushKey, *flEmail, *flCountry, *flCN) - if err != nil { - return errors.Wrap(err, "could not generate push CSR") - } - pemCSR := mdmcertutil.PemCSR(derBytes) - // Do we even need to write-out the CSR? - err = ioutil.WriteFile(*flCCSRPath, pemCSR, 0600) - if err != nil { - return errors.Wrap(err, "could not write PEM file") - } - - sign := newMdmcertDownloadSignRequest(*flEmail, pemCSR, pemPkiCert) - req, err := sign.HTTPRequest() - if err != nil { - return errors.Wrap(err, "could not create http request") - } - err = sendMdmcertDownloadRequest(http.DefaultClient, req) - if err != nil { - return errors.Wrap(err, "error sending http request") - } - - fmt.Print("Request successfully sent to mdmcert.download. Your CSR should now\n" + - "be signed. Check your email for next steps. Then use the -decrypt option\n" + - "to extract the CSR request which will then be uploaded to Apple.\n") - - } else { // -decrypt switch - if _, err := os.Stat(*flCReqPath); err == nil { - return fmt.Errorf("file already exists: %s", *flCReqPath) - } - hexBytes, err := ioutil.ReadFile(*flDecrypt) - if err != nil { - return errors.Wrap(err, "reading encrypted file") - } - pkcsBytes, err := hex.DecodeString(string(hexBytes)) - if err != nil { - return errors.Wrap(err, "error decoding hex") - } - pkiCert, err := crypto.ReadPEMCertificateFile(*flCertPath) - if err != nil { - return errors.Wrap(err, "reading PKI certificate") - } - var pkiKey *rsa.PrivateKey - if *flPKeyPass != "" { - pkiKey, err = crypto.ReadEncryptedPEMRSAKeyFile(*flKeyPath, []byte(*flPKeyPass)) - } else { - pkiKey, err = crypto.ReadPEMRSAKeyFile(*flKeyPath) - } - if err != nil { - return errors.Wrap(err, "reading PKI private key") - } - ioutil.WriteFile("/tmp/fubar.p7", pkcsBytes, 0666) - p7, err := pkcs7.Parse(pkcsBytes) - if err != nil { - return errors.Wrap(err, "parsing mdmcert PKCS7 response") - } - // fmt.Println(p7) - content, err := p7.Decrypt(pkiCert, pkiKey) - if err != nil { - return errors.Wrap(err, "decrypting mdmcert PKCS7 response") - } - err = ioutil.WriteFile(*flCReqPath, content, 0666) - if err != nil { - return errors.Wrap(err, "writing Push Request response") - } - - fmt.Printf("Successfully able to decrypt the MDM Push Certificate request! Please upload\n"+ - "the file '%s' to Apple by visiting https://identity.apple.com\n"+ - "Once your Push Certificate is signed by Apple you can download it\n"+ - "and import it into MicroMDM using the `mdmctl mdmcert upload` command\n", *flCReqPath) - } - - return nil -} - -func newMdmcertDownloadSignRequest(email string, pemCSR []byte, serverCertificate []byte) *signRequest { - encodedCSR := base64.StdEncoding.EncodeToString(pemCSR) - encodedServerCert := base64.StdEncoding.EncodeToString(serverCertificate) - return &signRequest{ - CSR: encodedCSR, - Email: email, - Key: mdmcertAPIKey, - Encrypt: encodedServerCert, - } -} - -func (sign *signRequest) HTTPRequest() (*http.Request, error) { - buf := new(bytes.Buffer) - if err := json.NewEncoder(buf).Encode(sign); err != nil { - return nil, err - } - req, err := http.NewRequest("POST", mdmcertRequestURL, ioutil.NopCloser(buf)) - if err != nil { - return nil, err - } - req.Header.Add("Content-Type", "application/json") - req.Header.Add("User-Agent", "micromdm/certhelper") - return req, nil -} - -func sendMdmcertDownloadRequest(client *http.Client, req *http.Request) error { - resp, err := client.Do(req) - if err != nil { - return err - } - defer resp.Body.Close() - if resp.StatusCode != http.StatusOK { - return fmt.Errorf("received bad status from mdmcert.download. status=%q", resp.Status) - } - var jsn = struct { - Result string - }{} - if err := json.NewDecoder(resp.Body).Decode(&jsn); err != nil { - return err - } - if jsn.Result != "success" { - return fmt.Errorf("got unexpected result body: %q\n", jsn.Result) - } - return nil -} diff --git a/cmd/mdmctl/mdmcert.go b/cmd/mdmctl/mdmcert.go deleted file mode 100644 index be00091c..00000000 --- a/cmd/mdmctl/mdmcert.go +++ /dev/null @@ -1,321 +0,0 @@ -package main - -import ( - "context" - "crypto/rsa" - "crypto/x509" - "encoding/pem" - "flag" - "fmt" - "io/ioutil" - "os" - "path/filepath" - "strings" - - "github.com/go-kit/kit/log" - "github.com/pkg/errors" - "golang.org/x/crypto/pkcs12" - - "github.com/micromdm/micromdm/pkg/crypto" - "github.com/micromdm/micromdm/pkg/crypto/mdmcertutil" -) - -type mdmcertCommand struct { - *remoteServices -} - -func (cmd *mdmcertCommand) setup() error { - logger := log.NewLogfmtLogger(os.Stderr) - remote, err := setupClient(logger) - if err != nil { - return err - } - cmd.remoteServices = remote - return nil -} - -func (cmd *mdmcertCommand) Usage() error { - const usageText = ` -Create new MDM Push Certificate. -This utility helps obtain an MDM Push Certificate using the Apple Developer MDM CSR option in the enterprise developer portal. - -First you must create a vendor CSR which you will upload to the enterprise developer portal and get a signed MDM Vendor certificate. Use the MDM-CSR option in the dev portal when creating the certificate. -The MDM Vendor certificate is required in order to obtain the MDM push certificate. After you complete the MDM-CSR step, copy the downloaded file to the same folder as the private key. By default this will be -mdm-certificates/ - - mdmctl mdmcert vendor -password=secret -country=US -email=admin@acme.co - -Next, create a push CSR. This step generates a CSR required to get a signed a push certificate. - - mdmctl mdmcert push -password=secret -country=US -email=admin@acme.co - -Once you created the push CSR, you mush sign the push CSR with the MDM Vendor Certificate, and get a push certificate request file. - - mdmctl mdmcert vendor -sign -cert=./mdm-certificates/mdm.cer -password=secret - -Once generated, upload the PushCertificateRequest.plist file to https://identity.apple.com to obtain your MDM Push Certificate. -Use the push private key and the push cert you got from identity.apple.com in your MDM server. - -Commands: - vendor - push - upload -` - fmt.Println(usageText) - return nil - -} - -func (cmd *mdmcertCommand) Run(args []string) error { - if len(args) < 1 { - cmd.Usage() - os.Exit(1) - } - - if err := cmd.setup(); err != nil { - return err - } - - var run func([]string) error - switch strings.ToLower(args[0]) { - case "vendor": - run = cmd.runVendor - case "push": - run = cmd.runPush - case "upload": - run = cmd.runUpload - default: - cmd.Usage() - os.Exit(1) - } - - return run(args[1:]) -} - -const ( - pushCSRFilename = "PushCertificateRequest.csr" - pushCertificatePrivateKeyFilename = "PushCertificatePrivateKey.key" - vendorPKeyFilename = "VendorPrivateKey.key" - vendorCSRFilename = "VendorCertificateRequest.csr" - pushRequestFilename = "PushCertificateRequest.plist" - mdmcertdir = "mdm-certificates" -) - -func (cmd *mdmcertCommand) runVendor(args []string) error { - flagset := flag.NewFlagSet("vendor", flag.ExitOnError) - flagset.Usage = usageFor(flagset, "mdmctl mdmcert vendor [flags]") - var ( - flSign = flagset.Bool("sign", false, "Signs a user CSR with the MDM vendor certificate.") - flEmail = flagset.String("email", "", "Email address to use in CSR Subject.") - flCountry = flagset.String("country", "US", "Two letter country code for the CSR Subject(example: US).") - flCN = flagset.String("cn", "micromdm-vendor", "CommonName for the CSR Subject.") - flPKeyPass = flagset.String("password", "", "Password to encrypt/read the RSA key.") - flVendorcertPath = flagset.String("cert", filepath.Join(mdmcertdir, "mdm.cer"), "Path to the MDM Vendor certificate from dev portal.") - flPushCSRPath = flagset.String("push-csr", filepath.Join(mdmcertdir, pushCSRFilename), "Path to the user CSR(required for the -sign step).") - flKeyPath = flagset.String("private-key", filepath.Join(mdmcertdir, vendorPKeyFilename), "Path to the vendor private key. A new RSA key will be created at this path.") - flCSRPath = flagset.String("out", filepath.Join(mdmcertdir, vendorCSRFilename), "Path to save the MDM Vendor CSR.") - ) - - if err := flagset.Parse(args); err != nil { - return err - } - - if err := os.MkdirAll(filepath.Dir(*flCSRPath), 0755); err != nil { - return errors.Wrapf(err, "create directory %s", filepath.Dir(*flCSRPath)) - } - - password := []byte(*flPKeyPass) - if *flSign { - request, err := mdmcertutil.CreatePushCertificateRequest( - *flVendorcertPath, - *flPushCSRPath, - *flKeyPath, - password, - ) - if err != nil { - return errors.Wrap(err, "signing push certificate request with vendor private key") - } - encoded, err := request.Encode() - if err != nil { - return errors.Wrap(err, "encode base64 push certificate request") - } - err = ioutil.WriteFile(filepath.Join(mdmcertdir, pushRequestFilename), encoded, 0600) - return errors.Wrapf(err, "write %s to file", pushRequestFilename) - } - - if err := checkCSRFlags(*flCN, *flCountry, *flEmail, password); err != nil { - return errors.Wrap(err, "Private key password, CN, Email, and country code must be specified when creating a CSR.") - } - - request := &mdmcertutil.CSRConfig{ - CommonName: *flCN, - Country: *flCountry, - Email: *flEmail, - PrivateKeyPassword: password, - PrivateKeyPath: *flKeyPath, - CSRPath: *flCSRPath, - } - - err := mdmcertutil.CreateCSR(request) - return errors.Wrap(err, "creating MDM vendor CSR") -} - -func (cmd *mdmcertCommand) runPush(args []string) error { - flagset := flag.NewFlagSet("push", flag.ExitOnError) - flagset.Usage = usageFor(flagset, "mdmctl mdmcert push [flags]") - var ( - flEmail = flagset.String("email", "", "Email address to use in CSR Subject.") - flCountry = flagset.String("country", "US", "Two letter country code for the CSR Subject(Example: US).") - flCN = flagset.String("cn", "micromdm-user", "CommonName for the CSR Subject.") - flPKeyPass = flagset.String("password", "", "Password to encrypt/read the RSA key.") - flKeyPath = flagset.String("private-key", filepath.Join(mdmcertdir, pushCertificatePrivateKeyFilename), "Path to the push certificate private key. A new RSA key will be created at this path.") - flLocalOnly= flagset.Bool("local-only",false,"No server configuration required.") - - flCSRPath = flagset.String("out", filepath.Join(mdmcertdir, pushCSRFilename), "Path to save the MDM Push Certificate request.") - ) - - if err := flagset.Parse(args); err != nil { - return err - } - - if !*flLocalOnly { - if err := cmd.setup(); err != nil { - return err - } - } - if err := os.MkdirAll(filepath.Dir(*flCSRPath), 0755); err != nil { - errors.Wrapf(err, "create directory %s", filepath.Dir(*flCSRPath)) - } - - password := []byte(*flPKeyPass) - if err := checkCSRFlags(*flCN, *flCountry, *flEmail, password); err != nil { - return errors.Wrap(err, "Private key password, CN, Email, and country code must be specified when creating a CSR.") - } - - request := &mdmcertutil.CSRConfig{ - CommonName: *flCN, - Country: *flCountry, - Email: *flEmail, - PrivateKeyPassword: password, - PrivateKeyPath: *flKeyPath, - CSRPath: *flCSRPath, - } - - err := mdmcertutil.CreateCSR(request) - return errors.Wrap(err, "creating MDM Push certificate request.") -} - -func (cmd *mdmcertCommand) runUpload(args []string) error { - flagset := flag.NewFlagSet("upload", flag.ExitOnError) - flagset.Usage = usageFor(flagset, "mdmctl mdmcert upload [flags]") - var ( - flKeyPass = flagset.String("password", "", "Password to encrypt/read the RSA key.") - flKeyPath = flagset.String("private-key", filepath.Join(mdmcertdir, pushCertificatePrivateKeyFilename), "Path to the push certificate private key.") - flCertPath = flagset.String("cert", "", "Path to the MDM Push Certificate.") - ) - if err := flagset.Parse(args); err != nil { - return err - } - - cert, key, err := loadPushCerts(*flCertPath, *flKeyPath, *flKeyPass) - if err != nil { - return errors.Wrap(err, "load push certificate") - } - - if err := cmd.configsvc.SavePushCertificate(context.Background(), cert, key); err != nil { - return errors.Wrap(err, "upload push certificate and key to server") - } - - return nil -} - -func loadPushCerts(certPath, keyPath, keyPass string) (cert, key []byte, err error) { - isP12 := filepath.Ext(certPath) == ".p12" - if isP12 { - pkcs12Data, err := ioutil.ReadFile(certPath) - if err != nil { - return nil, nil, errors.Wrapf(err, "read p12 path %s", certPath) - } - pkeyi, certificate, err := pkcs12.Decode(pkcs12Data, keyPass) - if err != nil { - return nil, nil, errors.Wrap(err, "decode pkcs12 file") - } - pkey, ok := pkeyi.(*rsa.PrivateKey) - if !ok { - return nil, nil, errors.New("private key not a valid rsa key") - } - - pemKey := pem.EncodeToMemory(&pem.Block{ - Type: "RSA PRIVATE KEY", - Bytes: x509.MarshalPKCS1PrivateKey(pkey), - }) - - pemCert := pem.EncodeToMemory(&pem.Block{ - Type: "CERTIFICATE", - Bytes: certificate.Raw, - }) - return pemCert, pemKey, nil - } - - keyData, err := ioutil.ReadFile(keyPath) - if err != nil { - return nil, nil, errors.Wrapf(err, "read push certificate private key at path %s", keyPath) - } - - keyDataBlock, _ := pem.Decode(keyData) - if keyDataBlock == nil { - return nil, nil, errors.Errorf("invalid PEM data for private key %s", keyPath) - } - - var pemKeyData []byte - if x509.IsEncryptedPEMBlock(keyDataBlock) { - b, err := x509.DecryptPEMBlock(keyDataBlock, []byte(keyPass)) - if err != nil { - return nil, nil, fmt.Errorf("decrypting DES private key %s", err) - } - pemKeyData = b - } else { - pemKeyData = keyDataBlock.Bytes - } - - priv, err := x509.ParsePKCS1PrivateKey(pemKeyData) - if err != nil { - return nil, nil, errors.Wrapf(err, "parse push certiificate private key %s", keyPath) - } - - pemKey := pem.EncodeToMemory(&pem.Block{ - Type: "RSA PRIVATE KEY", - Bytes: x509.MarshalPKCS1PrivateKey(priv), - }) - - certificate, err := crypto.ReadPEMCertificateFile(certPath) - if err != nil { - return nil, nil, errors.Wrapf(err, "read push certificate from pem file %s", certPath) - } - - pemCert := pem.EncodeToMemory(&pem.Block{ - Type: "CERTIFICATE", - Bytes: certificate.Raw, - }) - - return pemCert, pemKey, nil -} - -func checkCSRFlags(cname, country, email string, password []byte) error { - if cname == "" { - return errors.New("cn flag not specified") - } - if email == "" { - return errors.New("email flag not specified") - } - if country == "" { - return errors.New("country flag not specified") - } - if len(password) == 0 { - return errors.New("private key password empty") - } - if len(country) != 2 { - return errors.New("must be a two letter country code") - } - return nil -} diff --git a/cmd/mdmctl/mdmcert_test.go b/cmd/mdmctl/mdmcert_test.go deleted file mode 100644 index 2423692c..00000000 --- a/cmd/mdmctl/mdmcert_test.go +++ /dev/null @@ -1,21 +0,0 @@ -package main - -import "testing" - -func TestLoadPushCerts(t *testing.T) { - keypath := "testdata/ProviderPrivateKey.key" - certpath := "testdata/pushcert.pem" - p12path := "testdata/pushcert.p12" - keysecret := "secret" - - _, _, err := loadPushCerts(certpath, keypath, keysecret) - if err != nil { - t.Errorf("failed to load PEM push certs with err %s", err) - } - - // try to load from p12 - _, _, err = loadPushCerts(p12path, "", keysecret) - if err != nil { - t.Errorf("failed to load p12 push certs with err %s", err) - } -} diff --git a/cmd/mdmctl/mdmdctl.go b/cmd/mdmctl/mdmdctl.go deleted file mode 100644 index d2fd86e2..00000000 --- a/cmd/mdmctl/mdmdctl.go +++ /dev/null @@ -1,87 +0,0 @@ -package main - -import ( - "flag" - "fmt" - "os" - "strings" - "text/tabwriter" - - "github.com/micromdm/go4/version" -) - -func main() { - if len(os.Args) < 2 { - usage() - os.Exit(1) - } - if strings.ToLower(os.Args[1]) != "config" { - checkForOldConfig() - } - var run func([]string) error - switch strings.ToLower(os.Args[1]) { - case "version", "-version": - version.Print() - return - case "config": - cmd := new(configCommand) - run = cmd.Run - case "get": - cmd := new(getCommand) - run = cmd.Run - case "apply": - cmd := new(applyCommand) - run = cmd.Run - case "remove": - cmd := new(removeCommand) - run = cmd.Run - case "mdmcert": - cmd := new(mdmcertCommand) - run = cmd.Run - case "mdmcert.download": - cmd := new(mdmcertDownloadCommand) - run = cmd.Run - default: - usage() - os.Exit(1) - } - - if err := run(os.Args[2:]); err != nil { - fmt.Fprintf(os.Stderr, "%v\n", err) - os.Exit(1) - } -} - -func usage() error { - helpText := `USAGE: mdmctl - -Available Commands: - get - apply - config - remove - mdmcert - mdmcert.download - version - -Use mdmctl -h for additional usage of each command. -Example: mdmctl get devices -` - fmt.Println(helpText) - return nil -} - -func usageFor(fs *flag.FlagSet, short string) func() { - return func() { - fmt.Fprintf(os.Stderr, "USAGE\n") - fmt.Fprintf(os.Stderr, " %s\n", short) - fmt.Fprintf(os.Stderr, "\n") - fmt.Fprintf(os.Stderr, "FLAGS\n") - w := tabwriter.NewWriter(os.Stdout, 0, 2, 2, ' ', 0) - fs.VisitAll(func(f *flag.Flag) { - fmt.Fprintf(w, "\t-%s %s\t%s\n", f.Name, f.DefValue, f.Usage) - }) - w.Flush() - fmt.Fprintf(os.Stderr, "\n") - } -} diff --git a/cmd/mdmctl/remove.go b/cmd/mdmctl/remove.go deleted file mode 100644 index 3aa1efc7..00000000 --- a/cmd/mdmctl/remove.go +++ /dev/null @@ -1,76 +0,0 @@ -package main - -import ( - "fmt" - "os" - "strings" - - "github.com/go-kit/kit/log" -) - -type removeCommand struct { - config *ServerConfig - *remoteServices -} - -func (cmd *removeCommand) setup() error { - cfg, err := LoadServerConfig() - if err != nil { - return err - } - cmd.config = cfg - logger := log.NewLogfmtLogger(os.Stderr) - remote, err := setupClient(logger) - if err != nil { - return err - } - cmd.remoteServices = remote - return nil -} - -func (cmd *removeCommand) Run(args []string) error { - if len(args) < 1 { - cmd.Usage() - os.Exit(1) - } - - if err := cmd.setup(); err != nil { - return err - } - - var run func([]string) error - switch strings.ToLower(args[0]) { - case "blueprints": - run = cmd.removeBlueprints - case "devices": - run = cmd.removeDevices - case "profiles": - run = cmd.removeProfiles - case "block": - run = cmd.removeBlock - case "dep-autoassigner": - run = cmd.removeDEPAutoAssigner - default: - cmd.Usage() - os.Exit(1) - } - - return run(args[1:]) -} - -func (cmd *removeCommand) Usage() error { - const getUsage = ` -Display one or many resources. - -Valid resource types: - - * blueprints - * devices - * profiles - * block - * dep-autoassigner -` - - fmt.Println(getUsage) - return nil -} diff --git a/cmd/mdmctl/remove_block.go b/cmd/mdmctl/remove_block.go deleted file mode 100644 index 24e51024..00000000 --- a/cmd/mdmctl/remove_block.go +++ /dev/null @@ -1,34 +0,0 @@ -package main - -import ( - "context" - "flag" - "fmt" - - "github.com/pkg/errors" -) - -func (cmd *removeCommand) removeBlock(args []string) error { - flagset := flag.NewFlagSet("unblock", flag.ExitOnError) - var ( - flUDID = flagset.String("udid", "", "UDID of device to unblock") - ) - flagset.Usage = usageFor(flagset, "mdmctl remove block [flags]") - if err := flagset.Parse(args); err != nil { - return err - } - - if *flUDID == "" { - flagset.Usage() - return errors.New("bad input: must provide a device UDID to unblock.") - } - - ctx := context.Background() - if err := cmd.blocksvc.UnblockDevice(ctx, *flUDID); err != nil { - return err - } - - fmt.Println("success") - - return nil -} diff --git a/cmd/mdmctl/remove_blueprints.go b/cmd/mdmctl/remove_blueprints.go deleted file mode 100644 index c2c1c6bb..00000000 --- a/cmd/mdmctl/remove_blueprints.go +++ /dev/null @@ -1,29 +0,0 @@ -package main - -import ( - "context" - "flag" - "fmt" - "strings" -) - -func (cmd *removeCommand) removeBlueprints(args []string) error { - flagset := flag.NewFlagSet("remove-blueprints", flag.ExitOnError) - var ( - flBlueprintName = flagset.String("name", "", "name of blueprint, optionally comma-separated") - ) - flagset.Usage = usageFor(flagset, "mdmctl remove blueprints [flags]") - if err := flagset.Parse(args); err != nil { - return err - } - - ctx := context.Background() - err := cmd.blueprintsvc.RemoveBlueprints(ctx, strings.Split(*flBlueprintName, ",")) - if err != nil { - return err - } - - fmt.Printf("removed blueprint(s): %s\n", *flBlueprintName) - - return nil -} diff --git a/cmd/mdmctl/remove_dep_autoassigner.go b/cmd/mdmctl/remove_dep_autoassigner.go deleted file mode 100644 index 897dc969..00000000 --- a/cmd/mdmctl/remove_dep_autoassigner.go +++ /dev/null @@ -1,32 +0,0 @@ -package main - -import ( - "context" - "flag" - "fmt" - - "github.com/pkg/errors" -) - -func (cmd *removeCommand) removeDEPAutoAssigner(args []string) error { - flagset := flag.NewFlagSet("dep-autoassigner", flag.ExitOnError) - var ( - flFilter = flagset.String("filter", "*", "filter string (only '*' supported right now)") - ) - flagset.Usage = usageFor(flagset, "mdmctl remove dep-autoassigner [flags]") - if err := flagset.Parse(args); err != nil { - return err - } - - if *flFilter == "" { - return errors.New("bad input: must provide -filter") - } - - err := cmd.depsyncsvc.RemoveAutoAssigner(context.TODO(), *flFilter) - if err != nil { - return err - } - - fmt.Printf("removed DEP profile associated with filter '%s'\n", *flFilter) - return nil -} diff --git a/cmd/mdmctl/remove_devices.go b/cmd/mdmctl/remove_devices.go deleted file mode 100644 index f441d622..00000000 --- a/cmd/mdmctl/remove_devices.go +++ /dev/null @@ -1,47 +0,0 @@ -package main - -import ( - "context" - "flag" - "fmt" - "strings" - - "github.com/pkg/errors" - - "github.com/micromdm/micromdm/platform/device" -) - -func (cmd *removeCommand) removeDevices(args []string) error { - flagset := flag.NewFlagSet("remove-devices", flag.ExitOnError) - var ( - flIdentifier = flagset.String("udid", "", "device UDID, optionally comma-separated") - flSerials = flagset.String("serials", "", "device serial, optionally comma-separated") - ) - flagset.Usage = usageFor(flagset, "mdmctl remove devices [flags]") - if err := flagset.Parse(args); err != nil { - return err - } - - if *flIdentifier == "" && *flSerials == "" { - flagset.Usage() - return errors.New("bad input: device UDID or Serial must be provided") - } - - opts := device.RemoveDevicesOptions{} - if *flIdentifier != "" { - opts.UDIDs = strings.Split(*flIdentifier, ",") - } - if *flSerials != "" { - opts.Serials = strings.Split(*flSerials, ",") - } - - ctx := context.Background() - err := cmd.devicesvc.RemoveDevices(ctx, opts) - if err != nil { - return err - } - - fmt.Printf("removed devices(s): %s\n", strings.Join(append(opts.UDIDs, opts.Serials...), ", ")) - - return nil -} diff --git a/cmd/mdmctl/remove_profiles.go b/cmd/mdmctl/remove_profiles.go deleted file mode 100644 index 164f42dc..00000000 --- a/cmd/mdmctl/remove_profiles.go +++ /dev/null @@ -1,29 +0,0 @@ -package main - -import ( - "context" - "flag" - "fmt" - "strings" -) - -func (cmd *removeCommand) removeProfiles(args []string) error { - flagset := flag.NewFlagSet("remove-profiles", flag.ExitOnError) - var ( - flIdentifier = flagset.String("id", "", "profile identifier, optionally comma-separated") - ) - flagset.Usage = usageFor(flagset, "mdmctl remove profiles [flags]") - if err := flagset.Parse(args); err != nil { - return err - } - - ctx := context.Background() - err := cmd.profilesvc.RemoveProfiles(ctx, strings.Split(*flIdentifier, ",")) - if err != nil { - return err - } - - fmt.Printf("removed profile(s): %s\n", *flIdentifier) - - return nil -} diff --git a/cmd/mdmctl/setup.go b/cmd/mdmctl/setup.go deleted file mode 100644 index 27422f78..00000000 --- a/cmd/mdmctl/setup.go +++ /dev/null @@ -1,110 +0,0 @@ -package main - -import ( - "github.com/go-kit/kit/log" - httptransport "github.com/go-kit/kit/transport/http" - - "github.com/micromdm/micromdm/platform/appstore" - "github.com/micromdm/micromdm/platform/blueprint" - "github.com/micromdm/micromdm/platform/config" - "github.com/micromdm/micromdm/platform/dep" - "github.com/micromdm/micromdm/platform/dep/sync" - "github.com/micromdm/micromdm/platform/device" - "github.com/micromdm/micromdm/platform/profile" - "github.com/micromdm/micromdm/platform/remove" - "github.com/micromdm/micromdm/platform/user" -) - -type remoteServices struct { - profilesvc profile.Service - blueprintsvc blueprint.Service - blocksvc remove.Service - usersvc user.Service - devicesvc device.Service - configsvc config.Service - appsvc appstore.Service - depsvc dep.Service - depsyncsvc sync.Service -} - -func setupClient(logger log.Logger) (*remoteServices, error) { - cfg, err := LoadServerConfig() - if err != nil { - return nil, err - } - - profilesvc, err := profile.NewHTTPClient( - cfg.ServerURL, cfg.APIToken, logger, - httptransport.SetClient(skipVerifyHTTPClient(cfg.SkipVerify))) - if err != nil { - return nil, err - } - - blueprintsvc, err := blueprint.NewHTTPClient( - cfg.ServerURL, cfg.APIToken, logger, - httptransport.SetClient(skipVerifyHTTPClient(cfg.SkipVerify))) - if err != nil { - return nil, err - } - - blocksvc, err := remove.NewHTTPClient( - cfg.ServerURL, cfg.APIToken, logger, - httptransport.SetClient(skipVerifyHTTPClient(cfg.SkipVerify))) - if err != nil { - return nil, err - } - - usersvc, err := user.NewHTTPClient( - cfg.ServerURL, cfg.APIToken, logger, - httptransport.SetClient(skipVerifyHTTPClient(cfg.SkipVerify))) - if err != nil { - return nil, err - } - - devicesvc, err := device.NewHTTPClient( - cfg.ServerURL, cfg.APIToken, logger, - httptransport.SetClient(skipVerifyHTTPClient(cfg.SkipVerify))) - if err != nil { - return nil, err - } - - configsvc, err := config.NewHTTPClient( - cfg.ServerURL, cfg.APIToken, logger, - httptransport.SetClient(skipVerifyHTTPClient(cfg.SkipVerify))) - if err != nil { - return nil, err - } - - appsvc, err := appstore.NewHTTPClient( - cfg.ServerURL, cfg.APIToken, logger, - httptransport.SetClient(skipVerifyHTTPClient(cfg.SkipVerify))) - if err != nil { - return nil, err - } - - depsvc, err := dep.NewHTTPClient( - cfg.ServerURL, cfg.APIToken, logger, - httptransport.SetClient(skipVerifyHTTPClient(cfg.SkipVerify))) - if err != nil { - return nil, err - } - - depsyncsvc, err := sync.NewHTTPClient( - cfg.ServerURL, cfg.APIToken, logger, - httptransport.SetClient(skipVerifyHTTPClient(cfg.SkipVerify))) - if err != nil { - return nil, err - } - - return &remoteServices{ - profilesvc: profilesvc, - blueprintsvc: blueprintsvc, - blocksvc: blocksvc, - usersvc: usersvc, - devicesvc: devicesvc, - configsvc: configsvc, - appsvc: appsvc, - depsvc: depsvc, - depsyncsvc: depsyncsvc, - }, nil -} diff --git a/cmd/mdmctl/sign.go b/cmd/mdmctl/sign.go deleted file mode 100644 index 0fd226a9..00000000 --- a/cmd/mdmctl/sign.go +++ /dev/null @@ -1,15 +0,0 @@ -// +build !darwin - -package main - -import "fmt" - -func signPackage(path, outpath, developerID string) error { - fmt.Println("[WARNING] package signing only implemented on macOS") - return nil -} - -func checkSignature(pkgpath string) (bool, error) { - fmt.Println("[WARNING] package signing only implemented on macOS. An unsigned macOS package will not install with MDM.") - return true, nil -} diff --git a/cmd/mdmctl/sign_darwin.go b/cmd/mdmctl/sign_darwin.go deleted file mode 100644 index dd70a7ae..00000000 --- a/cmd/mdmctl/sign_darwin.go +++ /dev/null @@ -1,38 +0,0 @@ -package main - -import ( - "bytes" - "os" - "os/exec" - - "github.com/pkg/errors" -) - -func signPackage(pkgpath, outpath string, developerID string) error { - cmd := exec.Command("/usr/bin/productsign", "--sign", developerID, pkgpath, outpath) - cmd.Stderr = os.Stderr - cmd.Stdout = os.Stdout - if err := cmd.Run(); err != nil { - return errors.Wrap(err, "signing package") - } - return nil -} - -func checkSignature(pkgpath string) (bool, error) { - cmd := exec.Command("pkgutil", "--check-signature", pkgpath) - cmd.Stderr = os.Stderr - out, err := cmd.Output() - if err != nil && !isNoSignature(out) { - return false, errors.Wrap(err, "checking signature") - } - - if bytes.Contains(out, []byte(`Status: signed`)) { - return true, nil - } - - return false, nil -} - -func isNoSignature(out []byte) bool { - return bytes.Contains(out, []byte(`Status: no signature`)) -} diff --git a/cmd/mdmctl/testdata/ProviderPrivateKey.key b/cmd/mdmctl/testdata/ProviderPrivateKey.key deleted file mode 100644 index 647c64f8..00000000 --- a/cmd/mdmctl/testdata/ProviderPrivateKey.key +++ /dev/null @@ -1,30 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -Proc-Type: 4,ENCRYPTED -DEK-Info: DES-EDE3-CBC,22c0f4c89c7b1fcd - -KVnJeaMzHPrL5pHmkB6yAR9N8cvh2FKBfmJuRP61GiSR+PAI1UxsZ+627cnNZc/8 -Y2haoxAtW4k5Yl6gIQH8exf4el5yD+Ds4mEUacw7m3RV+WNL32I1+Z+jr55jetzP -nb3t9LQmsP07uigSe/oh0vumVhjxxSE31/iB2BISnEfJDsDYHFFc1XWAxNABG+JP -ttCnIHPXaFLb7jDdZnnsk2rBNsRkOPwJ27hna9b0RyHVmqMb3XZtQs2RtARTVqap -hCFSphMrS20wLqcHyJZ7v0p9MiCp71g58xs4Bl9Vh1FI86AA+AOaosA0Kl8lPa08 -ChuJf7ng3mhJ+nKRkPUK4eDtnCsNm3Xd0lQQHqRWcoUJ80Gdhla0CodJnt/BT35y -SP+j2SUJRuAvNpSeGyAcLv3wDwhMgkVTt1errZOL0tFa/ep5YwfFPMBDVNXx+lOd -AHDey8gnoGJFpwoQFdXp6TVZEJjP6kgN8njmAZmbwrFcqMdjg+eMZfAYXUAdy4aT -aMbMGwjyjUgP80iXX5OAgGchpQ+HO5otpbecAMKs6SAqAgTMbKMG2rLgZe+mlkbd -6xnwyrhkQpQHVN97gqWic2cIggyR3UL58mned/5eS3EcNTTxHJO8D7EwmIjkGVxY -fT+tdpJ6iKK6CfjIEZYFgtLafmKMxxDHaplLGnIK8VHiopwUIKxVcji9Pjp+0a1O -q9NSVZXAbt45mL2jV94hhEpt83YyBFdRYBFk5LT7AQg2ipVl51g7fO2SoTiHakzL -MrKfo+bSxDHOWefu9Z380Vmh1Mm0xDU44C8g9Jc4N7euCQtGfX5bnWuueuGwaaXL -lYrqKVuqKdc2y5d8N7KiHEHY0zsfyjFu4+zh/v2zYIBlbuM9ZGiuSlprHvy//wev -kPZDEtHNTeFXBn7qDeTGNlYK+aGQyTFOzasXcUbf3RywjpHOM/uL7rUpA11W+Ip/ -/b1h+mcADy90DMBv1xVX3vZVldwAdcqbQR0QTXxgCS1dzVdedG2N7noJVKUfbA4x -tI3NEAaBt7J7eLQm7TawRv6j5G+VB/ZS5B8WVCVbBjwwqbeccJcuzJKLBX0A7c+X -TouVuE7xpq9OK0zsaIwg7WMgKOY9ZMuMNzjKnXcSYcq5o9LHHsB1CHyOGdHkmj/J -AmME2xnyB+GCLWyN8B17hyC4MwkoNDWLnlUzL1Z3lf5jsorx+zORKho+rgg02Blw -hY02jVEcHoO8fup6GXkWtWpq2pljHD6DBg4thqwd2X3tpKBEDCcPYjMNRBmb+EZo -ZZrHMZX999BsgQip+9s6gpg4OxLbkn/wB94D+XoQYCF/rKb3ztlMHWygyjasKbWe -L5DnI4tDaO0CAYP79ixJWd8DnHy7lkDFCWA3ZdDV5brM81biJVr24b0SoV22/nT/ -wvTP0wgdRBmBmqFYZojlIWM+Gu09tVqXy8ui5oOGJThXgCyPWPrs9PSIfLyOjfDm -vUy/3yhOfCZmLEFG955P3A92ygojs/EvIrE2oWKVxf0X+T0mIVnBxeWpQ0OOVC1q -51gz/pyLNjbqxP2FUOkF5hLvRupAHhFpzbP4yZcDHUisNyUgjb4kHQ== ------END RSA PRIVATE KEY----- diff --git a/cmd/mdmctl/testdata/pushcert.p12 b/cmd/mdmctl/testdata/pushcert.p12 deleted file mode 100644 index c3cd1538..00000000 Binary files a/cmd/mdmctl/testdata/pushcert.p12 and /dev/null differ diff --git a/cmd/mdmctl/testdata/pushcert.pem b/cmd/mdmctl/testdata/pushcert.pem deleted file mode 100644 index 1328e203..00000000 --- a/cmd/mdmctl/testdata/pushcert.pem +++ /dev/null @@ -1,18 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIC9zCCAd+gAwIBAgIJAPQybPTtooGmMA0GCSqGSIb3DQEBCwUAMBIxEDAOBgNV -BAMMB21kbXB1c2gwHhcNMTcwMzIxMjMyNzEwWhcNNDQwODA2MjMyNzEwWjASMRAw -DgYDVQQDDAdtZG1wdXNoMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA -43VCT3Xw62hJ1t3HhLNsyJ/wTTaLJfyNu9zwNeNVY+yOxSaj6V5UVEpWiNIfyB+j -J7E+cUdWmEQewwXPaoNsCR4bKBElB1f45UApcrmkoqzruFI4O+yfmLJkN95fO5Sd -009VZPudFf96HdYjNpgg8ofIxAxo9dP+ReU+4QgxevIM2Hg+X+4zabDiLspfGX6Y -A5Iz/R6rFCx8rc+GEWFhkB4JE0cIV/TifP5xlOr0UFTCYQ1KUEM+30s928PFRXM4 -tsm/TcM5g0Mi2bNDiVHE0hvzxmJbiL2XjFE3VBK6Dphw9gF1GLe8D2TnZMeIAj3K -JW0sjnkmvBxRvTqTHA4LvwIDAQABo1AwTjAdBgNVHQ4EFgQUJmri9d+KEYhPyDu3 -dHsVm7eFWngwHwYDVR0jBBgwFoAUJmri9d+KEYhPyDu3dHsVm7eFWngwDAYDVR0T -BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAmRu4hFq4+WN7Vr9FucU+yHYcj0YV -kKfJMUSxDK/bab1DR02gxcYVR+bY/xtlcc/dA0zzzXUj97/BKLpkQCxu1+MtqMPx -bbVJnrSkGDXBXMmwn9C29WDdMjLQwS4WLrkDTEVc8W9kUqZsEBQalneKlV8u5kXi -A9tolc2Kaq2uJxKcsC2Yx1MLqpEm6bqKRlQSPM0G3uWupJBnvIQfXt0n3ErphQhf -m6BuVIs2iVvEo2W+VZ+LwfeN992Yd0DeMqvMAh6Rg/N/SGaxmMeD/Co+LHKCAzW4 -JVjDjF01dBDmWTBs+NC9euIoCBej+PjMwXUo229uA19DucZXMIed9Xyoqg== ------END CERTIFICATE----- diff --git a/cmd/micromdm/micromdm.go b/cmd/micromdm/micromdm.go deleted file mode 100644 index 55469832..00000000 --- a/cmd/micromdm/micromdm.go +++ /dev/null @@ -1,69 +0,0 @@ -package main - -import ( - "flag" - "fmt" - "math/rand" - "os" - "strings" - "text/tabwriter" - "time" - - "github.com/micromdm/go4/version" -) - -func init() { - rand.Seed(time.Now().UnixNano()) -} - -func main() { - if len(os.Args) < 2 { - usage() - os.Exit(1) - } - var run func([]string) error - switch strings.ToLower(os.Args[1]) { - case "version", "-version": - version.Print() - return - case "serve": - run = serve - default: - usage() - os.Exit(1) - } - - if err := run(os.Args[2:]); err != nil { - fmt.Fprintf(os.Stderr, "%v\n", err) - os.Exit(1) - } -} - -func usage() error { - helpText := `USAGE: micromdm - -Available Commands: - serve - version - -Use micromdm -h for additional usage of each command. -Example: micromdm serve -h -` - fmt.Println(helpText) - return nil -} - -func usageFor(fs *flag.FlagSet, short string) func() { - return func() { - fmt.Fprintf(os.Stderr, "USAGE\n") - fmt.Fprintf(os.Stderr, " %s\n", short) - fmt.Fprintf(os.Stderr, "\n") - fmt.Fprintf(os.Stderr, "FLAGS\n") - w := tabwriter.NewWriter(os.Stdout, 0, 2, 2, ' ', 0) - fs.VisitAll(func(f *flag.Flag) { - fmt.Fprintf(w, "\t-%s %s\t%s\n", f.Name, f.DefValue, f.Usage) - }) - w.Flush() - fmt.Fprintf(os.Stderr, "\n") - } -} diff --git a/cmd/micromdm/serve.go b/cmd/micromdm/serve.go deleted file mode 100644 index 7ffc9e64..00000000 --- a/cmd/micromdm/serve.go +++ /dev/null @@ -1,367 +0,0 @@ -package main - -import ( - "context" - "flag" - "fmt" - "io" - stdlog "log" - "net/http" - "net/url" - "os" - "path/filepath" - "strconv" - "strings" - "time" - - "github.com/boltdb/bolt" - "github.com/go-kit/kit/auth/basic" - "github.com/go-kit/kit/log" - httptransport "github.com/go-kit/kit/transport/http" - "github.com/groob/finalizer/logutil" - "github.com/micromdm/go4/env" - "github.com/micromdm/go4/httputil" - "github.com/micromdm/go4/version" - scep "github.com/micromdm/scep/server" - "github.com/pkg/errors" - "golang.org/x/crypto/acme/autocert" - - "github.com/micromdm/micromdm/mdm" - "github.com/micromdm/micromdm/mdm/enroll" - httputil2 "github.com/micromdm/micromdm/pkg/httputil" - "github.com/micromdm/micromdm/platform/apns" - "github.com/micromdm/micromdm/platform/appstore" - appsbuiltin "github.com/micromdm/micromdm/platform/appstore/builtin" - "github.com/micromdm/micromdm/platform/blueprint" - blueprintbuiltin "github.com/micromdm/micromdm/platform/blueprint/builtin" - "github.com/micromdm/micromdm/platform/challenge" - "github.com/micromdm/micromdm/platform/command" - "github.com/micromdm/micromdm/platform/config" - depapi "github.com/micromdm/micromdm/platform/dep" - "github.com/micromdm/micromdm/platform/dep/sync" - "github.com/micromdm/micromdm/platform/device" - devicebuiltin "github.com/micromdm/micromdm/platform/device/builtin" - "github.com/micromdm/micromdm/platform/profile" - block "github.com/micromdm/micromdm/platform/remove" - "github.com/micromdm/micromdm/platform/user" - userbuiltin "github.com/micromdm/micromdm/platform/user/builtin" - "github.com/micromdm/micromdm/server" -) - -const homePage = ` - - - - - MicroMDM - - - -

Welcome to MicroMDM!

-

Enroll a device

- - -` - -func serve(args []string) error { - flagset := flag.NewFlagSet("serve", flag.ExitOnError) - var ( - flConfigPath = flagset.String("config-path", env.String("MICROMDM_CONFIG_PATH", "/var/db/micromdm"), "Path to configuration directory") - flServerURL = flagset.String("server-url", env.String("MICROMDM_SERVER_URL", ""), "Public HTTPS url of your server") - flAPIKey = flagset.String("api-key", env.String("MICROMDM_API_KEY", ""), "API Token for mdmctl command") - flTLS = flagset.Bool("tls", env.Bool("MICROMDM_TLS", true), "Use https") - flTLSCert = flagset.String("tls-cert", env.String("MICROMDM_TLS_CERT", ""), "Path to TLS certificate") - flTLSKey = flagset.String("tls-key", env.String("MICROMDM_TLS_KEY", ""), "Path to TLS private key") - flHTTPAddr = flagset.String("http-addr", env.String("MICROMDM_HTTP_ADDR", ":https"), "http(s) listen address of mdm server. defaults to :8080 if tls is false") - flHTTPDebug = flagset.Bool("http-debug", env.Bool("MICROMDM_HTTP_DEBUG", false), "Enable debug for http(dumps full request)") - flRepoPath = flagset.String("filerepo", env.String("MICROMDM_FILE_REPO", ""), "Path to http file repo") - flDepSim = flagset.String("depsim", env.String("MICROMDM_DEPSIM_URL", ""), "Use depsim URL") - flExamples = flagset.Bool("examples", false, "Prints some example usage") - flCommandWebhookURL = flagset.String("command-webhook-url", env.String("MICROMDM_WEBHOOK_URL", ""), "URL to send command responses") - flHomePage = flagset.Bool("homepage", env.Bool("MICROMDM_HTTP_HOMEPAGE", true), "Hosts a simple built-in webpage at the / address") - flSCEPClientValidity = flagset.Int("scep-client-validity", env.Int("MICROMDM_SCEP_CLIENT_VALIDITY", 365), "Sets the scep certificate validity in days") - flNoCmdHistory = flagset.Bool("no-command-history", env.Bool("MICROMDM_NO_COMMAND_HISTORY", false), "disables saving of command history") - flUseDynChallenge = flagset.Bool("use-dynamic-challenge", env.Bool("MICROMDM_USE_DYNAMIC_CHALLENGE", false), "require dynamic SCEP challenges") - flGenDynChalEnroll = flagset.Bool("gen-dynamic-challenge", env.Bool("MICROMDM_GEN_DYNAMIC_CHALLENGE", false), "generate dynamic SCEP challenges in enrollment profile (built-in only)") - flPrintArgs = flagset.Bool("print-flags", false, "Print all flags and their values") - ) - flagset.Usage = usageFor(flagset, "micromdm serve [flags]") - if err := flagset.Parse(args); err != nil { - return err - } - - if *flPrintArgs { - flagset.VisitAll(func(fl *flag.Flag) { - fmt.Printf("%v: %v\n", fl.Usage, fl.Value) - }) - } - - if *flExamples { - printExamples() - return nil - } - - if *flServerURL == "" { - return errors.New("must supply -server-url") - } - if !strings.HasPrefix(*flServerURL, "https://") { - return errors.New("-server-url must begin with https://") - } - if !*flTLS && (*flTLSCert != "" || *flTLSKey != "") { - return errors.New("cannot set -tls=false and supply -tls-cert or -tls-key") - } - - logger := log.NewLogfmtLogger(os.Stderr) - stdlog.SetOutput(log.NewStdlibAdapter(logger)) // force structured logs - mainLogger := log.With(logger, "component", "main") - mainLogger.Log("msg", "started") - - if err := os.MkdirAll(*flConfigPath, 0755); err != nil { - return errors.Wrapf(err, "creating config directory %s", *flConfigPath) - } - sm := &server.Server{ - ConfigPath: *flConfigPath, - ServerPublicURL: strings.TrimRight(*flServerURL, "/"), - Depsim: *flDepSim, - TLSCertPath: *flTLSCert, - CommandWebhookURL: *flCommandWebhookURL, - NoCmdHistory: *flNoCmdHistory, - UseDynSCEPChallenge: *flUseDynChallenge, - GenDynSCEPChallenge: *flGenDynChalEnroll, - - WebhooksHTTPClient: &http.Client{Timeout: time.Second * 30}, - - SCEPClientValidity: *flSCEPClientValidity, - } - if !sm.UseDynSCEPChallenge { - // TODO: we have a static SCEP challenge password here to prevent - // being prompted for the SCEP challenge which happens in a "normal" - // (non-DEP) enrollment. While security is not improved it is at least - // no less secure and prevents a useless dialog from showing. - sm.SCEPChallenge = "micromdm" - } - - if err := sm.Setup(logger); err != nil { - stdlog.Fatal(err) - } - syncer, err := sm.CreateDEPSyncer(logger) - if err != nil { - stdlog.Fatal(err) - } - - var removeService block.Service - { - svc, err := block.New(sm.RemoveDB) - if err != nil { - stdlog.Fatal(err) - } - removeService = block.LoggingMiddleware(logger)(svc) - } - - devDB, err := devicebuiltin.NewDB(sm.DB) - if err != nil { - stdlog.Fatal(err) - } - - devWorker := device.NewWorker(devDB, sm.PubClient, logger) - go devWorker.Run(context.Background()) - - userDB, err := userbuiltin.NewDB(sm.DB) - if err != nil { - stdlog.Fatal(err) - } - userWorker := user.NewWorker(userDB, sm.PubClient, logger) - go userWorker.Run(context.Background()) - - bpDB, err := blueprintbuiltin.NewDB(sm.DB, sm.ProfileDB) - if err != nil { - stdlog.Fatal(err) - } - - blueprintWorker := blueprint.NewWorker( - bpDB, - userDB, - sm.ProfileDB, - sm.CommandService, - sm.PubClient, - logger, - ) - go blueprintWorker.Run(context.Background()) - - ctx := context.Background() - httpLogger := log.With(logger, "transport", "http") - - dc := sm.DEPClient - appDB := &appsbuiltin.Repo{Path: *flRepoPath} - - scepEndpoints := scep.MakeServerEndpoints(sm.SCEPService) - scepComponentLogger := log.With(logger, "component", "scep") - scepEndpoints.GetEndpoint = scep.EndpointLoggingMiddleware(scepComponentLogger)(scepEndpoints.GetEndpoint) - scepEndpoints.PostEndpoint = scep.EndpointLoggingMiddleware(scepComponentLogger)(scepEndpoints.PostEndpoint) - scepHandler := scep.MakeHTTPHandler(scepEndpoints, sm.SCEPService, scepComponentLogger) - - enrollHandlers := enroll.MakeHTTPHandlers(ctx, enroll.MakeServerEndpoints(sm.EnrollService, sm.SCEPDepot), httptransport.ServerErrorLogger(httpLogger)) - - r, options := httputil2.NewRouter(logger) - - r.Handle("/version", version.Handler()) - r.Handle("/mdm/enroll", enrollHandlers.EnrollHandler).Methods("GET", "POST") - r.Handle("/ota/enroll", enrollHandlers.OTAEnrollHandler) - r.Handle("/ota/phase23", enrollHandlers.OTAPhase2Phase3Handler).Methods("POST") - r.Handle("/scep", scepHandler) - if *flHomePage { - r.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { - io.WriteString(w, homePage) - }) - } - - mdmEndpoints := mdm.MakeServerEndpoints(sm.MDMService) - mdm.RegisterHTTPHandlers(r, mdmEndpoints, logger) - - // API commands. Only handled if the user provides an api key. - if *flAPIKey != "" { - basicAuthEndpointMiddleware := basic.AuthMiddleware("micromdm", *flAPIKey, "micromdm") - - configsvc := config.New(sm.ConfigDB) - configEndpoints := config.MakeServerEndpoints(configsvc, basicAuthEndpointMiddleware) - config.RegisterHTTPHandlers(r, configEndpoints, options...) - - apnsEndpoints := apns.MakeServerEndpoints(sm.APNSPushService, basicAuthEndpointMiddleware) - apns.RegisterHTTPHandlers(r, apnsEndpoints, options...) - - devicesvc := device.New(devDB) - deviceEndpoints := device.MakeServerEndpoints(devicesvc, basicAuthEndpointMiddleware) - device.RegisterHTTPHandlers(r, deviceEndpoints, options...) - - profilesvc := profile.New(sm.ProfileDB) - profileEndpoints := profile.MakeServerEndpoints(profilesvc, basicAuthEndpointMiddleware) - profile.RegisterHTTPHandlers(r, profileEndpoints, options...) - - blueprintsvc := blueprint.New(bpDB) - blueprintEndpoints := blueprint.MakeServerEndpoints(blueprintsvc, basicAuthEndpointMiddleware) - blueprint.RegisterHTTPHandlers(r, blueprintEndpoints, options...) - - blockEndpoints := block.MakeServerEndpoints(removeService, basicAuthEndpointMiddleware) - block.RegisterHTTPHandlers(r, blockEndpoints, options...) - - usersvc := user.New(userDB) - userEndpoints := user.MakeServerEndpoints(usersvc, basicAuthEndpointMiddleware) - user.RegisterHTTPHandlers(r, userEndpoints, options...) - - appsvc := appstore.New(appDB) - appEndpoints := appstore.MakeServerEndpoints(appsvc, basicAuthEndpointMiddleware) - appstore.RegisterHTTPHandlers(r, appEndpoints, options...) - - commandEndpoints := command.MakeServerEndpoints(sm.CommandService, basicAuthEndpointMiddleware) - command.RegisterHTTPHandlers(r, commandEndpoints, options...) - - depsvc := depapi.New(dc, sm.PubClient) - depsvc.Run() - depEndpoints := depapi.MakeServerEndpoints(depsvc, basicAuthEndpointMiddleware) - depapi.RegisterHTTPHandlers(r, depEndpoints, options...) - - depsyncEndpoints := sync.MakeServerEndpoints(sync.NewService(syncer, sm.SyncDB), basicAuthEndpointMiddleware) - sync.RegisterHTTPHandlers(r, depsyncEndpoints, options...) - - if sm.SCEPChallengeDepot != nil { - challengeEndpoints := challenge.MakeServerEndpoints(challenge.NewService(sm.SCEPChallengeDepot), basicAuthEndpointMiddleware) - challenge.RegisterHTTPHandlers(r, challengeEndpoints, options...) - } - - r.HandleFunc("/boltbackup", httputil2.RequireBasicAuth(boltBackup(sm.DB), "micromdm", *flAPIKey, "micromdm")) - } else { - mainLogger.Log("msg", "no api key specified") - } - - if *flRepoPath != "" { - if _, err := os.Stat(*flRepoPath); os.IsNotExist(err) { - stdlog.Fatal(err) - } - r.PathPrefix("/repo/").Handler(http.StripPrefix("/repo/", http.FileServer(http.Dir(*flRepoPath)))) - } - - var handler http.Handler - if *flHTTPDebug { - handler = httputil.HTTPDebugMiddleware(os.Stdout, true, logger.Log)(r) - } else { - handler = r - } - handler = logutil.NewHTTPLogger(httpLogger).Middleware(handler) - - srvURL, err := url.Parse(sm.ServerPublicURL) - if err != nil { - return errors.Wrapf(err, "parsing serverURL %q", sm.ServerPublicURL) - } - - serveOpts := serveOptions( - handler, - *flHTTPAddr, - srvURL.Hostname(), - logger, - *flTLSCert, - *flTLSKey, - sm.ConfigPath, - *flTLS, - ) - err = httputil.ListenAndServe(serveOpts...) - return errors.Wrap(err, "calling ListenAndServe") -} - -// serveOptions configures the []httputil.Options for ListenAndServe -func serveOptions( - handler http.Handler, - addr string, - hostname string, - logger log.Logger, - certPath string, - keyPath string, - configPath string, - tls bool, -) []httputil.Option { - tlsFromFile := (certPath != "" && keyPath != "") - serveOpts := []httputil.Option{ - httputil.WithACMEHosts([]string{hostname}), - httputil.WithLogger(logger), - httputil.WithHTTPHandler(handler), - } - if tlsFromFile { - serveOpts = append(serveOpts, httputil.WithKeyPair(certPath, keyPath)) - } - if !tls && addr == ":https" { - serveOpts = append(serveOpts, httputil.WithAddress(":8080")) - } - if tls { - serveOpts = append(serveOpts, httputil.WithAutocertCache(autocert.DirCache(filepath.Join(configPath, "le-certificates")))) - } - if addr != ":https" { - serveOpts = append(serveOpts, httputil.WithAddress(addr)) - } - return serveOpts -} - -func boltBackup(db *bolt.DB) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - err := db.View(func(tx *bolt.Tx) error { - w.Header().Set("Content-Type", "application/octet-stream") - w.Header().Set("Content-Disposition", `attachment; filename="micromdm.db"`) - w.Header().Set("Content-Length", strconv.Itoa(int(tx.Size()))) - _, err := tx.WriteTo(w) - return err - }) - if err != nil { - http.Error(w, err.Error(), http.StatusInternalServerError) - } - } -} - -func printExamples() { - const exampleText = ` - Quickstart: - micromdm serve -server-url=https://my-server-url -tls-cert tls.crt -tls-key tls.key - ` - fmt.Println(exampleText) -} diff --git a/dep/account.go b/dep/account.go deleted file mode 100644 index 3c3b89db..00000000 --- a/dep/account.go +++ /dev/null @@ -1,43 +0,0 @@ -package dep - -import "github.com/pkg/errors" - -const accountBasePath = "account" - -type LimitDict struct { - Default int `json:"default"` - Maximum int `json:"maximum"` -} - -type URL struct { - URI string `json:"uri"` - HTTPMethod []string `json:"http_method"` - Limit LimitDict `json:"limit"` -} - -type Account struct { - ServerName string `json:"server_name"` - ServerUUID string `json:"server_uuid"` - AdminID string `json:"admin_id"` - FacilitatorID string `json:"facilitator_id,omitempty"` //deprecated - OrgName string `json:"org_name"` - OrgEmail string `json:"org_email"` - OrgPhone string `json:"org_phone"` - OrgAddress string `json:"org_address"` - OrgID string `json:"org_id"` - OrgIDHash string `json:"org_id_hash"` - URLs []URL `json:"urls"` - OrgType string `json:"org_type"` - OrgVersion string `json:"org_version"` -} - -func (c *Client) Account() (*Account, error) { - var account Account - req, err := c.newRequest("GET", accountBasePath, nil) - if err != nil { - return nil, errors.Wrap(err, "create account request") - } - - err = c.do(req, &account) - return &account, errors.Wrap(err, "account request") -} diff --git a/dep/activation_lock.go b/dep/activation_lock.go deleted file mode 100644 index b42ff3a0..00000000 --- a/dep/activation_lock.go +++ /dev/null @@ -1,34 +0,0 @@ -package dep - -import "github.com/pkg/errors" - -const ( - activationLockPath = "device/activationlock" -) - -type ActivationLockRequest struct { - Device string `json:"device"` - - // If the escrow key is not provided, the device will be locked to the person who created the MDM server in the portal. - // https://developer.apple.com/documentation/devicemanagement/device_assignment/activation_lock_a_device/creating_and_using_bypass_codes - // The EscrowKey is a hex-encoded PBKDF2 derivation of the bypass code. See activationlock.BypassCode. - EscrowKey string `json:"escrow_key"` - - LostMessage string `json:"lost_message"` -} - -type ActivationLockResponse struct { - SerialNumber string `json:"serial_number"` - Status string `json:"response_status"` -} - -func (c *Client) ActivationLock(alr ActivationLockRequest) (*ActivationLockResponse, error) { - req, err := c.newRequest("POST", activationLockPath, &alr) - if err != nil { - return nil, errors.Wrap(err, "create activation lock request") - } - - var response ActivationLockResponse - err = c.do(req, &response) - return &response, errors.Wrap(err, "activation lock") -} diff --git a/dep/client.go b/dep/client.go deleted file mode 100644 index 6b0eee39..00000000 --- a/dep/client.go +++ /dev/null @@ -1,214 +0,0 @@ -package dep - -import ( - "bytes" - "encoding/json" - "io/ioutil" - "net/http" - "net/url" - "path" - "strings" - "time" - - "github.com/garyburd/go-oauth/oauth" - "github.com/pkg/errors" -) - -var version = "dev" - -const ( - defaultBaseURL = "https://mdmenrollment.apple.com" - mediaType = "application/json;charset=UTF8" - XServerProtocolVersionHeader = "X-Server-Protocol-Version" - XServerProtocolVersion = "3" -) - -type HTTPClient interface { - Do(req *http.Request) (*http.Response, error) -} - -type Option func(*Client) - -func WithServerURL(baseURL *url.URL) Option { - return func(c *Client) { - c.baseURL = baseURL - } -} - -func WithHTTPClient(client HTTPClient) Option { - return func(c *Client) { - c.client = client - } -} - -type Client struct { - consumerKey string //given by apple - consumerSecret string //given by apple - accessToken string //given by apple - accessSecret string //given by apple - authSessionToken string //requested from DEP using above credentials - sessionExpires time.Time - - userAgent string - client HTTPClient - - baseURL *url.URL -} - -type OAuthParameters struct { - ConsumerKey string `json:"consumer_key"` - ConsumerSecret string `json:"consumer_secret"` - AccessToken string `json:"access_token"` - AccessSecret string `json:"access_secret"` -} - -func NewClient(p OAuthParameters, opts ...Option) *Client { - baseURL, _ := url.Parse(defaultBaseURL) - client := Client{ - consumerKey: p.ConsumerKey, - consumerSecret: p.ConsumerSecret, - accessToken: p.AccessToken, - accessSecret: p.AccessSecret, - client: http.DefaultClient, - userAgent: path.Join("micromdm", version), - baseURL: baseURL, - } - for _, optFn := range opts { - optFn(&client) - } - return &client -} - -func (c *Client) session() error { - if c.authSessionToken == "" { - if err := c.newSession(); err != nil { - return errors.Wrap(err, "creating new auth session for dep") - } - } - - if time.Now().After(c.sessionExpires) { - if err := c.newSession(); err != nil { - return errors.Wrap(err, "refreshing expired dep session") - } - } - return nil -} - -func (c *Client) newSession() error { - var authSessionToken struct { - AuthSessionToken string `json:"auth_session_token"` - } - consumerCredentials := oauth.Credentials{ - Token: c.consumerKey, - Secret: c.consumerSecret, - } - - accessCredentials := &oauth.Credentials{ - Token: c.accessToken, - Secret: c.accessSecret, - } - form := url.Values{} - - rel, err := url.Parse("/session") - if err != nil { - return err - } - sessionURL := c.baseURL.ResolveReference(rel) - - oauthClient := oauth.Client{ - SignatureMethod: oauth.HMACSHA1, - TokenRequestURI: sessionURL.String(), - Credentials: consumerCredentials, - } - - // create request - req, err := http.NewRequest("GET", oauthClient.TokenRequestURI, strings.NewReader(form.Encode())) - if err != nil { - return err - } - - // set Authorization Header - if err := oauthClient.SetAuthorizationHeader( - req.Header, - accessCredentials, - "GET", - req.URL, - form, - ); err != nil { - return err - } - // add headers - req.Header.Add("User-Agent", c.userAgent) - req.Header.Add("Content-Type", mediaType) - req.Header.Add("Accept", mediaType) - req.Header.Add(XServerProtocolVersionHeader, XServerProtocolVersion) - - // get Authorization Header - resp, err := c.client.Do(req) - if err != nil { - return err - } - defer resp.Body.Close() - - // check resp statuscode - if resp.StatusCode != http.StatusOK { - return errors.Errorf("establishing DEP session: %v", resp.Status) - } - - if err := json.NewDecoder(resp.Body).Decode(&authSessionToken); err != nil { - return errors.Wrap(err, "decode authSessionToken from response") - } - - // set token and expiration value - c.authSessionToken = authSessionToken.AuthSessionToken - c.sessionExpires = time.Now().Add(time.Minute * 3) - return nil -} - -// NewRequest creates a DEP request -func (c *Client) newRequest(method, urlStr string, body interface{}) (*http.Request, error) { - rel, err := url.Parse(urlStr) - if err != nil { - return nil, errors.Wrapf(err, "parse dep request url %s", urlStr) - } - - u := c.baseURL.ResolveReference(rel) - var buf bytes.Buffer - if body != nil { - if err := json.NewEncoder(&buf).Encode(body); err != nil { - return nil, errors.Wrap(err, "encode http body for DEP request") - } - } - - req, err := http.NewRequest(method, u.String(), &buf) - if err != nil { - return nil, errors.Wrapf(err, "creating %s request to dep %s", method, u.String()) - } - - req.Header.Add("User-Agent", c.userAgent) - req.Header.Add("Content-Type", mediaType) - req.Header.Add("Accept", mediaType) - req.Header.Add(XServerProtocolVersionHeader, XServerProtocolVersion) - return req, nil -} - -func (c *Client) do(req *http.Request, into interface{}) error { - if err := c.session(); err != nil { - return errors.Wrapf(err, "get session for request to %s", c.baseURL.String()) - } - req.Header.Add("X-ADM-Auth-Session", c.authSessionToken) - - resp, err := c.client.Do(req) - if err != nil { - return errors.Wrap(err, "perform dep request") - } - defer resp.Body.Close() - - if resp.StatusCode != http.StatusOK { - body, _ := ioutil.ReadAll(resp.Body) - return errors.Errorf("unexpected dep response. status=%d DEP API Error: %s", resp.StatusCode, string(body)) - } - err = json.NewDecoder(resp.Body).Decode(into) - return errors.Wrap(err, "decode DEP response body") - -} diff --git a/dep/devices.go b/dep/devices.go deleted file mode 100644 index 437391b1..00000000 --- a/dep/devices.go +++ /dev/null @@ -1,121 +0,0 @@ -package dep - -import ( - "time" - - "github.com/pkg/errors" -) - -const ( - fetchDevicesPath = "server/devices" - syncDevicesPath = "devices/sync" - deviceDetailsPath = "devices" -) - -type Device struct { - SerialNumber string `json:"serial_number"` - Model string `json:"model"` - Description string `json:"description"` - Color string `json:"color"` - AssetTag string `json:"asset_tag,omitempty"` - ProfileStatus string `json:"profile_status"` - ProfileUUID string `json:"profile_uuid,omitempty"` - ProfileAssignTime time.Time `json:"profile_assign_time,omitempty"` - ProfilePushTime time.Time `json:"profile_push_time,omitempty"` - DeviceAssignedDate time.Time `json:"device_assigned_date,omitempty"` - DeviceAssignedBy string `json:"device_assigned_by,omitempty"` - OS string `json:"os,omitempty"` - DeviceFamily string `json:"device_family,omitempty"` - // sync fields - OpType string `json:"op_type,omitempty"` - OpDate time.Time `json:"op_date,omitempty"` - // details fields - ResponseStatus string `json:"response_status,omitempty"` -} - -// DeviceRequestOption is an optional parameter for the DeviceService API. -// The option can be used to set Cursor or Limit options for the request. -type DeviceRequestOption func(*deviceRequestOpts) error - -type deviceRequestOpts struct { - Cursor string `json:"cursor,omitempty"` - Limit int `json:"limit,omitempty"` -} - -// Cursor is an optional argument that can be added to FetchDevices -func Cursor(cursor string) DeviceRequestOption { - return func(opts *deviceRequestOpts) error { - opts.Cursor = cursor - return nil - } -} - -// Limit is an optional argument that can be passed to FetchDevices and SyncDevices -func Limit(limit int) DeviceRequestOption { - return func(opts *deviceRequestOpts) error { - if limit > 1000 { - return errors.New("limit must not be higher than 1000") - } - opts.Limit = limit - return nil - } -} - -type DeviceResponse struct { - Devices []Device `json:"devices"` - Cursor string `json:"cursor"` - FetchedUntil time.Time `json:"fetched_until"` - MoreToFollow bool `json:"more_to_follow"` -} - -func (c *Client) FetchDevices(opts ...DeviceRequestOption) (*DeviceResponse, error) { - request := &deviceRequestOpts{} - for _, option := range opts { - if err := option(request); err != nil { - return nil, err - } - } - var response DeviceResponse - req, err := c.newRequest("POST", fetchDevicesPath, request) - if err != nil { - return nil, errors.Wrap(err, "create fetch devices request") - } - err = c.do(req, &response) - return &response, errors.Wrap(err, "fetch devices") -} - -func (c *Client) SyncDevices(cursor string, opts ...DeviceRequestOption) (*DeviceResponse, error) { - request := &deviceRequestOpts{Cursor: cursor} - for _, option := range opts { - if err := option(request); err != nil { - return nil, err - } - } - var response DeviceResponse - req, err := c.newRequest("POST", syncDevicesPath, request) - if err != nil { - return nil, errors.Wrap(err, "create sync devices request") - } - err = c.do(req, &response) - return &response, errors.Wrap(err, "sync devices") -} - -type DeviceDetailsResponse struct { - Devices map[string]Device `json:"devices"` -} - -func (c *Client) DeviceDetails(serials ...string) (*DeviceDetailsResponse, error) { - request := struct { - Devices []string `json:"devices"` - }{ - Devices: serials, - } - - var response DeviceDetailsResponse - req, err := c.newRequest("POST", deviceDetailsPath, request) - if err != nil { - return nil, errors.Wrap(err, "create device details request") - } - err = c.do(req, &response) - return &response, errors.Wrap(err, "get device details") -} diff --git a/dep/profile.go b/dep/profile.go deleted file mode 100644 index 485d62fe..00000000 --- a/dep/profile.go +++ /dev/null @@ -1,95 +0,0 @@ -package dep - -import "github.com/pkg/errors" - -const ( - defineProfilePath = "profile" - assignProfilePath = "profile/devices" -) - -type Profile struct { - ProfileName string `json:"profile_name"` - ProfileUUID string `json:"profile_uuid,omitempty"` - URL string `json:"url"` - AllowPairing bool `json:"allow_pairing,omitempty"` - IsSupervised bool `json:"is_supervised,omitempty"` - IsMultiUser bool `json:"is_multi_user,omitempty"` - IsMandatory bool `json:"is_mandatory,omitempty"` - AwaitDeviceConfigured bool `json:"await_device_configured,omitempty"` - IsMDMRemovable bool `json:"is_mdm_removable"` - SupportPhoneNumber string `json:"support_phone_number,omitempty"` - AutoAdvanceSetup bool `json:"auto_advance_setup,omitempty"` - SupportEmailAddress string `json:"support_email_address,omitempty"` - OrgMagic string `json:"org_magic"` - AnchorCerts []string `json:"anchor_certs,omitempty"` - SupervisingHostCerts []string `json:"supervising_host_certs,omitempty"` - SkipSetupItems []string `json:"skip_setup_items,omitempty"` - Department string `json:"department,omitempty"` - Devices []string `json:"devices"` - Language string `json:"language,omitempty"` - Region string `json:"region,omitempty"` - ConfigurationWebURL string `json:"configuration_web_url,omitempty"` -} - -type ProfileResponse struct { - ProfileUUID string `json:"profile_uuid"` - Devices map[string]string `json:"devices"` -} - -func (c *Client) DefineProfile(request *Profile) (*ProfileResponse, error) { - var response ProfileResponse - req, err := c.newRequest("POST", defineProfilePath, request) - if err != nil { - return nil, errors.Wrap(err, "create define profile request") - } - err = c.do(req, &response) - return &response, errors.Wrap(err, "define profile") -} - -func (c *Client) AssignProfile(uuid string, serials ...string) (*ProfileResponse, error) { - var response ProfileResponse - var request = struct { - ProfileUUID string `json:"profile_uuid"` - Devices []string `json:"devices"` - }{ - ProfileUUID: uuid, - Devices: serials, - } - - req, err := c.newRequest("PUT", assignProfilePath, request) - if err != nil { - return nil, errors.Wrap(err, "create assign profile request") - } - err = c.do(req, &response) - return &response, errors.Wrap(err, "assign profile") -} - -func (c *Client) FetchProfile(uuid string) (*Profile, error) { - var response Profile - req, err := c.newRequest("GET", defineProfilePath, nil) - if err != nil { - return nil, errors.Wrap(err, "create fetch profile request") - } - query := req.URL.Query() - query.Add("profile_uuid", uuid) - req.URL.RawQuery = query.Encode() - - err = c.do(req, &response) - return &response, errors.Wrap(err, "fetch profile") -} - -func (c *Client) RemoveProfile(serials ...string) (map[string]string, error) { - var response struct { - Devices map[string]string `json:"devices"` - } - var request = struct { - Devices []string `json:"devices"` - }{Devices: serials} - - req, err := c.newRequest("DELETE", assignProfilePath, &request) - if err != nil { - return nil, errors.Wrap(err, "create fetch profile request") - } - err = c.do(req, &response) - return response.Devices, errors.Wrap(err, "remove profile") -} diff --git a/dep/testdata/account_response.json b/dep/testdata/account_response.json deleted file mode 100644 index f6a0170b..00000000 --- a/dep/testdata/account_response.json +++ /dev/null @@ -1,136 +0,0 @@ -{ - "server_name": "dev", - "server_uuid": "6666ED66666666666666666666666666", - "facilitator_id": "apple-dep@acme.co", - "admin_id": "apple-dep@acme.co", - "org_name": "Acme, Inc", - "org_email": "apple-dep@acme.co", - "org_phone": "8775277454", - "org_address": "1600 Pennsylvania Ave NW, Washington, DC 20500", - "org_id": "6666666", - "org_id_hash": "01cpx35ceg4bt5jzrvs6s0h18201cpx35ceg4bt5jzrvs6s0h182", - "urls": [ - { - "uri": "/session", - "http_method": [ - "GET" - ] - }, - { - "uri": "/devices", - "http_method": [ - "POST" - ] - }, - { - "uri": "/roster/class/person/sync", - "http_method": [ - "POST" - ] - }, - { - "uri": "/server/devices", - "http_method": [ - "POST" - ], - "limit": { - "default": 1000, - "maximum": 5000 - } - }, - { - "uri": "/roster/class", - "http_method": [ - "POST" - ] - }, - { - "uri": "/roster/course/sync", - "http_method": [ - "POST" - ] - }, - { - "uri": "/devices/sync", - "http_method": [ - "POST" - ], - "limit": { - "default": 1000, - "maximum": 5000 - } - }, - { - "uri": "/roster/class/person", - "http_method": [ - "POST" - ] - }, - { - "uri": "/profile/devices", - "http_method": [ - "DELETE", - "POST", - "PUT" - ] - }, - { - "uri": "/roster/class/location", - "http_method": [ - "POST" - ] - }, - { - "uri": "/roster/class/sync", - "http_method": [ - "POST" - ] - }, - { - "uri": "/account", - "http_method": [ - "GET" - ] - }, - { - "uri": "/roster/class/location/sync", - "http_method": [ - "POST" - ] - }, - { - "uri": "/devices/disown", - "http_method": [ - "POST" - ] - }, - { - "uri": "/roster/course", - "http_method": [ - "POST" - ] - }, - { - "uri": "/profile/tvprovider", - "http_method": [ - "POST", - "GET" - ] - }, - { - "uri": "/device/activationlock", - "http_method": [ - "POST" - ] - }, - { - "uri": "/profile", - "http_method": [ - "POST", - "GET" - ] - } - ], - "org_type": "org", - "org_version": "v2" -} diff --git a/dep/testdata/device_details_response.json b/dep/testdata/device_details_response.json deleted file mode 100644 index 89aeab7b..00000000 --- a/dep/testdata/device_details_response.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "devices": { - "C02T0HL0GGC0": { - "serial_number": "C02T0HL0GGC0", - "description": "MBP 13.3 SPACE GRAY/2.0GHZ/8GB/256GB-USA", - "model": "MacBook Pro", - "os": "OSX", - "device_family": "Mac", - "color": "SPACE GRAY", - "profile_uuid": "C1F123098EB5074580041E69883004C3", - "profile_assign_time": "2018-09-08T16:49:09Z", - "profile_status": "assigned", - "device_assigned_by": "apple-dep@acme.co", - "device_assigned_date": "2017-10-16T01:55:30Z", - "response_status": "SUCCESS" - } - } -} diff --git a/dep/testdata/device_response.json b/dep/testdata/device_response.json deleted file mode 100644 index e6833aef..00000000 --- a/dep/testdata/device_response.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "devices": [ - { - "serial_number": "C02T0HL0GGC0", - "description": "MBP 13.3 SPACE GRAY/2.0GHZ/8GB/256GB-USA", - "model": "MacBook Pro", - "os": "OSX", - "device_family": "Mac", - "color": "SPACE GRAY", - "profile_uuid": "C1F123098EB5074580041E69883004C3", - "profile_assign_time": "2018-09-08T16:49:09Z", - "profile_status": "assigned", - "device_assigned_by": "apple-dep@acme.co", - "device_assigned_date": "2017-10-16T01:55:30Z" - } - ], - "fetched_until": "2018-09-08T17:28:18Z", - "more_to_follow": false, - "cursor": "MDowOjE1MzY0Mjc2OTg5MTQ6MTUzNjQyNzY5ODkxNDp0cnVlOjE1MzY0Mjc2OTg5MTQ" -} diff --git a/dep/testdata/empty_sync_response.json b/dep/testdata/empty_sync_response.json deleted file mode 100644 index 02828dff..00000000 --- a/dep/testdata/empty_sync_response.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "devices": [], - "fetched_until": "2018-09-08T17:41:29Z", - "more_to_follow": false, - "cursor": "MDowOjE1MzY0Mjg0ODkzMDc6MTUzNjQyODQ4OTMwNzp0cnVlOjE1MzY0Mjg0ODkzMDc" -} diff --git a/dep/testdata/fetch_profile_response.json b/dep/testdata/fetch_profile_response.json deleted file mode 100644 index 62612fcb..00000000 --- a/dep/testdata/fetch_profile_response.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "support_phone_number": "(Optional) +1 877 527 7454", - "support_email_address": "(Optional) support@example.com", - "department": "(Optional) support@example.com", - "org_magic": "0729093D-D02C-4D8B-89DC-4EF900AED5B2", - "url": "https://mdm.acme.co/mdm/enroll", - "is_supervised": false, - "allow_pairing": true, - "is_mandatory": false, - "is_mdm_removable": true, - "await_device_configured": true, - "is_multi_user": false, - "auto_advance_setup": false, - "skip_setup_items": [ - "AppleID", - "Android" - ], - "profile_uuid": "C1F123098EB5074580041E69883004C3", - "profile_name": "default" -} diff --git a/docker-compose-dev.yaml b/docker-compose-dev.yaml deleted file mode 100644 index 74067925..00000000 --- a/docker-compose-dev.yaml +++ /dev/null @@ -1,11 +0,0 @@ -version: "2" - -services: - postgresql: - image: postgres:9.6 - environment: - POSTGRES_DB: micromdm - POSTGRES_USER: micromdm - POSTGRES_PASSWORD: micromdm - ports: - - 5432:5432 diff --git a/docs/architecture/2019-05-03_no_device_configured_without_blueprint.md b/docs/architecture/2019-05-03_no_device_configured_without_blueprint.md deleted file mode 100644 index b91a6d93..00000000 --- a/docs/architecture/2019-05-03_no_device_configured_without_blueprint.md +++ /dev/null @@ -1,17 +0,0 @@ -# Do not send DeviceConfigured when there are no user configured blueprints. - -## Context - -DEP enrolled devices use an `AwaitDeviceConfigured` mode, which can be optionally enabled in a DEP profile. If enabled, the device will wait at the Remote Management screen, and not proceed until the MDM issues a `DeviceConfigured` command. -MicroMDM introduced the concept of a `Blueprint`, which an administrator can configure to apply `InstallProfile` and `InstallApplication` payloads. At the end of the list of pre-configured commands the MDM would default to sending the `DeviceConfigured` command. - -It would be useful to allow a separate service to make a decision about whether it is ok to proceed with device provisioning past enrollment. - -## Decision - -When there are no blueprints configured, the MicroMDM server will not send _any_ commands to the device. -That means, if `AwaitDeviceConfigured` is enabled on the device, upon enrollment the device will remain at the Remote Management screen until an API request queues the DeviceConfigured command. - -## Status - -Accepted diff --git a/docs/user-guide/api-and-webhooks.md b/docs/user-guide/api-and-webhooks.md deleted file mode 100644 index e64eae26..00000000 --- a/docs/user-guide/api-and-webhooks.md +++ /dev/null @@ -1,222 +0,0 @@ -MicroMDM is intended to be a dependency for implementing a higher level workflow. To do so, it exposes all its capabilities through an HTTP API and also forwards all the device responses to an HTTP endpoint of your choice. - -For examples of what you can do with the API, reference the [tools/api](https://github.com/micromdm/micromdm/tree/main/tools/api) directory of the micromdm repository. The directory includes executable `curl` examples of API requests which you can run, but also reference when implementing an API client in another language. - -Throughout this document we will reference the provided scripts as shorthand for making API requests. - -# Configure a webhook URL to process device events - -When you schedule a command on the device, it will respond. As a rule of thumb, MicroMDM does not process the responses from the devices outside of maintaining the command queue and storing tokens/certificates it needs to keep communication with the devices. Instead, it allows the configuration of an HTTP Webhook URL, which gives you the ability to process the responses how you wish. - -To configure the webhook URL, start `micromdm` with the `-command-webhook-url` flag. - -## Events - -Each event sent to the webhook url contains a json object in the body of the request which represents the event. - -| Property | Description | -|-------------------|--------------------------------------------------| -| topic | The type of MicroMDM event. See values below. | -| event_id | A unique id representing the event. | -| created_at | The timestamp that MicroMDM generated the event. | -| checkin_event | Optional payload based on the topic. | -| acknowledge_event | Optional payload based on the topic. | - - -The following MicroMDM Topics are exposed via the webhook functionality: - -| Topic | Payload | -|-----------------------------------|------------------------------------------| -| [mdm.Authenticate](#authenticate) | [checkin_event](#checkin-events) | -| [mdm.TokenUpdate](#token-update) | [checkin_event](#checkin-events) | -| [mdm.CheckOut](#checkout) | [checkin_event](#checkin-events) | -| [mdm.Connect](#connect) | [acknowledge_event](#acknowledge-events) | - - -The following is an example of the json payload in the body of the request. - -```json -{ - "topic": "mdm.Connect", - "event_id": "09fd3348-24c8-43cf-91d7-1a5d5d599012", - "created_at": "2018-08-13T14:30:20.491166786Z", - "checkin_event": { - ... - "raw_payload": "" - }, - "acknowledge_event": { - ... - "raw_payload": "" - } -} -``` - -Depending on which topic the event is for one of the optional `_event` payloads will be filled in. Each `_event` payload contains a `raw_payload` field which is a base64 encoded representation of the actual data the device sent back to the MDM server. For more detailed information on these raw payloads please refer to the official Apple MDM Protocol Reference. - -https://developer.apple.com/enterprise/documentation/MDM-Protocol-Reference.pdf - -### Checkin Events - -The MDM check-in protocol is used during initialization to validate a deviceʼs eligibility for MDM enrollment and to inform the server that a deviceʼs push token has been updated. - -| Property | Description | -|-------------|-----------------------------------------------------------------------------------------------------------| -| udid | UDID of the device. | -| url_params | Any additional http params added in the enrollment profile `CheckInURL` field are passed through to here. | -| raw_payload | The raw data sent from the device to MicroMDM. | - -#### Authenticate - -While the user is installing an MDM payload, the device sends an authenticate message. - -```json -{ - "topic": "mdm.Authenticate", - "event_id": "5ee634b5-bd58-4b3e-8b77-3f764d087787", - "created_at": "2018-08-13T14:30:16.13272395Z", - "checkin_event": { - "udid": "A5EF1BA1-586D-4F29-B4F3-759DADAC2DDD", - "url_params": null, - "raw_payload": "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPCFET0NUWVBFIHBsaXN0IFBVQkxJQyAiLS8vQXBwbGUvL0RURCBQTElTVCAxLjAvL0VOIiAiaHR0cDovL3d3dy5hcHBsZS5jb20vRFREcy9Qcm9wZXJ0eUxpc3QtMS4wLmR0ZCI+CjxwbGlzdCB2ZXJzaW9uPSIxLjAiPgo8ZGljdD4KCTxrZXk+QnVpbGRWZXJzaW9uPC9rZXk+Cgk8c3RyaW5nPjE3RzY1PC9zdHJpbmc+Cgk8a2V5PkNoYWxsZW5nZTwva2V5PgoJPGRhdGE+CglZWEJ3YkdVPQoJPC9kYXRhPgoJPGtleT5EZXZpY2VOYW1lPC9rZXk+Cgk8c3RyaW5nPkhvc3ROYW1lPC9zdHJpbmc+Cgk8a2V5Pk1lc3NhZ2VUeXBlPC9rZXk+Cgk8c3RyaW5nPkF1dGhlbnRpY2F0ZTwvc3RyaW5nPgoJPGtleT5Nb2RlbDwva2V5PgoJPHN0cmluZz5NYWNCb29rUHJvMTQsMzwvc3RyaW5nPgoJPGtleT5Nb2RlbE5hbWU8L2tleT4KCTxzdHJpbmc+TWFjQm9vayBQcm88L3N0cmluZz4KCTxrZXk+T1NWZXJzaW9uPC9rZXk+Cgk8c3RyaW5nPjEwLjEzLjY8L3N0cmluZz4KCTxrZXk+UHJvZHVjdE5hbWU8L2tleT4KCTxzdHJpbmc+TWFjQm9va1BybzE0LDM8L3N0cmluZz4KCTxrZXk+U2VyaWFsTnVtYmVyPC9rZXk+Cgk8c3RyaW5nPkMwNFcwMEQzSFREMDwvc3RyaW5nPgoJPGtleT5Ub3BpYzwva2V5PgoJPHN0cmluZz5jb20uYXBwbGUubWdtdC5FeHRlcm5hbC4zYTdjOTVmMi1jMjE0LTRiNTMtYTU4NS1hNTUzYzI2MjNlMDQ8L3N0cmluZz4KCTxrZXk+VURJRDwva2V5PgoJPHN0cmluZz5BNUVGMUJBMS01ODZELTRGMjktQjRGMy03NTlEQURBQzJEREQ8L3N0cmluZz4KPC9kaWN0Pgo8L3BsaXN0Pgo=" - } -} -``` - -#### Token Update - -A device sends a token update message to the check-in server whenever its device push token, push magic, or -unlock token change. These fields are needed by the server to send the device push notifications or passcode -resets. The device sends an initial token update message to the server when it has installed the MDM payload. The server -should send push messages to the device **only** after receiving the first token update message. - -```json -{ - "topic": "mdm.TokenUpdate", - "event_id": "99eb840c-3e1f-48a7-a4f9-1ef092445129", - "created_at": "2018-08-13T14:30:16.529223669Z", - "checkin_event": { - "udid": "A5EF1BA1-586D-4F29-B4F3-759DADAC2DDD", - "url_params": null, - "raw_payload": "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPCFET0NUWVBFIHBsaXN0IFBVQkxJQyAiLS8vQXBwbGUvL0RURCBQTElTVCAxLjAvL0VOIiAiaHR0cDovL3d3dy5hcHBsZS5jb20vRFREcy9Qcm9wZXJ0eUxpc3QtMS4wLmR0ZCI+CjxwbGlzdCB2ZXJzaW9uPSIxLjAiPgo8ZGljdD4KCTxrZXk+QXdhaXRpbmdDb25maWd1cmF0aW9uPC9rZXk+Cgk8ZmFsc2UvPgoJPGtleT5NZXNzYWdlVHlwZTwva2V5PgoJPHN0cmluZz5Ub2tlblVwZGF0ZTwvc3RyaW5nPgoJPGtleT5QdXNoTWFnaWM8L2tleT4KCTxzdHJpbmc+NzI4Rjg2NzAtNDkzNC00QTMwLUJBREYtN0I0M0MyNjFGQzE0PC9zdHJpbmc+Cgk8a2V5PlRva2VuPC9rZXk+Cgk8ZGF0YT4KCWMzRnlIV2hqRzN0bVNBNTVMRkZJUWc9PQoJPC9kYXRhPgoJPGtleT5Ub3BpYzwva2V5PgoJPHN0cmluZz5jb20uYXBwbGUubWdtdC5FeHRlcm5hbC4zYTdjOTVmMi1jMjE0LTRiNTMtYTU4NS1hNTUzYzI2MjNlMDQ8L3N0cmluZz4KCTxrZXk+VURJRDwva2V5PgoJPHN0cmluZz5BNUVGMUJBMS01ODZELTRGMjktQjRGMy03NTlEQURBQzJEREQ8L3N0cmluZz4KPC9kaWN0Pgo8L3BsaXN0Pgo=" - } -} -``` - -#### CheckOut - -In iOS 5.0 and later, and in macOS v10.9, if the CheckOutWhenRemoved key in the MDM enrollment profile is set to true, the device attempts to send a CheckOut message when the MDM profile is removed. - -```json -{ - "topic": "mdm.CheckOut", - "event_id": "3f3a0620-6c3a-4dc5-bdc6-523f071e5865", - "created_at": "2018-08-13T18:36:12.727463835Z", - "checkin_event": { - "udid": "A5EF1BA1-586D-4F29-B4F3-759DADAC2DDD", - "url_params": null, - "raw_payload": "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPCFET0NUWVBFIHBsaXN0IFBVQkxJQyAiLS8vQXBwbGUvL0RURCBQTElTVCAxLjAvL0VOIiAiaHR0cDovL3d3dy5hcHBsZS5jb20vRFREcy9Qcm9wZXJ0eUxpc3QtMS4wLmR0ZCI+CjxwbGlzdCB2ZXJzaW9uPSIxLjAiPgo8ZGljdD4KCTxrZXk+TWVzc2FnZVR5cGU8L2tleT4KCTxzdHJpbmc+Q2hlY2tPdXQ8L3N0cmluZz4KCTxrZXk+VG9waWM8L2tleT4KCTxzdHJpbmc+Y29tLmFwcGxlLm1nbXQuRXh0ZXJuYWwuM2E3Yzk1ZjItYzIxNC00YjUzLWE1ODUtYTU1M2MyNjIzZTA0PC9zdHJpbmc+Cgk8a2V5PlVESUQ8L2tleT4KCTxzdHJpbmc+QTVFRjFCQTEtNTg2RC00RjI5LUI0RjMtNzU5REFEQUMyREREPC9zdHJpbmc+CjwvZGljdD4KPC9wbGlzdD4K" - } -} -``` - -### Acknowledge Events - -Acknowledge events are sent when the device responds to a command sent to it. - -| Property | Description | -|--------------|----------------------------------------------------------------------------------------------------------| -| udid | UDID of the device. | -| status | Status. See the [Apple MDM Protocol Reference](https://developer.apple.com/enterprise/documentation/MDM-Protocol-Reference.pdf) for values. | -| command_uuid | UUID of the command that this response is for (if any). | -| url_params | Any additional http params added in the enrollment profile `ServerURL` field are passed through to here. | -| raw_payload | The raw data sent from the device to MicroMDM. | - -#### Connect - -After the MDM server has sent a command to the device, the device replies to the server by sending a plist-encoded dictionary containing the response to the command. - -```json -{ - "topic": "mdm.Connect", - "event_id": "3444be1d-bbf0-45dc-9da3-f707beeecf1b", - "created_at": "2018-08-13T14:30:16.789541405Z", - "acknowledge_event": { - "udid": "A5EF1BA1-586D-4F29-B4F3-759DADAC2DDD", - "status": "Acknowledged", - "command_uuid": "41d35de3-a343-4146-ba4b-0069bae2a54f", - "url_params": null, - "raw_payload": "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPCFET0NUWVBFIHBsaXN0IFBVQkxJQyAiLS8vQXBwbGUvL0RURCBQTElTVCAxLjAvL0VOIiAiaHR0cDovL3d3dy5hcHBsZS5jb20vRFREcy9Qcm9wZXJ0eUxpc3QtMS4wLmR0ZCI+CjxwbGlzdCB2ZXJzaW9uPSIxLjAiPgo8ZGljdD4KCTxrZXk+Q29tbWFuZFVVSUQ8L2tleT4KCTxzdHJpbmc+NDFkMzVkZTMtYTM0My00MTQ2LWJhNGItMDA2OWJhZTJhNTRmPC9zdHJpbmc+Cgk8a2V5PlN0YXR1czwva2V5PgoJPHN0cmluZz5BY2tub3dsZWRnZWQ8L3N0cmluZz4KCTxrZXk+VURJRDwva2V5PgoJPHN0cmluZz5BNUVGMUJBMS01ODZELTRGMjktQjRGMy03NTlEQURBQzJEREQ8L3N0cmluZz4KPC9kaWN0Pgo8L3BsaXN0Pgo=" - } -} -``` - -## Example Code - -Creating a simple webhook listener is as simple as listening for the POST requests from MicroMDM. Below is an example of a python [Flask](http://flask.pocoo.org/) server that just prints out all the messages it receives. - -```python -from flask import Flask, request, abort - -app = Flask(__name__) - -@app.route('/webhook', methods=['POST']) -def webhook(): - print(request.json) - return '' - -if __name__ == '__main__': - app.run() -``` - -For examples in more languages please see the [micromdm-webhook-blueprints](https://github.com/knightsc/micromdm-webhook-blueprints) project. - - -# Schedule Commands with the API - -MicroMDM uses Basic Auth for its rest API, requiring you to provide `micromdm` as the user, and the `-api-key` value as the password. - -Let's take a look at the `./tools/api/send_push_notification` script as an example of how to use the API. - -``` -#!/bin/bash - -source $MICROMDM_ENV_PATH -endpoint="push" -curl $CURL_OPTS -u "micromdm:$API_TOKEN" "$SERVER_URL/$endpoint/$1" -``` - -This `curl` request will use the `-u` flag for authentication, and make a request to `https://your-mdm/push/your-device-udid`. Once received, MicroMDM will send an MDM push notification to that device(or user) UDID. - -Assuming the device is online and able to respond, it will contact the `/mdm/connect` endpoint with a request like so: - -``` - - - - - Status - Idle - UDID - 55693EB3-DF03-5FD1-9263-F7CDB8AD7FFD - - -``` - -This request will be processed by MicroMDM and also delivered to the webhook URL under the `raw_payload` property. - - -An important endpoint in MicroMDM's API is the `/v1/commands` endpoint, which you can use to schedule MDM commands. -This commands endpoint accepts a POST request, with a JSON payload that closely matches the [documented](https://developer.apple.com/documentation/devicemanagement/mdm_commands_and_queries?changes=latest_minor) device management specification by Apple. Knowing the request type you want to use, you can compose a command to this endpoint. - -For example, to install a configuration profile to a device, you can schedule the following command: -``` -POST /v1/commands HTTP/1.1 -Authorization: Basic bWljcm9tZG06c3VwZXJzZWNyZXQ= -{ - "udid": "55693EB3-DF03-5FD1-9263-F7CDB8AD7FFD", - "request_type": "InstallProfile", - "payload": "PD94bWwgdmVyc2lvbj0iMS4...base64_encoded_mobileconfig", -} -``` - -MicroMDM will convert this request into a complete command, and schedule it on the queue. It will then send a push notification to ask the device to check in, and respond with the InstallProfile command. diff --git a/docs/user-guide/enrolling-devices.md b/docs/user-guide/enrolling-devices.md deleted file mode 100644 index bfd04b61..00000000 --- a/docs/user-guide/enrolling-devices.md +++ /dev/null @@ -1,72 +0,0 @@ -To enroll into MDM, a device needs to install an MDM Configuration Profile. There are many ways of doing that, you could even email one to your users and have them install it manually. - -MicroMDM has a built-in option for enrollment profiles and some helpers to tweak defaults. If the built-in options don't help, a separate enrollment service can be used. - -# Default Enrollment Method - -MicroMDM offers an enrollment handler at its `/mdm/enroll` URL. This endpoint is used both for user and DEP enrollments and is the same across all your devices. The default enrollment profile includes all permissions and is also unsigned. - -# DEP Device Assignment -If you're enrolled in Apple Business Manager, you can configure all your devices to use MicroMDM during provisioning. - -Get a DEP profile template and fill it out. -All the keys you can use [are documented](https://developer.apple.com/documentation/devicemanagement/profile?changes=latest_minor) by Apple. -``` -mdmctl apply dep-profiles -template > /tmp/profile.json -``` - -Use -``` -mdmctl apply dep-profiles -f /path//to/profile.json -``` -to define the profile. - -You can use the `devices` array to assign this profile to specific serial numbers. -You can also make this profile the default for all devices in your linked DEP server. - -``` -mdmctl apply dep-profiles -f /path/to/dep-profile.json -filter='*' -``` - -For more details on auto-assignment, [check](https://github.com/micromdm/micromdm/wiki/DEP-auto-assignment) the wiki page. - -# Replacing the default Enrollment Profile - -You might want to customize the enrollment profile offered to your devices. To do so, you can download the default enrollment profile, tweak it, and upload a new one. - -To download and save the enrollment profile, you can use `curl`: - -``` -curl -o enroll.mobileconfig https://mdm.acme.co/mdm/enroll -``` - -Next, use a text editor to modify the payload. -You can also [sign](./mdmctl-signing-profiles.md) the profile. - -Once modified and signed, you can replace the default. - -``` -mdmctl apply profiles -f /path/to/enroll.mobileconfig -``` - -Now, the profile is still offered at `/mdm/enroll`, but is the customized one. - -# OTA Enrollment - -For Over-the-Air profile delivery, [check out notes](https://github.com/micromdm/micromdm/wiki/OTA-Enrollment) from the wiki. - -# A custom enrollment endpoint - -For some environments, serving the same enrollment profile might not be enough. You can create your own HTTP service which generates the configuration profile, and not use `/mdm/enroll` endpoint. - -How you do that is up to you, you just need to ensure that the profile has the CheckIn and ServerURL values pointing back to the micromdm endpoints. - -``` - CheckInURL - https://mdm.acme.co/mdm/checkin - ServerURL - https://mdm.acme.co/mdm/connect -``` - - - diff --git a/docs/user-guide/introduction.md b/docs/user-guide/introduction.md deleted file mode 100644 index 1ec10796..00000000 --- a/docs/user-guide/introduction.md +++ /dev/null @@ -1,90 +0,0 @@ -# Getting Help - -The best place to get help with setting up and ongoing maintenance of MicroMDM is the MacAdmins Slack. Join by getting an [invitation here](https://macadmins.herokuapp.com/). - -Once you join Slack, the following channels will be useful. -- `#micromdm` for MicroMDM specific questions. -- `#mdm` and `#dep` for generic questions about MDM and deployment programs. - -For defects and feature requests, please [open an issue](https://github.com/micromdm/micromdm/issues/new). - -# Not a product! - -MicroMDM is not a full featured device management product. The mission of MicroMDM is to enable a secure and scalable MDM deployment for Apple Devices, and expose the full set of Apple MDM commands and responses through an API. -But it is more correct to think of MicroMDM as a lower level dependency for one or more products, not a solution that lives on its own. - -For example, MicroMDM has no high level options for configuration profiles. It accepts an already composed `mobileconfig` file and queues it for a single device at a time. Device Management products often have built-in support for signing profiles or pushing them to a chosen device group. MicroMDM expects those features to exist in a higher level companion service. - -MicroMDM has no Web UI. - -MicroMDM can enable disk encryption and escrow a secret, but it has no option for storing that secret on the server. - -Dynamic enrollment / user authentication workflows belong in an external service. MicroMDM serves the exact same enrollment profile at the `/mdm/enroll` server endpoint for every device. It also does not care about how the enrollment is protected from unauthorized devices. The number of possible workflows are infinite, and the recommendation is to point the devices at a separate URL for serving the enrollment profile. - -As you see, MicroMDM itself lacks many features that are usually present in device management products. But it also exposes a low level API that would allow an organization to build a product that is highly custom to ones environment. Over time, the community will likely share solutions that depend on MicroMDM and expose higher level workflows. - -*Before using MicroMDM, consider that there are a number of alternative, commercial products like Airwatch, SimpleMDM and Fleetsmith that might already fit your needs. Importantly, the companies behind these products employ developers dedicated to the development of their products. -It is probably not a good idea to deploy MicroMDM as a cost cutting option, as the money you save will likely go towards hiring emplyees with the required domain knowledge and development expertise.* - -# Apple Requirements - -If you've decided to run an instance of MicroMDM in your organization, there are a few Apple specific requirements you need to meet. -First, you need to [enroll](https://developer.apple.com/programs/enterprise/enroll/) your organization in the Apple Developer Enterprise Portal. Enrolling costs $299/year and requires that your organization have a [DUNS](https://en.wikipedia.org/wiki/Data_Universal_Numbering_System) number. -Once signed up, or during the verification process in the first step, you need to ask Apple to enable the `MDM CSR` option. This option enables the signing of the APNS Push Certificate. The MDM CSR is typically reserved for commercial vendors, but Apple should enable it for you once you specify that you intend to use it for managing your company owned devices. - -Finally, familiarize yourself with the [education](https://www.apple.com/education/it/) or [business](https://www.apple.com/business/it/) programs and enroll in Apple School/Business Manager(ABM). While MicroMDM does not require that you use the [deployment programs](https://support.apple.com/en-ca/HT204142) to enroll your devices, this is an increasingly popular option for enterprise deployments. - -# Requirements for running MicroMDM - -MicroMDM is a web server which handles connections from Apple Devices and exposes an authenticated web API for operators and other services to interact with the enrolled devices. If configured to do so, the server also syncs device records and profiles with ABM. - -The web server component is built into the `micromdm` binary, and launched with `micromdm serve [flags]`. -For convenience, a second binary `mdmctl` is also provided and can be used to interact with the API. It does not implement _all_ the API endpoints, but should support most actions an administrator needs. -Notably, `mdmctl` does not need to beinstalled on the same server as `micromdm`. It is intended to be used by the server operator, and will be most commonly run on the operator's laptop. - -## Hardware Requirements - -`micromdm` is a native Go binary and can be run on any hardware/VM/container environment. The release versions are built for `darwin` (for test environments on macOS) and `linux` for running on a server. Of course, you can compile for any platform that Go [supports](https://github.com/golang/go/wiki/MinimumRequirements). - -Currently, `micromdm` does not use a distributed database such as PostgreSQL and requires a persistent disk to be available. Because of this, only a single `micromdm` process can run at once, and high-availability setups are not possible. However, the database can be backed up/replicated while the server is running, allowing for failover with minimal downtime. -PostgreSQL database support is planned as a future option. - -Unlike many other services, once enrolled, devices do not maintain communication until an [APNS](https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/APNSOverview.html#//apple_ref/doc/uid/TP40008194-CH8-SW1) command is scheduled to ask the device to check in. This architecture, makes the default setup of MicroMDM have relatively low hardware/requirements. -For installations with under 10,000 device enrollments the recommended VM size is the GCP `n1-standard-2` [instance type](https://cloud.google.com/compute/docs/machine-types) or similar. This is roughly equivalent to 2 vCPUs and 7.5GB of RAM. - -API usage of any kind(ex: actions like pushing a configuration profile to all enrolled devices) will require additional resources, and will need additional planning. The recommendation is to [follow monitoring SRE best practices](https://landing.google.com/sre/workbook/chapters/monitoring/) and adjust your resources according to usage. - -## Network, TLS, DNS, APNS etc - -The best supported deployment configuration is to run `micromdm` on a internet accessible cloud VM, with an internet routable domain and TLS certificates from a public certificate authority like Let's Encrypt. -Other options like using self signed certificates, private networks or proxies are possible, but mostly out of scope for the documentation in this guide. It's assumed that if you're deploying in an enterprise environment, you know how to deploy a webservice already. It should be roughly equivalent to deploying common software like nginx, wordpress or a Rails application. Users are encouraged to share their experiences in various enterprise environments on the Wiki, personal blogs or by speaking at conferences. - -You will need to allow the server to bind to port `443` for incoming TLS connections from devices and the admin API. This port is configurable if you'd like to use a different one. When binding to port `443`, it's encouraged to also allow connections on port `80`, which allows MicroMDM to redirect `http://` to `https://`. - -Your firewall MUST allow incoming connections to the ports MicroMDM is bound to(`443` and `80` by default). Your firewall MUST also allow outgoing connections to port `443`. This is necessary for sending messages over APNS. - -You should use a dedicated domain or subdomain for MicroMDM. One of the MDM requirements is that the server URL devices use does not change for the lifecycle of an enrollement. - -You will need to have a trusted TLS certificate in order for your devices to connect to MicroMDM. The certificate must be valid for the domain you're using with MicroMDM and can be terminated either by `micromdm` directly or any proxy running on the edge. -Let's Encrypt is a great option for a CA, but any other will also work. -The certificate file should be encoded as PEM and include the full chain: - -``` ------BEGIN CERTIFICATE----- -(Your leaf TLS certificate: your_domain_name.crt) ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -(Your Intermediate certificate: TrustedCA.crt) ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -(Your Root certificate: TrustedRoot.crt) ------END CERTIFICATE----- -``` - -Finally, your devices need to have access to APNS, a service run by Apple. This is not negotiable if you plan on using MDM. -For a full description of APNS requirements, see https://support.apple.com/en-us/HT203609. -Apple also documents network requirements for devices connecting to the DEP services: https://support.apple.com/en-us/HT207516 - -# Operating - -This document provided a high level description of various requirements to deploy MicroMDM. The rest of the user guide will provide detailed descriptions for how to operate the service and use the API. diff --git a/docs/user-guide/mdmctl-signing-profiles.md b/docs/user-guide/mdmctl-signing-profiles.md deleted file mode 100644 index 7c5ddaa3..00000000 --- a/docs/user-guide/mdmctl-signing-profiles.md +++ /dev/null @@ -1,33 +0,0 @@ -# Overview - -The MicroMDM server does not composite or sign profiles for you. Instead, it gives you the option of providing a profile which you have signed through an external process, before uploading it to the server. -To make signing easier, MicroMDM adds the option to sign the profile as part of the `mdmctl` tool. -First, you will need a private key and certificate. Any certificate will do, but to be verified on the device, you should choose one that is trusted on the devices where you're sending the payloads. The `Developer ID` certificates from Apple are examples of trusted certificates. - -# Signing with mdmctl - -The `mdmctl apply profiles` command is used to upload a new configuration profile to the server. It can also be used to sign a profile. -First, run `mdmctl apply profiles -help` to see all the available command line flags. - -Example command to sign a profile before uploading it to the server: -``` - mdmctl apply profiles \ - -f /path/to/profile.mobileconfig \ - -private-key /path/to/key.pem \ - -cert /path/to/certificate.pem \ - -password=private_key_password \ - -sign -``` - -You can also specify the `-out /path/to/signed_output.mobileconfig` to save the signed output locally, instead of uploading it to the server. -Using `-out -` will print the signed contents to the standard output, allowing you to pipe the output to another operation. - -# Signing with other tools - -You can use the `security` command on the Mac to sign configuration profiles with a certificate stored in the Keychain. -Example: -``` -usr/bin/security cms -S -N 'Your KeyChain Cert' -i profile.mobileconfig -o signed.mobileconfig -``` - -Another popular choice is Jeremy Agostino's [Hancock](https://github.com/JeremyAgost/Hancock), a GUI utility for signing profiles and packages. diff --git a/docs/user-guide/quickstart.md b/docs/user-guide/quickstart.md deleted file mode 100644 index de395b68..00000000 --- a/docs/user-guide/quickstart.md +++ /dev/null @@ -1,153 +0,0 @@ -The quickstart page is intended to provide a quick guide for setting up a running MicroMDM service. It does not cover all the possible deployment environments. More complex configuration details will be covered in their own sections. - -Before proceeding, make sure to read the [Introduction](./introduction.md) page, which describes requirements you might need before using MicroMDM. - -# Up and Running with MicroMDM - -First, [download](https://github.com/micromdm/micromdm/releases/latest) the latest release of MicroMDM. Copy the `micromdm` binary somewhere in your `$PATH`. - -Next, run the server binary. - -``` -sudo micromdm serve \ - -server-url=https://my-server-url \ - -api-key MySecretAPIKey \ - -filerepo /path/to/pkg/folder \ - -tls-cert /path/to/tls.crt \ - -tls-key /path/to/tls.key -``` - -- `server-url` MUST be the `https://` URL you(and your devices) will use to connect to MicroMDM. -- `api-key` is a secret you MUST create to protect the API. It will be used to authenticate API requests both from your own integrations, as well as `mdmdctl`. -- `filerepo` is an optional key which needs to point to a directory `micromdm` can read and write to. It is used for packages uploaded by `mdmctl apply app`. - It is not necessary if you do not intend to push custom packages via InstallApplication commands. -- `tls-*` flags are used to specify the path to your TLS certificate and key. You MUST configure them if `micromdm` will terminate connections to a device. -If you prefer to terminate TLS with a loadbalancer, you can set `-tls=false`. -**NOTE**: You must use the `-flag=false` form to turn off a boolean flag. - -Command line flags are used for configuration, because they are easy to discover and document. -For a full list of available configurations and their usage, run `micromdm -help`. -In some cases you can choose to use environment variables to provide the same configuration to `micromdm`. Each flag has a corresponding `MICROMDM_CONFIG_FLAG` environment variable option. -For example, `-api-key` becomes `MICROMDM_API_KEY`. - -**NOTE**: In a production environment, secrets should _always_ be set via environment variables and not CLI flags, so they don't remain in your shell history or server monitoring logs. - -This section described how to start the `micromdm` process interactively in a shell, but that won't persist a server restart or exiting your current session. Having the process remain persistent depends on your environment. Since systemd is a common choice, there are [notes](https://github.com/micromdm/micromdm/wiki/Using-MicroMDM-with-systemd) from users on the wiki. - -# Configure mdmctl - -At this point, you should have a running server process, but you do not yet have a working MDM service. Some important configuration is still required. MicroMDM does not come with a built in web interface for administrators. Instead, it comes with a CLI utility called `mdmctl` which uses the API to provide helpful commands for the MDM administrator. -The `mdmctl` binary does not need to run on the same computer as `micromdm`. It is usually convenient to run it on your laptop, but you can of course run it anywhere you want, as long as it can reach the server URL. - -To use `mdmctl`, we will first have to configure it. - -``` -mdmctl config set \ - -name production \ - -api-token MySecretAPIKey \ - -server-url https://my-server-url -``` - -The value for `-api-key` you set on the server is the `-api-token` value you're setting for `mdmctl`. - -And immediately after, run: - -``` -mdmctl config switch -name production -``` - -The configuration `mdmctl` uses lives in the `~/.micromdm/servers.json` file and you can view it in a text editor, or with the `mdmctl config print` command. - -You're likely to run more than one instance of micromdm(ex: production and staging). You can store several configurations with the `-name` flag, and then switch between them with `mdmctl config switch` command. - -`mdmctl` has many helpul commands. You can discover them with the `-help` flag. Many actions are grouped by subcommands like `get`, `apply`, `remove`. For example, `mdmctl get devices` will list devices enrolled in the MDM. - -# Configure an APNS certificate - -To communicate with your device fleet, MDM needs an APNS certificate issued by Apple. As noted in the introduction, this process requires that you have an Enterprise Developer Account, and the `MDM CSR` option enabled under the *Certificates, IDs & Profiles* tab for *iOS*. - -Apple has a separate flow for the MDM vendor than the one for customers. For an in-house deployment without third parties, you must complete boththe vendor and the customer process yourself. The `mdmctl mdmcert` command will help you with your APNS certificate needs. - -Create a request for the MDM CSR, with a password used to encrypt the private key. -After this step you will have a new `mdm-certificates` directory, with the necessary files. -``` -mdmctl mdmcert vendor -password=secret -country=US -email=admin@acme.co -``` -### Generate MDM CSR -Log in to the Apple Developer Portal (https://developer.apple.com/account), and navigate to the Certificates, IDs & Profiles section (https://developer.apple.com/account/resources/certificates/list). - 1. Click the plus symbol (+) next to *Certificates* - 2. Select *MDM CSR* under the *Services* section, click *Continue* - 3. Upload the `VendorCertificateRequest.csr` file, click *Continue* - 4. Click *Download* to download the certificate. - 5. Move the downloaded certificate file (likely called mdm.cer) to the `mdm-certificates` folder. - -You now have the vendor side of the certificate flow complete, and you need to complete the customer side of this flow, with the help of the vendor cert. - -Sign a push certificate request with the vendor certificate. This step uses the private key you created above, so specify the same password to be able to decrypt it. - -``` -mdmctl mdmcert vendor -sign -cert=./mdm-certificates/mdm.cer -password=secret -``` - -You should now have a `mdm-certificates/PushCertificateRequest.plist` file. - -Sign in to [identity.apple.com](https://identity.apple.com) and upload the `PushCertificateRequest.plist` file to get the APNS certificate. The site offers a notes field, it's a good idea to use it to mark which server you're obtaining a certificate for, as you will come back for renewals. - -If you're getting certificates for multiple environments (staging, production) or running multiple in house MDM instances, you MUST sign a separate push request for each one. Using the same vendor certificate is okay, but using the same push certificate is not. - -If you've uploaded the plist, you will be offered a certificate, which is signed for the `mdm-certificates/PushCertificatePrivateKey.key` key. Copy the certificate to the same directory. - -Finally, upload the certificate to MicroMDM. - -``` -mdmctl mdmcert upload \ - -cert mdm-certificates/MDM_\ Acme\,\ Inc._Certificate.pem \ - -private-key mdm-certificates/PushCertificatePrivateKey.key \ - -password=secret -``` - -Keep a backup of the `mdm-certificates` directory somewhere safe(like a 1Password vault) in case you need to use the vendor certificate again. But once the upload has completed, you don't need the local copy around on your computer, since MicroMDM stores the APNS key. - -See the renewals sections at the end of this document for renewals steps. - -# Configure Apple Business Manager (DEP) - -Using DEP is not required for MicroMDM, but is supported. If you do not need it, skip this section. - -In this section you will use `mdmctl` to create a public key, upload it to the DEP portal and then upload the DEP token to MicroMDM. This exchange will link your MDM server with DEP, and allow you to sync devices and associate them with MDM. - -First, run: -``` -mdmctl get dep-tokens -export-public-key /tmp/DEPPublicKey.pem -``` - -Next, log in to your deployment program website, and [follow the instructions](https://help.apple.com/businessmanager/#/asm1c1be359d) for adding an MDM server. Once you get to the step to upload the public key certificate, use the file from the previous step. -You'll be asked to save a file containing the server token. - -Upload the token file to the server: - -``` -mdmctl apply dep-tokens \ - -import /path/to/Some_Server_Token_smime.p7 -``` - -Now, your server should be capable of syncing devices. To verify, you can run - -``` -mdmctl get dep-account -``` - -Which will return the information about your account. - -# Renewing certificates - -At least once a year you will have to renew your DEP and MDM certificate connections with Apple. It's a good idea not to wait until expiration, but to set a calendar reminder somewhere 9-10 months from the day you configured your services. - -To renew the MDM certificate you will re-do the entire process as described in the APNS section. The vendor cert needs to be re-created as well. When you get to the step of requesting a push certificate from identity.apple.com, make sure you are using the *Renew* button in the portal. Doing so ensures you maintain the same APNS topic year to year, which is necessary to avoid re-enrollment. - -To renew your DEP tokens, follow the same instructions as setting up for the first time. - -# Restart the server - -Once you configured DEP and the MDM certificates you should be good to begin enrolling devices. -To avoid any issues, restart the `micromdm` process once you configured everything. diff --git a/go.mod b/go.mod deleted file mode 100644 index 3f5a32a7..00000000 --- a/go.mod +++ /dev/null @@ -1,41 +0,0 @@ -module github.com/micromdm/micromdm - -require ( - github.com/RobotsAndPencils/buford v0.12.0 - github.com/boltdb/bolt v1.3.1 - github.com/davecgh/go-spew v1.1.1 // indirect - github.com/fullsailor/pkcs7 v0.0.0-20180824154052-36585635cb64 - github.com/garyburd/go-oauth v0.0.0-20180319155456-bca2e7f09a17 - github.com/go-kit/kit v0.7.0 - github.com/go-sql-driver/mysql v1.4.0 // indirect - github.com/go-stack/stack v1.7.0 // indirect - github.com/gogo/protobuf v1.3.1 - github.com/golang/protobuf v1.4.2 - github.com/google/uuid v1.1.1 - github.com/gorilla/context v1.1.1 // indirect - github.com/gorilla/mux v1.6.2 - github.com/groob/finalizer v0.0.0-20170707115354-4c2ed49aabda - github.com/groob/plist v0.0.0-20180203051248-dd56909aee38 - github.com/jmoiron/sqlx v0.0.0-20180614180643-0dae4fefe7c0 - github.com/kolide/kit v0.0.0-20180912215818-0c28f72eb2b0 - github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect - github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect - github.com/lib/pq v1.0.0 - github.com/mattn/go-sqlite3 v1.9.0 // indirect - github.com/micromdm/go4 v0.0.0-20191221011012-654e10aaab18 - github.com/micromdm/scep v1.0.1-0.20181014170139-9be65e185499 - github.com/pkg/errors v0.8.0 - github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/pressly/goose v2.3.0+incompatible - github.com/stretchr/testify v1.2.2 // indirect - github.com/ziutek/mymysql v1.5.4 // indirect - golang.org/x/crypto v0.0.0-20180614174826-fd5f17ee7299 - golang.org/x/net v0.0.0-20180724234803-3673e40ba225 - golang.org/x/sys v0.0.0-20180614134839-8883426083c0 // indirect - google.golang.org/appengine v1.2.0 // indirect - gopkg.in/Masterminds/squirrel.v1 v1.0.0-20170825200431-a6b93000bd21 -) - -replace github.com/fullsailor/pkcs7 => github.com/groob/pkcs7 v0.0.0-20180824154052-36585635cb64 - -go 1.13 diff --git a/go.sum b/go.sum deleted file mode 100644 index c84726cd..00000000 --- a/go.sum +++ /dev/null @@ -1,101 +0,0 @@ -github.com/RobotsAndPencils/buford v0.12.0 h1:2nfOk+N/QVoQHwXIS0m5TFdvlUjEnqAj/0yXKR75azY= -github.com/RobotsAndPencils/buford v0.12.0/go.mod h1:27KhJZ/wLQHRnsZF+mTWKvF5w8U4dVl4Nh+BfQem4Lo= -github.com/boltdb/bolt v1.3.1 h1:JQmyP4ZBrce+ZQu0dY660FMfatumYDLun9hBCUVIkF4= -github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/garyburd/go-oauth v0.0.0-20180319155456-bca2e7f09a17 h1:GOfMz6cRgTJ9jWV0qAezv642OhPnKEG7gtUjJSdStHE= -github.com/garyburd/go-oauth v0.0.0-20180319155456-bca2e7f09a17/go.mod h1:HfkOCN6fkKKaPSAeNq/er3xObxTW4VLeY6UUK895gLQ= -github.com/go-kit/kit v0.4.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/kit v0.7.0 h1:ApufNmWF1H6/wUbAG81hZOHmqwd0zRf8mNfLjYj/064= -github.com/go-kit/kit v0.7.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-logfmt/logfmt v0.3.0 h1:8HUsc87TaSWLKwrnumgC8/YconD2fJQsRJAsWaPg2ic= -github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= -github.com/go-sql-driver/mysql v1.4.0 h1:7LxgVwFb2hIQtMm87NdgAVfXjnt4OePseqT1tKx+opk= -github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= -github.com/go-stack/stack v1.6.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/go-stack/stack v1.7.0 h1:S04+lLfST9FvL8dl4R31wVUC/paZp/WQZbLmUgWboGw= -github.com/go-stack/stack v1.7.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls= -github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= -github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= -github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= -github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= -github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= -github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= -github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0= -github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= -github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/gorilla/context v0.0.0-20160226214623-1ea25387ff6f/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= -github.com/gorilla/context v1.1.1 h1:AWwleXJkX/nhcU9bZSnZoi3h/qGYqQAGhq6zZe/aQW8= -github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= -github.com/gorilla/mux v1.4.0/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= -github.com/gorilla/mux v1.6.2 h1:Pgr17XVTNXAk3q/r4CpKzC5xBM/qW1uVLV+IhRZpIIk= -github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= -github.com/groob/finalizer v0.0.0-20170707115354-4c2ed49aabda h1:5ikpG9mYCMFiZX0nkxoV6aU2IpCHPdws3gCNgdZeEV0= -github.com/groob/finalizer v0.0.0-20170707115354-4c2ed49aabda/go.mod h1:MyndkAZd5rUMdNogn35MWXBX1UiBigrU8eTj8DoAC2c= -github.com/groob/pkcs7 v0.0.0-20180824154052-36585635cb64 h1:1ALD84dEnUxPKZENhUAeQ0tuJ+s3PuL85pV95B0Ekfk= -github.com/groob/pkcs7 v0.0.0-20180824154052-36585635cb64/go.mod h1:mEOMQ8C7oeXY3LnE2jy4UkLAqrW9rrpwiP5U4hVV+MY= -github.com/groob/plist v0.0.0-20180203051248-dd56909aee38 h1:afbUddvIjPRC7XHHgeSTRfzZtIxEsSl4VCxumLBGDJU= -github.com/groob/plist v0.0.0-20180203051248-dd56909aee38/go.mod h1:qg2Nek0ND/hIr+nY8H1oVqEW2cLzVVNaAQ0QexOyjyc= -github.com/jmoiron/sqlx v0.0.0-20180614180643-0dae4fefe7c0 h1:5B0uxl2lzNRVkJVg+uGHxWtRt4C0Wjc6kJKo5XYx8xE= -github.com/jmoiron/sqlx v0.0.0-20180614180643-0dae4fefe7c0/go.mod h1:IiEW3SEiiErVyFdH8NTuWjSifiEQKUoyK3LNqr2kCHU= -github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/kolide/kit v0.0.0-20180912215818-0c28f72eb2b0 h1:8UB0NJBoB/lN2O9zG9+U2klyYE0UhvN2Zrn7HBjhwNY= -github.com/kolide/kit v0.0.0-20180912215818-0c28f72eb2b0/go.mod h1:N3Yv8okDVC/5qZhPA9uxVYRfkp4mD2vrlQiSCWlNCpg= -github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515 h1:T+h1c/A9Gawja4Y9mFVWj2vyii2bbUNDw3kt9VxK2EY= -github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= -github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 h1:SOEGU9fKiNWd/HOJuq6+3iTQz8KNCLtVX6idSoTLdUw= -github.com/lann/builder v0.0.0-20180802200727-47ae307949d0/go.mod h1:dXGbAdH5GtBTC4WfIxhKZfyBF/HBFgRZSWwZ9g/He9o= -github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 h1:P6pPBnrTSX3DEVR4fDembhRWSsG5rVo6hYhAB/ADZrk= -github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0/go.mod h1:vmVJ0l/dxyfGW6FmdpVm2joNMFikkuWg0EoCKLGUMNw= -github.com/lib/pq v1.0.0 h1:X5PMW56eZitiTeO7tKzZxFCSpbFZJtkMMooicw2us9A= -github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= -github.com/mattn/go-sqlite3 v1.9.0 h1:pDRiWfl+++eC2FEFRy6jXmQlvp4Yh3z1MJKg4UeYM/4= -github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= -github.com/micromdm/go4 v0.0.0-20191221011012-654e10aaab18 h1:0XJmYdtM8IWZPsFWwaOYOQuPLbaj1kaSYixLN8JB62g= -github.com/micromdm/go4 v0.0.0-20191221011012-654e10aaab18/go.mod h1:8EzTEgA3q2ZdZotWXs1bWnFCXuaFHU0+jDNZbHlwduM= -github.com/micromdm/scep v1.0.1-0.20181014170139-9be65e185499 h1:tAPbBGVDrfo7Tv4rvmzVQPfbQTrR/XSLbl4JuGfJbPI= -github.com/micromdm/scep v1.0.1-0.20181014170139-9be65e185499/go.mod h1:a4hGfYA9e51888COzEduLGsstH9NPxJPndn/Ke5/Tw8= -github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw= -github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/pressly/goose v2.3.0+incompatible h1:Nc9o+JsN4j8sS4hvRzcfKYOrr7W2EXMDY2wNYtKmaVc= -github.com/pressly/goose v2.3.0+incompatible/go.mod h1:m+QHWCqxR3k8D9l7qfzuC/djtlfzxr34mozWDYEu1z8= -github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/ziutek/mymysql v1.5.4 h1:GB0qdRGsTwQSBVYuVShFBKaXSnSnYYC2d9knnE1LHFs= -github.com/ziutek/mymysql v1.5.4/go.mod h1:LMSpPZ6DbqWFxNCHW77HeMg9I646SAhApZ/wKdgO/C0= -golang.org/x/crypto v0.0.0-20180614174826-fd5f17ee7299 h1:zxP+xTjjk4kD+M5IFPweL7/4851FUhYkzbDqbzkN1JE= -golang.org/x/crypto v0.0.0-20180614174826-fd5f17ee7299/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/net v0.0.0-20170726083632-f5079bd7f6f7/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180724234803-3673e40ba225 h1:kNX+jCowfMYzvlSvJu5pQWEmyWFrBXJ3PBy10xKMXK8= -golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/sys v0.0.0-20170728174421-0f826bdd13b5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180614134839-8883426083c0 h1:5mOaSPjCt3RW5w1KpSFOVg8VdqQQ/FjfM5/m50f/8wM= -golang.org/x/sys v0.0.0-20180614134839-8883426083c0/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/appengine v1.2.0 h1:S0iUepdCWODXRvtE+gcRDd15L+k+k1AiHlMiMjefH24= -google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= -google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= -google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= -google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= -google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM= -google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -gopkg.in/Masterminds/squirrel.v1 v1.0.0-20170825200431-a6b93000bd21 h1:GmGVIcDxdecAcVjcTp4IpK4VmCMxXhyZKwN2eIzsZ4Y= -gopkg.in/Masterminds/squirrel.v1 v1.0.0-20170825200431-a6b93000bd21/go.mod h1:8PH4rQjb7OdPC6OWDDuY6J/PT8iSNTiff3jmccc2m10= diff --git a/mdm/acknowledge.go b/mdm/acknowledge.go deleted file mode 100644 index c0c10d15..00000000 --- a/mdm/acknowledge.go +++ /dev/null @@ -1,70 +0,0 @@ -package mdm - -import ( - "context" - "net/http" - "time" - - "github.com/go-kit/kit/endpoint" - "github.com/google/uuid" - "github.com/pkg/errors" -) - -func (svc *MDMService) Acknowledge(ctx context.Context, req AcknowledgeEvent) (payload []byte, err error) { - msg, err := MarshalAcknowledgeEvent(&req) - if err != nil { - return nil, errors.Wrap(err, "marshal acknowledge response to proto") - } - - if err := svc.pub.Publish(ctx, ConnectTopic, msg); err != nil { - return nil, errors.Wrap(err, "publish connect Response on pubsub") - } - - payload, err = svc.queue.Next(ctx, req.Response) - return payload, errors.Wrap(err, "calling Next with mdm response") - -} - -type acknowledgeRequest struct { - Event AcknowledgeEvent -} - -type acknowledgeResponse struct { - Payload []byte - Err error `plist:"error,omitempty"` -} - -func (r acknowledgeResponse) Response() []byte { return r.Payload } -func (r acknowledgeResponse) Failed() error { return r.Err } - -func decodeAcknowledgeRequest(ctx context.Context, r *http.Request) (interface{}, error) { - var res Response - body, err := mdmRequestBody(r, &res) - if err != nil { - return nil, errors.Wrap(err, "read MDM request") - } - - values := r.URL.Query() - params := make(map[string]string, len(values)) - for k, v := range values { - params[k] = v[0] - } - - event := AcknowledgeEvent{ - ID: uuid.New().String(), - Time: time.Now().UTC(), - Response: res, - Params: params, - Raw: body, - } - req := acknowledgeRequest{Event: event} - return req, nil -} - -func MakeAcknowledgeEndpoint(svc Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (interface{}, error) { - req := request.(acknowledgeRequest) - payload, err := svc.Acknowledge(ctx, req.Event) - return acknowledgeResponse{Payload: payload, Err: err}, nil - } -} diff --git a/mdm/acknowledge_event.go b/mdm/acknowledge_event.go deleted file mode 100644 index 32115598..00000000 --- a/mdm/acknowledge_event.go +++ /dev/null @@ -1,87 +0,0 @@ -package mdm - -import ( - "time" - - "github.com/gogo/protobuf/proto" - "github.com/micromdm/micromdm/mdm/internal/connectproto" -) - -type AcknowledgeEvent struct { - ID string - Time time.Time - Response Response - Params map[string]string - Raw []byte -} - -type Response struct { - RequestType string `json:"request_type,omitempty" plist:",omitempty"` - UDID string - UserID *string `json:"user_id,omitempty" plist:"UserID,omitempty"` - EnrollmentID *string `json:"enrollment_id,omitempty" plist:"EnrollmentID,omitempty"` - Status string - CommandUUID string - ErrorChain []ErrorChainItem `json:"error_chain" plist:",omitempty"` -} - -type ErrorChainItem struct { - ErrorCode int `json:"error_code,omitempty"` - ErrorDomain string `json:"error_domain,omitempty"` - LocalizedDescription string `json:"localized_description,omitempty"` - USEnglishDescription string `json:"us_english_description,omitempty"` -} - -func MarshalAcknowledgeEvent(e *AcknowledgeEvent) ([]byte, error) { - response := &connectproto.Response{ - CommandUuid: e.Response.CommandUUID, - Udid: e.Response.UDID, - Status: e.Response.Status, - RequestType: e.Response.RequestType, - } - if e.Response.UserID != nil { - response.UserId = *e.Response.UserID - } - if e.Response.EnrollmentID != nil { - response.EnrollmentId = *e.Response.EnrollmentID - } - - return proto.Marshal(&connectproto.Event{ - Id: e.ID, - Time: e.Time.UnixNano(), - Response: response, - Params: e.Params, - Raw: e.Raw, - }) -} - -func UnmarshalAcknowledgeEvent(data []byte, e *AcknowledgeEvent) error { - var pb connectproto.Event - if err := proto.Unmarshal(data, &pb); err != nil { - return err - } - e.ID = pb.Id - e.Time = time.Unix(0, pb.Time).UTC() - if pb.Response == nil { - return nil - } - r := pb.GetResponse() - e.Response = Response{ - UDID: r.GetUdid(), - UserID: strPtr(r.GetUserId()), - EnrollmentID: strPtr(r.GetEnrollmentId()), - Status: r.GetStatus(), - RequestType: r.GetRequestType(), - CommandUUID: r.GetCommandUuid(), - } - e.Raw = pb.GetRaw() - e.Params = pb.GetParams() - return nil -} - -func strPtr(s string) *string { - if s == "" { - return nil - } - return &s -} diff --git a/mdm/appmanifest/appmanifest.go b/mdm/appmanifest/appmanifest.go deleted file mode 100644 index 77e946cb..00000000 --- a/mdm/appmanifest/appmanifest.go +++ /dev/null @@ -1,129 +0,0 @@ -// package appmanifest provides utilities for managing app manifest files -// used by MDM InstallApplication commands. -package appmanifest - -import ( - "crypto/md5" - "fmt" - "io" - - "github.com/pkg/errors" -) - -// DefaultMD5Size is the default size of each file chunk that needs to be hashed -const DefaultMD5Size = 10 << 20 // 10MB - -// http://help.apple.com/deployment/osx/#/ior5df10f73a -type Manifest struct { - ManifestItems []Item `plist:"items" json:"items"` -} - -type Item struct { - Assets []Asset `plist:"assets" json:"assets"` - // Apple claims the metadata struct is required, - // but testing shows otherwise. - Metadata *Metadata `plist:"metadata,omitempty" json:"metadata,omitempty"` -} - -type Asset struct { - Kind string `plist:"kind" json:"kind"` - MD5Size int64 `plist:"md5-size,omitempty" json:"md5-size,omitempty"` - MD5s []string `plist:"md5s,omitempty" json:"md5s,omitempty"` - SHA256Size int64 `plist:"sha256-size,omitempty" json:"sha256-size,omitempty"` - SHA256s []string `plist:"sha256s,omitempty" json:"sha256s,omitempty"` - URL string `plist:"url" json:"url"` -} - -type Metadata struct { - BundleInfo - Items []BundleInfo `plist:"items,omitempty" json:"items,omitempty"` - Kind string `plist:"kind" json:"kind"` - Subtitle string `plist:"subtitle" json:"subtitle"` - Title string `plist:"title" json:"title"` - SizeInBytes int64 `plist:"sizeInBytes,omitempty" json:"sizeInBytes,omitempty"` -} - -type BundleInfo struct { - BundleIdentifier string `plist:"bundle-identifier" json:"bundle-identifier"` - BundleVersion string `plist:"bundle-version" json:"bundle-version"` -} - -// File is an io.Reader which knows its size. -type File interface { - io.Reader - Size() int64 -} - -type Option func(*config) - -// WithMD5Size overrides the DefaultMD5Size when creating an AppManifest. -func WithMD5Size(md5Size int64) Option { - return func(c *config) { - c.md5Size = md5Size - } -} - -type config struct { - md5Size int64 -} - -// Create an AppManifest and write it to an io.Writer. -func Create(file File, url string, opts ...Option) (*Manifest, error) { - c := config{ - md5Size: DefaultMD5Size, - } - - for _, opt := range opts { - opt(&c) - } - - fSize := file.Size() - if c.md5Size > fSize { - c.md5Size = fSize - } - - // create a list of md5s - md5s, err := calculateMD5s(file, c.md5Size) - if err != nil { - return nil, errors.Wrap(err, "calculate appmanifest md5s") - } - - // create an asset - ast := Asset{ - Kind: "software-package", - MD5Size: c.md5Size, - MD5s: md5s, - URL: url, - } - - // make a manifest - m := Manifest{ - ManifestItems: []Item{ - { - Assets: []Asset{ast}, - }, - }, - } - - return &m, nil -} - -// reads a file and returns a slice of hashes, one for each -// 10mb chunk -func calculateMD5s(f io.Reader, s int64) ([]string, error) { - h := md5.New() - var md5s []string - for { - n, err := io.CopyN(h, f, s) - if n > 0 { - md5s = append(md5s, fmt.Sprintf("%x", h.Sum(nil))) - h.Reset() - } - if err != nil { - if err == io.EOF { - err = nil - } - return md5s, err - } - } -} diff --git a/mdm/appmanifest/appmanifest_test.go b/mdm/appmanifest/appmanifest_test.go deleted file mode 100644 index 754e8374..00000000 --- a/mdm/appmanifest/appmanifest_test.go +++ /dev/null @@ -1,56 +0,0 @@ -package appmanifest - -import ( - "bytes" - "testing" -) - -func TestCalucalteMD5s(t *testing.T) { - ok := []string{ - "f1c9645dbc14efddc7d8a322685f26eb", - "f1c9645dbc14efddc7d8a322685f26eb", - "f1c9645dbc14efddc7d8a322685f26eb", - "93b885adfe0da089cdf634904fd59f71", - } - buf := make([]byte, DefaultMD5Size*3+1) - r := bytes.NewReader(buf) - md5s, err := calculateMD5s(r, DefaultMD5Size) - if err != nil { - t.Fatal(err) - } - if len(md5s) != len(ok) { - t.Fatal("expected", len(ok), "got", len(md5s)) - } - for i, h := range md5s { - if ok[i] != h { - t.Fatal("expected", ok[i], "got", h) - } - } -} - -/* -Benchmark10MB-8 500000 3297 ns/op 32896 B/op 3 allocs/op -Benchmark100MB-8 300000 3528 ns/op 32897 B/op 3 allocs/op -Benchmark1000MB-8 1 1967685209 ns/op 3334064 B/op 829 allocs/op -*/ - -func benchmarkSize(b *testing.B, size int) { - var buf = make([]byte, size) - r := bytes.NewReader(buf) - b.ResetTimer() - for i := 0; i < b.N; i++ { - calculateMD5s(r, DefaultMD5Size) - } -} - -func Benchmark10MB(b *testing.B) { - benchmarkSize(b, DefaultMD5Size) -} - -func Benchmark100MB(b *testing.B) { - benchmarkSize(b, DefaultMD5Size*10) -} - -func Benchmark1000MB(b *testing.B) { - benchmarkSize(b, DefaultMD5Size*100) -} diff --git a/mdm/checkin.go b/mdm/checkin.go deleted file mode 100644 index 0b996957..00000000 --- a/mdm/checkin.go +++ /dev/null @@ -1,106 +0,0 @@ -package mdm - -import ( - "context" - "net/http" - "time" - - "github.com/go-kit/kit/endpoint" - "github.com/google/uuid" - "github.com/pkg/errors" -) - -func (svc *MDMService) Checkin(ctx context.Context, event CheckinEvent) error { - // reject user settings at the loginwindow. - // https://github.com/micromdm/micromdm/pull/379 - if event.Command.MessageType == "UserAuthenticate" { - return &rejectUserAuth{} - } - - msg, err := MarshalCheckinEvent(&event) - if err != nil { - return errors.Wrap(err, "marshal checkin event") - } - - topic, err := topicFromMessage(event.Command.MessageType) - if err != nil { - return errors.Wrap(err, "get checkin topic from message") - } - - err = svc.pub.Publish(ctx, topic, msg) - return errors.Wrapf(err, "publish checkin on topic: %s", topic) -} - -func topicFromMessage(messageType string) (string, error) { - switch messageType { - case "Authenticate": - return AuthenticateTopic, nil - case "TokenUpdate": - return TokenUpdateTopic, nil - case "CheckOut": - return CheckoutTopic, nil - default: - return "", errors.Errorf("unknown checkin message type %s", messageType) - } -} - -type rejectUserAuth struct{} - -func (e *rejectUserAuth) Error() string { - return "reject user auth" -} -func (e *rejectUserAuth) UserAuthReject() bool { - return true -} - -func isRejectedUserAuth(err error) bool { - type rejectUserAuthError interface { - error - UserAuthReject() bool - } - - _, ok := errors.Cause(err).(rejectUserAuthError) - return ok -} - -type checkinRequest struct { - Event CheckinEvent -} - -type checkinResponse struct { - Err error `plist:"error,omitempty"` -} - -func (r checkinResponse) Failed() error { return r.Err } - -func decodeCheckinRequest(ctx context.Context, r *http.Request) (interface{}, error) { - var cmd CheckinCommand - body, err := mdmRequestBody(r, &cmd) - if err != nil { - return nil, errors.Wrap(err, "read MDM request") - } - - values := r.URL.Query() - params := make(map[string]string, len(values)) - for k, v := range values { - params[k] = v[0] - } - - event := CheckinEvent{ - ID: uuid.New().String(), - Time: time.Now().UTC(), - Command: cmd, - Params: params, - Raw: body, - } - req := checkinRequest{Event: event} - return req, nil -} - -func MakeCheckinEndpoint(svc Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (interface{}, error) { - req := request.(checkinRequest) - err := svc.Checkin(ctx, req.Event) - return checkinResponse{Err: err}, nil - } -} diff --git a/mdm/checkin_event.go b/mdm/checkin_event.go deleted file mode 100644 index ef7c2dc1..00000000 --- a/mdm/checkin_event.go +++ /dev/null @@ -1,158 +0,0 @@ -package mdm - -import ( - "encoding/hex" - "time" - - "github.com/gogo/protobuf/proto" - - "github.com/micromdm/micromdm/mdm/internal/checkinproto" -) - -type CheckinEvent struct { - ID string - Time time.Time - Command CheckinCommand - Params map[string]string - Raw []byte -} - -// CheckinRequest represents an MDM checkin command struct. -type CheckinCommand struct { - // MessageType can be either Authenticate, - // TokenUpdate or CheckOut - MessageType string - Topic string - UDID string - EnrollmentID string - auth - update -} - -// Authenticate Message Type -type auth struct { - OSVersion string - BuildVersion string - ProductName string - SerialNumber string - IMEI string - MEID string - DeviceName string `plist:"DeviceName,omitempty"` - Challenge []byte `plist:"Challenge,omitempty"` - Model string `plist:"Model,omitpempty"` - ModelName string `plist:"ModelName,omitempty"` -} - -// TokenUpdate Mesage Type -type update struct { - Token hexData - PushMagic string - UnlockToken hexData - AwaitingConfiguration bool - userTokenUpdate -} - -// TokenUpdate with user keys -type userTokenUpdate struct { - UserID string `plist:",omitempty"` - UserLongName string `plist:",omitempty"` - UserShortName string `plist:",omitempty"` - NotOnConsole bool `plist:",omitempty"` -} - -// data decodes to []byte, -// we can then attach a string method to the type -// Tokens are encoded as Hex Strings -type hexData []byte - -func (d hexData) String() string { - return hex.EncodeToString(d) -} - -// MarshalCheckinEvent serializes an event to a protocol buffer wire format. -func MarshalCheckinEvent(e *CheckinEvent) ([]byte, error) { - command := &checkinproto.Command{ - MessageType: e.Command.MessageType, - Topic: e.Command.Topic, - Udid: e.Command.UDID, - EnrollmentId: e.Command.EnrollmentID, - } - switch e.Command.MessageType { - case "Authenticate": - command.Authenticate = &checkinproto.Authenticate{ - OsVersion: e.Command.OSVersion, - BuildVersion: e.Command.BuildVersion, - SerialNumber: e.Command.SerialNumber, - Imei: e.Command.IMEI, - Meid: e.Command.MEID, - DeviceName: e.Command.DeviceName, - Challenge: e.Command.Challenge, - Model: e.Command.Model, - ModelName: e.Command.ModelName, - ProductName: e.Command.ProductName, - } - case "TokenUpdate": - command.TokenUpdate = &checkinproto.TokenUpdate{ - Token: e.Command.Token, - PushMagic: e.Command.PushMagic, - UnlockToken: e.Command.UnlockToken, - AwaitingConfiguration: e.Command.AwaitingConfiguration, - UserId: e.Command.UserID, - UserLongName: e.Command.UserLongName, - UserShortName: e.Command.UserShortName, - NotOnConsole: e.Command.NotOnConsole, - } - } - return proto.Marshal(&checkinproto.Event{ - Id: e.ID, - Time: e.Time.UnixNano(), - Command: command, - Params: e.Params, - Raw: e.Raw, - }) -} - -// UnmarshalCheckinEvent parses a protocol buffer representation of data into -// the Event. -func UnmarshalCheckinEvent(data []byte, e *CheckinEvent) error { - var pb checkinproto.Event - if err := proto.Unmarshal(data, &pb); err != nil { - return err - } - e.ID = pb.Id - e.Time = time.Unix(0, pb.Time).UTC() - if pb.Command == nil { - return nil - } - e.Command = CheckinCommand{ - MessageType: pb.Command.MessageType, - Topic: pb.Command.Topic, - UDID: pb.Command.Udid, - EnrollmentID: pb.Command.EnrollmentId, - } - switch pb.Command.MessageType { - case "Authenticate": - e.Command.OSVersion = pb.Command.Authenticate.OsVersion - e.Command.BuildVersion = pb.Command.Authenticate.BuildVersion - e.Command.SerialNumber = pb.Command.Authenticate.SerialNumber - e.Command.IMEI = pb.Command.Authenticate.Imei - e.Command.MEID = pb.Command.Authenticate.Meid - e.Command.DeviceName = pb.Command.Authenticate.DeviceName - e.Command.Challenge = pb.Command.Authenticate.Challenge - e.Command.Model = pb.Command.Authenticate.Model - e.Command.ModelName = pb.Command.Authenticate.ModelName - e.Command.ProductName = pb.Command.Authenticate.ProductName - case "TokenUpdate": - e.Command.Token = pb.Command.TokenUpdate.Token - e.Command.PushMagic = pb.Command.TokenUpdate.PushMagic - e.Command.UnlockToken = pb.Command.TokenUpdate.UnlockToken - e.Command.AwaitingConfiguration = pb.Command.TokenUpdate.AwaitingConfiguration - e.Command.UserID = pb.Command.TokenUpdate.UserId - e.Command.UserLongName = pb.Command.TokenUpdate.UserLongName - e.Command.UserShortName = pb.Command.TokenUpdate.UserShortName - e.Command.NotOnConsole = pb.Command.TokenUpdate.NotOnConsole - } - e.Raw = pb.GetRaw() - e.Params = pb.GetParams() - return nil -} diff --git a/mdm/checkin_test.go b/mdm/checkin_test.go deleted file mode 100644 index 1c6ab598..00000000 --- a/mdm/checkin_test.go +++ /dev/null @@ -1,42 +0,0 @@ -package mdm - -import ( - "bytes" - "context" - "net/http/httptest" - "testing" -) - -func Test_decodeCheckinRequest(t *testing.T) { - // test that url values from checkin and acknowledge requests are passed to the event. - req := httptest.NewRequest("GET", "/mdm/checkin?id=1111", bytes.NewReader([]byte(sampleCheckinRequest))) - resp, err := decodeCheckinRequest(context.Background(), req) - if err != nil { - t.Fatal(err) - } - response := resp.(checkinRequest) - if have, want := response.Event.Params["id"], "1111"; have != want { - t.Errorf("have %s, want %s", have, want) - } -} - -const sampleCheckinRequest = ` - - - - AwaitingConfiguration - - MessageType - TokenUpdate - PushMagic - AB62BB8A-7757-4130-94CC-CC8C5333D481 - Token - - YWJjZGUK - - Topic - com.apple.mgmt.External.80bb2169-e864-4685-9a96-faa734f0b978 - UDID - BC5E2DA4-7FB6-5E70-9928-4981680DAFBF - -` diff --git a/mdm/enroll/endpoint.go b/mdm/enroll/endpoint.go deleted file mode 100644 index 3ac227f0..00000000 --- a/mdm/enroll/endpoint.go +++ /dev/null @@ -1,142 +0,0 @@ -package enroll - -import ( - "context" - "errors" - "fmt" - - "github.com/fullsailor/pkcs7" - "github.com/go-kit/kit/endpoint" - boltdepot "github.com/micromdm/scep/depot/bolt" - - "github.com/micromdm/micromdm/pkg/crypto" - "github.com/micromdm/micromdm/platform/profile" -) - -type Endpoints struct { - GetEnrollEndpoint endpoint.Endpoint - OTAEnrollEndpoint endpoint.Endpoint - OTAPhase2Phase3Endpoint endpoint.Endpoint -} - -type depEnrollmentRequest struct { - Language string `plist:"LANGUAGE"` - Product string `plist:"PRODUCT"` - Serial string `plist:"SERIAL"` - UDID string `plist:"UDID"` - Version string `plist:"VERSION"` - IMEI string `plist:"IMEI,omitempty"` - MEID string `plist:"MEID,omitempty"` -} - -type otaEnrollmentRequest struct { - Challenge string `plist:"CHALLENGE"` - Product string `plist:"PRODUCT"` - Serial string `plist:"SERIAL"` - UDID string `plist:"UDID"` - Version string `plist:"VERSION"` // build no. - IMSI string `plist:"IMSI"` - IMEI string `plist:"IMEI,omitempty"` - MEID string `plist:"MEID,omitempty"` - ICCID string `plist:"ICCID"` - MACAddressEN0 string `plist:"MAC_ADDRESS_EN0"` - DeviceName string `plist:"DEVICE_NAME"` - NotOnConsole bool - UserID string // GUID of User - UserLongName string - UserShortName string -} - -type mdmEnrollRequest struct{} - -type mobileconfigResponse struct { - profile.Mobileconfig - Err error `plist:"error,omitempty"` -} - -type mdmOTAPhase2Phase3Request struct { - otaEnrollmentRequest otaEnrollmentRequest - p7 *pkcs7.PKCS7 -} - -func MakeServerEndpoints(s Service, scepDepot *boltdepot.Depot) Endpoints { - return Endpoints{ - GetEnrollEndpoint: MakeGetEnrollEndpoint(s), - OTAEnrollEndpoint: MakeOTAEnrollEndpoint(s), - OTAPhase2Phase3Endpoint: MakeOTAPhase2Phase3Endpoint(s, scepDepot), - } -} - -func MakeGetEnrollEndpoint(s Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (interface{}, error) { - switch req := request.(type) { - case mdmEnrollRequest: - mc, err := s.Enroll(ctx) - return mobileconfigResponse{mc, err}, nil - case depEnrollmentRequest: - fmt.Printf("got DEP enrollment request from %s\n", req.Serial) - mc, err := s.Enroll(ctx) - return mobileconfigResponse{mc, err}, nil - default: - return nil, errors.New("unknown enrollment type") - } - } -} - -func MakeOTAEnrollEndpoint(s Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (interface{}, error) { - mc, err := s.OTAEnroll(ctx) - return mobileconfigResponse{mc, err}, nil - } -} - -func MakeOTAPhase2Phase3Endpoint(s Service, scepDepot *boltdepot.Depot) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (interface{}, error) { - req := request.(mdmOTAPhase2Phase3Request) - - if req.p7 == nil || req.p7.GetOnlySigner() == nil { - return nil, errors.New("invalid signer/signer not provided") - } - - // TODO: currently only verifying the signing certificate but ought to - // verify the whole provided chain. Note this will be difficult to do - // given the inconsist certificate chain returned by macOS in OTA mode, - // macOS in DEP mode, and iOS in either mode. See: - // https://openradar.appspot.com/radar?id=4957320861712384 - if err := crypto.VerifyFromAppleDeviceCA(req.p7.GetOnlySigner()); err == nil { - // signing certificate is signed by the Apple Device CA. this means - // we don't yet have a SCEP identity and thus are in Phase 2 of the - // OTA enrollment - mc, err := s.OTAPhase2(ctx) - return mobileconfigResponse{mc, err}, nil - } - - caChain, _, err := scepDepot.CA(nil) - if err != nil { - return nil, err - } - - if len(caChain) < 1 { - return nil, errors.New("invalid SCEP CA chain") - } - - if req.p7.GetOnlySigner().CheckSignatureFrom(caChain[0]) == nil { - // signing certificate is signed by our SCEP CA. this means we - // we are in Phase 3 of OTA enrollment (as we already have a - // identified certificate) - - // TODO: possibly deliver a different enrollment profile based - // on device certificates - // TODO: we can encrypt the enrollment (or any profile) at this - // point: we have a device identity that we can encrypt to that - // device's private key that it can decrypt - // TODO: the SCEP CA checking ought to be more robust - // see: https://github.com/micromdm/scep/issues/32 - - mc, err := s.Enroll(ctx) - // profile, err := s.OTAPhase3(ctx) - return mobileconfigResponse{mc, err}, nil - } - return mobileconfigResponse{profile.Mobileconfig{}, errors.New("unauthorized client")}, nil - } -} diff --git a/mdm/enroll/profile.go b/mdm/enroll/profile.go deleted file mode 100644 index 09632f05..00000000 --- a/mdm/enroll/profile.go +++ /dev/null @@ -1,149 +0,0 @@ -package enroll - -import ( - "time" - - "github.com/google/uuid" -) - -type Payload struct { - PayloadType string `json:"type" db:"type"` - PayloadVersion int `json:"version" db:"version"` - PayloadIdentifier string `json:"identifier" db:"identifier"` - PayloadUUID string `json:"uuid" db:"uuid"` - PayloadDisplayName string `json:"displayname" db:"displayname"` - PayloadDescription string `json:"description,omitempty" db:"description"` - PayloadOrganization string `json:"organization,omitempty" db:"organization"` - PayloadScope string `json:"scope" db:"scope" plist:",omitempty"` - PayloadContent interface{} `json:"content,omitempty" plist:"PayloadContent,omitempty"` -} - -type Profile struct { - PayloadContent []interface{} `json:"content,omitempty" db:"content"` - PayloadDescription string `json:"description,omitempty" db:"description"` - PayloadDisplayName string `json:"displayname,omitempty" db:"displayname"` - PayloadExpirationDate *time.Time `json:"expiration_date,omitempty" db:"expiration_date" plist:",omitempty"` - PayloadIdentifier string `json:"identifier" db:"identifier"` - PayloadOrganization string `json:"organization,omitempty" db:"organization"` - PayloadUUID string `json:"uuid" db:"uuid"` - PayloadRemovalDisallowed bool `json:"removal_disallowed" db:"removal_disallowed" plist:",omitempty"` - PayloadType string `json:"type" db:"type"` - PayloadVersion int `json:"version" db:"version"` - PayloadScope string `json:"scope" db:"scope" plist:",omitempty"` - RemovalDate *time.Time `json:"removal_date" db:"removal_date" plist:"-" plist:",omitempty"` - DurationUntilRemoval float32 `json:"duration_until_removal" db:"duration_until_removal" plist:",omitempty"` - ConsentText map[string]string `json:"consent_text" db:"consent_text" plist:",omitempty"` -} - -func NewProfile() *Profile { - payloadUuid := uuid.New() - - return &Profile{ - PayloadVersion: 1, - PayloadType: "Configuration", - PayloadUUID: payloadUuid.String(), - } -} - -func NewPayload(payloadType string) *Payload { - payloadUuid := uuid.New() - - return &Payload{ - PayloadVersion: 1, - PayloadType: payloadType, - PayloadUUID: payloadUuid.String(), - } -} - -type SCEPPayloadContent struct { - CAFingerprint []byte `plist:"CAFingerprint,omitempty"` // NSData - Challenge string `plist:"Challenge,omitempty"` - Keysize int - KeyType string `plist:"Key Type"` - KeyUsage int `plist:"Key Usage"` - Name string - Subject [][][]string `plist:"Subject,omitempty"` - URL string -} - -// AccessRights define the management rights of the MDM server over the device. -// May not be zero. If 2 is specified, 1 must also be specified. If 128 is specified, 64 must also be specified. -type AccessRights int - -const ( - // Allow inspection of installed configuration profiles. - ProfileInspection AccessRights = 1 << iota - - // Allow installation and removal of configuration profiles. - ProfileInstallAndRemoval - - // Allow device lock and passcode removal. - DeviceLock - - // Allow device erase. - DeviceErase - - // Allow query of Device Information (device capacity, serial number). - DeviceInformationQuery - - // Allow query of Network Information (phone/SIM numbers, MAC addresses). - NetworkInformationQuery - - // Allow inspection of installed provisioning profiles. - ProvisioningProfileInspection - - // Allow installation and removal of provisioning profiles. - ProvisioningProfileInstallAndRemoval - - // Allow inspection of installed applications. - ApplicationInspection - - // Allow restriction-related queries. - RestrictionQuery - - // Allow security-related queries. - SecurityQuery - - // Allow manipulation of settings. - // Availability: Available in iOS 5.0 and later. Available in macOS 10.9 for certain commands. - SettingsManipulation - - // Allow app management. - // Availability: Available in iOS 5.0 and later. Available in macOS 10.9 for certain commands. - AppManagement -) - -func allRights() AccessRights { - return ProfileInspection | - ProfileInstallAndRemoval | - DeviceLock | - DeviceErase | - DeviceInformationQuery | - NetworkInformationQuery | - ProvisioningProfileInspection | - ProvisioningProfileInstallAndRemoval | - ApplicationInspection | - RestrictionQuery | - SecurityQuery | - SettingsManipulation | - AppManagement -} - -// TODO: Actually this is one of those non-nested payloads that doesnt respect the PayloadContent key. -type MDMPayloadContent struct { - Payload - AccessRights AccessRights - CheckInURL string - CheckOutWhenRemoved bool - IdentityCertificateUUID string - ServerCapabilities []string `plist:"ServerCapabilities,omitempty"` - SignMessage bool `plist:"SignMessage,omitempty"` - ServerURL string - Topic string -} - -type ProfileServicePayload struct { - URL string - Challenge string `plist:",omitempty"` - DeviceAttributes []string -} diff --git a/mdm/enroll/profile_test.go b/mdm/enroll/profile_test.go deleted file mode 100644 index b6c9db11..00000000 --- a/mdm/enroll/profile_test.go +++ /dev/null @@ -1,35 +0,0 @@ -package enroll - -import ( - "testing" -) - -func TestEnrollProfile(t *testing.T) { - svc := new(service) - profile, err := svc.MakeEnrollmentProfile() - if err != nil { - t.Fatal(err) - } - - var payloadContent MDMPayloadContent - for _, payload := range profile.PayloadContent { - if c, ok := payload.(MDMPayloadContent); ok { - payloadContent = c - } - } - - if have, want := payloadContent.AccessRights, AccessRights(8191); have != want { - t.Errorf("have %d, want %d", have, want) - } - - var hasPerUserConnections bool - for _, cap := range payloadContent.ServerCapabilities { - if cap == perUserConnections { - hasPerUserConnections = true - } - } - - if have, want := hasPerUserConnections, true; have != want { - t.Errorf("missing ServerCapabilities: macOS enrollment profile requires %s", perUserConnections) - } -} diff --git a/mdm/enroll/service.go b/mdm/enroll/service.go deleted file mode 100644 index d50127d4..00000000 --- a/mdm/enroll/service.go +++ /dev/null @@ -1,317 +0,0 @@ -package enroll - -import ( - "bytes" - "crypto/x509" - "io/ioutil" - "log" - "strings" - "sync" - - "github.com/groob/plist" - "github.com/pkg/errors" - "golang.org/x/net/context" - - "github.com/micromdm/micromdm/platform/config" - "github.com/micromdm/micromdm/platform/profile" - "github.com/micromdm/micromdm/platform/pubsub" - challengestore "github.com/micromdm/scep/challenge/bolt" -) - -const ( - EnrollmentProfileId string = "com.github.micromdm.micromdm.enroll" - OTAProfileId string = "com.github.micromdm.micromdm.ota" -) - -type Service interface { - Enroll(ctx context.Context) (profile.Mobileconfig, error) - OTAEnroll(ctx context.Context) (profile.Mobileconfig, error) - OTAPhase2(ctx context.Context) (profile.Mobileconfig, error) - OTAPhase3(ctx context.Context) (profile.Mobileconfig, error) -} - -func NewService(topic TopicProvider, sub pubsub.Subscriber, scepURL, scepChallenge, url, tlsCertPath, scepSubject string, profileDB profile.Store, cs *challengestore.Depot) (Service, error) { - var tlsCert []byte - var err error - - if tlsCertPath != "" { - tlsCert, err = ioutil.ReadFile(tlsCertPath) - - if err != nil { - return nil, err - } - } - - if scepSubject == "" { - scepSubject = "/O=MicroMDM/CN=MicroMDM Identity (%ComputerName%)" - } - - subjectElements := strings.Split(scepSubject, "/") - var subject [][][]string - - for _, element := range subjectElements { - if element == "" { - continue - } - subjectKeyValue := strings.Split(element, "=") - subject = append(subject, [][]string{{subjectKeyValue[0], subjectKeyValue[1]}}) - } - - // fetch the push topic from the db. - // will be "" if the push certificate hasn't been uploaded yet - pushTopic, _ := topic.PushTopic() - svc := &service{ - URL: url, - SCEPURL: scepURL, - SCEPSubject: subject, - SCEPChallenge: scepChallenge, - SCEPChallengeStore: cs, - TLSCert: tlsCert, - ProfileDB: profileDB, - Topic: pushTopic, - topicProvier: topic, - } - - if err := updateTopic(svc, sub); err != nil { - return nil, errors.Wrap(err, "enroll: start topic update goroutine") - } - - return svc, nil -} - -func updateTopic(svc *service, sub pubsub.Subscriber) error { - configEvents, err := sub.Subscribe(context.TODO(), "enroll-server-configs", config.ConfigTopic) - if err != nil { - return errors.Wrap(err, "update enrollment service") - } - go func() { - for { - select { - case <-configEvents: - topic, err := svc.topicProvier.PushTopic() - if err != nil { - log.Printf("enroll: get push topic %s\n", topic) - } - svc.mu.Lock() - svc.Topic = topic - svc.mu.Unlock() - - // terminate the loop here because the topic should never change - goto exit - } - } - exit: - return - }() - return nil -} - -type service struct { - URL string - SCEPURL string - SCEPChallenge string - SCEPChallengeStore *challengestore.Depot - SCEPSubject [][][]string - TLSCert []byte - ProfileDB profile.Store - - topicProvier TopicProvider - - mu sync.RWMutex - Topic string // APNS Topic for MDM notifications -} - -type TopicProvider interface { - PushTopic() (string, error) -} - -func profileOrPayloadFromFunc(f interface{}) (interface{}, error) { - fPayload, ok := f.(func() (Payload, error)) - if !ok { - fProfile := f.(func() (Profile, error)) - return fProfile() - } - return fPayload() -} - -func profileOrPayloadToMobileconfig(in interface{}) (profile.Mobileconfig, error) { - if _, ok := in.(Payload); !ok { - _ = in.(Profile) - } - buf := new(bytes.Buffer) - enc := plist.NewEncoder(buf) - enc.Indent(" ") - err := enc.Encode(in) - return buf.Bytes(), err -} - -func (svc *service) findOrMakeMobileconfig(ctx context.Context, id string, f interface{}) (profile.Mobileconfig, error) { - p, err := svc.ProfileDB.ProfileById(ctx, id) - if err != nil { - if profile.IsNotFound(err) { - profile, err := profileOrPayloadFromFunc(f) - if err != nil { - return nil, err - } - return profileOrPayloadToMobileconfig(profile) - } - return nil, err - } - return p.Mobileconfig, nil -} - -func (svc *service) Enroll(ctx context.Context) (profile.Mobileconfig, error) { - return svc.findOrMakeMobileconfig(ctx, EnrollmentProfileId, svc.MakeEnrollmentProfile) -} - -const perUserConnections = "com.apple.mdm.per-user-connections" - -func (svc *service) MakeEnrollmentProfile() (Profile, error) { - profile := NewProfile() - profile.PayloadIdentifier = EnrollmentProfileId - profile.PayloadOrganization = "MicroMDM" - profile.PayloadDisplayName = "Enrollment Profile" - profile.PayloadDescription = "The server may alter your settings" - profile.PayloadScope = "System" - - mdmPayload := NewPayload("com.apple.mdm") - mdmPayload.PayloadDescription = "Enrolls with the MDM server" - mdmPayload.PayloadOrganization = "MicroMDM" - mdmPayload.PayloadIdentifier = EnrollmentProfileId + ".mdm" - mdmPayload.PayloadScope = "System" - - svc.mu.Lock() - topic := svc.Topic - svc.mu.Unlock() - - mdmPayloadContent := MDMPayloadContent{ - Payload: *mdmPayload, - AccessRights: allRights(), - CheckInURL: svc.URL + "/mdm/checkin", - CheckOutWhenRemoved: true, - ServerURL: svc.URL + "/mdm/connect", - Topic: topic, - SignMessage: true, - ServerCapabilities: []string{perUserConnections}, - } - - payloadContent := []interface{}{} - - if svc.SCEPURL != "" { - scepContent := SCEPPayloadContent{ - URL: svc.SCEPURL, - Keysize: 2048, - KeyType: "RSA", - KeyUsage: int(x509.KeyUsageDigitalSignature | x509.KeyUsageKeyEncipherment), - Name: "Device Management Identity Certificate", - Subject: svc.SCEPSubject, - } - - if svc.SCEPChallengeStore != nil { - challenge, err := svc.SCEPChallengeStore.SCEPChallenge() - if err != nil { - return *profile, err - } - scepContent.Challenge = challenge - } else if svc.SCEPChallenge != "" { - scepContent.Challenge = svc.SCEPChallenge - } - - scepPayload := NewPayload("com.apple.security.scep") - scepPayload.PayloadDescription = "Configures SCEP" - scepPayload.PayloadDisplayName = "SCEP" - scepPayload.PayloadIdentifier = EnrollmentProfileId + ".scep" - scepPayload.PayloadOrganization = "MicroMDM" - scepPayload.PayloadContent = scepContent - scepPayload.PayloadScope = "System" - - payloadContent = append(payloadContent, *scepPayload) - mdmPayloadContent.IdentityCertificateUUID = scepPayload.PayloadUUID - } - - payloadContent = append(payloadContent, mdmPayloadContent) - - // Client needs to trust us at this point if we are using a self signed certificate. - if len(svc.TLSCert) > 0 { - tlsPayload := NewPayload("com.apple.security.pem") - tlsPayload.PayloadDisplayName = "Self-signed TLS certificate for MicroMDM" - tlsPayload.PayloadDescription = "Installs the TLS certificate for MicroMDM" - tlsPayload.PayloadIdentifier = EnrollmentProfileId + ".cert.selfsigned" - tlsPayload.PayloadContent = svc.TLSCert - - payloadContent = append(payloadContent, *tlsPayload) - } - - profile.PayloadContent = payloadContent - - return *profile, nil -} - -// OTAEnroll returns an Over-the-Air "Profile Service" Payload for enrollment. -func (svc *service) OTAEnroll(ctx context.Context) (profile.Mobileconfig, error) { - return svc.findOrMakeMobileconfig(ctx, OTAProfileId, svc.MakeOTAEnrollPayload) -} - -func (svc *service) MakeOTAEnrollPayload() (Payload, error) { - payload := NewPayload("Profile Service") - payload.PayloadIdentifier = OTAProfileId - payload.PayloadDisplayName = "MicroMDM Profile Service" - payload.PayloadDescription = "Profile Service enrollment" - payload.PayloadOrganization = "MicroMDM" - payload.PayloadContent = ProfileServicePayload{ - URL: svc.URL + "/ota/phase23", - Challenge: "", - DeviceAttributes: []string{"UDID", "VERSION", "PRODUCT", "SERIAL", "MEID", "IMEI"}, - } - - // yes, this is a bare Payload, not a Profile - return *payload, nil -} - -// OTAPhase2 returns a SCEP Profile for use in phase 2 of Over-the-Air enrollment. -func (svc *service) OTAPhase2(ctx context.Context) (profile.Mobileconfig, error) { - return svc.findOrMakeMobileconfig(ctx, OTAProfileId+".phase2", svc.MakeOTAPhase2Profile) -} - -func (svc *service) MakeOTAPhase2Profile() (Profile, error) { - profile := NewProfile() - profile.PayloadIdentifier = OTAProfileId + ".phase2" - profile.PayloadOrganization = "MicroMDM" - profile.PayloadDisplayName = "OTA Phase 2" - profile.PayloadDescription = "The server may alter your settings" - profile.PayloadScope = "System" - - scepContent := SCEPPayloadContent{ - URL: svc.SCEPURL, - Keysize: 2048, // NOTE: OTA docs recommend 1024 - KeyType: "RSA", - KeyUsage: int(x509.KeyUsageDigitalSignature | x509.KeyUsageKeyEncipherment), - Name: "OTA Phase 2 Certificate", - Subject: svc.SCEPSubject, - } - - if svc.SCEPChallenge != "" { - scepContent.Challenge = svc.SCEPChallenge - } - - scepPayload := NewPayload("com.apple.security.scep") - scepPayload.PayloadDescription = "Configures SCEP" - scepPayload.PayloadDisplayName = "SCEP" - scepPayload.PayloadIdentifier = OTAProfileId + ".phase2.scep" - scepPayload.PayloadOrganization = "MicroMDM" - scepPayload.PayloadContent = scepContent - scepPayload.PayloadScope = "System" - - profile.PayloadContent = append(profile.PayloadContent, *scepPayload) - - return *profile, nil -} - -// OTAPhase3 returns a Profile for use in phase 3 of Over-the-Air profile enrollment. -// This would typically be the final or end profile of the Over-the-Air -// enrollment process. In our case this would probably be a device-specifc -// MDM enrollment payload. -// TODO: Not implemented. -func (svc *service) OTAPhase3(ctx context.Context) (profile.Mobileconfig, error) { - return profile.Mobileconfig{}, nil -} diff --git a/mdm/enroll/transport_http.go b/mdm/enroll/transport_http.go deleted file mode 100644 index f5490b19..00000000 --- a/mdm/enroll/transport_http.go +++ /dev/null @@ -1,115 +0,0 @@ -package enroll - -import ( - "context" - "errors" - "io/ioutil" - "net/http" - - "github.com/fullsailor/pkcs7" - httptransport "github.com/go-kit/kit/transport/http" - "github.com/groob/plist" - - "github.com/micromdm/micromdm/pkg/crypto" -) - -type HTTPHandlers struct { - EnrollHandler http.Handler - OTAEnrollHandler http.Handler - - // In Apple's Over-the-Air design Phases 2 and 3 happen over the same URL. - // The differentiator is which certificate signed the CMS POST body. - OTAPhase2Phase3Handler http.Handler -} - -func MakeHTTPHandlers(ctx context.Context, endpoints Endpoints, opts ...httptransport.ServerOption) HTTPHandlers { - h := HTTPHandlers{ - EnrollHandler: httptransport.NewServer( - endpoints.GetEnrollEndpoint, - decodeMDMEnrollRequest, - encodeMobileconfigResponse, - opts..., - ), - OTAEnrollHandler: httptransport.NewServer( - endpoints.OTAEnrollEndpoint, - decodeEmptyRequest, - encodeMobileconfigResponse, - opts..., - ), - OTAPhase2Phase3Handler: httptransport.NewServer( - endpoints.OTAPhase2Phase3Endpoint, - decodeOTAPhase2Phase3Request, - encodeMobileconfigResponse, - opts..., - ), - } - return h -} - -func decodeEmptyRequest(_ context.Context, _ *http.Request) (interface{}, error) { - return nil, nil -} - -func decodeMDMEnrollRequest(_ context.Context, r *http.Request) (interface{}, error) { - switch r.Method { - case "GET": - return mdmEnrollRequest{}, nil - case "POST": // DEP request - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return nil, err - } - p7, err := pkcs7.Parse(data) - if err != nil { - return nil, err - } - err = p7.Verify() - if err != nil { - return nil, err - } - // TODO: for thse errors provide better feedback as 4xx HTTP status - signer := p7.GetOnlySigner() - if signer == nil { - return nil, errors.New("invalid CMS signer during enrollment") - } - err = crypto.VerifyFromAppleDeviceCA(signer) - if err != nil { - return nil, errors.New("unauthorized enrollment client: not signed by Apple Device CA") - } - var request depEnrollmentRequest - if err := plist.Unmarshal(p7.Content, &request); err != nil { - return nil, err - } - return request, nil - default: - return nil, errors.New("unknown enrollment method") - } -} - -func encodeMobileconfigResponse(ctx context.Context, w http.ResponseWriter, response interface{}) error { - w.Header().Set("Content-Type", "application/x-apple-aspen-config") - mcResp := response.(mobileconfigResponse) - _, err := w.Write(mcResp.Mobileconfig) - return err -} - -func decodeOTAPhase2Phase3Request(_ context.Context, r *http.Request) (interface{}, error) { - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return nil, err - } - p7, err := pkcs7.Parse(data) - if err != nil { - return nil, err - } - err = p7.Verify() - if err != nil { - return nil, err - } - var request otaEnrollmentRequest - err = plist.Unmarshal(p7.Content, &request) - if err != nil { - return nil, err - } - return mdmOTAPhase2Phase3Request{request, p7}, nil -} diff --git a/mdm/internal/checkinproto/checkin.go b/mdm/internal/checkinproto/checkin.go deleted file mode 100644 index d5f55eed..00000000 --- a/mdm/internal/checkinproto/checkin.go +++ /dev/null @@ -1,3 +0,0 @@ -package checkinproto - -//go:generate protoc --go_out=. checkin.proto diff --git a/mdm/internal/checkinproto/checkin.pb.go b/mdm/internal/checkinproto/checkin.pb.go deleted file mode 100644 index 5ca61046..00000000 --- a/mdm/internal/checkinproto/checkin.pb.go +++ /dev/null @@ -1,424 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// source: checkin.proto - -package checkinproto - -import proto "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package - -type Event struct { - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Time int64 `protobuf:"varint,2,opt,name=time,proto3" json:"time,omitempty"` - Command *Command `protobuf:"bytes,3,opt,name=command,proto3" json:"command,omitempty"` - Raw []byte `protobuf:"bytes,4,opt,name=raw,proto3" json:"raw,omitempty"` - Params map[string]string `protobuf:"bytes,5,rep,name=params,proto3" json:"params,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Event) Reset() { *m = Event{} } -func (m *Event) String() string { return proto.CompactTextString(m) } -func (*Event) ProtoMessage() {} -func (*Event) Descriptor() ([]byte, []int) { - return fileDescriptor_checkin_f106eb4ffaf2f7e3, []int{0} -} -func (m *Event) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Event.Unmarshal(m, b) -} -func (m *Event) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Event.Marshal(b, m, deterministic) -} -func (dst *Event) XXX_Merge(src proto.Message) { - xxx_messageInfo_Event.Merge(dst, src) -} -func (m *Event) XXX_Size() int { - return xxx_messageInfo_Event.Size(m) -} -func (m *Event) XXX_DiscardUnknown() { - xxx_messageInfo_Event.DiscardUnknown(m) -} - -var xxx_messageInfo_Event proto.InternalMessageInfo - -func (m *Event) GetId() string { - if m != nil { - return m.Id - } - return "" -} - -func (m *Event) GetTime() int64 { - if m != nil { - return m.Time - } - return 0 -} - -func (m *Event) GetCommand() *Command { - if m != nil { - return m.Command - } - return nil -} - -func (m *Event) GetRaw() []byte { - if m != nil { - return m.Raw - } - return nil -} - -func (m *Event) GetParams() map[string]string { - if m != nil { - return m.Params - } - return nil -} - -type Command struct { - MessageType string `protobuf:"bytes,1,opt,name=message_type,json=messageType,proto3" json:"message_type,omitempty"` - Topic string `protobuf:"bytes,2,opt,name=topic,proto3" json:"topic,omitempty"` - Udid string `protobuf:"bytes,3,opt,name=udid,proto3" json:"udid,omitempty"` - Authenticate *Authenticate `protobuf:"bytes,4,opt,name=authenticate,proto3" json:"authenticate,omitempty"` - TokenUpdate *TokenUpdate `protobuf:"bytes,5,opt,name=token_update,json=tokenUpdate,proto3" json:"token_update,omitempty"` - EnrollmentId string `protobuf:"bytes,6,opt,name=enrollment_id,json=enrollmentId,proto3" json:"enrollment_id,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Command) Reset() { *m = Command{} } -func (m *Command) String() string { return proto.CompactTextString(m) } -func (*Command) ProtoMessage() {} -func (*Command) Descriptor() ([]byte, []int) { - return fileDescriptor_checkin_f106eb4ffaf2f7e3, []int{1} -} -func (m *Command) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Command.Unmarshal(m, b) -} -func (m *Command) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Command.Marshal(b, m, deterministic) -} -func (dst *Command) XXX_Merge(src proto.Message) { - xxx_messageInfo_Command.Merge(dst, src) -} -func (m *Command) XXX_Size() int { - return xxx_messageInfo_Command.Size(m) -} -func (m *Command) XXX_DiscardUnknown() { - xxx_messageInfo_Command.DiscardUnknown(m) -} - -var xxx_messageInfo_Command proto.InternalMessageInfo - -func (m *Command) GetMessageType() string { - if m != nil { - return m.MessageType - } - return "" -} - -func (m *Command) GetTopic() string { - if m != nil { - return m.Topic - } - return "" -} - -func (m *Command) GetUdid() string { - if m != nil { - return m.Udid - } - return "" -} - -func (m *Command) GetAuthenticate() *Authenticate { - if m != nil { - return m.Authenticate - } - return nil -} - -func (m *Command) GetTokenUpdate() *TokenUpdate { - if m != nil { - return m.TokenUpdate - } - return nil -} - -func (m *Command) GetEnrollmentId() string { - if m != nil { - return m.EnrollmentId - } - return "" -} - -type Authenticate struct { - OsVersion string `protobuf:"bytes,1,opt,name=os_version,json=osVersion,proto3" json:"os_version,omitempty"` - BuildVersion string `protobuf:"bytes,2,opt,name=build_version,json=buildVersion,proto3" json:"build_version,omitempty"` - ProductName string `protobuf:"bytes,3,opt,name=product_name,json=productName,proto3" json:"product_name,omitempty"` - SerialNumber string `protobuf:"bytes,4,opt,name=serial_number,json=serialNumber,proto3" json:"serial_number,omitempty"` - Imei string `protobuf:"bytes,5,opt,name=imei,proto3" json:"imei,omitempty"` - Meid string `protobuf:"bytes,6,opt,name=meid,proto3" json:"meid,omitempty"` - DeviceName string `protobuf:"bytes,7,opt,name=device_name,json=deviceName,proto3" json:"device_name,omitempty"` - Challenge []byte `protobuf:"bytes,8,opt,name=challenge,proto3" json:"challenge,omitempty"` - Model string `protobuf:"bytes,9,opt,name=model,proto3" json:"model,omitempty"` - ModelName string `protobuf:"bytes,10,opt,name=model_name,json=modelName,proto3" json:"model_name,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Authenticate) Reset() { *m = Authenticate{} } -func (m *Authenticate) String() string { return proto.CompactTextString(m) } -func (*Authenticate) ProtoMessage() {} -func (*Authenticate) Descriptor() ([]byte, []int) { - return fileDescriptor_checkin_f106eb4ffaf2f7e3, []int{2} -} -func (m *Authenticate) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Authenticate.Unmarshal(m, b) -} -func (m *Authenticate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Authenticate.Marshal(b, m, deterministic) -} -func (dst *Authenticate) XXX_Merge(src proto.Message) { - xxx_messageInfo_Authenticate.Merge(dst, src) -} -func (m *Authenticate) XXX_Size() int { - return xxx_messageInfo_Authenticate.Size(m) -} -func (m *Authenticate) XXX_DiscardUnknown() { - xxx_messageInfo_Authenticate.DiscardUnknown(m) -} - -var xxx_messageInfo_Authenticate proto.InternalMessageInfo - -func (m *Authenticate) GetOsVersion() string { - if m != nil { - return m.OsVersion - } - return "" -} - -func (m *Authenticate) GetBuildVersion() string { - if m != nil { - return m.BuildVersion - } - return "" -} - -func (m *Authenticate) GetProductName() string { - if m != nil { - return m.ProductName - } - return "" -} - -func (m *Authenticate) GetSerialNumber() string { - if m != nil { - return m.SerialNumber - } - return "" -} - -func (m *Authenticate) GetImei() string { - if m != nil { - return m.Imei - } - return "" -} - -func (m *Authenticate) GetMeid() string { - if m != nil { - return m.Meid - } - return "" -} - -func (m *Authenticate) GetDeviceName() string { - if m != nil { - return m.DeviceName - } - return "" -} - -func (m *Authenticate) GetChallenge() []byte { - if m != nil { - return m.Challenge - } - return nil -} - -func (m *Authenticate) GetModel() string { - if m != nil { - return m.Model - } - return "" -} - -func (m *Authenticate) GetModelName() string { - if m != nil { - return m.ModelName - } - return "" -} - -type TokenUpdate struct { - Token []byte `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` - PushMagic string `protobuf:"bytes,2,opt,name=push_magic,json=pushMagic,proto3" json:"push_magic,omitempty"` - UnlockToken []byte `protobuf:"bytes,3,opt,name=unlock_token,json=unlockToken,proto3" json:"unlock_token,omitempty"` - AwaitingConfiguration bool `protobuf:"varint,4,opt,name=awaiting_configuration,json=awaitingConfiguration,proto3" json:"awaiting_configuration,omitempty"` - UserId string `protobuf:"bytes,5,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` - UserLongName string `protobuf:"bytes,6,opt,name=user_long_name,json=userLongName,proto3" json:"user_long_name,omitempty"` - UserShortName string `protobuf:"bytes,7,opt,name=user_short_name,json=userShortName,proto3" json:"user_short_name,omitempty"` - NotOnConsole bool `protobuf:"varint,8,opt,name=not_on_console,json=notOnConsole,proto3" json:"not_on_console,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *TokenUpdate) Reset() { *m = TokenUpdate{} } -func (m *TokenUpdate) String() string { return proto.CompactTextString(m) } -func (*TokenUpdate) ProtoMessage() {} -func (*TokenUpdate) Descriptor() ([]byte, []int) { - return fileDescriptor_checkin_f106eb4ffaf2f7e3, []int{3} -} -func (m *TokenUpdate) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_TokenUpdate.Unmarshal(m, b) -} -func (m *TokenUpdate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_TokenUpdate.Marshal(b, m, deterministic) -} -func (dst *TokenUpdate) XXX_Merge(src proto.Message) { - xxx_messageInfo_TokenUpdate.Merge(dst, src) -} -func (m *TokenUpdate) XXX_Size() int { - return xxx_messageInfo_TokenUpdate.Size(m) -} -func (m *TokenUpdate) XXX_DiscardUnknown() { - xxx_messageInfo_TokenUpdate.DiscardUnknown(m) -} - -var xxx_messageInfo_TokenUpdate proto.InternalMessageInfo - -func (m *TokenUpdate) GetToken() []byte { - if m != nil { - return m.Token - } - return nil -} - -func (m *TokenUpdate) GetPushMagic() string { - if m != nil { - return m.PushMagic - } - return "" -} - -func (m *TokenUpdate) GetUnlockToken() []byte { - if m != nil { - return m.UnlockToken - } - return nil -} - -func (m *TokenUpdate) GetAwaitingConfiguration() bool { - if m != nil { - return m.AwaitingConfiguration - } - return false -} - -func (m *TokenUpdate) GetUserId() string { - if m != nil { - return m.UserId - } - return "" -} - -func (m *TokenUpdate) GetUserLongName() string { - if m != nil { - return m.UserLongName - } - return "" -} - -func (m *TokenUpdate) GetUserShortName() string { - if m != nil { - return m.UserShortName - } - return "" -} - -func (m *TokenUpdate) GetNotOnConsole() bool { - if m != nil { - return m.NotOnConsole - } - return false -} - -func init() { - proto.RegisterType((*Event)(nil), "checkinproto.Event") - proto.RegisterMapType((map[string]string)(nil), "checkinproto.Event.ParamsEntry") - proto.RegisterType((*Command)(nil), "checkinproto.Command") - proto.RegisterType((*Authenticate)(nil), "checkinproto.Authenticate") - proto.RegisterType((*TokenUpdate)(nil), "checkinproto.TokenUpdate") -} - -func init() { proto.RegisterFile("checkin.proto", fileDescriptor_checkin_f106eb4ffaf2f7e3) } - -var fileDescriptor_checkin_f106eb4ffaf2f7e3 = []byte{ - // 619 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x54, 0x52, 0xdd, 0x6a, 0xdb, 0x4a, - 0x10, 0x46, 0x76, 0x6c, 0x47, 0x23, 0x25, 0xe7, 0xb0, 0x9c, 0x9c, 0xa3, 0x13, 0x5a, 0xe2, 0xb8, - 0xa1, 0xf8, 0xca, 0x85, 0x94, 0xd2, 0x1f, 0x4a, 0xa1, 0x84, 0x5c, 0x04, 0xda, 0xb4, 0x6c, 0xd3, - 0xde, 0x8a, 0x8d, 0x34, 0x95, 0x17, 0x6b, 0x77, 0x85, 0xb4, 0x72, 0xf0, 0x23, 0xf5, 0x05, 0xfa, - 0x40, 0x7d, 0x8b, 0xde, 0x95, 0x9d, 0x95, 0x13, 0xf9, 0x6e, 0xe6, 0x9b, 0x6f, 0xbe, 0x9d, 0xf9, - 0x76, 0xe0, 0x20, 0x5b, 0x62, 0xb6, 0x92, 0x7a, 0x51, 0xd5, 0xc6, 0x1a, 0x16, 0x77, 0x29, 0x65, - 0xb3, 0x5f, 0x01, 0x8c, 0x2e, 0xd7, 0xa8, 0x2d, 0x3b, 0x84, 0x81, 0xcc, 0x93, 0x60, 0x1a, 0xcc, - 0x43, 0x3e, 0x90, 0x39, 0x63, 0xb0, 0x67, 0xa5, 0xc2, 0x64, 0x30, 0x0d, 0xe6, 0x43, 0x4e, 0x31, - 0x7b, 0x06, 0x93, 0xcc, 0x28, 0x25, 0x74, 0x9e, 0x0c, 0xa7, 0xc1, 0x3c, 0x3a, 0x3f, 0x5a, 0xf4, - 0xd5, 0x16, 0x17, 0xbe, 0xc8, 0xb7, 0x2c, 0xf6, 0x37, 0x0c, 0x6b, 0x71, 0x97, 0xec, 0x4d, 0x83, - 0x79, 0xcc, 0x5d, 0xc8, 0x5e, 0xc2, 0xb8, 0x12, 0xb5, 0x50, 0x4d, 0x32, 0x9a, 0x0e, 0xe7, 0xd1, - 0xf9, 0xc9, 0xae, 0x02, 0xcd, 0xb2, 0xf8, 0x4c, 0x8c, 0x4b, 0x6d, 0xeb, 0x0d, 0xef, 0xe8, 0xc7, - 0xaf, 0x21, 0xea, 0xc1, 0x4e, 0x79, 0x85, 0x9b, 0x6e, 0x5e, 0x17, 0xb2, 0x7f, 0x60, 0xb4, 0x16, - 0x65, 0xeb, 0x27, 0x0e, 0xb9, 0x4f, 0xde, 0x0c, 0x5e, 0x05, 0xb3, 0xdf, 0x01, 0x4c, 0xba, 0xd1, - 0xd8, 0x29, 0xc4, 0x0a, 0x9b, 0x46, 0x14, 0x98, 0xda, 0x4d, 0x85, 0x9d, 0x40, 0xd4, 0x61, 0x37, - 0x9b, 0x0a, 0x9d, 0x90, 0x35, 0x95, 0xcc, 0xb6, 0x42, 0x94, 0x38, 0x3f, 0xda, 0x5c, 0xfa, 0xc5, - 0x43, 0x4e, 0x31, 0x7b, 0x07, 0xb1, 0x68, 0xed, 0x12, 0xb5, 0x95, 0x99, 0xb0, 0x48, 0x7b, 0x46, - 0xe7, 0xc7, 0xbb, 0x2b, 0xbd, 0xef, 0x31, 0xf8, 0x0e, 0x9f, 0xbd, 0x85, 0xd8, 0x9a, 0x15, 0xea, - 0xb4, 0xad, 0x72, 0xd7, 0x3f, 0xa2, 0xfe, 0xff, 0x77, 0xfb, 0x6f, 0x1c, 0xe3, 0x2b, 0x11, 0x78, - 0x64, 0x1f, 0x12, 0xf6, 0x04, 0x0e, 0x50, 0xd7, 0xa6, 0x2c, 0x15, 0x6a, 0x9b, 0xca, 0x3c, 0x19, - 0xd3, 0x68, 0xf1, 0x03, 0x78, 0x95, 0xcf, 0x7e, 0x0e, 0x20, 0xee, 0x4f, 0xc0, 0x1e, 0x03, 0x98, - 0x26, 0x5d, 0x63, 0xdd, 0x48, 0xa3, 0xbb, 0xf5, 0x43, 0xd3, 0x7c, 0xf3, 0x80, 0x13, 0xbd, 0x6d, - 0x65, 0x99, 0xdf, 0x33, 0xbc, 0x09, 0x31, 0x81, 0x5b, 0xd2, 0x29, 0xc4, 0x55, 0x6d, 0xf2, 0x36, - 0xb3, 0xa9, 0x16, 0x0a, 0x3b, 0x4f, 0xa2, 0x0e, 0xbb, 0x16, 0x8a, 0x86, 0x6b, 0xb0, 0x96, 0xa2, - 0x4c, 0x75, 0xab, 0x6e, 0xb1, 0x26, 0x6f, 0x42, 0x1e, 0x7b, 0xf0, 0x9a, 0x30, 0xe7, 0xa9, 0x54, - 0x28, 0x69, 0xef, 0x90, 0x53, 0xec, 0x30, 0x85, 0xf7, 0xcb, 0x50, 0xcc, 0x4e, 0x20, 0xca, 0x71, - 0x2d, 0x33, 0xf4, 0xcf, 0x4d, 0xa8, 0x04, 0x1e, 0xa2, 0xd7, 0x1e, 0x41, 0x98, 0x2d, 0x45, 0x59, - 0xa2, 0x2e, 0x30, 0xd9, 0xa7, 0x6b, 0x7b, 0x00, 0xdc, 0x87, 0x2a, 0x93, 0x63, 0x99, 0x84, 0xfe, - 0x43, 0x29, 0x71, 0x46, 0x50, 0xe0, 0x35, 0xc1, 0x1b, 0x41, 0x88, 0x93, 0x9c, 0xfd, 0x18, 0x40, - 0xd4, 0xb3, 0xde, 0x5f, 0xc5, 0x0a, 0xbd, 0x65, 0x31, 0xf7, 0x89, 0x13, 0xa9, 0xda, 0x66, 0x99, - 0x2a, 0x51, 0xdc, 0x1f, 0x4c, 0xe8, 0x90, 0x8f, 0x0e, 0x70, 0x46, 0xb5, 0xba, 0x34, 0xd9, 0x2a, - 0xf5, 0xbd, 0x43, 0xea, 0x8d, 0x3c, 0x46, 0xea, 0xec, 0x05, 0xfc, 0x2b, 0xee, 0x84, 0xb4, 0x52, - 0x17, 0x69, 0x66, 0xf4, 0x77, 0x59, 0xb4, 0xb5, 0xb0, 0xce, 0x79, 0xe7, 0xd8, 0x3e, 0x3f, 0xda, - 0x56, 0x2f, 0xfa, 0x45, 0xf6, 0x1f, 0x4c, 0xda, 0x06, 0x6b, 0xf7, 0xed, 0xde, 0xbd, 0xb1, 0x4b, - 0xaf, 0x72, 0x76, 0x06, 0x87, 0x54, 0x28, 0x8d, 0x2e, 0xfc, 0x6a, 0xdd, 0x59, 0x38, 0xf4, 0x83, - 0xd1, 0x05, 0x19, 0xf6, 0x14, 0xfe, 0x22, 0x56, 0xb3, 0x34, 0xb5, 0xed, 0xbb, 0x7a, 0xe0, 0xe0, - 0x2f, 0x0e, 0x25, 0xde, 0x19, 0x1c, 0x6a, 0x63, 0x53, 0xa3, 0xdd, 0x6c, 0x8d, 0x29, 0xbd, 0xbb, - 0xfb, 0x3c, 0xd6, 0xc6, 0x7e, 0xd2, 0x17, 0x1e, 0xbb, 0x1d, 0xd3, 0xa5, 0x3e, 0xff, 0x13, 0x00, - 0x00, 0xff, 0xff, 0x5a, 0x90, 0x46, 0x6c, 0x6b, 0x04, 0x00, 0x00, -} diff --git a/mdm/internal/checkinproto/checkin.proto b/mdm/internal/checkinproto/checkin.proto deleted file mode 100644 index c6cc9179..00000000 --- a/mdm/internal/checkinproto/checkin.proto +++ /dev/null @@ -1,44 +0,0 @@ -syntax = "proto3"; - -package checkinproto; - -message Event { - string id = 1; - int64 time = 2; - Command command = 3; - bytes raw = 4; - map params = 5; -} - -message Command { - string message_type = 1; - string topic = 2; - string udid = 3; - Authenticate authenticate = 4; - TokenUpdate token_update = 5; - string enrollment_id = 6; -} - -message Authenticate { - string os_version = 1; - string build_version = 2; - string product_name = 3; - string serial_number = 4; - string imei = 5; - string meid = 6; - string device_name = 7; - bytes challenge = 8; - string model = 9; - string model_name =10; -} - -message TokenUpdate { - bytes token = 1; - string push_magic = 2; - bytes unlock_token = 3; - bool awaiting_configuration = 4; - string user_id = 5; - string user_long_name = 6; - string user_short_name = 7; - bool not_on_console = 8; -} diff --git a/mdm/internal/connectproto/connect.go b/mdm/internal/connectproto/connect.go deleted file mode 100644 index 45c7a4b6..00000000 --- a/mdm/internal/connectproto/connect.go +++ /dev/null @@ -1,3 +0,0 @@ -package connectproto - -//go:generate protoc --go_out=. connect.proto diff --git a/mdm/internal/connectproto/connect.pb.go b/mdm/internal/connectproto/connect.pb.go deleted file mode 100644 index 164677fc..00000000 --- a/mdm/internal/connectproto/connect.pb.go +++ /dev/null @@ -1,199 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// source: connect.proto - -package connectproto - -import proto "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package - -type Event struct { - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Time int64 `protobuf:"varint,2,opt,name=time,proto3" json:"time,omitempty"` - Response *Response `protobuf:"bytes,3,opt,name=response,proto3" json:"response,omitempty"` - Raw []byte `protobuf:"bytes,4,opt,name=raw,proto3" json:"raw,omitempty"` - Params map[string]string `protobuf:"bytes,5,rep,name=params,proto3" json:"params,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Event) Reset() { *m = Event{} } -func (m *Event) String() string { return proto.CompactTextString(m) } -func (*Event) ProtoMessage() {} -func (*Event) Descriptor() ([]byte, []int) { - return fileDescriptor_connect_1685d4746e4a2c8b, []int{0} -} -func (m *Event) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Event.Unmarshal(m, b) -} -func (m *Event) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Event.Marshal(b, m, deterministic) -} -func (dst *Event) XXX_Merge(src proto.Message) { - xxx_messageInfo_Event.Merge(dst, src) -} -func (m *Event) XXX_Size() int { - return xxx_messageInfo_Event.Size(m) -} -func (m *Event) XXX_DiscardUnknown() { - xxx_messageInfo_Event.DiscardUnknown(m) -} - -var xxx_messageInfo_Event proto.InternalMessageInfo - -func (m *Event) GetId() string { - if m != nil { - return m.Id - } - return "" -} - -func (m *Event) GetTime() int64 { - if m != nil { - return m.Time - } - return 0 -} - -func (m *Event) GetResponse() *Response { - if m != nil { - return m.Response - } - return nil -} - -func (m *Event) GetRaw() []byte { - if m != nil { - return m.Raw - } - return nil -} - -func (m *Event) GetParams() map[string]string { - if m != nil { - return m.Params - } - return nil -} - -type Response struct { - Udid string `protobuf:"bytes,1,opt,name=udid,proto3" json:"udid,omitempty"` - UserId string `protobuf:"bytes,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` - Status string `protobuf:"bytes,3,opt,name=status,proto3" json:"status,omitempty"` - RequestType string `protobuf:"bytes,4,opt,name=request_type,json=requestType,proto3" json:"request_type,omitempty"` - CommandUuid string `protobuf:"bytes,5,opt,name=command_uuid,json=commandUuid,proto3" json:"command_uuid,omitempty"` - EnrollmentId string `protobuf:"bytes,6,opt,name=enrollment_id,json=enrollmentId,proto3" json:"enrollment_id,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Response) Reset() { *m = Response{} } -func (m *Response) String() string { return proto.CompactTextString(m) } -func (*Response) ProtoMessage() {} -func (*Response) Descriptor() ([]byte, []int) { - return fileDescriptor_connect_1685d4746e4a2c8b, []int{1} -} -func (m *Response) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Response.Unmarshal(m, b) -} -func (m *Response) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Response.Marshal(b, m, deterministic) -} -func (dst *Response) XXX_Merge(src proto.Message) { - xxx_messageInfo_Response.Merge(dst, src) -} -func (m *Response) XXX_Size() int { - return xxx_messageInfo_Response.Size(m) -} -func (m *Response) XXX_DiscardUnknown() { - xxx_messageInfo_Response.DiscardUnknown(m) -} - -var xxx_messageInfo_Response proto.InternalMessageInfo - -func (m *Response) GetUdid() string { - if m != nil { - return m.Udid - } - return "" -} - -func (m *Response) GetUserId() string { - if m != nil { - return m.UserId - } - return "" -} - -func (m *Response) GetStatus() string { - if m != nil { - return m.Status - } - return "" -} - -func (m *Response) GetRequestType() string { - if m != nil { - return m.RequestType - } - return "" -} - -func (m *Response) GetCommandUuid() string { - if m != nil { - return m.CommandUuid - } - return "" -} - -func (m *Response) GetEnrollmentId() string { - if m != nil { - return m.EnrollmentId - } - return "" -} - -func init() { - proto.RegisterType((*Event)(nil), "connectproto.Event") - proto.RegisterMapType((map[string]string)(nil), "connectproto.Event.ParamsEntry") - proto.RegisterType((*Response)(nil), "connectproto.Response") -} - -func init() { proto.RegisterFile("connect.proto", fileDescriptor_connect_1685d4746e4a2c8b) } - -var fileDescriptor_connect_1685d4746e4a2c8b = []byte{ - // 306 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x54, 0x50, 0x3d, 0x4f, 0xf3, 0x30, - 0x18, 0x94, 0x93, 0x26, 0x6f, 0xf3, 0x24, 0x7d, 0x85, 0x2c, 0x54, 0x22, 0x16, 0x42, 0x59, 0x32, - 0x65, 0x28, 0x03, 0x1f, 0x7b, 0x87, 0x6e, 0xc8, 0x82, 0xb9, 0x0a, 0xf5, 0x33, 0x44, 0x34, 0x76, - 0xf0, 0x47, 0x51, 0xfe, 0x1a, 0xff, 0x87, 0xff, 0x81, 0xec, 0x9a, 0x52, 0xb6, 0xbb, 0xf3, 0xf9, - 0x7c, 0x67, 0x98, 0x6d, 0xa5, 0x10, 0xb8, 0x35, 0xcd, 0xa0, 0xa4, 0x91, 0xb4, 0x08, 0xd4, 0xb3, - 0xc5, 0x17, 0x81, 0x64, 0xb5, 0x47, 0x61, 0xe8, 0x7f, 0x88, 0x3a, 0x5e, 0x92, 0x8a, 0xd4, 0x19, - 0x8b, 0x3a, 0x4e, 0x29, 0x4c, 0x4c, 0xd7, 0x63, 0x19, 0x55, 0xa4, 0x8e, 0x99, 0xc7, 0x74, 0x09, - 0x53, 0x85, 0x7a, 0x90, 0x42, 0x63, 0x19, 0x57, 0xa4, 0xce, 0x97, 0xf3, 0xe6, 0x34, 0xae, 0x61, - 0xe1, 0x94, 0x1d, 0x7d, 0xf4, 0x0c, 0x62, 0xd5, 0x7e, 0x94, 0x93, 0x8a, 0xd4, 0x05, 0x73, 0x90, - 0xde, 0x41, 0x3a, 0xb4, 0xaa, 0xed, 0x75, 0x99, 0x54, 0x71, 0x9d, 0x2f, 0xaf, 0xfe, 0x66, 0xf8, - 0x3a, 0xcd, 0x93, 0x77, 0xac, 0x84, 0x51, 0x23, 0x0b, 0xf6, 0xcb, 0x07, 0xc8, 0x4f, 0x64, 0x97, - 0xfc, 0x86, 0x63, 0xa8, 0xec, 0x20, 0x3d, 0x87, 0x64, 0xdf, 0xee, 0xec, 0xa1, 0x74, 0xc6, 0x0e, - 0xe4, 0x31, 0xba, 0x27, 0x8b, 0x4f, 0x02, 0xd3, 0x9f, 0x72, 0x6e, 0x9a, 0xe5, 0xc7, 0xb1, 0x1e, - 0xd3, 0x0b, 0xf8, 0x67, 0x35, 0xaa, 0x4d, 0xc7, 0xc3, 0xe5, 0xd4, 0xd1, 0x35, 0xa7, 0x73, 0x48, - 0xb5, 0x69, 0x8d, 0xd5, 0x7e, 0x71, 0xc6, 0x02, 0xa3, 0xd7, 0x50, 0x28, 0x7c, 0xb7, 0xa8, 0xcd, - 0xc6, 0x8c, 0x03, 0xfa, 0x81, 0x19, 0xcb, 0x83, 0xf6, 0x3c, 0x0e, 0xe8, 0x2c, 0x5b, 0xd9, 0xf7, - 0xad, 0xe0, 0x1b, 0x6b, 0x3b, 0x5e, 0x26, 0x07, 0x4b, 0xd0, 0x5e, 0x6c, 0xc7, 0xe9, 0x0d, 0xcc, - 0x50, 0x28, 0xb9, 0xdb, 0xf5, 0x28, 0x8c, 0x7b, 0x3c, 0xf5, 0x9e, 0xe2, 0x57, 0x5c, 0xf3, 0xd7, - 0xd4, 0x7f, 0xcc, 0xed, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0xe1, 0x57, 0xaf, 0x0d, 0xca, 0x01, - 0x00, 0x00, -} diff --git a/mdm/internal/connectproto/connect.proto b/mdm/internal/connectproto/connect.proto deleted file mode 100644 index 2faa76bf..00000000 --- a/mdm/internal/connectproto/connect.proto +++ /dev/null @@ -1,20 +0,0 @@ -syntax = "proto3"; - -package connectproto; - -message Event { - string id = 1; - int64 time = 2; - Response response = 3; - bytes raw = 4; - map params = 5; -} - -message Response { - string udid = 1; - string user_id = 2; - string status = 3; - string request_type = 4; - string command_uuid = 5; - string enrollment_id = 6; -} diff --git a/mdm/mdm/command.go b/mdm/mdm/command.go deleted file mode 100644 index ab3d6a41..00000000 --- a/mdm/mdm/command.go +++ /dev/null @@ -1,290 +0,0 @@ -package mdm - -import ( - "github.com/google/uuid" - "github.com/micromdm/micromdm/mdm/appmanifest" -) - -type CommandRequest struct { - UDID string `json:"udid"` - *Command -} - -type CommandPayload struct { - CommandUUID string `json:"command_uuid"` - Command *Command `json:"command"` -} - -func NewCommandPayload(request *CommandRequest) (*CommandPayload, error) { - payload := &CommandPayload{ - CommandUUID: uuid.New().String(), - Command: request.Command, - } - return payload, nil -} - -type Command struct { - RequestType string `json:"request_type"` - InstallProfile *InstallProfile - RemoveProfile *RemoveProfile - InstallProvisioningProfile *InstallProvisioningProfile - RemoveProvisioningProfile *RemoveProvisioningProfile - InstalledApplicationList *InstalledApplicationList - DeviceInformation *DeviceInformation - DeviceLock *DeviceLock - ClearPasscode *ClearPasscode - EraseDevice *EraseDevice - RequestMirroring *RequestMirroring - Restrictions *Restrictions - UnlockUserAccount *UnlockUserAccount - DeleteUser *DeleteUser - EnableLostMode *EnableLostMode - InstallApplication *InstallApplication - InstallEnterpriseApplication *InstallEnterpriseApplication - AccountConfiguration *AccountConfiguration - ApplyRedemptionCode *ApplyRedemptionCode - ManagedApplicationList *ManagedApplicationList - RemoveApplication *RemoveApplication - InviteToProgram *InviteToProgram - ValidateApplications *ValidateApplications - InstallMedia *InstallMedia - RemoveMedia *RemoveMedia - Settings *Settings - ManagedApplicationConfiguration *ManagedApplicationConfiguration - ManagedApplicationAttributes *ManagedApplicationAttributes - ManagedApplicationFeedback *ManagedApplicationFeedback - SetFirmwarePassword *SetFirmwarePassword - VerifyFirmwarePassword *VerifyFirmwarePassword - SetAutoAdminPassword *SetAutoAdminPassword - ScheduleOSUpdate *ScheduleOSUpdate - ScheduleOSUpdateScan *ScheduleOSUpdateScan - ActiveNSExtensions *ActiveNSExtensions - RotateFileVaultKey *RotateFileVaultKey - SetBootstrapToken *SetBootstrapToken -} - -// InstallProfile is an InstallProfile MDM Command -type InstallProfile struct { - Payload []byte `json:"payload,omitempty"` -} - -type RemoveProfile struct { - Identifier string `json:"identifier,omitempty"` -} - -type InstallProvisioningProfile struct { - ProvisioningProfile []byte `plist:",omitempty" json:"provisioning_profile,omitempty"` -} - -type RemoveProvisioningProfile struct { - UUID string `json:"uuid"` -} - -type InstalledApplicationList struct { - Identifiers []string `plist:",omitempty" json:"identifiers,omitempty"` - ManagedAppsOnly bool `plist:",omitempty" json:"managed_appd_only,omitempty"` -} - -type DeviceInformation struct { - Queries []string `plist:",omitempty" json:"queries,omitempty"` -} - -type DeviceLock struct { - PIN string `plist:",omitempty" json:"pin"` - Message string `plist:",omitempty" json:"message,omitempty"` - PhoneNumber string `plist:",omitempty" json:"phone_number,omitempty"` -} - -type ClearPasscode struct { - UnlockToken []byte `json:"unlock_token"` -} - -type EraseDevice struct { - PIN string `json:"pin"` - PreserveDataPlan bool `plist:",omitempty" json:"preserve_data_plan,omitempty"` - DisallowProximitySetup bool `plist:",omitempty" json:"disallow_proximity_setup,omitempty"` -} - -type RequestMirroring struct { - DestinationName string `plist:",omitempty" json:"destination_name,omitempty"` - DestinationDeviceID string `plist:",omitempty" json:"destination_device_id,omitempty"` - ScanTime string `plist:",omitempty" json:"scan_time,omitempty"` - Password string `plist:",omitempty" json:"password,omitempty"` -} - -type Restrictions struct { - ProfileRestrictions bool `json:"profile_restrictions"` -} - -type UnlockUserAccount struct { - UserName string `json:"username"` -} - -type DeleteUser struct { - UserName string `plist:",omitempty" json:"username,omitempty"` - ForceDeletion bool `plist:",omitempty" json:"force_deletion,omitempty"` -} - -type EnableLostMode struct { - Message string `plist:",omitempty" json:"message,omitempty"` - PhoneNumber string `plist:",omitempty" json:"phone_number,omitempty"` - Footnote string `plist:",omitempty" json:"footnote,omitempty"` -} - -type InstallEnterpriseApplication struct { - Manifest *appmanifest.Manifest `plist:",omitempty" json:"manifest,omitempty"` - ManifestURL *string `plist:",omitempty" json:"manifest_url,omitempty"` - ManifestURLPinningCerts [][]byte `plist:",omitempty" json:"manifest_url_pinning_certs,omitempty"` - PinningRevocationCheckRequired *bool `plist:",omitempty" json:"pinning_revocation_check_required,omitempty"` -} - -type InstallApplication struct { - ITunesStoreID *int64 `plist:"iTunesStoreID,omitempty" json:"itunes_store_id,omitempty"` - Identifier *string `plist:",omitempty" json:"identifier,omitempty"` - ManagementFlags *int `plist:",omitempty" json:"management_flags,omitempty"` - ChangeManagementState *string `plist:",omitempty" json:"change_management_state,omitempty"` - ManifestURL *string `plist:",omitempty" json:"manifest_url,omitempty"` - Options *InstallApplicationOptions `plist:"Options,omitempty" json:"options,omitempty"` - Configuration *InstallApplicationConfiguration `plist:",omitempty" json:"configuration,omitempty"` - Attributes *InstallApplicationAttributes `plist:",omitempty" json:"attributes,omitempty"` -} - -type InstallApplicationOptions struct { - PurchaseMethod *int64 `plist:"PurchaseMethod,omitempty" json:"purchase_method,omitempty"` -} - -type InstallApplicationConfiguration struct{} -type InstallApplicationAttributes struct{} - -type AccountConfiguration struct { - SkipPrimarySetupAccountCreation bool `plist:",omitempty" json:"skip_primary_setup_account_creation,omitempty"` - SetPrimarySetupAccountAsRegularUser bool `plist:",omitempty" json:"set_primary_setup_account_as_regular_user,omitempty"` - DontAutoPopulatePrimaryAccountInfo bool `plist:",omitempty" json:"dont_auto_populate_primary_account_info,omitempty"` - LockPrimaryAccountInfo bool `plist:",omitempty" json:"lock_primary_account_info,omitempty"` - PrimaryAccountFullName string `plist:",omitempty" json:"primary_account_full_name,omitempty"` - PrimaryAccountUserName string `plist:",omitempty" json:"primary_account_user_name,omitempty"` - AutoSetupAdminAccounts []AdminAccount `plist:",omitempty" json:"auto_setup_admin_accounts,omitempty"` -} - -type AdminAccount struct { - ShortName string `plist:"shortName" json:"short_name"` - FullName string `plist:"fullName,omitempty" json:"full_name,omitempty"` - PasswordHash []byte `plist:"passwordHash" json:"password_hash"` - Hidden bool `plist:"hidden,omitempty" json:"hidden,omitempty"` -} - -type ApplyRedemptionCode struct { - Identifier string `plist:",omitempty" json:"identifier,omitempty"` - RedemptionCode string `plist:",omitempty" json:"redemption_code,omitempty"` -} - -type ManagedApplicationList struct { - Identifiers []string `plist:",omitempty" json:"identifiers,omitempty"` -} - -type RemoveApplication struct { - Identifier string `plist:",omitempty" json:"identifier,omitempty"` -} - -type InviteToProgram struct { - ProgramID string `plist:",omitempty" json:"program_id,omitempty"` - InvitationURL string `plist:",omitempty" json:"invitation_url,omitempty"` -} - -type ValidateApplications struct { - Identifiers []string `plist:",omitempty" json:"identifiers,omitempty"` -} - -type InstallMedia struct { - ITunesStoreID *int64 `plist:"iTunesStoreID,omitempty" json:"itunes_store_id,omitempty"` - MediaURL string `plist:",omitempty" json:"media_url,omitempty"` - MediaType string `plist:",omitempty" json:"media_type,omitempty"` -} - -type RemoveMedia struct { - ITunesStoreID *int64 `plist:"iTunesStoreID,omitempty" json:"itunes_store_id,omitempty"` - MediaType string `plist:",omitempty" json:"media_type,omitempty"` - PersistentID string `plist:",omitempty" json:"persistent_id,omitempty"` -} - -type Settings struct { - Settings []Setting `plist:",omitempty" json:"settings,omitempty"` -} - -type Setting struct { - Item string `json:"item"` - Enabled *bool `plist:",omitempty" json:"enabled,omitempty"` - DeviceName *string `plist:",omitempty" json:"device_name,omitempty"` - HostName *string `plist:",omitempty" json:"hostname,omitempty"` - Identifier *string `plist:",omitempty" json:"identifier"` - Attributes map[string]string `plist:",omitempty" json:"attributes,omitempty"` - Image []byte `plist:",omitempty" json:"image,omitempty"` - Where *int `plist:",omitempty" json:"where,omitempty"` - MDMOptions map[string]interface{} `plist:",omitempty" json:"mdm_options,omitempty"` - PasscodeLockGracePeriod *int `plist:",omitempty" json:"passcode_lock_grace_period,omitempty"` - MaximumResidentUsers *int `plist:",omitempty" json:"maximum_resident_users,omitempty"` - Configuration map[string]interface{} `plist:",omitempty" json:"-"` - ConfigurationData []byte `plist:"-" json:"configuration"` // used to build the dictionary -} - -type ManagedApplicationConfiguration struct { - Identifiers []string `plist:",omitempty" json:"identifiers,omitempty"` -} - -type ManagedApplicationAttributes struct { - Identifiers []string `plist:",omitempty" json:"identifiers,omitempty"` -} - -type ManagedApplicationFeedback struct { - Identifiers []string `plist:",omitempty" json:"identifiers,omitempty"` - DeleteFeedback bool `plist:",omitempty" json:"delete_feedback,omitempty"` -} - -type SetFirmwarePassword struct { - CurrentPassword string `plist:",omitempty" json:"current_password,omitempty"` - NewPassword string `plist:",omitempty" json:"new_password,omitempty"` - AllowOroms bool `plist:",omitempty" json:"allow_oroms,omitempty"` -} - -type VerifyFirmwarePassword struct { - Password string `plist:",omitempty" json:"password,omitempty"` -} - -type SetAutoAdminPassword struct { - GUID string `plist:",omitempty" json:"guid,omitempty"` - PasswordHash []byte `plist:"passwordHash" json:"password_hash"` -} - -type SetBootstrapToken struct { - BootstrapToken string `plist:",omitempty" json:"bootstrap_token,omitempty"` -} - -type OSUpdate struct { - ProductKey string `json:"product_key"` - InstallAction string `json:"install_action"` -} - -type ScheduleOSUpdate struct { - Updates []OSUpdate `plist:",omitempty" json:"updates,omitempty"` -} - -type ScheduleOSUpdateScan struct { - Force bool `plist:",omitempty" json:"force,omitempty"` -} - -type ActiveNSExtensions struct { - FilterExtensionPoints []string `plist:",omitempty" json:"filter_extensions_points,omitempty"` -} - -type RotateFileVaultKey struct { - KeyType string `plist:",omitempty" json:"key_type,omitempty"` - FileVaultUnlock FileVaultUnlock `plist:",omitempty" json:"filevault_unlock,omitempty"` - NewCertificate []byte `plist:",omitempty" json:"new_certificate,omitempty"` - ReplyEncryptionCertificate []byte `plist:",omitempty" json:"reply_encryption_certificate,omitempty"` -} - -type FileVaultUnlock struct { - Password string `plist:",omitempty" json:"password,omitempty"` - PrivateKeyExport []byte `plist:",omitempty" json:"private_key_export,omitempty"` - PrivateKeyExportPassword string `plist:",omitempty" json:"private_key_export_password,omitempty"` -} diff --git a/mdm/mdm/internal/mdmproto/mdm.go b/mdm/mdm/internal/mdmproto/mdm.go deleted file mode 100644 index 8018c0be..00000000 --- a/mdm/mdm/internal/mdmproto/mdm.go +++ /dev/null @@ -1,3 +0,0 @@ -package mdmproto - -//go:generate protoc mdm.proto -I. --gofast_out=:. diff --git a/mdm/mdm/internal/mdmproto/mdm.pb.go b/mdm/mdm/internal/mdmproto/mdm.pb.go deleted file mode 100644 index 6849547b..00000000 --- a/mdm/mdm/internal/mdmproto/mdm.pb.go +++ /dev/null @@ -1,20017 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: mdm.proto - -package mdmproto - -import ( - fmt "fmt" - proto "github.com/golang/protobuf/proto" - io "io" - math "math" - math_bits "math/bits" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package - -type ResultPayload_Status int32 - -const ( - ResultPayload_Acknowledged ResultPayload_Status = 0 - ResultPayload_Error ResultPayload_Status = 1 - ResultPayload_CommandFormatError ResultPayload_Status = 2 - ResultPayload_Idle ResultPayload_Status = 3 - ResultPayload_NotNow ResultPayload_Status = 4 -) - -var ResultPayload_Status_name = map[int32]string{ - 0: "Acknowledged", - 1: "Error", - 2: "CommandFormatError", - 3: "Idle", - 4: "NotNow", -} - -var ResultPayload_Status_value = map[string]int32{ - "Acknowledged": 0, - "Error": 1, - "CommandFormatError": 2, - "Idle": 3, - "NotNow": 4, -} - -func (x ResultPayload_Status) String() string { - return proto.EnumName(ResultPayload_Status_name, int32(x)) -} - -func (ResultPayload_Status) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{66, 0} -} - -type CommandPayload struct { - CommandUuid string `protobuf:"bytes,1,opt,name=command_uuid,json=commandUuid,proto3" json:"command_uuid,omitempty"` - Command *Command `protobuf:"bytes,2,opt,name=command,proto3" json:"command,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *CommandPayload) Reset() { *m = CommandPayload{} } -func (m *CommandPayload) String() string { return proto.CompactTextString(m) } -func (*CommandPayload) ProtoMessage() {} -func (*CommandPayload) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{0} -} -func (m *CommandPayload) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *CommandPayload) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_CommandPayload.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *CommandPayload) XXX_Merge(src proto.Message) { - xxx_messageInfo_CommandPayload.Merge(m, src) -} -func (m *CommandPayload) XXX_Size() int { - return m.Size() -} -func (m *CommandPayload) XXX_DiscardUnknown() { - xxx_messageInfo_CommandPayload.DiscardUnknown(m) -} - -var xxx_messageInfo_CommandPayload proto.InternalMessageInfo - -func (m *CommandPayload) GetCommandUuid() string { - if m != nil { - return m.CommandUuid - } - return "" -} - -func (m *CommandPayload) GetCommand() *Command { - if m != nil { - return m.Command - } - return nil -} - -type Command struct { - RequestType string `protobuf:"bytes,1,opt,name=request_type,json=requestType,proto3" json:"request_type,omitempty"` - // - //Request Types that do not have additional fields: - //- ProfileList - //- ProvisioningProfileList - //- CertificateList", - //- SecurityInfo - //- RestartDevice - //- ShutDownDevice - //- StopMirroring - //- ClearRestrictionsPassword - //- UserList - //- LogOutUser - //- PlayLostModeSound - //- DisableLostMode - //- DeviceLocation - //- ManagedMediaList - //- DeviceConfigured - //- AvailableOSUpdates - //- NSExtensionMappings - //- EnableRemoteDesktop - //- DisableRemoteDesktop - //- ActivationLockBypassCode - // - // Types that are valid to be assigned to Request: - // *Command_InstallProfile - // *Command_RemoveProfile - // *Command_InstallProvisioningProfile - // *Command_RemoveProfisioningProfile - // *Command_InstalledApplicationList - // *Command_DeviceInformation - // *Command_DeviceLock - // *Command_ClearPasscode - // *Command_EraseDevice - // *Command_RequestMirroring - // *Command_Restrictions - // *Command_UnlockUserAccount - // *Command_DeleteUser - // *Command_EnableLostMode - // *Command_InstallApplication - // *Command_AccountConfiguration - // *Command_ApplyRedemptionCode - // *Command_ManagedApplicationList - // *Command_RemoveApplication - // *Command_InviteToProgram - // *Command_ValidataApplications - // *Command_InstallMedia - // *Command_RemoveMedia - // *Command_Settings - // *Command_ManagedApplicationConfiguration - // *Command_ManagedApplicationAttributes - // *Command_ManagedApplicationFeedback - // *Command_SetFirmwarePassword - // *Command_VerifyFirmwarePassword - // *Command_SetAutoAdminPassword - // *Command_ScheduleOsUpdate - // *Command_ScheduleOsUpdateScan - // *Command_ActiveNsExtensions - // *Command_RotateFilevaultKey - // *Command_InstallEnterpriseApplication - // *Command_SetBootstrapToken - Request isCommand_Request `protobuf_oneof:"request"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Command) Reset() { *m = Command{} } -func (m *Command) String() string { return proto.CompactTextString(m) } -func (*Command) ProtoMessage() {} -func (*Command) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{1} -} -func (m *Command) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Command) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Command.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Command) XXX_Merge(src proto.Message) { - xxx_messageInfo_Command.Merge(m, src) -} -func (m *Command) XXX_Size() int { - return m.Size() -} -func (m *Command) XXX_DiscardUnknown() { - xxx_messageInfo_Command.DiscardUnknown(m) -} - -var xxx_messageInfo_Command proto.InternalMessageInfo - -type isCommand_Request interface { - isCommand_Request() - MarshalTo([]byte) (int, error) - Size() int -} - -type Command_InstallProfile struct { - InstallProfile *InstallProfile `protobuf:"bytes,2,opt,name=install_profile,json=installProfile,proto3,oneof" json:"install_profile,omitempty"` -} -type Command_RemoveProfile struct { - RemoveProfile *RemoveProfile `protobuf:"bytes,3,opt,name=remove_profile,json=removeProfile,proto3,oneof" json:"remove_profile,omitempty"` -} -type Command_InstallProvisioningProfile struct { - InstallProvisioningProfile *InstallProvisioningProfile `protobuf:"bytes,4,opt,name=install_provisioning_profile,json=installProvisioningProfile,proto3,oneof" json:"install_provisioning_profile,omitempty"` -} -type Command_RemoveProfisioningProfile struct { - RemoveProfisioningProfile *RemoveProvisioningProfile `protobuf:"bytes,5,opt,name=remove_profisioning_profile,json=removeProfisioningProfile,proto3,oneof" json:"remove_profisioning_profile,omitempty"` -} -type Command_InstalledApplicationList struct { - InstalledApplicationList *InstalledApplicationList `protobuf:"bytes,6,opt,name=installed_application_list,json=installedApplicationList,proto3,oneof" json:"installed_application_list,omitempty"` -} -type Command_DeviceInformation struct { - DeviceInformation *DeviceInformation `protobuf:"bytes,7,opt,name=device_information,json=deviceInformation,proto3,oneof" json:"device_information,omitempty"` -} -type Command_DeviceLock struct { - DeviceLock *DeviceLock `protobuf:"bytes,8,opt,name=device_lock,json=deviceLock,proto3,oneof" json:"device_lock,omitempty"` -} -type Command_ClearPasscode struct { - ClearPasscode *ClearPasscode `protobuf:"bytes,9,opt,name=clear_passcode,json=clearPasscode,proto3,oneof" json:"clear_passcode,omitempty"` -} -type Command_EraseDevice struct { - EraseDevice *EraseDevice `protobuf:"bytes,10,opt,name=erase_device,json=eraseDevice,proto3,oneof" json:"erase_device,omitempty"` -} -type Command_RequestMirroring struct { - RequestMirroring *RequestMirroring `protobuf:"bytes,11,opt,name=request_mirroring,json=requestMirroring,proto3,oneof" json:"request_mirroring,omitempty"` -} -type Command_Restrictions struct { - Restrictions *Restrictions `protobuf:"bytes,12,opt,name=restrictions,proto3,oneof" json:"restrictions,omitempty"` -} -type Command_UnlockUserAccount struct { - UnlockUserAccount *UnlockUserAccount `protobuf:"bytes,13,opt,name=unlock_user_account,json=unlockUserAccount,proto3,oneof" json:"unlock_user_account,omitempty"` -} -type Command_DeleteUser struct { - DeleteUser *DeleteUser `protobuf:"bytes,14,opt,name=delete_user,json=deleteUser,proto3,oneof" json:"delete_user,omitempty"` -} -type Command_EnableLostMode struct { - EnableLostMode *EnableLostMode `protobuf:"bytes,15,opt,name=enable_lost_mode,json=enableLostMode,proto3,oneof" json:"enable_lost_mode,omitempty"` -} -type Command_InstallApplication struct { - InstallApplication *InstallApplication `protobuf:"bytes,16,opt,name=install_application,json=installApplication,proto3,oneof" json:"install_application,omitempty"` -} -type Command_AccountConfiguration struct { - AccountConfiguration *AccountConfiguration `protobuf:"bytes,17,opt,name=account_configuration,json=accountConfiguration,proto3,oneof" json:"account_configuration,omitempty"` -} -type Command_ApplyRedemptionCode struct { - ApplyRedemptionCode *ApplyRedemptionCode `protobuf:"bytes,18,opt,name=apply_redemption_code,json=applyRedemptionCode,proto3,oneof" json:"apply_redemption_code,omitempty"` -} -type Command_ManagedApplicationList struct { - ManagedApplicationList *ManagedApplicationList `protobuf:"bytes,19,opt,name=managed_application_list,json=managedApplicationList,proto3,oneof" json:"managed_application_list,omitempty"` -} -type Command_RemoveApplication struct { - RemoveApplication *RemoveApplication `protobuf:"bytes,20,opt,name=remove_application,json=removeApplication,proto3,oneof" json:"remove_application,omitempty"` -} -type Command_InviteToProgram struct { - InviteToProgram *InviteToProgram `protobuf:"bytes,21,opt,name=invite_to_program,json=inviteToProgram,proto3,oneof" json:"invite_to_program,omitempty"` -} -type Command_ValidataApplications struct { - ValidataApplications *ValidateApplications `protobuf:"bytes,22,opt,name=validata_applications,json=validataApplications,proto3,oneof" json:"validata_applications,omitempty"` -} -type Command_InstallMedia struct { - InstallMedia *InstallMedia `protobuf:"bytes,23,opt,name=install_media,json=installMedia,proto3,oneof" json:"install_media,omitempty"` -} -type Command_RemoveMedia struct { - RemoveMedia *RemoveMedia `protobuf:"bytes,24,opt,name=remove_media,json=removeMedia,proto3,oneof" json:"remove_media,omitempty"` -} -type Command_Settings struct { - Settings *Settings `protobuf:"bytes,25,opt,name=settings,proto3,oneof" json:"settings,omitempty"` -} -type Command_ManagedApplicationConfiguration struct { - ManagedApplicationConfiguration *ManagedApplicationConfiguration `protobuf:"bytes,26,opt,name=managed_application_configuration,json=managedApplicationConfiguration,proto3,oneof" json:"managed_application_configuration,omitempty"` -} -type Command_ManagedApplicationAttributes struct { - ManagedApplicationAttributes *ManagedApplicationAttributes `protobuf:"bytes,27,opt,name=managed_application_attributes,json=managedApplicationAttributes,proto3,oneof" json:"managed_application_attributes,omitempty"` -} -type Command_ManagedApplicationFeedback struct { - ManagedApplicationFeedback *ManagedApplicationFeedback `protobuf:"bytes,28,opt,name=managed_application_feedback,json=managedApplicationFeedback,proto3,oneof" json:"managed_application_feedback,omitempty"` -} -type Command_SetFirmwarePassword struct { - SetFirmwarePassword *SetFirmwarePassword `protobuf:"bytes,29,opt,name=set_firmware_password,json=setFirmwarePassword,proto3,oneof" json:"set_firmware_password,omitempty"` -} -type Command_VerifyFirmwarePassword struct { - VerifyFirmwarePassword *VerifyFirmwarePassword `protobuf:"bytes,30,opt,name=verify_firmware_password,json=verifyFirmwarePassword,proto3,oneof" json:"verify_firmware_password,omitempty"` -} -type Command_SetAutoAdminPassword struct { - SetAutoAdminPassword *SetAutoAdminPassword `protobuf:"bytes,31,opt,name=set_auto_admin_password,json=setAutoAdminPassword,proto3,oneof" json:"set_auto_admin_password,omitempty"` -} -type Command_ScheduleOsUpdate struct { - ScheduleOsUpdate *ScheduleOSUpdate `protobuf:"bytes,32,opt,name=schedule_os_update,json=scheduleOsUpdate,proto3,oneof" json:"schedule_os_update,omitempty"` -} -type Command_ScheduleOsUpdateScan struct { - ScheduleOsUpdateScan *ScheduleOSUpdateScan `protobuf:"bytes,33,opt,name=schedule_os_update_scan,json=scheduleOsUpdateScan,proto3,oneof" json:"schedule_os_update_scan,omitempty"` -} -type Command_ActiveNsExtensions struct { - ActiveNsExtensions *ActiveNSExtensions `protobuf:"bytes,34,opt,name=active_ns_extensions,json=activeNsExtensions,proto3,oneof" json:"active_ns_extensions,omitempty"` -} -type Command_RotateFilevaultKey struct { - RotateFilevaultKey *RotateFileVaultKey `protobuf:"bytes,35,opt,name=rotate_filevault_key,json=rotateFilevaultKey,proto3,oneof" json:"rotate_filevault_key,omitempty"` -} -type Command_InstallEnterpriseApplication struct { - InstallEnterpriseApplication *InstallEnterpriseApplication `protobuf:"bytes,36,opt,name=install_enterprise_application,json=installEnterpriseApplication,proto3,oneof" json:"install_enterprise_application,omitempty"` -} -type Command_SetBootstrapToken struct { - SetBootstrapToken *SetBootstrapToken `protobuf:"bytes,37,opt,name=set_bootstrap_token,json=setBootstrapToken,proto3,oneof" json:"set_bootstrap_token,omitempty"` -} - -func (*Command_InstallProfile) isCommand_Request() {} -func (*Command_RemoveProfile) isCommand_Request() {} -func (*Command_InstallProvisioningProfile) isCommand_Request() {} -func (*Command_RemoveProfisioningProfile) isCommand_Request() {} -func (*Command_InstalledApplicationList) isCommand_Request() {} -func (*Command_DeviceInformation) isCommand_Request() {} -func (*Command_DeviceLock) isCommand_Request() {} -func (*Command_ClearPasscode) isCommand_Request() {} -func (*Command_EraseDevice) isCommand_Request() {} -func (*Command_RequestMirroring) isCommand_Request() {} -func (*Command_Restrictions) isCommand_Request() {} -func (*Command_UnlockUserAccount) isCommand_Request() {} -func (*Command_DeleteUser) isCommand_Request() {} -func (*Command_EnableLostMode) isCommand_Request() {} -func (*Command_InstallApplication) isCommand_Request() {} -func (*Command_AccountConfiguration) isCommand_Request() {} -func (*Command_ApplyRedemptionCode) isCommand_Request() {} -func (*Command_ManagedApplicationList) isCommand_Request() {} -func (*Command_RemoveApplication) isCommand_Request() {} -func (*Command_InviteToProgram) isCommand_Request() {} -func (*Command_ValidataApplications) isCommand_Request() {} -func (*Command_InstallMedia) isCommand_Request() {} -func (*Command_RemoveMedia) isCommand_Request() {} -func (*Command_Settings) isCommand_Request() {} -func (*Command_ManagedApplicationConfiguration) isCommand_Request() {} -func (*Command_ManagedApplicationAttributes) isCommand_Request() {} -func (*Command_ManagedApplicationFeedback) isCommand_Request() {} -func (*Command_SetFirmwarePassword) isCommand_Request() {} -func (*Command_VerifyFirmwarePassword) isCommand_Request() {} -func (*Command_SetAutoAdminPassword) isCommand_Request() {} -func (*Command_ScheduleOsUpdate) isCommand_Request() {} -func (*Command_ScheduleOsUpdateScan) isCommand_Request() {} -func (*Command_ActiveNsExtensions) isCommand_Request() {} -func (*Command_RotateFilevaultKey) isCommand_Request() {} -func (*Command_InstallEnterpriseApplication) isCommand_Request() {} -func (*Command_SetBootstrapToken) isCommand_Request() {} - -func (m *Command) GetRequest() isCommand_Request { - if m != nil { - return m.Request - } - return nil -} - -func (m *Command) GetRequestType() string { - if m != nil { - return m.RequestType - } - return "" -} - -func (m *Command) GetInstallProfile() *InstallProfile { - if x, ok := m.GetRequest().(*Command_InstallProfile); ok { - return x.InstallProfile - } - return nil -} - -func (m *Command) GetRemoveProfile() *RemoveProfile { - if x, ok := m.GetRequest().(*Command_RemoveProfile); ok { - return x.RemoveProfile - } - return nil -} - -func (m *Command) GetInstallProvisioningProfile() *InstallProvisioningProfile { - if x, ok := m.GetRequest().(*Command_InstallProvisioningProfile); ok { - return x.InstallProvisioningProfile - } - return nil -} - -func (m *Command) GetRemoveProfisioningProfile() *RemoveProvisioningProfile { - if x, ok := m.GetRequest().(*Command_RemoveProfisioningProfile); ok { - return x.RemoveProfisioningProfile - } - return nil -} - -func (m *Command) GetInstalledApplicationList() *InstalledApplicationList { - if x, ok := m.GetRequest().(*Command_InstalledApplicationList); ok { - return x.InstalledApplicationList - } - return nil -} - -func (m *Command) GetDeviceInformation() *DeviceInformation { - if x, ok := m.GetRequest().(*Command_DeviceInformation); ok { - return x.DeviceInformation - } - return nil -} - -func (m *Command) GetDeviceLock() *DeviceLock { - if x, ok := m.GetRequest().(*Command_DeviceLock); ok { - return x.DeviceLock - } - return nil -} - -func (m *Command) GetClearPasscode() *ClearPasscode { - if x, ok := m.GetRequest().(*Command_ClearPasscode); ok { - return x.ClearPasscode - } - return nil -} - -func (m *Command) GetEraseDevice() *EraseDevice { - if x, ok := m.GetRequest().(*Command_EraseDevice); ok { - return x.EraseDevice - } - return nil -} - -func (m *Command) GetRequestMirroring() *RequestMirroring { - if x, ok := m.GetRequest().(*Command_RequestMirroring); ok { - return x.RequestMirroring - } - return nil -} - -func (m *Command) GetRestrictions() *Restrictions { - if x, ok := m.GetRequest().(*Command_Restrictions); ok { - return x.Restrictions - } - return nil -} - -func (m *Command) GetUnlockUserAccount() *UnlockUserAccount { - if x, ok := m.GetRequest().(*Command_UnlockUserAccount); ok { - return x.UnlockUserAccount - } - return nil -} - -func (m *Command) GetDeleteUser() *DeleteUser { - if x, ok := m.GetRequest().(*Command_DeleteUser); ok { - return x.DeleteUser - } - return nil -} - -func (m *Command) GetEnableLostMode() *EnableLostMode { - if x, ok := m.GetRequest().(*Command_EnableLostMode); ok { - return x.EnableLostMode - } - return nil -} - -func (m *Command) GetInstallApplication() *InstallApplication { - if x, ok := m.GetRequest().(*Command_InstallApplication); ok { - return x.InstallApplication - } - return nil -} - -func (m *Command) GetAccountConfiguration() *AccountConfiguration { - if x, ok := m.GetRequest().(*Command_AccountConfiguration); ok { - return x.AccountConfiguration - } - return nil -} - -func (m *Command) GetApplyRedemptionCode() *ApplyRedemptionCode { - if x, ok := m.GetRequest().(*Command_ApplyRedemptionCode); ok { - return x.ApplyRedemptionCode - } - return nil -} - -func (m *Command) GetManagedApplicationList() *ManagedApplicationList { - if x, ok := m.GetRequest().(*Command_ManagedApplicationList); ok { - return x.ManagedApplicationList - } - return nil -} - -func (m *Command) GetRemoveApplication() *RemoveApplication { - if x, ok := m.GetRequest().(*Command_RemoveApplication); ok { - return x.RemoveApplication - } - return nil -} - -func (m *Command) GetInviteToProgram() *InviteToProgram { - if x, ok := m.GetRequest().(*Command_InviteToProgram); ok { - return x.InviteToProgram - } - return nil -} - -func (m *Command) GetValidataApplications() *ValidateApplications { - if x, ok := m.GetRequest().(*Command_ValidataApplications); ok { - return x.ValidataApplications - } - return nil -} - -func (m *Command) GetInstallMedia() *InstallMedia { - if x, ok := m.GetRequest().(*Command_InstallMedia); ok { - return x.InstallMedia - } - return nil -} - -func (m *Command) GetRemoveMedia() *RemoveMedia { - if x, ok := m.GetRequest().(*Command_RemoveMedia); ok { - return x.RemoveMedia - } - return nil -} - -func (m *Command) GetSettings() *Settings { - if x, ok := m.GetRequest().(*Command_Settings); ok { - return x.Settings - } - return nil -} - -func (m *Command) GetManagedApplicationConfiguration() *ManagedApplicationConfiguration { - if x, ok := m.GetRequest().(*Command_ManagedApplicationConfiguration); ok { - return x.ManagedApplicationConfiguration - } - return nil -} - -func (m *Command) GetManagedApplicationAttributes() *ManagedApplicationAttributes { - if x, ok := m.GetRequest().(*Command_ManagedApplicationAttributes); ok { - return x.ManagedApplicationAttributes - } - return nil -} - -func (m *Command) GetManagedApplicationFeedback() *ManagedApplicationFeedback { - if x, ok := m.GetRequest().(*Command_ManagedApplicationFeedback); ok { - return x.ManagedApplicationFeedback - } - return nil -} - -func (m *Command) GetSetFirmwarePassword() *SetFirmwarePassword { - if x, ok := m.GetRequest().(*Command_SetFirmwarePassword); ok { - return x.SetFirmwarePassword - } - return nil -} - -func (m *Command) GetVerifyFirmwarePassword() *VerifyFirmwarePassword { - if x, ok := m.GetRequest().(*Command_VerifyFirmwarePassword); ok { - return x.VerifyFirmwarePassword - } - return nil -} - -func (m *Command) GetSetAutoAdminPassword() *SetAutoAdminPassword { - if x, ok := m.GetRequest().(*Command_SetAutoAdminPassword); ok { - return x.SetAutoAdminPassword - } - return nil -} - -func (m *Command) GetScheduleOsUpdate() *ScheduleOSUpdate { - if x, ok := m.GetRequest().(*Command_ScheduleOsUpdate); ok { - return x.ScheduleOsUpdate - } - return nil -} - -func (m *Command) GetScheduleOsUpdateScan() *ScheduleOSUpdateScan { - if x, ok := m.GetRequest().(*Command_ScheduleOsUpdateScan); ok { - return x.ScheduleOsUpdateScan - } - return nil -} - -func (m *Command) GetActiveNsExtensions() *ActiveNSExtensions { - if x, ok := m.GetRequest().(*Command_ActiveNsExtensions); ok { - return x.ActiveNsExtensions - } - return nil -} - -func (m *Command) GetRotateFilevaultKey() *RotateFileVaultKey { - if x, ok := m.GetRequest().(*Command_RotateFilevaultKey); ok { - return x.RotateFilevaultKey - } - return nil -} - -func (m *Command) GetInstallEnterpriseApplication() *InstallEnterpriseApplication { - if x, ok := m.GetRequest().(*Command_InstallEnterpriseApplication); ok { - return x.InstallEnterpriseApplication - } - return nil -} - -func (m *Command) GetSetBootstrapToken() *SetBootstrapToken { - if x, ok := m.GetRequest().(*Command_SetBootstrapToken); ok { - return x.SetBootstrapToken - } - return nil -} - -// XXX_OneofWrappers is for the internal use of the proto package. -func (*Command) XXX_OneofWrappers() []interface{} { - return []interface{}{ - (*Command_InstallProfile)(nil), - (*Command_RemoveProfile)(nil), - (*Command_InstallProvisioningProfile)(nil), - (*Command_RemoveProfisioningProfile)(nil), - (*Command_InstalledApplicationList)(nil), - (*Command_DeviceInformation)(nil), - (*Command_DeviceLock)(nil), - (*Command_ClearPasscode)(nil), - (*Command_EraseDevice)(nil), - (*Command_RequestMirroring)(nil), - (*Command_Restrictions)(nil), - (*Command_UnlockUserAccount)(nil), - (*Command_DeleteUser)(nil), - (*Command_EnableLostMode)(nil), - (*Command_InstallApplication)(nil), - (*Command_AccountConfiguration)(nil), - (*Command_ApplyRedemptionCode)(nil), - (*Command_ManagedApplicationList)(nil), - (*Command_RemoveApplication)(nil), - (*Command_InviteToProgram)(nil), - (*Command_ValidataApplications)(nil), - (*Command_InstallMedia)(nil), - (*Command_RemoveMedia)(nil), - (*Command_Settings)(nil), - (*Command_ManagedApplicationConfiguration)(nil), - (*Command_ManagedApplicationAttributes)(nil), - (*Command_ManagedApplicationFeedback)(nil), - (*Command_SetFirmwarePassword)(nil), - (*Command_VerifyFirmwarePassword)(nil), - (*Command_SetAutoAdminPassword)(nil), - (*Command_ScheduleOsUpdate)(nil), - (*Command_ScheduleOsUpdateScan)(nil), - (*Command_ActiveNsExtensions)(nil), - (*Command_RotateFilevaultKey)(nil), - (*Command_InstallEnterpriseApplication)(nil), - (*Command_SetBootstrapToken)(nil), - } -} - -type InstallProfile struct { - Payload []byte `protobuf:"bytes,1,opt,name=payload,proto3" json:"payload,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *InstallProfile) Reset() { *m = InstallProfile{} } -func (m *InstallProfile) String() string { return proto.CompactTextString(m) } -func (*InstallProfile) ProtoMessage() {} -func (*InstallProfile) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{2} -} -func (m *InstallProfile) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *InstallProfile) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_InstallProfile.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *InstallProfile) XXX_Merge(src proto.Message) { - xxx_messageInfo_InstallProfile.Merge(m, src) -} -func (m *InstallProfile) XXX_Size() int { - return m.Size() -} -func (m *InstallProfile) XXX_DiscardUnknown() { - xxx_messageInfo_InstallProfile.DiscardUnknown(m) -} - -var xxx_messageInfo_InstallProfile proto.InternalMessageInfo - -func (m *InstallProfile) GetPayload() []byte { - if m != nil { - return m.Payload - } - return nil -} - -type RemoveProfile struct { - Identifier string `protobuf:"bytes,1,opt,name=identifier,proto3" json:"identifier,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *RemoveProfile) Reset() { *m = RemoveProfile{} } -func (m *RemoveProfile) String() string { return proto.CompactTextString(m) } -func (*RemoveProfile) ProtoMessage() {} -func (*RemoveProfile) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{3} -} -func (m *RemoveProfile) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *RemoveProfile) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_RemoveProfile.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *RemoveProfile) XXX_Merge(src proto.Message) { - xxx_messageInfo_RemoveProfile.Merge(m, src) -} -func (m *RemoveProfile) XXX_Size() int { - return m.Size() -} -func (m *RemoveProfile) XXX_DiscardUnknown() { - xxx_messageInfo_RemoveProfile.DiscardUnknown(m) -} - -var xxx_messageInfo_RemoveProfile proto.InternalMessageInfo - -func (m *RemoveProfile) GetIdentifier() string { - if m != nil { - return m.Identifier - } - return "" -} - -type InstallProvisioningProfile struct { - ProvisioningProfile []byte `protobuf:"bytes,1,opt,name=provisioning_profile,json=provisioningProfile,proto3" json:"provisioning_profile,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *InstallProvisioningProfile) Reset() { *m = InstallProvisioningProfile{} } -func (m *InstallProvisioningProfile) String() string { return proto.CompactTextString(m) } -func (*InstallProvisioningProfile) ProtoMessage() {} -func (*InstallProvisioningProfile) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{4} -} -func (m *InstallProvisioningProfile) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *InstallProvisioningProfile) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_InstallProvisioningProfile.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *InstallProvisioningProfile) XXX_Merge(src proto.Message) { - xxx_messageInfo_InstallProvisioningProfile.Merge(m, src) -} -func (m *InstallProvisioningProfile) XXX_Size() int { - return m.Size() -} -func (m *InstallProvisioningProfile) XXX_DiscardUnknown() { - xxx_messageInfo_InstallProvisioningProfile.DiscardUnknown(m) -} - -var xxx_messageInfo_InstallProvisioningProfile proto.InternalMessageInfo - -func (m *InstallProvisioningProfile) GetProvisioningProfile() []byte { - if m != nil { - return m.ProvisioningProfile - } - return nil -} - -type RemoveProvisioningProfile struct { - Uuid string `protobuf:"bytes,1,opt,name=uuid,proto3" json:"uuid,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *RemoveProvisioningProfile) Reset() { *m = RemoveProvisioningProfile{} } -func (m *RemoveProvisioningProfile) String() string { return proto.CompactTextString(m) } -func (*RemoveProvisioningProfile) ProtoMessage() {} -func (*RemoveProvisioningProfile) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{5} -} -func (m *RemoveProvisioningProfile) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *RemoveProvisioningProfile) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_RemoveProvisioningProfile.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *RemoveProvisioningProfile) XXX_Merge(src proto.Message) { - xxx_messageInfo_RemoveProvisioningProfile.Merge(m, src) -} -func (m *RemoveProvisioningProfile) XXX_Size() int { - return m.Size() -} -func (m *RemoveProvisioningProfile) XXX_DiscardUnknown() { - xxx_messageInfo_RemoveProvisioningProfile.DiscardUnknown(m) -} - -var xxx_messageInfo_RemoveProvisioningProfile proto.InternalMessageInfo - -func (m *RemoveProvisioningProfile) GetUuid() string { - if m != nil { - return m.Uuid - } - return "" -} - -type InstalledApplicationList struct { - Identifiers []string `protobuf:"bytes,1,rep,name=identifiers,proto3" json:"identifiers,omitempty"` - ManagedAppsOnly bool `protobuf:"varint,2,opt,name=managed_apps_only,json=managedAppsOnly,proto3" json:"managed_apps_only,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *InstalledApplicationList) Reset() { *m = InstalledApplicationList{} } -func (m *InstalledApplicationList) String() string { return proto.CompactTextString(m) } -func (*InstalledApplicationList) ProtoMessage() {} -func (*InstalledApplicationList) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{6} -} -func (m *InstalledApplicationList) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *InstalledApplicationList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_InstalledApplicationList.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *InstalledApplicationList) XXX_Merge(src proto.Message) { - xxx_messageInfo_InstalledApplicationList.Merge(m, src) -} -func (m *InstalledApplicationList) XXX_Size() int { - return m.Size() -} -func (m *InstalledApplicationList) XXX_DiscardUnknown() { - xxx_messageInfo_InstalledApplicationList.DiscardUnknown(m) -} - -var xxx_messageInfo_InstalledApplicationList proto.InternalMessageInfo - -func (m *InstalledApplicationList) GetIdentifiers() []string { - if m != nil { - return m.Identifiers - } - return nil -} - -func (m *InstalledApplicationList) GetManagedAppsOnly() bool { - if m != nil { - return m.ManagedAppsOnly - } - return false -} - -type DeviceInformation struct { - Queries []string `protobuf:"bytes,1,rep,name=queries,proto3" json:"queries,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *DeviceInformation) Reset() { *m = DeviceInformation{} } -func (m *DeviceInformation) String() string { return proto.CompactTextString(m) } -func (*DeviceInformation) ProtoMessage() {} -func (*DeviceInformation) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{7} -} -func (m *DeviceInformation) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *DeviceInformation) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_DeviceInformation.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *DeviceInformation) XXX_Merge(src proto.Message) { - xxx_messageInfo_DeviceInformation.Merge(m, src) -} -func (m *DeviceInformation) XXX_Size() int { - return m.Size() -} -func (m *DeviceInformation) XXX_DiscardUnknown() { - xxx_messageInfo_DeviceInformation.DiscardUnknown(m) -} - -var xxx_messageInfo_DeviceInformation proto.InternalMessageInfo - -func (m *DeviceInformation) GetQueries() []string { - if m != nil { - return m.Queries - } - return nil -} - -type ClearPasscode struct { - UnlockToken []byte `protobuf:"bytes,1,opt,name=unlock_token,json=unlockToken,proto3" json:"unlock_token,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ClearPasscode) Reset() { *m = ClearPasscode{} } -func (m *ClearPasscode) String() string { return proto.CompactTextString(m) } -func (*ClearPasscode) ProtoMessage() {} -func (*ClearPasscode) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{8} -} -func (m *ClearPasscode) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ClearPasscode) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ClearPasscode.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ClearPasscode) XXX_Merge(src proto.Message) { - xxx_messageInfo_ClearPasscode.Merge(m, src) -} -func (m *ClearPasscode) XXX_Size() int { - return m.Size() -} -func (m *ClearPasscode) XXX_DiscardUnknown() { - xxx_messageInfo_ClearPasscode.DiscardUnknown(m) -} - -var xxx_messageInfo_ClearPasscode proto.InternalMessageInfo - -func (m *ClearPasscode) GetUnlockToken() []byte { - if m != nil { - return m.UnlockToken - } - return nil -} - -type DeviceLock struct { - Pin string `protobuf:"bytes,1,opt,name=pin,proto3" json:"pin,omitempty"` - Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` - PhoneNumber string `protobuf:"bytes,3,opt,name=phone_number,json=phoneNumber,proto3" json:"phone_number,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *DeviceLock) Reset() { *m = DeviceLock{} } -func (m *DeviceLock) String() string { return proto.CompactTextString(m) } -func (*DeviceLock) ProtoMessage() {} -func (*DeviceLock) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{9} -} -func (m *DeviceLock) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *DeviceLock) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_DeviceLock.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *DeviceLock) XXX_Merge(src proto.Message) { - xxx_messageInfo_DeviceLock.Merge(m, src) -} -func (m *DeviceLock) XXX_Size() int { - return m.Size() -} -func (m *DeviceLock) XXX_DiscardUnknown() { - xxx_messageInfo_DeviceLock.DiscardUnknown(m) -} - -var xxx_messageInfo_DeviceLock proto.InternalMessageInfo - -func (m *DeviceLock) GetPin() string { - if m != nil { - return m.Pin - } - return "" -} - -func (m *DeviceLock) GetMessage() string { - if m != nil { - return m.Message - } - return "" -} - -func (m *DeviceLock) GetPhoneNumber() string { - if m != nil { - return m.PhoneNumber - } - return "" -} - -type EraseDevice struct { - Pin string `protobuf:"bytes,1,opt,name=pin,proto3" json:"pin,omitempty"` - PreserveDataPlan bool `protobuf:"varint,2,opt,name=preserve_data_plan,json=preserveDataPlan,proto3" json:"preserve_data_plan,omitempty"` - DisallowProximitySetup bool `protobuf:"varint,3,opt,name=disallow_proximity_setup,json=disallowProximitySetup,proto3" json:"disallow_proximity_setup,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *EraseDevice) Reset() { *m = EraseDevice{} } -func (m *EraseDevice) String() string { return proto.CompactTextString(m) } -func (*EraseDevice) ProtoMessage() {} -func (*EraseDevice) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{10} -} -func (m *EraseDevice) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *EraseDevice) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_EraseDevice.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *EraseDevice) XXX_Merge(src proto.Message) { - xxx_messageInfo_EraseDevice.Merge(m, src) -} -func (m *EraseDevice) XXX_Size() int { - return m.Size() -} -func (m *EraseDevice) XXX_DiscardUnknown() { - xxx_messageInfo_EraseDevice.DiscardUnknown(m) -} - -var xxx_messageInfo_EraseDevice proto.InternalMessageInfo - -func (m *EraseDevice) GetPin() string { - if m != nil { - return m.Pin - } - return "" -} - -func (m *EraseDevice) GetPreserveDataPlan() bool { - if m != nil { - return m.PreserveDataPlan - } - return false -} - -func (m *EraseDevice) GetDisallowProximitySetup() bool { - if m != nil { - return m.DisallowProximitySetup - } - return false -} - -type RequestMirroring struct { - DestinationName string `protobuf:"bytes,1,opt,name=destination_name,json=destinationName,proto3" json:"destination_name,omitempty"` - DestinationDeviceId string `protobuf:"bytes,2,opt,name=destination_device_id,json=destinationDeviceId,proto3" json:"destination_device_id,omitempty"` - ScanTime string `protobuf:"bytes,3,opt,name=scan_time,json=scanTime,proto3" json:"scan_time,omitempty"` - Password string `protobuf:"bytes,4,opt,name=password,proto3" json:"password,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *RequestMirroring) Reset() { *m = RequestMirroring{} } -func (m *RequestMirroring) String() string { return proto.CompactTextString(m) } -func (*RequestMirroring) ProtoMessage() {} -func (*RequestMirroring) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{11} -} -func (m *RequestMirroring) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *RequestMirroring) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_RequestMirroring.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *RequestMirroring) XXX_Merge(src proto.Message) { - xxx_messageInfo_RequestMirroring.Merge(m, src) -} -func (m *RequestMirroring) XXX_Size() int { - return m.Size() -} -func (m *RequestMirroring) XXX_DiscardUnknown() { - xxx_messageInfo_RequestMirroring.DiscardUnknown(m) -} - -var xxx_messageInfo_RequestMirroring proto.InternalMessageInfo - -func (m *RequestMirroring) GetDestinationName() string { - if m != nil { - return m.DestinationName - } - return "" -} - -func (m *RequestMirroring) GetDestinationDeviceId() string { - if m != nil { - return m.DestinationDeviceId - } - return "" -} - -func (m *RequestMirroring) GetScanTime() string { - if m != nil { - return m.ScanTime - } - return "" -} - -func (m *RequestMirroring) GetPassword() string { - if m != nil { - return m.Password - } - return "" -} - -type Restrictions struct { - ProfileRestrictions bool `protobuf:"varint,1,opt,name=profile_restrictions,json=profileRestrictions,proto3" json:"profile_restrictions,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Restrictions) Reset() { *m = Restrictions{} } -func (m *Restrictions) String() string { return proto.CompactTextString(m) } -func (*Restrictions) ProtoMessage() {} -func (*Restrictions) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{12} -} -func (m *Restrictions) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Restrictions) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Restrictions.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Restrictions) XXX_Merge(src proto.Message) { - xxx_messageInfo_Restrictions.Merge(m, src) -} -func (m *Restrictions) XXX_Size() int { - return m.Size() -} -func (m *Restrictions) XXX_DiscardUnknown() { - xxx_messageInfo_Restrictions.DiscardUnknown(m) -} - -var xxx_messageInfo_Restrictions proto.InternalMessageInfo - -func (m *Restrictions) GetProfileRestrictions() bool { - if m != nil { - return m.ProfileRestrictions - } - return false -} - -type UnlockUserAccount struct { - Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *UnlockUserAccount) Reset() { *m = UnlockUserAccount{} } -func (m *UnlockUserAccount) String() string { return proto.CompactTextString(m) } -func (*UnlockUserAccount) ProtoMessage() {} -func (*UnlockUserAccount) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{13} -} -func (m *UnlockUserAccount) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *UnlockUserAccount) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_UnlockUserAccount.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *UnlockUserAccount) XXX_Merge(src proto.Message) { - xxx_messageInfo_UnlockUserAccount.Merge(m, src) -} -func (m *UnlockUserAccount) XXX_Size() int { - return m.Size() -} -func (m *UnlockUserAccount) XXX_DiscardUnknown() { - xxx_messageInfo_UnlockUserAccount.DiscardUnknown(m) -} - -var xxx_messageInfo_UnlockUserAccount proto.InternalMessageInfo - -func (m *UnlockUserAccount) GetUsername() string { - if m != nil { - return m.Username - } - return "" -} - -type DeleteUser struct { - Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"` - ForceDeletion bool `protobuf:"varint,2,opt,name=force_deletion,json=forceDeletion,proto3" json:"force_deletion,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *DeleteUser) Reset() { *m = DeleteUser{} } -func (m *DeleteUser) String() string { return proto.CompactTextString(m) } -func (*DeleteUser) ProtoMessage() {} -func (*DeleteUser) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{14} -} -func (m *DeleteUser) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *DeleteUser) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_DeleteUser.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *DeleteUser) XXX_Merge(src proto.Message) { - xxx_messageInfo_DeleteUser.Merge(m, src) -} -func (m *DeleteUser) XXX_Size() int { - return m.Size() -} -func (m *DeleteUser) XXX_DiscardUnknown() { - xxx_messageInfo_DeleteUser.DiscardUnknown(m) -} - -var xxx_messageInfo_DeleteUser proto.InternalMessageInfo - -func (m *DeleteUser) GetUsername() string { - if m != nil { - return m.Username - } - return "" -} - -func (m *DeleteUser) GetForceDeletion() bool { - if m != nil { - return m.ForceDeletion - } - return false -} - -type EnableLostMode struct { - Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` - PhoneNumber string `protobuf:"bytes,2,opt,name=phone_number,json=phoneNumber,proto3" json:"phone_number,omitempty"` - Footnote string `protobuf:"bytes,3,opt,name=footnote,proto3" json:"footnote,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *EnableLostMode) Reset() { *m = EnableLostMode{} } -func (m *EnableLostMode) String() string { return proto.CompactTextString(m) } -func (*EnableLostMode) ProtoMessage() {} -func (*EnableLostMode) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{15} -} -func (m *EnableLostMode) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *EnableLostMode) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_EnableLostMode.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *EnableLostMode) XXX_Merge(src proto.Message) { - xxx_messageInfo_EnableLostMode.Merge(m, src) -} -func (m *EnableLostMode) XXX_Size() int { - return m.Size() -} -func (m *EnableLostMode) XXX_DiscardUnknown() { - xxx_messageInfo_EnableLostMode.DiscardUnknown(m) -} - -var xxx_messageInfo_EnableLostMode proto.InternalMessageInfo - -func (m *EnableLostMode) GetMessage() string { - if m != nil { - return m.Message - } - return "" -} - -func (m *EnableLostMode) GetPhoneNumber() string { - if m != nil { - return m.PhoneNumber - } - return "" -} - -func (m *EnableLostMode) GetFootnote() string { - if m != nil { - return m.Footnote - } - return "" -} - -type InstallApplication struct { - ItunesStoreId int64 `protobuf:"varint,1,opt,name=itunes_store_id,json=itunesStoreId,proto3" json:"itunes_store_id,omitempty"` - Identifier string `protobuf:"bytes,2,opt,name=identifier,proto3" json:"identifier,omitempty"` - Options *InstallApplicationOptions `protobuf:"bytes,3,opt,name=options,proto3" json:"options,omitempty"` - ManifestUrl string `protobuf:"bytes,4,opt,name=manifest_url,json=manifestUrl,proto3" json:"manifest_url,omitempty"` - ManagementFlags int64 `protobuf:"varint,5,opt,name=management_flags,json=managementFlags,proto3" json:"management_flags,omitempty"` - Configuration *InstallApplicationConfiguration `protobuf:"bytes,6,opt,name=configuration,proto3" json:"configuration,omitempty"` - Attributes *InstallApplicationAttributes `protobuf:"bytes,7,opt,name=attributes,proto3" json:"attributes,omitempty"` - ChangeManagementState string `protobuf:"bytes,8,opt,name=change_management_state,json=changeManagementState,proto3" json:"change_management_state,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *InstallApplication) Reset() { *m = InstallApplication{} } -func (m *InstallApplication) String() string { return proto.CompactTextString(m) } -func (*InstallApplication) ProtoMessage() {} -func (*InstallApplication) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{16} -} -func (m *InstallApplication) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *InstallApplication) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_InstallApplication.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *InstallApplication) XXX_Merge(src proto.Message) { - xxx_messageInfo_InstallApplication.Merge(m, src) -} -func (m *InstallApplication) XXX_Size() int { - return m.Size() -} -func (m *InstallApplication) XXX_DiscardUnknown() { - xxx_messageInfo_InstallApplication.DiscardUnknown(m) -} - -var xxx_messageInfo_InstallApplication proto.InternalMessageInfo - -func (m *InstallApplication) GetItunesStoreId() int64 { - if m != nil { - return m.ItunesStoreId - } - return 0 -} - -func (m *InstallApplication) GetIdentifier() string { - if m != nil { - return m.Identifier - } - return "" -} - -func (m *InstallApplication) GetOptions() *InstallApplicationOptions { - if m != nil { - return m.Options - } - return nil -} - -func (m *InstallApplication) GetManifestUrl() string { - if m != nil { - return m.ManifestUrl - } - return "" -} - -func (m *InstallApplication) GetManagementFlags() int64 { - if m != nil { - return m.ManagementFlags - } - return 0 -} - -func (m *InstallApplication) GetConfiguration() *InstallApplicationConfiguration { - if m != nil { - return m.Configuration - } - return nil -} - -func (m *InstallApplication) GetAttributes() *InstallApplicationAttributes { - if m != nil { - return m.Attributes - } - return nil -} - -func (m *InstallApplication) GetChangeManagementState() string { - if m != nil { - return m.ChangeManagementState - } - return "" -} - -type InstallApplicationOptions struct { - PurchaseMethod int64 `protobuf:"varint,1,opt,name=purchase_method,json=purchaseMethod,proto3" json:"purchase_method,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *InstallApplicationOptions) Reset() { *m = InstallApplicationOptions{} } -func (m *InstallApplicationOptions) String() string { return proto.CompactTextString(m) } -func (*InstallApplicationOptions) ProtoMessage() {} -func (*InstallApplicationOptions) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{17} -} -func (m *InstallApplicationOptions) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *InstallApplicationOptions) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_InstallApplicationOptions.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *InstallApplicationOptions) XXX_Merge(src proto.Message) { - xxx_messageInfo_InstallApplicationOptions.Merge(m, src) -} -func (m *InstallApplicationOptions) XXX_Size() int { - return m.Size() -} -func (m *InstallApplicationOptions) XXX_DiscardUnknown() { - xxx_messageInfo_InstallApplicationOptions.DiscardUnknown(m) -} - -var xxx_messageInfo_InstallApplicationOptions proto.InternalMessageInfo - -func (m *InstallApplicationOptions) GetPurchaseMethod() int64 { - if m != nil { - return m.PurchaseMethod - } - return 0 -} - -type InstallApplicationConfiguration struct { - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *InstallApplicationConfiguration) Reset() { *m = InstallApplicationConfiguration{} } -func (m *InstallApplicationConfiguration) String() string { return proto.CompactTextString(m) } -func (*InstallApplicationConfiguration) ProtoMessage() {} -func (*InstallApplicationConfiguration) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{18} -} -func (m *InstallApplicationConfiguration) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *InstallApplicationConfiguration) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_InstallApplicationConfiguration.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *InstallApplicationConfiguration) XXX_Merge(src proto.Message) { - xxx_messageInfo_InstallApplicationConfiguration.Merge(m, src) -} -func (m *InstallApplicationConfiguration) XXX_Size() int { - return m.Size() -} -func (m *InstallApplicationConfiguration) XXX_DiscardUnknown() { - xxx_messageInfo_InstallApplicationConfiguration.DiscardUnknown(m) -} - -var xxx_messageInfo_InstallApplicationConfiguration proto.InternalMessageInfo - -type InstallApplicationAttributes struct { - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *InstallApplicationAttributes) Reset() { *m = InstallApplicationAttributes{} } -func (m *InstallApplicationAttributes) String() string { return proto.CompactTextString(m) } -func (*InstallApplicationAttributes) ProtoMessage() {} -func (*InstallApplicationAttributes) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{19} -} -func (m *InstallApplicationAttributes) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *InstallApplicationAttributes) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_InstallApplicationAttributes.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *InstallApplicationAttributes) XXX_Merge(src proto.Message) { - xxx_messageInfo_InstallApplicationAttributes.Merge(m, src) -} -func (m *InstallApplicationAttributes) XXX_Size() int { - return m.Size() -} -func (m *InstallApplicationAttributes) XXX_DiscardUnknown() { - xxx_messageInfo_InstallApplicationAttributes.DiscardUnknown(m) -} - -var xxx_messageInfo_InstallApplicationAttributes proto.InternalMessageInfo - -type InstallEnterpriseApplication struct { - Manifest *Manifest `protobuf:"bytes,1,opt,name=manifest,proto3" json:"manifest,omitempty"` - ManifestUrl string `protobuf:"bytes,2,opt,name=manifest_url,json=manifestUrl,proto3" json:"manifest_url,omitempty"` - ManifestUrlPinningCerts [][]byte `protobuf:"bytes,3,rep,name=manifest_url_pinning_certs,json=manifestUrlPinningCerts,proto3" json:"manifest_url_pinning_certs,omitempty"` - PinningRevocationCheckRequired bool `protobuf:"varint,4,opt,name=pinning_revocation_check_required,json=pinningRevocationCheckRequired,proto3" json:"pinning_revocation_check_required,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *InstallEnterpriseApplication) Reset() { *m = InstallEnterpriseApplication{} } -func (m *InstallEnterpriseApplication) String() string { return proto.CompactTextString(m) } -func (*InstallEnterpriseApplication) ProtoMessage() {} -func (*InstallEnterpriseApplication) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{20} -} -func (m *InstallEnterpriseApplication) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *InstallEnterpriseApplication) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_InstallEnterpriseApplication.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *InstallEnterpriseApplication) XXX_Merge(src proto.Message) { - xxx_messageInfo_InstallEnterpriseApplication.Merge(m, src) -} -func (m *InstallEnterpriseApplication) XXX_Size() int { - return m.Size() -} -func (m *InstallEnterpriseApplication) XXX_DiscardUnknown() { - xxx_messageInfo_InstallEnterpriseApplication.DiscardUnknown(m) -} - -var xxx_messageInfo_InstallEnterpriseApplication proto.InternalMessageInfo - -func (m *InstallEnterpriseApplication) GetManifest() *Manifest { - if m != nil { - return m.Manifest - } - return nil -} - -func (m *InstallEnterpriseApplication) GetManifestUrl() string { - if m != nil { - return m.ManifestUrl - } - return "" -} - -func (m *InstallEnterpriseApplication) GetManifestUrlPinningCerts() [][]byte { - if m != nil { - return m.ManifestUrlPinningCerts - } - return nil -} - -func (m *InstallEnterpriseApplication) GetPinningRevocationCheckRequired() bool { - if m != nil { - return m.PinningRevocationCheckRequired - } - return false -} - -type Manifest struct { - ManifestItems []*ManifestItem `protobuf:"bytes,1,rep,name=manifest_items,json=manifestItems,proto3" json:"manifest_items,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Manifest) Reset() { *m = Manifest{} } -func (m *Manifest) String() string { return proto.CompactTextString(m) } -func (*Manifest) ProtoMessage() {} -func (*Manifest) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{21} -} -func (m *Manifest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Manifest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Manifest.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Manifest) XXX_Merge(src proto.Message) { - xxx_messageInfo_Manifest.Merge(m, src) -} -func (m *Manifest) XXX_Size() int { - return m.Size() -} -func (m *Manifest) XXX_DiscardUnknown() { - xxx_messageInfo_Manifest.DiscardUnknown(m) -} - -var xxx_messageInfo_Manifest proto.InternalMessageInfo - -func (m *Manifest) GetManifestItems() []*ManifestItem { - if m != nil { - return m.ManifestItems - } - return nil -} - -type ManifestItem struct { - Assets []*Asset `protobuf:"bytes,1,rep,name=assets,proto3" json:"assets,omitempty"` - Metadata *Metadata `protobuf:"bytes,2,opt,name=metadata,proto3" json:"metadata,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ManifestItem) Reset() { *m = ManifestItem{} } -func (m *ManifestItem) String() string { return proto.CompactTextString(m) } -func (*ManifestItem) ProtoMessage() {} -func (*ManifestItem) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{22} -} -func (m *ManifestItem) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ManifestItem) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ManifestItem.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ManifestItem) XXX_Merge(src proto.Message) { - xxx_messageInfo_ManifestItem.Merge(m, src) -} -func (m *ManifestItem) XXX_Size() int { - return m.Size() -} -func (m *ManifestItem) XXX_DiscardUnknown() { - xxx_messageInfo_ManifestItem.DiscardUnknown(m) -} - -var xxx_messageInfo_ManifestItem proto.InternalMessageInfo - -func (m *ManifestItem) GetAssets() []*Asset { - if m != nil { - return m.Assets - } - return nil -} - -func (m *ManifestItem) GetMetadata() *Metadata { - if m != nil { - return m.Metadata - } - return nil -} - -type Asset struct { - Kind string `protobuf:"bytes,1,opt,name=kind,proto3" json:"kind,omitempty"` - Md5Size int64 `protobuf:"varint,2,opt,name=md5_size,json=md5Size,proto3" json:"md5_size,omitempty"` - Md5S []string `protobuf:"bytes,3,rep,name=md5s,proto3" json:"md5s,omitempty"` - Url string `protobuf:"bytes,4,opt,name=url,proto3" json:"url,omitempty"` - Sha256Size int64 `protobuf:"varint,5,opt,name=sha256_size,json=sha256Size,proto3" json:"sha256_size,omitempty"` - Sha256S []string `protobuf:"bytes,6,rep,name=sha256s,proto3" json:"sha256s,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Asset) Reset() { *m = Asset{} } -func (m *Asset) String() string { return proto.CompactTextString(m) } -func (*Asset) ProtoMessage() {} -func (*Asset) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{23} -} -func (m *Asset) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Asset) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Asset.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Asset) XXX_Merge(src proto.Message) { - xxx_messageInfo_Asset.Merge(m, src) -} -func (m *Asset) XXX_Size() int { - return m.Size() -} -func (m *Asset) XXX_DiscardUnknown() { - xxx_messageInfo_Asset.DiscardUnknown(m) -} - -var xxx_messageInfo_Asset proto.InternalMessageInfo - -func (m *Asset) GetKind() string { - if m != nil { - return m.Kind - } - return "" -} - -func (m *Asset) GetMd5Size() int64 { - if m != nil { - return m.Md5Size - } - return 0 -} - -func (m *Asset) GetMd5S() []string { - if m != nil { - return m.Md5S - } - return nil -} - -func (m *Asset) GetUrl() string { - if m != nil { - return m.Url - } - return "" -} - -func (m *Asset) GetSha256Size() int64 { - if m != nil { - return m.Sha256Size - } - return 0 -} - -func (m *Asset) GetSha256S() []string { - if m != nil { - return m.Sha256S - } - return nil -} - -type Metadata struct { - BundleIdentifier string `protobuf:"bytes,1,opt,name=bundle_identifier,json=bundleIdentifier,proto3" json:"bundle_identifier,omitempty"` - BundleVersion string `protobuf:"bytes,2,opt,name=bundle_version,json=bundleVersion,proto3" json:"bundle_version,omitempty"` - Items []*BundleInfo `protobuf:"bytes,3,rep,name=items,proto3" json:"items,omitempty"` - Kind string `protobuf:"bytes,4,opt,name=kind,proto3" json:"kind,omitempty"` - Subtitle string `protobuf:"bytes,5,opt,name=subtitle,proto3" json:"subtitle,omitempty"` - Title string `protobuf:"bytes,6,opt,name=title,proto3" json:"title,omitempty"` - SizeInBytes int64 `protobuf:"varint,7,opt,name=size_in_bytes,json=sizeInBytes,proto3" json:"size_in_bytes,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Metadata) Reset() { *m = Metadata{} } -func (m *Metadata) String() string { return proto.CompactTextString(m) } -func (*Metadata) ProtoMessage() {} -func (*Metadata) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{24} -} -func (m *Metadata) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Metadata) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Metadata.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Metadata) XXX_Merge(src proto.Message) { - xxx_messageInfo_Metadata.Merge(m, src) -} -func (m *Metadata) XXX_Size() int { - return m.Size() -} -func (m *Metadata) XXX_DiscardUnknown() { - xxx_messageInfo_Metadata.DiscardUnknown(m) -} - -var xxx_messageInfo_Metadata proto.InternalMessageInfo - -func (m *Metadata) GetBundleIdentifier() string { - if m != nil { - return m.BundleIdentifier - } - return "" -} - -func (m *Metadata) GetBundleVersion() string { - if m != nil { - return m.BundleVersion - } - return "" -} - -func (m *Metadata) GetItems() []*BundleInfo { - if m != nil { - return m.Items - } - return nil -} - -func (m *Metadata) GetKind() string { - if m != nil { - return m.Kind - } - return "" -} - -func (m *Metadata) GetSubtitle() string { - if m != nil { - return m.Subtitle - } - return "" -} - -func (m *Metadata) GetTitle() string { - if m != nil { - return m.Title - } - return "" -} - -func (m *Metadata) GetSizeInBytes() int64 { - if m != nil { - return m.SizeInBytes - } - return 0 -} - -type BundleInfo struct { - BundleIdentifier string `protobuf:"bytes,1,opt,name=bundle_identifier,json=bundleIdentifier,proto3" json:"bundle_identifier,omitempty"` - BundleVersion string `protobuf:"bytes,2,opt,name=bundle_version,json=bundleVersion,proto3" json:"bundle_version,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *BundleInfo) Reset() { *m = BundleInfo{} } -func (m *BundleInfo) String() string { return proto.CompactTextString(m) } -func (*BundleInfo) ProtoMessage() {} -func (*BundleInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{25} -} -func (m *BundleInfo) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *BundleInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_BundleInfo.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *BundleInfo) XXX_Merge(src proto.Message) { - xxx_messageInfo_BundleInfo.Merge(m, src) -} -func (m *BundleInfo) XXX_Size() int { - return m.Size() -} -func (m *BundleInfo) XXX_DiscardUnknown() { - xxx_messageInfo_BundleInfo.DiscardUnknown(m) -} - -var xxx_messageInfo_BundleInfo proto.InternalMessageInfo - -func (m *BundleInfo) GetBundleIdentifier() string { - if m != nil { - return m.BundleIdentifier - } - return "" -} - -func (m *BundleInfo) GetBundleVersion() string { - if m != nil { - return m.BundleVersion - } - return "" -} - -type ApplyRedemptionCode struct { - Identifier string `protobuf:"bytes,1,opt,name=identifier,proto3" json:"identifier,omitempty"` - RedemptionCode string `protobuf:"bytes,2,opt,name=redemption_code,json=redemptionCode,proto3" json:"redemption_code,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ApplyRedemptionCode) Reset() { *m = ApplyRedemptionCode{} } -func (m *ApplyRedemptionCode) String() string { return proto.CompactTextString(m) } -func (*ApplyRedemptionCode) ProtoMessage() {} -func (*ApplyRedemptionCode) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{26} -} -func (m *ApplyRedemptionCode) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ApplyRedemptionCode) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ApplyRedemptionCode.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ApplyRedemptionCode) XXX_Merge(src proto.Message) { - xxx_messageInfo_ApplyRedemptionCode.Merge(m, src) -} -func (m *ApplyRedemptionCode) XXX_Size() int { - return m.Size() -} -func (m *ApplyRedemptionCode) XXX_DiscardUnknown() { - xxx_messageInfo_ApplyRedemptionCode.DiscardUnknown(m) -} - -var xxx_messageInfo_ApplyRedemptionCode proto.InternalMessageInfo - -func (m *ApplyRedemptionCode) GetIdentifier() string { - if m != nil { - return m.Identifier - } - return "" -} - -func (m *ApplyRedemptionCode) GetRedemptionCode() string { - if m != nil { - return m.RedemptionCode - } - return "" -} - -type ManagedApplicationList struct { - Identifiers []string `protobuf:"bytes,1,rep,name=identifiers,proto3" json:"identifiers,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ManagedApplicationList) Reset() { *m = ManagedApplicationList{} } -func (m *ManagedApplicationList) String() string { return proto.CompactTextString(m) } -func (*ManagedApplicationList) ProtoMessage() {} -func (*ManagedApplicationList) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{27} -} -func (m *ManagedApplicationList) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ManagedApplicationList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ManagedApplicationList.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ManagedApplicationList) XXX_Merge(src proto.Message) { - xxx_messageInfo_ManagedApplicationList.Merge(m, src) -} -func (m *ManagedApplicationList) XXX_Size() int { - return m.Size() -} -func (m *ManagedApplicationList) XXX_DiscardUnknown() { - xxx_messageInfo_ManagedApplicationList.DiscardUnknown(m) -} - -var xxx_messageInfo_ManagedApplicationList proto.InternalMessageInfo - -func (m *ManagedApplicationList) GetIdentifiers() []string { - if m != nil { - return m.Identifiers - } - return nil -} - -type RemoveApplication struct { - Identifier string `protobuf:"bytes,1,opt,name=identifier,proto3" json:"identifier,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *RemoveApplication) Reset() { *m = RemoveApplication{} } -func (m *RemoveApplication) String() string { return proto.CompactTextString(m) } -func (*RemoveApplication) ProtoMessage() {} -func (*RemoveApplication) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{28} -} -func (m *RemoveApplication) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *RemoveApplication) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_RemoveApplication.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *RemoveApplication) XXX_Merge(src proto.Message) { - xxx_messageInfo_RemoveApplication.Merge(m, src) -} -func (m *RemoveApplication) XXX_Size() int { - return m.Size() -} -func (m *RemoveApplication) XXX_DiscardUnknown() { - xxx_messageInfo_RemoveApplication.DiscardUnknown(m) -} - -var xxx_messageInfo_RemoveApplication proto.InternalMessageInfo - -func (m *RemoveApplication) GetIdentifier() string { - if m != nil { - return m.Identifier - } - return "" -} - -type InviteToProgram struct { - ProgramId string `protobuf:"bytes,1,opt,name=program_id,json=programId,proto3" json:"program_id,omitempty"` - InvitationUrl string `protobuf:"bytes,2,opt,name=invitation_url,json=invitationUrl,proto3" json:"invitation_url,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *InviteToProgram) Reset() { *m = InviteToProgram{} } -func (m *InviteToProgram) String() string { return proto.CompactTextString(m) } -func (*InviteToProgram) ProtoMessage() {} -func (*InviteToProgram) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{29} -} -func (m *InviteToProgram) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *InviteToProgram) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_InviteToProgram.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *InviteToProgram) XXX_Merge(src proto.Message) { - xxx_messageInfo_InviteToProgram.Merge(m, src) -} -func (m *InviteToProgram) XXX_Size() int { - return m.Size() -} -func (m *InviteToProgram) XXX_DiscardUnknown() { - xxx_messageInfo_InviteToProgram.DiscardUnknown(m) -} - -var xxx_messageInfo_InviteToProgram proto.InternalMessageInfo - -func (m *InviteToProgram) GetProgramId() string { - if m != nil { - return m.ProgramId - } - return "" -} - -func (m *InviteToProgram) GetInvitationUrl() string { - if m != nil { - return m.InvitationUrl - } - return "" -} - -type ValidateApplications struct { - Identifiers []string `protobuf:"bytes,1,rep,name=identifiers,proto3" json:"identifiers,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ValidateApplications) Reset() { *m = ValidateApplications{} } -func (m *ValidateApplications) String() string { return proto.CompactTextString(m) } -func (*ValidateApplications) ProtoMessage() {} -func (*ValidateApplications) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{30} -} -func (m *ValidateApplications) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ValidateApplications) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ValidateApplications.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ValidateApplications) XXX_Merge(src proto.Message) { - xxx_messageInfo_ValidateApplications.Merge(m, src) -} -func (m *ValidateApplications) XXX_Size() int { - return m.Size() -} -func (m *ValidateApplications) XXX_DiscardUnknown() { - xxx_messageInfo_ValidateApplications.DiscardUnknown(m) -} - -var xxx_messageInfo_ValidateApplications proto.InternalMessageInfo - -func (m *ValidateApplications) GetIdentifiers() []string { - if m != nil { - return m.Identifiers - } - return nil -} - -type AccountConfiguration struct { - SkipPrimarySetupAccountCreation bool `protobuf:"varint,1,opt,name=skip_primary_setup_account_creation,json=skipPrimarySetupAccountCreation,proto3" json:"skip_primary_setup_account_creation,omitempty"` - SetPrimarySetupAccountAsRegularUser bool `protobuf:"varint,2,opt,name=set_primary_setup_account_as_regular_user,json=setPrimarySetupAccountAsRegularUser,proto3" json:"set_primary_setup_account_as_regular_user,omitempty"` - DontAutoPopulatePrimaryAccountInfo bool `protobuf:"varint,4,opt,name=dont_auto_populate_primary_account_info,json=dontAutoPopulatePrimaryAccountInfo,proto3" json:"dont_auto_populate_primary_account_info,omitempty"` - LockPrimaryAccountInfo bool `protobuf:"varint,5,opt,name=lock_primary_account_info,json=lockPrimaryAccountInfo,proto3" json:"lock_primary_account_info,omitempty"` - PrimaryAccountFullName string `protobuf:"bytes,6,opt,name=primary_account_full_name,json=primaryAccountFullName,proto3" json:"primary_account_full_name,omitempty"` - PrimaryAccountUserName string `protobuf:"bytes,7,opt,name=primary_account_user_name,json=primaryAccountUserName,proto3" json:"primary_account_user_name,omitempty"` - AutoSetupAdminAccounts []*AutoSetupAdminAccounts `protobuf:"bytes,3,rep,name=auto_setup_admin_accounts,json=autoSetupAdminAccounts,proto3" json:"auto_setup_admin_accounts,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *AccountConfiguration) Reset() { *m = AccountConfiguration{} } -func (m *AccountConfiguration) String() string { return proto.CompactTextString(m) } -func (*AccountConfiguration) ProtoMessage() {} -func (*AccountConfiguration) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{31} -} -func (m *AccountConfiguration) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *AccountConfiguration) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_AccountConfiguration.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *AccountConfiguration) XXX_Merge(src proto.Message) { - xxx_messageInfo_AccountConfiguration.Merge(m, src) -} -func (m *AccountConfiguration) XXX_Size() int { - return m.Size() -} -func (m *AccountConfiguration) XXX_DiscardUnknown() { - xxx_messageInfo_AccountConfiguration.DiscardUnknown(m) -} - -var xxx_messageInfo_AccountConfiguration proto.InternalMessageInfo - -func (m *AccountConfiguration) GetSkipPrimarySetupAccountCreation() bool { - if m != nil { - return m.SkipPrimarySetupAccountCreation - } - return false -} - -func (m *AccountConfiguration) GetSetPrimarySetupAccountAsRegularUser() bool { - if m != nil { - return m.SetPrimarySetupAccountAsRegularUser - } - return false -} - -func (m *AccountConfiguration) GetDontAutoPopulatePrimaryAccountInfo() bool { - if m != nil { - return m.DontAutoPopulatePrimaryAccountInfo - } - return false -} - -func (m *AccountConfiguration) GetLockPrimaryAccountInfo() bool { - if m != nil { - return m.LockPrimaryAccountInfo - } - return false -} - -func (m *AccountConfiguration) GetPrimaryAccountFullName() string { - if m != nil { - return m.PrimaryAccountFullName - } - return "" -} - -func (m *AccountConfiguration) GetPrimaryAccountUserName() string { - if m != nil { - return m.PrimaryAccountUserName - } - return "" -} - -func (m *AccountConfiguration) GetAutoSetupAdminAccounts() []*AutoSetupAdminAccounts { - if m != nil { - return m.AutoSetupAdminAccounts - } - return nil -} - -type AutoSetupAdminAccounts struct { - ShortName string `protobuf:"bytes,1,opt,name=short_name,json=shortName,proto3" json:"short_name,omitempty"` - FullName string `protobuf:"bytes,2,opt,name=full_name,json=fullName,proto3" json:"full_name,omitempty"` - PasswordHash []byte `protobuf:"bytes,3,opt,name=password_hash,json=passwordHash,proto3" json:"password_hash,omitempty"` - Hidden bool `protobuf:"varint,4,opt,name=hidden,proto3" json:"hidden,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *AutoSetupAdminAccounts) Reset() { *m = AutoSetupAdminAccounts{} } -func (m *AutoSetupAdminAccounts) String() string { return proto.CompactTextString(m) } -func (*AutoSetupAdminAccounts) ProtoMessage() {} -func (*AutoSetupAdminAccounts) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{32} -} -func (m *AutoSetupAdminAccounts) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *AutoSetupAdminAccounts) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_AutoSetupAdminAccounts.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *AutoSetupAdminAccounts) XXX_Merge(src proto.Message) { - xxx_messageInfo_AutoSetupAdminAccounts.Merge(m, src) -} -func (m *AutoSetupAdminAccounts) XXX_Size() int { - return m.Size() -} -func (m *AutoSetupAdminAccounts) XXX_DiscardUnknown() { - xxx_messageInfo_AutoSetupAdminAccounts.DiscardUnknown(m) -} - -var xxx_messageInfo_AutoSetupAdminAccounts proto.InternalMessageInfo - -func (m *AutoSetupAdminAccounts) GetShortName() string { - if m != nil { - return m.ShortName - } - return "" -} - -func (m *AutoSetupAdminAccounts) GetFullName() string { - if m != nil { - return m.FullName - } - return "" -} - -func (m *AutoSetupAdminAccounts) GetPasswordHash() []byte { - if m != nil { - return m.PasswordHash - } - return nil -} - -func (m *AutoSetupAdminAccounts) GetHidden() bool { - if m != nil { - return m.Hidden - } - return false -} - -type InstallMedia struct { - ItunesStoreId int64 `protobuf:"varint,1,opt,name=itunes_store_id,json=itunesStoreId,proto3" json:"itunes_store_id,omitempty"` - MediaUrl string `protobuf:"bytes,2,opt,name=media_url,json=mediaUrl,proto3" json:"media_url,omitempty"` - MediaType string `protobuf:"bytes,3,opt,name=media_type,json=mediaType,proto3" json:"media_type,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *InstallMedia) Reset() { *m = InstallMedia{} } -func (m *InstallMedia) String() string { return proto.CompactTextString(m) } -func (*InstallMedia) ProtoMessage() {} -func (*InstallMedia) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{33} -} -func (m *InstallMedia) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *InstallMedia) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_InstallMedia.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *InstallMedia) XXX_Merge(src proto.Message) { - xxx_messageInfo_InstallMedia.Merge(m, src) -} -func (m *InstallMedia) XXX_Size() int { - return m.Size() -} -func (m *InstallMedia) XXX_DiscardUnknown() { - xxx_messageInfo_InstallMedia.DiscardUnknown(m) -} - -var xxx_messageInfo_InstallMedia proto.InternalMessageInfo - -func (m *InstallMedia) GetItunesStoreId() int64 { - if m != nil { - return m.ItunesStoreId - } - return 0 -} - -func (m *InstallMedia) GetMediaUrl() string { - if m != nil { - return m.MediaUrl - } - return "" -} - -func (m *InstallMedia) GetMediaType() string { - if m != nil { - return m.MediaType - } - return "" -} - -type RemoveMedia struct { - MediaType string `protobuf:"bytes,1,opt,name=media_type,json=mediaType,proto3" json:"media_type,omitempty"` - ItunesStoreId int64 `protobuf:"varint,2,opt,name=itunes_store_id,json=itunesStoreId,proto3" json:"itunes_store_id,omitempty"` - PersistentId string `protobuf:"bytes,3,opt,name=persistent_id,json=persistentId,proto3" json:"persistent_id,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *RemoveMedia) Reset() { *m = RemoveMedia{} } -func (m *RemoveMedia) String() string { return proto.CompactTextString(m) } -func (*RemoveMedia) ProtoMessage() {} -func (*RemoveMedia) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{34} -} -func (m *RemoveMedia) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *RemoveMedia) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_RemoveMedia.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *RemoveMedia) XXX_Merge(src proto.Message) { - xxx_messageInfo_RemoveMedia.Merge(m, src) -} -func (m *RemoveMedia) XXX_Size() int { - return m.Size() -} -func (m *RemoveMedia) XXX_DiscardUnknown() { - xxx_messageInfo_RemoveMedia.DiscardUnknown(m) -} - -var xxx_messageInfo_RemoveMedia proto.InternalMessageInfo - -func (m *RemoveMedia) GetMediaType() string { - if m != nil { - return m.MediaType - } - return "" -} - -func (m *RemoveMedia) GetItunesStoreId() int64 { - if m != nil { - return m.ItunesStoreId - } - return 0 -} - -func (m *RemoveMedia) GetPersistentId() string { - if m != nil { - return m.PersistentId - } - return "" -} - -type Settings struct { - Settings []*Setting `protobuf:"bytes,1,rep,name=settings,proto3" json:"settings,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Settings) Reset() { *m = Settings{} } -func (m *Settings) String() string { return proto.CompactTextString(m) } -func (*Settings) ProtoMessage() {} -func (*Settings) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{35} -} -func (m *Settings) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Settings) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Settings.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Settings) XXX_Merge(src proto.Message) { - xxx_messageInfo_Settings.Merge(m, src) -} -func (m *Settings) XXX_Size() int { - return m.Size() -} -func (m *Settings) XXX_DiscardUnknown() { - xxx_messageInfo_Settings.DiscardUnknown(m) -} - -var xxx_messageInfo_Settings proto.InternalMessageInfo - -func (m *Settings) GetSettings() []*Setting { - if m != nil { - return m.Settings - } - return nil -} - -type Setting struct { - Item string `protobuf:"bytes,1,opt,name=item,proto3" json:"item,omitempty"` - DeviceName *DeviceNameSetting `protobuf:"bytes,2,opt,name=device_name,json=deviceName,proto3" json:"device_name,omitempty"` - Hostname *HostnameSetting `protobuf:"bytes,3,opt,name=hostname,proto3" json:"hostname,omitempty"` - VoiceRoaming *VoiceRoamingSetting `protobuf:"bytes,4,opt,name=voice_roaming,json=voiceRoaming,proto3" json:"voice_roaming,omitempty"` - PersonalHotspot *PersonalHotspotSetting `protobuf:"bytes,5,opt,name=personal_hotspot,json=personalHotspot,proto3" json:"personal_hotspot,omitempty"` - Wallpaper *WallpaperSetting `protobuf:"bytes,6,opt,name=wallpaper,proto3" json:"wallpaper,omitempty"` - DataRoaming *DataRoamingSetting `protobuf:"bytes,7,opt,name=data_roaming,json=dataRoaming,proto3" json:"data_roaming,omitempty"` - Bluetooth *BluetoothSetting `protobuf:"bytes,8,opt,name=bluetooth,proto3" json:"bluetooth,omitempty"` - ApplicationAttributes *ApplicationAttributesSetting `protobuf:"bytes,9,opt,name=application_attributes,json=applicationAttributes,proto3" json:"application_attributes,omitempty"` - MdmOptions *MDMOptionsSetting `protobuf:"bytes,10,opt,name=mdm_options,json=mdmOptions,proto3" json:"mdm_options,omitempty"` - PasscodeLockGracePeriod *PasscodeLockGracePeriodSetting `protobuf:"bytes,11,opt,name=passcode_lock_grace_period,json=passcodeLockGracePeriod,proto3" json:"passcode_lock_grace_period,omitempty"` - MaximumResidentUsers *MaximumResidentUsersSetting `protobuf:"bytes,12,opt,name=maximum_resident_users,json=maximumResidentUsers,proto3" json:"maximum_resident_users,omitempty"` - DiagnosticSubmission *DiagnosticSubmissionSetting `protobuf:"bytes,13,opt,name=diagnostic_submission,json=diagnosticSubmission,proto3" json:"diagnostic_submission,omitempty"` - AppAnalytics *AppAnalyticsSetting `protobuf:"bytes,14,opt,name=app_analytics,json=appAnalytics,proto3" json:"app_analytics,omitempty"` - ApplicationConfiguration *ApplicationConfigurationSetting `protobuf:"bytes,15,opt,name=application_configuration,json=applicationConfiguration,proto3" json:"application_configuration,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Setting) Reset() { *m = Setting{} } -func (m *Setting) String() string { return proto.CompactTextString(m) } -func (*Setting) ProtoMessage() {} -func (*Setting) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{36} -} -func (m *Setting) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Setting) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Setting.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Setting) XXX_Merge(src proto.Message) { - xxx_messageInfo_Setting.Merge(m, src) -} -func (m *Setting) XXX_Size() int { - return m.Size() -} -func (m *Setting) XXX_DiscardUnknown() { - xxx_messageInfo_Setting.DiscardUnknown(m) -} - -var xxx_messageInfo_Setting proto.InternalMessageInfo - -func (m *Setting) GetItem() string { - if m != nil { - return m.Item - } - return "" -} - -func (m *Setting) GetDeviceName() *DeviceNameSetting { - if m != nil { - return m.DeviceName - } - return nil -} - -func (m *Setting) GetHostname() *HostnameSetting { - if m != nil { - return m.Hostname - } - return nil -} - -func (m *Setting) GetVoiceRoaming() *VoiceRoamingSetting { - if m != nil { - return m.VoiceRoaming - } - return nil -} - -func (m *Setting) GetPersonalHotspot() *PersonalHotspotSetting { - if m != nil { - return m.PersonalHotspot - } - return nil -} - -func (m *Setting) GetWallpaper() *WallpaperSetting { - if m != nil { - return m.Wallpaper - } - return nil -} - -func (m *Setting) GetDataRoaming() *DataRoamingSetting { - if m != nil { - return m.DataRoaming - } - return nil -} - -func (m *Setting) GetBluetooth() *BluetoothSetting { - if m != nil { - return m.Bluetooth - } - return nil -} - -func (m *Setting) GetApplicationAttributes() *ApplicationAttributesSetting { - if m != nil { - return m.ApplicationAttributes - } - return nil -} - -func (m *Setting) GetMdmOptions() *MDMOptionsSetting { - if m != nil { - return m.MdmOptions - } - return nil -} - -func (m *Setting) GetPasscodeLockGracePeriod() *PasscodeLockGracePeriodSetting { - if m != nil { - return m.PasscodeLockGracePeriod - } - return nil -} - -func (m *Setting) GetMaximumResidentUsers() *MaximumResidentUsersSetting { - if m != nil { - return m.MaximumResidentUsers - } - return nil -} - -func (m *Setting) GetDiagnosticSubmission() *DiagnosticSubmissionSetting { - if m != nil { - return m.DiagnosticSubmission - } - return nil -} - -func (m *Setting) GetAppAnalytics() *AppAnalyticsSetting { - if m != nil { - return m.AppAnalytics - } - return nil -} - -func (m *Setting) GetApplicationConfiguration() *ApplicationConfigurationSetting { - if m != nil { - return m.ApplicationConfiguration - } - return nil -} - -type VoiceRoamingSetting struct { - Enabled bool `protobuf:"varint,1,opt,name=enabled,proto3" json:"enabled,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *VoiceRoamingSetting) Reset() { *m = VoiceRoamingSetting{} } -func (m *VoiceRoamingSetting) String() string { return proto.CompactTextString(m) } -func (*VoiceRoamingSetting) ProtoMessage() {} -func (*VoiceRoamingSetting) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{37} -} -func (m *VoiceRoamingSetting) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *VoiceRoamingSetting) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_VoiceRoamingSetting.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *VoiceRoamingSetting) XXX_Merge(src proto.Message) { - xxx_messageInfo_VoiceRoamingSetting.Merge(m, src) -} -func (m *VoiceRoamingSetting) XXX_Size() int { - return m.Size() -} -func (m *VoiceRoamingSetting) XXX_DiscardUnknown() { - xxx_messageInfo_VoiceRoamingSetting.DiscardUnknown(m) -} - -var xxx_messageInfo_VoiceRoamingSetting proto.InternalMessageInfo - -func (m *VoiceRoamingSetting) GetEnabled() bool { - if m != nil { - return m.Enabled - } - return false -} - -type PersonalHotspotSetting struct { - Enabled bool `protobuf:"varint,1,opt,name=enabled,proto3" json:"enabled,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *PersonalHotspotSetting) Reset() { *m = PersonalHotspotSetting{} } -func (m *PersonalHotspotSetting) String() string { return proto.CompactTextString(m) } -func (*PersonalHotspotSetting) ProtoMessage() {} -func (*PersonalHotspotSetting) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{38} -} -func (m *PersonalHotspotSetting) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *PersonalHotspotSetting) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_PersonalHotspotSetting.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *PersonalHotspotSetting) XXX_Merge(src proto.Message) { - xxx_messageInfo_PersonalHotspotSetting.Merge(m, src) -} -func (m *PersonalHotspotSetting) XXX_Size() int { - return m.Size() -} -func (m *PersonalHotspotSetting) XXX_DiscardUnknown() { - xxx_messageInfo_PersonalHotspotSetting.DiscardUnknown(m) -} - -var xxx_messageInfo_PersonalHotspotSetting proto.InternalMessageInfo - -func (m *PersonalHotspotSetting) GetEnabled() bool { - if m != nil { - return m.Enabled - } - return false -} - -type WallpaperSetting struct { - Image []byte `protobuf:"bytes,1,opt,name=image,proto3" json:"image,omitempty"` - Where int64 `protobuf:"varint,2,opt,name=where,proto3" json:"where,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *WallpaperSetting) Reset() { *m = WallpaperSetting{} } -func (m *WallpaperSetting) String() string { return proto.CompactTextString(m) } -func (*WallpaperSetting) ProtoMessage() {} -func (*WallpaperSetting) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{39} -} -func (m *WallpaperSetting) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *WallpaperSetting) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_WallpaperSetting.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *WallpaperSetting) XXX_Merge(src proto.Message) { - xxx_messageInfo_WallpaperSetting.Merge(m, src) -} -func (m *WallpaperSetting) XXX_Size() int { - return m.Size() -} -func (m *WallpaperSetting) XXX_DiscardUnknown() { - xxx_messageInfo_WallpaperSetting.DiscardUnknown(m) -} - -var xxx_messageInfo_WallpaperSetting proto.InternalMessageInfo - -func (m *WallpaperSetting) GetImage() []byte { - if m != nil { - return m.Image - } - return nil -} - -func (m *WallpaperSetting) GetWhere() int64 { - if m != nil { - return m.Where - } - return 0 -} - -type DataRoamingSetting struct { - Enabled bool `protobuf:"varint,1,opt,name=enabled,proto3" json:"enabled,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *DataRoamingSetting) Reset() { *m = DataRoamingSetting{} } -func (m *DataRoamingSetting) String() string { return proto.CompactTextString(m) } -func (*DataRoamingSetting) ProtoMessage() {} -func (*DataRoamingSetting) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{40} -} -func (m *DataRoamingSetting) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *DataRoamingSetting) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_DataRoamingSetting.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *DataRoamingSetting) XXX_Merge(src proto.Message) { - xxx_messageInfo_DataRoamingSetting.Merge(m, src) -} -func (m *DataRoamingSetting) XXX_Size() int { - return m.Size() -} -func (m *DataRoamingSetting) XXX_DiscardUnknown() { - xxx_messageInfo_DataRoamingSetting.DiscardUnknown(m) -} - -var xxx_messageInfo_DataRoamingSetting proto.InternalMessageInfo - -func (m *DataRoamingSetting) GetEnabled() bool { - if m != nil { - return m.Enabled - } - return false -} - -type BluetoothSetting struct { - Enabled bool `protobuf:"varint,1,opt,name=enabled,proto3" json:"enabled,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *BluetoothSetting) Reset() { *m = BluetoothSetting{} } -func (m *BluetoothSetting) String() string { return proto.CompactTextString(m) } -func (*BluetoothSetting) ProtoMessage() {} -func (*BluetoothSetting) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{41} -} -func (m *BluetoothSetting) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *BluetoothSetting) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_BluetoothSetting.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *BluetoothSetting) XXX_Merge(src proto.Message) { - xxx_messageInfo_BluetoothSetting.Merge(m, src) -} -func (m *BluetoothSetting) XXX_Size() int { - return m.Size() -} -func (m *BluetoothSetting) XXX_DiscardUnknown() { - xxx_messageInfo_BluetoothSetting.DiscardUnknown(m) -} - -var xxx_messageInfo_BluetoothSetting proto.InternalMessageInfo - -func (m *BluetoothSetting) GetEnabled() bool { - if m != nil { - return m.Enabled - } - return false -} - -type ApplicationAttributesSetting struct { - Identifier string `protobuf:"bytes,1,opt,name=identifier,proto3" json:"identifier,omitempty"` - ApplicationAttributes *ApplicationAttributes `protobuf:"bytes,2,opt,name=application_attributes,json=applicationAttributes,proto3" json:"application_attributes,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ApplicationAttributesSetting) Reset() { *m = ApplicationAttributesSetting{} } -func (m *ApplicationAttributesSetting) String() string { return proto.CompactTextString(m) } -func (*ApplicationAttributesSetting) ProtoMessage() {} -func (*ApplicationAttributesSetting) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{42} -} -func (m *ApplicationAttributesSetting) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ApplicationAttributesSetting) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ApplicationAttributesSetting.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ApplicationAttributesSetting) XXX_Merge(src proto.Message) { - xxx_messageInfo_ApplicationAttributesSetting.Merge(m, src) -} -func (m *ApplicationAttributesSetting) XXX_Size() int { - return m.Size() -} -func (m *ApplicationAttributesSetting) XXX_DiscardUnknown() { - xxx_messageInfo_ApplicationAttributesSetting.DiscardUnknown(m) -} - -var xxx_messageInfo_ApplicationAttributesSetting proto.InternalMessageInfo - -func (m *ApplicationAttributesSetting) GetIdentifier() string { - if m != nil { - return m.Identifier - } - return "" -} - -func (m *ApplicationAttributesSetting) GetApplicationAttributes() *ApplicationAttributes { - if m != nil { - return m.ApplicationAttributes - } - return nil -} - -type ApplicationConfigurationSetting struct { - Identifier string `protobuf:"bytes,1,opt,name=identifier,proto3" json:"identifier,omitempty"` - ConfigurationDictionaryData []byte `protobuf:"bytes,2,opt,name=configuration_dictionary_data,json=configurationDictionaryData,proto3" json:"configuration_dictionary_data,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ApplicationConfigurationSetting) Reset() { *m = ApplicationConfigurationSetting{} } -func (m *ApplicationConfigurationSetting) String() string { return proto.CompactTextString(m) } -func (*ApplicationConfigurationSetting) ProtoMessage() {} -func (*ApplicationConfigurationSetting) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{43} -} -func (m *ApplicationConfigurationSetting) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ApplicationConfigurationSetting) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ApplicationConfigurationSetting.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ApplicationConfigurationSetting) XXX_Merge(src proto.Message) { - xxx_messageInfo_ApplicationConfigurationSetting.Merge(m, src) -} -func (m *ApplicationConfigurationSetting) XXX_Size() int { - return m.Size() -} -func (m *ApplicationConfigurationSetting) XXX_DiscardUnknown() { - xxx_messageInfo_ApplicationConfigurationSetting.DiscardUnknown(m) -} - -var xxx_messageInfo_ApplicationConfigurationSetting proto.InternalMessageInfo - -func (m *ApplicationConfigurationSetting) GetIdentifier() string { - if m != nil { - return m.Identifier - } - return "" -} - -func (m *ApplicationConfigurationSetting) GetConfigurationDictionaryData() []byte { - if m != nil { - return m.ConfigurationDictionaryData - } - return nil -} - -type ApplicationAttributes struct { - VpnUuid string `protobuf:"bytes,1,opt,name=vpn_uuid,json=vpnUuid,proto3" json:"vpn_uuid,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ApplicationAttributes) Reset() { *m = ApplicationAttributes{} } -func (m *ApplicationAttributes) String() string { return proto.CompactTextString(m) } -func (*ApplicationAttributes) ProtoMessage() {} -func (*ApplicationAttributes) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{44} -} -func (m *ApplicationAttributes) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ApplicationAttributes) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ApplicationAttributes.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ApplicationAttributes) XXX_Merge(src proto.Message) { - xxx_messageInfo_ApplicationAttributes.Merge(m, src) -} -func (m *ApplicationAttributes) XXX_Size() int { - return m.Size() -} -func (m *ApplicationAttributes) XXX_DiscardUnknown() { - xxx_messageInfo_ApplicationAttributes.DiscardUnknown(m) -} - -var xxx_messageInfo_ApplicationAttributes proto.InternalMessageInfo - -func (m *ApplicationAttributes) GetVpnUuid() string { - if m != nil { - return m.VpnUuid - } - return "" -} - -type DeviceNameSetting struct { - DeviceName string `protobuf:"bytes,1,opt,name=device_name,json=deviceName,proto3" json:"device_name,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *DeviceNameSetting) Reset() { *m = DeviceNameSetting{} } -func (m *DeviceNameSetting) String() string { return proto.CompactTextString(m) } -func (*DeviceNameSetting) ProtoMessage() {} -func (*DeviceNameSetting) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{45} -} -func (m *DeviceNameSetting) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *DeviceNameSetting) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_DeviceNameSetting.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *DeviceNameSetting) XXX_Merge(src proto.Message) { - xxx_messageInfo_DeviceNameSetting.Merge(m, src) -} -func (m *DeviceNameSetting) XXX_Size() int { - return m.Size() -} -func (m *DeviceNameSetting) XXX_DiscardUnknown() { - xxx_messageInfo_DeviceNameSetting.DiscardUnknown(m) -} - -var xxx_messageInfo_DeviceNameSetting proto.InternalMessageInfo - -func (m *DeviceNameSetting) GetDeviceName() string { - if m != nil { - return m.DeviceName - } - return "" -} - -type HostnameSetting struct { - Hostname string `protobuf:"bytes,1,opt,name=hostname,proto3" json:"hostname,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *HostnameSetting) Reset() { *m = HostnameSetting{} } -func (m *HostnameSetting) String() string { return proto.CompactTextString(m) } -func (*HostnameSetting) ProtoMessage() {} -func (*HostnameSetting) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{46} -} -func (m *HostnameSetting) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *HostnameSetting) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_HostnameSetting.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *HostnameSetting) XXX_Merge(src proto.Message) { - xxx_messageInfo_HostnameSetting.Merge(m, src) -} -func (m *HostnameSetting) XXX_Size() int { - return m.Size() -} -func (m *HostnameSetting) XXX_DiscardUnknown() { - xxx_messageInfo_HostnameSetting.DiscardUnknown(m) -} - -var xxx_messageInfo_HostnameSetting proto.InternalMessageInfo - -func (m *HostnameSetting) GetHostname() string { - if m != nil { - return m.Hostname - } - return "" -} - -type MDMOptionsSetting struct { - MdmOptions *MDMOptions `protobuf:"bytes,1,opt,name=mdm_options,json=mdmOptions,proto3" json:"mdm_options,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *MDMOptionsSetting) Reset() { *m = MDMOptionsSetting{} } -func (m *MDMOptionsSetting) String() string { return proto.CompactTextString(m) } -func (*MDMOptionsSetting) ProtoMessage() {} -func (*MDMOptionsSetting) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{47} -} -func (m *MDMOptionsSetting) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MDMOptionsSetting) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MDMOptionsSetting.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *MDMOptionsSetting) XXX_Merge(src proto.Message) { - xxx_messageInfo_MDMOptionsSetting.Merge(m, src) -} -func (m *MDMOptionsSetting) XXX_Size() int { - return m.Size() -} -func (m *MDMOptionsSetting) XXX_DiscardUnknown() { - xxx_messageInfo_MDMOptionsSetting.DiscardUnknown(m) -} - -var xxx_messageInfo_MDMOptionsSetting proto.InternalMessageInfo - -func (m *MDMOptionsSetting) GetMdmOptions() *MDMOptions { - if m != nil { - return m.MdmOptions - } - return nil -} - -type MDMOptions struct { - ActivationLockAllowedWhileSupervised bool `protobuf:"varint,1,opt,name=activation_lock_allowed_while_supervised,json=activationLockAllowedWhileSupervised,proto3" json:"activation_lock_allowed_while_supervised,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *MDMOptions) Reset() { *m = MDMOptions{} } -func (m *MDMOptions) String() string { return proto.CompactTextString(m) } -func (*MDMOptions) ProtoMessage() {} -func (*MDMOptions) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{48} -} -func (m *MDMOptions) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MDMOptions) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MDMOptions.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *MDMOptions) XXX_Merge(src proto.Message) { - xxx_messageInfo_MDMOptions.Merge(m, src) -} -func (m *MDMOptions) XXX_Size() int { - return m.Size() -} -func (m *MDMOptions) XXX_DiscardUnknown() { - xxx_messageInfo_MDMOptions.DiscardUnknown(m) -} - -var xxx_messageInfo_MDMOptions proto.InternalMessageInfo - -func (m *MDMOptions) GetActivationLockAllowedWhileSupervised() bool { - if m != nil { - return m.ActivationLockAllowedWhileSupervised - } - return false -} - -type PasscodeLockGracePeriodSetting struct { - PasscodeLockGracePeriod int64 `protobuf:"varint,1,opt,name=passcode_lock_grace_period,json=passcodeLockGracePeriod,proto3" json:"passcode_lock_grace_period,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *PasscodeLockGracePeriodSetting) Reset() { *m = PasscodeLockGracePeriodSetting{} } -func (m *PasscodeLockGracePeriodSetting) String() string { return proto.CompactTextString(m) } -func (*PasscodeLockGracePeriodSetting) ProtoMessage() {} -func (*PasscodeLockGracePeriodSetting) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{49} -} -func (m *PasscodeLockGracePeriodSetting) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *PasscodeLockGracePeriodSetting) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_PasscodeLockGracePeriodSetting.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *PasscodeLockGracePeriodSetting) XXX_Merge(src proto.Message) { - xxx_messageInfo_PasscodeLockGracePeriodSetting.Merge(m, src) -} -func (m *PasscodeLockGracePeriodSetting) XXX_Size() int { - return m.Size() -} -func (m *PasscodeLockGracePeriodSetting) XXX_DiscardUnknown() { - xxx_messageInfo_PasscodeLockGracePeriodSetting.DiscardUnknown(m) -} - -var xxx_messageInfo_PasscodeLockGracePeriodSetting proto.InternalMessageInfo - -func (m *PasscodeLockGracePeriodSetting) GetPasscodeLockGracePeriod() int64 { - if m != nil { - return m.PasscodeLockGracePeriod - } - return 0 -} - -type MaximumResidentUsersSetting struct { - MaximumResidentUsers int64 `protobuf:"varint,1,opt,name=maximum_resident_users,json=maximumResidentUsers,proto3" json:"maximum_resident_users,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *MaximumResidentUsersSetting) Reset() { *m = MaximumResidentUsersSetting{} } -func (m *MaximumResidentUsersSetting) String() string { return proto.CompactTextString(m) } -func (*MaximumResidentUsersSetting) ProtoMessage() {} -func (*MaximumResidentUsersSetting) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{50} -} -func (m *MaximumResidentUsersSetting) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MaximumResidentUsersSetting) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MaximumResidentUsersSetting.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *MaximumResidentUsersSetting) XXX_Merge(src proto.Message) { - xxx_messageInfo_MaximumResidentUsersSetting.Merge(m, src) -} -func (m *MaximumResidentUsersSetting) XXX_Size() int { - return m.Size() -} -func (m *MaximumResidentUsersSetting) XXX_DiscardUnknown() { - xxx_messageInfo_MaximumResidentUsersSetting.DiscardUnknown(m) -} - -var xxx_messageInfo_MaximumResidentUsersSetting proto.InternalMessageInfo - -func (m *MaximumResidentUsersSetting) GetMaximumResidentUsers() int64 { - if m != nil { - return m.MaximumResidentUsers - } - return 0 -} - -type DiagnosticSubmissionSetting struct { - Enabled bool `protobuf:"varint,1,opt,name=enabled,proto3" json:"enabled,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *DiagnosticSubmissionSetting) Reset() { *m = DiagnosticSubmissionSetting{} } -func (m *DiagnosticSubmissionSetting) String() string { return proto.CompactTextString(m) } -func (*DiagnosticSubmissionSetting) ProtoMessage() {} -func (*DiagnosticSubmissionSetting) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{51} -} -func (m *DiagnosticSubmissionSetting) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *DiagnosticSubmissionSetting) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_DiagnosticSubmissionSetting.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *DiagnosticSubmissionSetting) XXX_Merge(src proto.Message) { - xxx_messageInfo_DiagnosticSubmissionSetting.Merge(m, src) -} -func (m *DiagnosticSubmissionSetting) XXX_Size() int { - return m.Size() -} -func (m *DiagnosticSubmissionSetting) XXX_DiscardUnknown() { - xxx_messageInfo_DiagnosticSubmissionSetting.DiscardUnknown(m) -} - -var xxx_messageInfo_DiagnosticSubmissionSetting proto.InternalMessageInfo - -func (m *DiagnosticSubmissionSetting) GetEnabled() bool { - if m != nil { - return m.Enabled - } - return false -} - -type AppAnalyticsSetting struct { - Enabled bool `protobuf:"varint,1,opt,name=enabled,proto3" json:"enabled,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *AppAnalyticsSetting) Reset() { *m = AppAnalyticsSetting{} } -func (m *AppAnalyticsSetting) String() string { return proto.CompactTextString(m) } -func (*AppAnalyticsSetting) ProtoMessage() {} -func (*AppAnalyticsSetting) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{52} -} -func (m *AppAnalyticsSetting) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *AppAnalyticsSetting) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_AppAnalyticsSetting.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *AppAnalyticsSetting) XXX_Merge(src proto.Message) { - xxx_messageInfo_AppAnalyticsSetting.Merge(m, src) -} -func (m *AppAnalyticsSetting) XXX_Size() int { - return m.Size() -} -func (m *AppAnalyticsSetting) XXX_DiscardUnknown() { - xxx_messageInfo_AppAnalyticsSetting.DiscardUnknown(m) -} - -var xxx_messageInfo_AppAnalyticsSetting proto.InternalMessageInfo - -func (m *AppAnalyticsSetting) GetEnabled() bool { - if m != nil { - return m.Enabled - } - return false -} - -type ManagedApplicationConfiguration struct { - Identifiers []string `protobuf:"bytes,1,rep,name=identifiers,proto3" json:"identifiers,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ManagedApplicationConfiguration) Reset() { *m = ManagedApplicationConfiguration{} } -func (m *ManagedApplicationConfiguration) String() string { return proto.CompactTextString(m) } -func (*ManagedApplicationConfiguration) ProtoMessage() {} -func (*ManagedApplicationConfiguration) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{53} -} -func (m *ManagedApplicationConfiguration) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ManagedApplicationConfiguration) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ManagedApplicationConfiguration.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ManagedApplicationConfiguration) XXX_Merge(src proto.Message) { - xxx_messageInfo_ManagedApplicationConfiguration.Merge(m, src) -} -func (m *ManagedApplicationConfiguration) XXX_Size() int { - return m.Size() -} -func (m *ManagedApplicationConfiguration) XXX_DiscardUnknown() { - xxx_messageInfo_ManagedApplicationConfiguration.DiscardUnknown(m) -} - -var xxx_messageInfo_ManagedApplicationConfiguration proto.InternalMessageInfo - -func (m *ManagedApplicationConfiguration) GetIdentifiers() []string { - if m != nil { - return m.Identifiers - } - return nil -} - -type ManagedApplicationAttributes struct { - Identifiers []string `protobuf:"bytes,1,rep,name=identifiers,proto3" json:"identifiers,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ManagedApplicationAttributes) Reset() { *m = ManagedApplicationAttributes{} } -func (m *ManagedApplicationAttributes) String() string { return proto.CompactTextString(m) } -func (*ManagedApplicationAttributes) ProtoMessage() {} -func (*ManagedApplicationAttributes) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{54} -} -func (m *ManagedApplicationAttributes) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ManagedApplicationAttributes) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ManagedApplicationAttributes.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ManagedApplicationAttributes) XXX_Merge(src proto.Message) { - xxx_messageInfo_ManagedApplicationAttributes.Merge(m, src) -} -func (m *ManagedApplicationAttributes) XXX_Size() int { - return m.Size() -} -func (m *ManagedApplicationAttributes) XXX_DiscardUnknown() { - xxx_messageInfo_ManagedApplicationAttributes.DiscardUnknown(m) -} - -var xxx_messageInfo_ManagedApplicationAttributes proto.InternalMessageInfo - -func (m *ManagedApplicationAttributes) GetIdentifiers() []string { - if m != nil { - return m.Identifiers - } - return nil -} - -type ManagedApplicationFeedback struct { - Identifiers []string `protobuf:"bytes,1,rep,name=identifiers,proto3" json:"identifiers,omitempty"` - DeleteFeedback bool `protobuf:"varint,2,opt,name=delete_feedback,json=deleteFeedback,proto3" json:"delete_feedback,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ManagedApplicationFeedback) Reset() { *m = ManagedApplicationFeedback{} } -func (m *ManagedApplicationFeedback) String() string { return proto.CompactTextString(m) } -func (*ManagedApplicationFeedback) ProtoMessage() {} -func (*ManagedApplicationFeedback) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{55} -} -func (m *ManagedApplicationFeedback) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ManagedApplicationFeedback) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ManagedApplicationFeedback.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ManagedApplicationFeedback) XXX_Merge(src proto.Message) { - xxx_messageInfo_ManagedApplicationFeedback.Merge(m, src) -} -func (m *ManagedApplicationFeedback) XXX_Size() int { - return m.Size() -} -func (m *ManagedApplicationFeedback) XXX_DiscardUnknown() { - xxx_messageInfo_ManagedApplicationFeedback.DiscardUnknown(m) -} - -var xxx_messageInfo_ManagedApplicationFeedback proto.InternalMessageInfo - -func (m *ManagedApplicationFeedback) GetIdentifiers() []string { - if m != nil { - return m.Identifiers - } - return nil -} - -func (m *ManagedApplicationFeedback) GetDeleteFeedback() bool { - if m != nil { - return m.DeleteFeedback - } - return false -} - -type SetFirmwarePassword struct { - CurrentPassword string `protobuf:"bytes,1,opt,name=current_password,json=currentPassword,proto3" json:"current_password,omitempty"` - NewPassword string `protobuf:"bytes,2,opt,name=new_password,json=newPassword,proto3" json:"new_password,omitempty"` - AllowOroms bool `protobuf:"varint,3,opt,name=allow_oroms,json=allowOroms,proto3" json:"allow_oroms,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *SetFirmwarePassword) Reset() { *m = SetFirmwarePassword{} } -func (m *SetFirmwarePassword) String() string { return proto.CompactTextString(m) } -func (*SetFirmwarePassword) ProtoMessage() {} -func (*SetFirmwarePassword) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{56} -} -func (m *SetFirmwarePassword) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *SetFirmwarePassword) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_SetFirmwarePassword.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *SetFirmwarePassword) XXX_Merge(src proto.Message) { - xxx_messageInfo_SetFirmwarePassword.Merge(m, src) -} -func (m *SetFirmwarePassword) XXX_Size() int { - return m.Size() -} -func (m *SetFirmwarePassword) XXX_DiscardUnknown() { - xxx_messageInfo_SetFirmwarePassword.DiscardUnknown(m) -} - -var xxx_messageInfo_SetFirmwarePassword proto.InternalMessageInfo - -func (m *SetFirmwarePassword) GetCurrentPassword() string { - if m != nil { - return m.CurrentPassword - } - return "" -} - -func (m *SetFirmwarePassword) GetNewPassword() string { - if m != nil { - return m.NewPassword - } - return "" -} - -func (m *SetFirmwarePassword) GetAllowOroms() bool { - if m != nil { - return m.AllowOroms - } - return false -} - -type VerifyFirmwarePassword struct { - Password string `protobuf:"bytes,1,opt,name=password,proto3" json:"password,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *VerifyFirmwarePassword) Reset() { *m = VerifyFirmwarePassword{} } -func (m *VerifyFirmwarePassword) String() string { return proto.CompactTextString(m) } -func (*VerifyFirmwarePassword) ProtoMessage() {} -func (*VerifyFirmwarePassword) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{57} -} -func (m *VerifyFirmwarePassword) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *VerifyFirmwarePassword) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_VerifyFirmwarePassword.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *VerifyFirmwarePassword) XXX_Merge(src proto.Message) { - xxx_messageInfo_VerifyFirmwarePassword.Merge(m, src) -} -func (m *VerifyFirmwarePassword) XXX_Size() int { - return m.Size() -} -func (m *VerifyFirmwarePassword) XXX_DiscardUnknown() { - xxx_messageInfo_VerifyFirmwarePassword.DiscardUnknown(m) -} - -var xxx_messageInfo_VerifyFirmwarePassword proto.InternalMessageInfo - -func (m *VerifyFirmwarePassword) GetPassword() string { - if m != nil { - return m.Password - } - return "" -} - -type SetAutoAdminPassword struct { - Guid string `protobuf:"bytes,1,opt,name=guid,proto3" json:"guid,omitempty"` - PasswordHash []byte `protobuf:"bytes,2,opt,name=password_hash,json=passwordHash,proto3" json:"password_hash,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *SetAutoAdminPassword) Reset() { *m = SetAutoAdminPassword{} } -func (m *SetAutoAdminPassword) String() string { return proto.CompactTextString(m) } -func (*SetAutoAdminPassword) ProtoMessage() {} -func (*SetAutoAdminPassword) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{58} -} -func (m *SetAutoAdminPassword) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *SetAutoAdminPassword) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_SetAutoAdminPassword.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *SetAutoAdminPassword) XXX_Merge(src proto.Message) { - xxx_messageInfo_SetAutoAdminPassword.Merge(m, src) -} -func (m *SetAutoAdminPassword) XXX_Size() int { - return m.Size() -} -func (m *SetAutoAdminPassword) XXX_DiscardUnknown() { - xxx_messageInfo_SetAutoAdminPassword.DiscardUnknown(m) -} - -var xxx_messageInfo_SetAutoAdminPassword proto.InternalMessageInfo - -func (m *SetAutoAdminPassword) GetGuid() string { - if m != nil { - return m.Guid - } - return "" -} - -func (m *SetAutoAdminPassword) GetPasswordHash() []byte { - if m != nil { - return m.PasswordHash - } - return nil -} - -type ScheduleOSUpdate struct { - Updates []*Update `protobuf:"bytes,1,rep,name=updates,proto3" json:"updates,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ScheduleOSUpdate) Reset() { *m = ScheduleOSUpdate{} } -func (m *ScheduleOSUpdate) String() string { return proto.CompactTextString(m) } -func (*ScheduleOSUpdate) ProtoMessage() {} -func (*ScheduleOSUpdate) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{59} -} -func (m *ScheduleOSUpdate) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ScheduleOSUpdate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ScheduleOSUpdate.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ScheduleOSUpdate) XXX_Merge(src proto.Message) { - xxx_messageInfo_ScheduleOSUpdate.Merge(m, src) -} -func (m *ScheduleOSUpdate) XXX_Size() int { - return m.Size() -} -func (m *ScheduleOSUpdate) XXX_DiscardUnknown() { - xxx_messageInfo_ScheduleOSUpdate.DiscardUnknown(m) -} - -var xxx_messageInfo_ScheduleOSUpdate proto.InternalMessageInfo - -func (m *ScheduleOSUpdate) GetUpdates() []*Update { - if m != nil { - return m.Updates - } - return nil -} - -type Update struct { - ProductKey string `protobuf:"bytes,1,opt,name=product_key,json=productKey,proto3" json:"product_key,omitempty"` - ProductVersion string `protobuf:"bytes,2,opt,name=product_version,json=productVersion,proto3" json:"product_version,omitempty"` - InstallAction string `protobuf:"bytes,3,opt,name=install_action,json=installAction,proto3" json:"install_action,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *Update) Reset() { *m = Update{} } -func (m *Update) String() string { return proto.CompactTextString(m) } -func (*Update) ProtoMessage() {} -func (*Update) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{60} -} -func (m *Update) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Update) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Update.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Update) XXX_Merge(src proto.Message) { - xxx_messageInfo_Update.Merge(m, src) -} -func (m *Update) XXX_Size() int { - return m.Size() -} -func (m *Update) XXX_DiscardUnknown() { - xxx_messageInfo_Update.DiscardUnknown(m) -} - -var xxx_messageInfo_Update proto.InternalMessageInfo - -func (m *Update) GetProductKey() string { - if m != nil { - return m.ProductKey - } - return "" -} - -func (m *Update) GetProductVersion() string { - if m != nil { - return m.ProductVersion - } - return "" -} - -func (m *Update) GetInstallAction() string { - if m != nil { - return m.InstallAction - } - return "" -} - -type ScheduleOSUpdateScan struct { - Force bool `protobuf:"varint,1,opt,name=force,proto3" json:"force,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ScheduleOSUpdateScan) Reset() { *m = ScheduleOSUpdateScan{} } -func (m *ScheduleOSUpdateScan) String() string { return proto.CompactTextString(m) } -func (*ScheduleOSUpdateScan) ProtoMessage() {} -func (*ScheduleOSUpdateScan) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{61} -} -func (m *ScheduleOSUpdateScan) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ScheduleOSUpdateScan) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ScheduleOSUpdateScan.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ScheduleOSUpdateScan) XXX_Merge(src proto.Message) { - xxx_messageInfo_ScheduleOSUpdateScan.Merge(m, src) -} -func (m *ScheduleOSUpdateScan) XXX_Size() int { - return m.Size() -} -func (m *ScheduleOSUpdateScan) XXX_DiscardUnknown() { - xxx_messageInfo_ScheduleOSUpdateScan.DiscardUnknown(m) -} - -var xxx_messageInfo_ScheduleOSUpdateScan proto.InternalMessageInfo - -func (m *ScheduleOSUpdateScan) GetForce() bool { - if m != nil { - return m.Force - } - return false -} - -type ActiveNSExtensions struct { - FilterExtensionPoints []string `protobuf:"bytes,1,rep,name=filter_extension_points,json=filterExtensionPoints,proto3" json:"filter_extension_points,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ActiveNSExtensions) Reset() { *m = ActiveNSExtensions{} } -func (m *ActiveNSExtensions) String() string { return proto.CompactTextString(m) } -func (*ActiveNSExtensions) ProtoMessage() {} -func (*ActiveNSExtensions) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{62} -} -func (m *ActiveNSExtensions) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ActiveNSExtensions) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ActiveNSExtensions.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ActiveNSExtensions) XXX_Merge(src proto.Message) { - xxx_messageInfo_ActiveNSExtensions.Merge(m, src) -} -func (m *ActiveNSExtensions) XXX_Size() int { - return m.Size() -} -func (m *ActiveNSExtensions) XXX_DiscardUnknown() { - xxx_messageInfo_ActiveNSExtensions.DiscardUnknown(m) -} - -var xxx_messageInfo_ActiveNSExtensions proto.InternalMessageInfo - -func (m *ActiveNSExtensions) GetFilterExtensionPoints() []string { - if m != nil { - return m.FilterExtensionPoints - } - return nil -} - -type RotateFileVaultKey struct { - KeyType string `protobuf:"bytes,1,opt,name=key_type,json=keyType,proto3" json:"key_type,omitempty"` - FilevaultUnlock *FileVaultUnlock `protobuf:"bytes,2,opt,name=filevault_unlock,json=filevaultUnlock,proto3" json:"filevault_unlock,omitempty"` - NewCertificate []byte `protobuf:"bytes,3,opt,name=new_certificate,json=newCertificate,proto3" json:"new_certificate,omitempty"` - ReplyEncryptionCertificate []byte `protobuf:"bytes,4,opt,name=reply_encryption_certificate,json=replyEncryptionCertificate,proto3" json:"reply_encryption_certificate,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *RotateFileVaultKey) Reset() { *m = RotateFileVaultKey{} } -func (m *RotateFileVaultKey) String() string { return proto.CompactTextString(m) } -func (*RotateFileVaultKey) ProtoMessage() {} -func (*RotateFileVaultKey) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{63} -} -func (m *RotateFileVaultKey) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *RotateFileVaultKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_RotateFileVaultKey.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *RotateFileVaultKey) XXX_Merge(src proto.Message) { - xxx_messageInfo_RotateFileVaultKey.Merge(m, src) -} -func (m *RotateFileVaultKey) XXX_Size() int { - return m.Size() -} -func (m *RotateFileVaultKey) XXX_DiscardUnknown() { - xxx_messageInfo_RotateFileVaultKey.DiscardUnknown(m) -} - -var xxx_messageInfo_RotateFileVaultKey proto.InternalMessageInfo - -func (m *RotateFileVaultKey) GetKeyType() string { - if m != nil { - return m.KeyType - } - return "" -} - -func (m *RotateFileVaultKey) GetFilevaultUnlock() *FileVaultUnlock { - if m != nil { - return m.FilevaultUnlock - } - return nil -} - -func (m *RotateFileVaultKey) GetNewCertificate() []byte { - if m != nil { - return m.NewCertificate - } - return nil -} - -func (m *RotateFileVaultKey) GetReplyEncryptionCertificate() []byte { - if m != nil { - return m.ReplyEncryptionCertificate - } - return nil -} - -type FileVaultUnlock struct { - Password string `protobuf:"bytes,1,opt,name=password,proto3" json:"password,omitempty"` - PrivateKeyExport []byte `protobuf:"bytes,2,opt,name=private_key_export,json=privateKeyExport,proto3" json:"private_key_export,omitempty"` - PrivateKeyExportPassword string `protobuf:"bytes,3,opt,name=private_key_export_password,json=privateKeyExportPassword,proto3" json:"private_key_export_password,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *FileVaultUnlock) Reset() { *m = FileVaultUnlock{} } -func (m *FileVaultUnlock) String() string { return proto.CompactTextString(m) } -func (*FileVaultUnlock) ProtoMessage() {} -func (*FileVaultUnlock) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{64} -} -func (m *FileVaultUnlock) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *FileVaultUnlock) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_FileVaultUnlock.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *FileVaultUnlock) XXX_Merge(src proto.Message) { - xxx_messageInfo_FileVaultUnlock.Merge(m, src) -} -func (m *FileVaultUnlock) XXX_Size() int { - return m.Size() -} -func (m *FileVaultUnlock) XXX_DiscardUnknown() { - xxx_messageInfo_FileVaultUnlock.DiscardUnknown(m) -} - -var xxx_messageInfo_FileVaultUnlock proto.InternalMessageInfo - -func (m *FileVaultUnlock) GetPassword() string { - if m != nil { - return m.Password - } - return "" -} - -func (m *FileVaultUnlock) GetPrivateKeyExport() []byte { - if m != nil { - return m.PrivateKeyExport - } - return nil -} - -func (m *FileVaultUnlock) GetPrivateKeyExportPassword() string { - if m != nil { - return m.PrivateKeyExportPassword - } - return "" -} - -type SetBootstrapToken struct { - BootstrapToken string `protobuf:"bytes,1,opt,name=bootstrap_token,json=bootstrapToken,proto3" json:"bootstrap_token,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *SetBootstrapToken) Reset() { *m = SetBootstrapToken{} } -func (m *SetBootstrapToken) String() string { return proto.CompactTextString(m) } -func (*SetBootstrapToken) ProtoMessage() {} -func (*SetBootstrapToken) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{65} -} -func (m *SetBootstrapToken) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *SetBootstrapToken) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_SetBootstrapToken.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *SetBootstrapToken) XXX_Merge(src proto.Message) { - xxx_messageInfo_SetBootstrapToken.Merge(m, src) -} -func (m *SetBootstrapToken) XXX_Size() int { - return m.Size() -} -func (m *SetBootstrapToken) XXX_DiscardUnknown() { - xxx_messageInfo_SetBootstrapToken.DiscardUnknown(m) -} - -var xxx_messageInfo_SetBootstrapToken proto.InternalMessageInfo - -func (m *SetBootstrapToken) GetBootstrapToken() string { - if m != nil { - return m.BootstrapToken - } - return "" -} - -type ResultPayload struct { - Udid string `protobuf:"bytes,1,opt,name=udid,proto3" json:"udid,omitempty"` - CommandUuid string `protobuf:"bytes,2,opt,name=command_uuid,json=commandUuid,proto3" json:"command_uuid,omitempty"` - ErrorChain []*ErrorChain `protobuf:"bytes,3,rep,name=error_chain,json=errorChain,proto3" json:"error_chain,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ResultPayload) Reset() { *m = ResultPayload{} } -func (m *ResultPayload) String() string { return proto.CompactTextString(m) } -func (*ResultPayload) ProtoMessage() {} -func (*ResultPayload) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{66} -} -func (m *ResultPayload) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ResultPayload) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ResultPayload.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ResultPayload) XXX_Merge(src proto.Message) { - xxx_messageInfo_ResultPayload.Merge(m, src) -} -func (m *ResultPayload) XXX_Size() int { - return m.Size() -} -func (m *ResultPayload) XXX_DiscardUnknown() { - xxx_messageInfo_ResultPayload.DiscardUnknown(m) -} - -var xxx_messageInfo_ResultPayload proto.InternalMessageInfo - -func (m *ResultPayload) GetUdid() string { - if m != nil { - return m.Udid - } - return "" -} - -func (m *ResultPayload) GetCommandUuid() string { - if m != nil { - return m.CommandUuid - } - return "" -} - -func (m *ResultPayload) GetErrorChain() []*ErrorChain { - if m != nil { - return m.ErrorChain - } - return nil -} - -type ErrorChain struct { - LocalizedDescription string `protobuf:"bytes,1,opt,name=localized_description,json=localizedDescription,proto3" json:"localized_description,omitempty"` - UsEnglishDescription string `protobuf:"bytes,2,opt,name=us_english_description,json=usEnglishDescription,proto3" json:"us_english_description,omitempty"` - // The ErrorDomain and ErrorCode keys contain internal codes used by Apple - // that may be useful for diagnostics. Your host should not rely on these - // values, as they may change between software releases. - ErrorDomain string `protobuf:"bytes,3,opt,name=error_domain,json=errorDomain,proto3" json:"error_domain,omitempty"` - ErrorCode int32 `protobuf:"varint,4,opt,name=error_code,json=errorCode,proto3" json:"error_code,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ErrorChain) Reset() { *m = ErrorChain{} } -func (m *ErrorChain) String() string { return proto.CompactTextString(m) } -func (*ErrorChain) ProtoMessage() {} -func (*ErrorChain) Descriptor() ([]byte, []int) { - return fileDescriptor_fd1fa389f704dbf7, []int{67} -} -func (m *ErrorChain) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ErrorChain) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ErrorChain.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ErrorChain) XXX_Merge(src proto.Message) { - xxx_messageInfo_ErrorChain.Merge(m, src) -} -func (m *ErrorChain) XXX_Size() int { - return m.Size() -} -func (m *ErrorChain) XXX_DiscardUnknown() { - xxx_messageInfo_ErrorChain.DiscardUnknown(m) -} - -var xxx_messageInfo_ErrorChain proto.InternalMessageInfo - -func (m *ErrorChain) GetLocalizedDescription() string { - if m != nil { - return m.LocalizedDescription - } - return "" -} - -func (m *ErrorChain) GetUsEnglishDescription() string { - if m != nil { - return m.UsEnglishDescription - } - return "" -} - -func (m *ErrorChain) GetErrorDomain() string { - if m != nil { - return m.ErrorDomain - } - return "" -} - -func (m *ErrorChain) GetErrorCode() int32 { - if m != nil { - return m.ErrorCode - } - return 0 -} - -func init() { - proto.RegisterEnum("mdmproto.ResultPayload_Status", ResultPayload_Status_name, ResultPayload_Status_value) - proto.RegisterType((*CommandPayload)(nil), "mdmproto.CommandPayload") - proto.RegisterType((*Command)(nil), "mdmproto.Command") - proto.RegisterType((*InstallProfile)(nil), "mdmproto.InstallProfile") - proto.RegisterType((*RemoveProfile)(nil), "mdmproto.RemoveProfile") - proto.RegisterType((*InstallProvisioningProfile)(nil), "mdmproto.InstallProvisioningProfile") - proto.RegisterType((*RemoveProvisioningProfile)(nil), "mdmproto.RemoveProvisioningProfile") - proto.RegisterType((*InstalledApplicationList)(nil), "mdmproto.InstalledApplicationList") - proto.RegisterType((*DeviceInformation)(nil), "mdmproto.DeviceInformation") - proto.RegisterType((*ClearPasscode)(nil), "mdmproto.ClearPasscode") - proto.RegisterType((*DeviceLock)(nil), "mdmproto.DeviceLock") - proto.RegisterType((*EraseDevice)(nil), "mdmproto.EraseDevice") - proto.RegisterType((*RequestMirroring)(nil), "mdmproto.RequestMirroring") - proto.RegisterType((*Restrictions)(nil), "mdmproto.Restrictions") - proto.RegisterType((*UnlockUserAccount)(nil), "mdmproto.UnlockUserAccount") - proto.RegisterType((*DeleteUser)(nil), "mdmproto.DeleteUser") - proto.RegisterType((*EnableLostMode)(nil), "mdmproto.EnableLostMode") - proto.RegisterType((*InstallApplication)(nil), "mdmproto.InstallApplication") - proto.RegisterType((*InstallApplicationOptions)(nil), "mdmproto.InstallApplicationOptions") - proto.RegisterType((*InstallApplicationConfiguration)(nil), "mdmproto.InstallApplicationConfiguration") - proto.RegisterType((*InstallApplicationAttributes)(nil), "mdmproto.InstallApplicationAttributes") - proto.RegisterType((*InstallEnterpriseApplication)(nil), "mdmproto.InstallEnterpriseApplication") - proto.RegisterType((*Manifest)(nil), "mdmproto.Manifest") - proto.RegisterType((*ManifestItem)(nil), "mdmproto.ManifestItem") - proto.RegisterType((*Asset)(nil), "mdmproto.Asset") - proto.RegisterType((*Metadata)(nil), "mdmproto.Metadata") - proto.RegisterType((*BundleInfo)(nil), "mdmproto.BundleInfo") - proto.RegisterType((*ApplyRedemptionCode)(nil), "mdmproto.ApplyRedemptionCode") - proto.RegisterType((*ManagedApplicationList)(nil), "mdmproto.ManagedApplicationList") - proto.RegisterType((*RemoveApplication)(nil), "mdmproto.RemoveApplication") - proto.RegisterType((*InviteToProgram)(nil), "mdmproto.InviteToProgram") - proto.RegisterType((*ValidateApplications)(nil), "mdmproto.ValidateApplications") - proto.RegisterType((*AccountConfiguration)(nil), "mdmproto.AccountConfiguration") - proto.RegisterType((*AutoSetupAdminAccounts)(nil), "mdmproto.AutoSetupAdminAccounts") - proto.RegisterType((*InstallMedia)(nil), "mdmproto.InstallMedia") - proto.RegisterType((*RemoveMedia)(nil), "mdmproto.RemoveMedia") - proto.RegisterType((*Settings)(nil), "mdmproto.Settings") - proto.RegisterType((*Setting)(nil), "mdmproto.Setting") - proto.RegisterType((*VoiceRoamingSetting)(nil), "mdmproto.VoiceRoamingSetting") - proto.RegisterType((*PersonalHotspotSetting)(nil), "mdmproto.PersonalHotspotSetting") - proto.RegisterType((*WallpaperSetting)(nil), "mdmproto.WallpaperSetting") - proto.RegisterType((*DataRoamingSetting)(nil), "mdmproto.DataRoamingSetting") - proto.RegisterType((*BluetoothSetting)(nil), "mdmproto.BluetoothSetting") - proto.RegisterType((*ApplicationAttributesSetting)(nil), "mdmproto.ApplicationAttributesSetting") - proto.RegisterType((*ApplicationConfigurationSetting)(nil), "mdmproto.ApplicationConfigurationSetting") - proto.RegisterType((*ApplicationAttributes)(nil), "mdmproto.ApplicationAttributes") - proto.RegisterType((*DeviceNameSetting)(nil), "mdmproto.DeviceNameSetting") - proto.RegisterType((*HostnameSetting)(nil), "mdmproto.HostnameSetting") - proto.RegisterType((*MDMOptionsSetting)(nil), "mdmproto.MDMOptionsSetting") - proto.RegisterType((*MDMOptions)(nil), "mdmproto.MDMOptions") - proto.RegisterType((*PasscodeLockGracePeriodSetting)(nil), "mdmproto.PasscodeLockGracePeriodSetting") - proto.RegisterType((*MaximumResidentUsersSetting)(nil), "mdmproto.MaximumResidentUsersSetting") - proto.RegisterType((*DiagnosticSubmissionSetting)(nil), "mdmproto.DiagnosticSubmissionSetting") - proto.RegisterType((*AppAnalyticsSetting)(nil), "mdmproto.AppAnalyticsSetting") - proto.RegisterType((*ManagedApplicationConfiguration)(nil), "mdmproto.ManagedApplicationConfiguration") - proto.RegisterType((*ManagedApplicationAttributes)(nil), "mdmproto.ManagedApplicationAttributes") - proto.RegisterType((*ManagedApplicationFeedback)(nil), "mdmproto.ManagedApplicationFeedback") - proto.RegisterType((*SetFirmwarePassword)(nil), "mdmproto.SetFirmwarePassword") - proto.RegisterType((*VerifyFirmwarePassword)(nil), "mdmproto.VerifyFirmwarePassword") - proto.RegisterType((*SetAutoAdminPassword)(nil), "mdmproto.SetAutoAdminPassword") - proto.RegisterType((*ScheduleOSUpdate)(nil), "mdmproto.ScheduleOSUpdate") - proto.RegisterType((*Update)(nil), "mdmproto.Update") - proto.RegisterType((*ScheduleOSUpdateScan)(nil), "mdmproto.ScheduleOSUpdateScan") - proto.RegisterType((*ActiveNSExtensions)(nil), "mdmproto.ActiveNSExtensions") - proto.RegisterType((*RotateFileVaultKey)(nil), "mdmproto.RotateFileVaultKey") - proto.RegisterType((*FileVaultUnlock)(nil), "mdmproto.FileVaultUnlock") - proto.RegisterType((*SetBootstrapToken)(nil), "mdmproto.SetBootstrapToken") - proto.RegisterType((*ResultPayload)(nil), "mdmproto.ResultPayload") - proto.RegisterType((*ErrorChain)(nil), "mdmproto.ErrorChain") -} - -func init() { proto.RegisterFile("mdm.proto", fileDescriptor_fd1fa389f704dbf7) } - -var fileDescriptor_fd1fa389f704dbf7 = []byte{ - // 3797 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x5a, 0xcd, 0x73, 0x1b, 0x47, - 0x76, 0x27, 0x48, 0x8a, 0x04, 0x1e, 0x40, 0x12, 0x6c, 0x7e, 0x08, 0x24, 0x25, 0x52, 0x1a, 0xd9, - 0x6b, 0xd9, 0x6b, 0x4b, 0x89, 0x6c, 0x79, 0xbd, 0xbb, 0x76, 0x62, 0x8a, 0x94, 0x96, 0x5c, 0x8b, - 0x22, 0x6b, 0x20, 0xc9, 0x55, 0x71, 0x36, 0xb3, 0x43, 0x4c, 0x13, 0xe8, 0xe2, 0x7c, 0x6d, 0xf7, - 0x0c, 0x68, 0xf8, 0x9c, 0x54, 0xce, 0xb9, 0x24, 0xa9, 0x5c, 0x72, 0x4f, 0xe5, 0x1f, 0x48, 0x6e, - 0xb9, 0xe5, 0x98, 0xca, 0x5f, 0xe0, 0x72, 0xfe, 0x85, 0x5c, 0x72, 0x4b, 0xbd, 0xfe, 0x98, 0x19, - 0x0c, 0x86, 0xa0, 0x2e, 0x7b, 0x43, 0xbf, 0xf7, 0xeb, 0xd7, 0x3d, 0xaf, 0xbb, 0xdf, 0x27, 0xa0, - 0x11, 0x78, 0xc1, 0xa3, 0x98, 0x47, 0x49, 0x44, 0xea, 0x81, 0x17, 0xc8, 0x5f, 0xd6, 0xef, 0x61, - 0xf9, 0x20, 0x0a, 0x02, 0x37, 0xf4, 0xce, 0xdc, 0x91, 0x1f, 0xb9, 0x1e, 0xb9, 0x0f, 0xad, 0x9e, - 0xa2, 0x38, 0x69, 0xca, 0xbc, 0x4e, 0xed, 0x5e, 0xed, 0x61, 0xc3, 0x6e, 0x6a, 0xda, 0x9b, 0x94, - 0x79, 0xe4, 0xe7, 0xb0, 0xa8, 0x87, 0x9d, 0xd9, 0x7b, 0xb5, 0x87, 0xcd, 0x27, 0xab, 0x8f, 0x8c, - 0xc0, 0x47, 0x5a, 0x9a, 0x6d, 0x10, 0xd6, 0xbf, 0xde, 0x86, 0x45, 0x4d, 0x44, 0xd9, 0x9c, 0xfe, - 0x21, 0xa5, 0x22, 0x71, 0x92, 0x51, 0x4c, 0x8d, 0x6c, 0x4d, 0x7b, 0x3d, 0x8a, 0x29, 0x39, 0x80, - 0x15, 0x16, 0x8a, 0xc4, 0xf5, 0x7d, 0x27, 0xe6, 0xd1, 0x05, 0xf3, 0xa9, 0x5e, 0xa3, 0x93, 0xaf, - 0x71, 0xac, 0x00, 0x67, 0x8a, 0x7f, 0x34, 0x63, 0x2f, 0xb3, 0x31, 0x0a, 0xf9, 0x1a, 0x96, 0x39, - 0x0d, 0xa2, 0x21, 0xcd, 0x64, 0xcc, 0x49, 0x19, 0xb7, 0x73, 0x19, 0xb6, 0xe4, 0xe7, 0x22, 0x96, - 0x78, 0x91, 0x40, 0x06, 0x70, 0xa7, 0xb0, 0x8d, 0x21, 0x13, 0x2c, 0x0a, 0x59, 0xd8, 0xcf, 0xe4, - 0xcd, 0x4b, 0x79, 0xef, 0x55, 0xed, 0x29, 0x03, 0xe7, 0xc2, 0xb7, 0xd9, 0xb5, 0x5c, 0x42, 0x61, - 0xa7, 0xb8, 0xd7, 0xf2, 0x42, 0xb7, 0xe4, 0x42, 0x0f, 0x2a, 0x36, 0x5e, 0xb1, 0xce, 0x56, 0xe1, - 0x23, 0x4a, 0xcb, 0x9c, 0x83, 0xd9, 0x04, 0xf5, 0x1c, 0x37, 0x8e, 0x7d, 0xd6, 0x73, 0x13, 0x16, - 0x85, 0x8e, 0xcf, 0x44, 0xd2, 0x59, 0x90, 0xab, 0x58, 0x13, 0x9f, 0x43, 0xbd, 0xfd, 0x1c, 0xfa, - 0x92, 0x89, 0xe4, 0x68, 0xc6, 0xee, 0xb0, 0x6b, 0x78, 0xe4, 0x25, 0x10, 0x8f, 0x0e, 0x59, 0x8f, - 0x3a, 0x2c, 0xbc, 0x88, 0x78, 0x20, 0x39, 0x9d, 0x45, 0x29, 0x7b, 0x27, 0x97, 0x7d, 0x28, 0x31, - 0xc7, 0x39, 0xe4, 0x68, 0xc6, 0x5e, 0xf5, 0xca, 0x44, 0xf2, 0x0b, 0x68, 0x6a, 0x69, 0x7e, 0xd4, - 0xbb, 0xec, 0xd4, 0xa5, 0x98, 0xf5, 0xb2, 0x98, 0x97, 0x51, 0xef, 0xf2, 0x68, 0xc6, 0x06, 0x2f, - 0x1b, 0xe1, 0xe9, 0xf7, 0x7c, 0xea, 0x72, 0x27, 0x76, 0x85, 0xe8, 0x45, 0x1e, 0xed, 0x34, 0xca, - 0xa7, 0x7f, 0x80, 0xfc, 0x33, 0xcd, 0xc6, 0xd3, 0xef, 0x15, 0x09, 0xe4, 0x57, 0xd0, 0xa2, 0xdc, - 0x15, 0xd4, 0x51, 0x52, 0x3b, 0x20, 0xe7, 0x6f, 0xe4, 0xf3, 0x9f, 0x23, 0x57, 0x6d, 0xe0, 0x68, - 0xc6, 0x6e, 0xd2, 0x7c, 0x48, 0x8e, 0x61, 0xd5, 0xdc, 0xf1, 0x80, 0x71, 0x1e, 0x71, 0x16, 0xf6, - 0x3b, 0x4d, 0x29, 0x60, 0xbb, 0x78, 0x8a, 0x12, 0x72, 0x62, 0x10, 0x47, 0x33, 0x76, 0x9b, 0x97, - 0x68, 0xe4, 0x4b, 0x7c, 0x2e, 0x22, 0xe1, 0xac, 0x87, 0x0a, 0x11, 0x9d, 0x96, 0x94, 0xb2, 0x59, - 0x94, 0x92, 0x73, 0x8f, 0x66, 0xec, 0x31, 0x34, 0x39, 0x81, 0xb5, 0x34, 0x44, 0xd5, 0x39, 0xa9, - 0xa0, 0xdc, 0x71, 0x7b, 0xbd, 0x28, 0x0d, 0x93, 0xce, 0x52, 0xf9, 0x38, 0xde, 0x48, 0xd0, 0x1b, - 0x41, 0xf9, 0xbe, 0x82, 0xe0, 0x71, 0xa4, 0x65, 0xa2, 0x3a, 0x0e, 0x9f, 0x26, 0x54, 0x8a, 0xeb, - 0x2c, 0x4f, 0x1e, 0x07, 0x32, 0x71, 0x86, 0x3a, 0x0e, 0x33, 0x22, 0x87, 0xd0, 0xa6, 0xa1, 0x7b, - 0xee, 0xe3, 0x39, 0xa2, 0x52, 0xf0, 0x40, 0x56, 0xca, 0x4f, 0xfa, 0xb9, 0x44, 0xbc, 0x8c, 0x44, - 0x72, 0xa2, 0x4e, 0x64, 0x99, 0x8e, 0x51, 0xc8, 0x29, 0xac, 0x99, 0x07, 0x59, 0xb8, 0xbd, 0x9d, - 0xb6, 0x14, 0x74, 0x67, 0xe2, 0xe2, 0x16, 0xae, 0xe6, 0xd1, 0x8c, 0x4d, 0xd8, 0x04, 0x95, 0xbc, - 0x81, 0x0d, 0xad, 0x12, 0xa7, 0x17, 0x85, 0x17, 0xac, 0x9f, 0x72, 0x25, 0x72, 0x55, 0x8a, 0xdc, - 0xcd, 0x45, 0x6a, 0x0d, 0x1c, 0x14, 0x51, 0x47, 0x33, 0xf6, 0xba, 0x5b, 0x41, 0x27, 0x5d, 0xd8, - 0xc0, 0xfd, 0x8d, 0x1c, 0x4e, 0x3d, 0x1a, 0xc4, 0xf2, 0x89, 0xc9, 0x3b, 0x48, 0xa4, 0xd8, 0xbb, - 0x05, 0xb1, 0x08, 0xb3, 0x33, 0xd4, 0x81, 0xfa, 0xee, 0x35, 0x77, 0x92, 0x4c, 0xfe, 0x12, 0x3a, - 0x81, 0x1b, 0xba, 0xfd, 0xaa, 0xa7, 0xbb, 0x26, 0xe5, 0xde, 0xcb, 0xe5, 0x9e, 0x28, 0xe4, 0xe4, - 0xc3, 0xdd, 0x0c, 0x2a, 0x39, 0xf8, 0x6c, 0xb5, 0x05, 0x2a, 0x6a, 0x76, 0xbd, 0x7c, 0x4f, 0x94, - 0xe1, 0x19, 0x57, 0xec, 0x2a, 0x2f, 0x13, 0xc9, 0x6f, 0x60, 0x95, 0x85, 0x43, 0x96, 0x50, 0x27, - 0x89, 0xd0, 0x8a, 0xf5, 0xb9, 0x1b, 0x74, 0x36, 0xa4, 0xb0, 0xad, 0xe2, 0x31, 0x21, 0xe4, 0x75, - 0x74, 0xa6, 0x00, 0x47, 0x33, 0xf6, 0x0a, 0x1b, 0x27, 0xe1, 0x01, 0x0d, 0x5d, 0x9f, 0x79, 0x6e, - 0xe2, 0x16, 0x37, 0x26, 0x3a, 0x9b, 0xe5, 0x03, 0x7a, 0xab, 0x60, 0xc5, 0x6d, 0xe0, 0x73, 0x58, - 0x37, 0xd3, 0x8b, 0x74, 0xf2, 0x15, 0x2c, 0x99, 0x8b, 0x14, 0x50, 0x8f, 0xb9, 0x9d, 0xdb, 0xe5, - 0x57, 0xa5, 0xaf, 0xd0, 0x09, 0x72, 0xf1, 0x55, 0xb1, 0xc2, 0x18, 0x4d, 0x83, 0x56, 0x96, 0x9a, - 0xdd, 0x29, 0x9b, 0x06, 0xa5, 0x26, 0x33, 0xb9, 0xc9, 0xf3, 0x21, 0xf9, 0x13, 0xa8, 0x0b, 0x9a, - 0x24, 0x2c, 0xec, 0x8b, 0xce, 0x96, 0x9c, 0x47, 0xf2, 0x79, 0x5d, 0xcd, 0x39, 0x9a, 0xb1, 0x33, - 0x14, 0xb9, 0x82, 0xfb, 0x55, 0x07, 0x3f, 0x7e, 0x61, 0xb7, 0xa5, 0xa8, 0x0f, 0xa7, 0xdd, 0x80, - 0xf2, 0xdd, 0xdd, 0x0b, 0xa6, 0x43, 0x48, 0x08, 0xbb, 0x55, 0x0b, 0xbb, 0x49, 0xc2, 0xd9, 0x79, - 0x9a, 0x50, 0xd1, 0xd9, 0x91, 0xab, 0xfe, 0x6c, 0xda, 0xaa, 0xfb, 0x19, 0xfa, 0x68, 0xc6, 0xbe, - 0x13, 0x4c, 0xe1, 0xa3, 0xbf, 0xad, 0x5a, 0xef, 0x82, 0x52, 0xef, 0xdc, 0xed, 0x5d, 0x76, 0xee, - 0x94, 0xfd, 0xed, 0xe4, 0x6a, 0x2f, 0x34, 0x16, 0xfd, 0x6d, 0x70, 0x2d, 0x17, 0x1f, 0xa8, 0xa0, - 0x89, 0x73, 0xc1, 0x78, 0x70, 0xe5, 0x72, 0x2a, 0x9d, 0xc4, 0x55, 0xc4, 0xbd, 0xce, 0xdd, 0xf2, - 0x03, 0xed, 0xd2, 0xe4, 0x85, 0x46, 0x9d, 0x69, 0x10, 0x3e, 0x50, 0x31, 0x49, 0xc6, 0x07, 0x3a, - 0xa4, 0x9c, 0x5d, 0x8c, 0x2a, 0xe4, 0xee, 0x96, 0x1f, 0xe8, 0x5b, 0x89, 0xac, 0x10, 0xbd, 0x39, - 0xac, 0xe4, 0x90, 0x6f, 0xe1, 0x36, 0x6e, 0xd9, 0x4d, 0x93, 0xc8, 0x71, 0xbd, 0x80, 0x85, 0xb9, - 0xf0, 0xbd, 0xf2, 0x5b, 0xe8, 0xd2, 0x64, 0x3f, 0x4d, 0xa2, 0x7d, 0x84, 0x15, 0x44, 0xaf, 0x8b, - 0x0a, 0x3a, 0xf9, 0x2d, 0x10, 0xd1, 0x1b, 0x50, 0x2f, 0xf5, 0xa9, 0x13, 0x09, 0x27, 0x8d, 0xf1, - 0x15, 0x75, 0xee, 0x95, 0x9d, 0x55, 0x57, 0x63, 0x4e, 0xbb, 0x6f, 0x24, 0x02, 0x9d, 0x95, 0x99, - 0x77, 0x2a, 0x14, 0x4d, 0x6e, 0x72, 0x42, 0x96, 0x23, 0x7a, 0x6e, 0xd8, 0xb9, 0x3f, 0xb1, 0xc9, - 0x92, 0xc0, 0x6e, 0xcf, 0x95, 0x16, 0xb5, 0x2c, 0x14, 0xe9, 0xe4, 0x0c, 0xd6, 0xdd, 0x5e, 0xc2, - 0x86, 0xd4, 0x09, 0x85, 0x43, 0xbf, 0x4f, 0x68, 0x28, 0xa4, 0x19, 0xb0, 0xca, 0xa6, 0x7f, 0x5f, - 0xa2, 0x5e, 0x75, 0x9f, 0x67, 0x18, 0x34, 0xfd, 0x6a, 0xee, 0x2b, 0x91, 0x53, 0x51, 0x22, 0x8f, - 0x12, 0xdc, 0x1e, 0x86, 0x46, 0x43, 0x37, 0xf5, 0x13, 0xe7, 0x92, 0x8e, 0x3a, 0x0f, 0xca, 0x12, - 0x6d, 0x89, 0x7a, 0xc1, 0x7c, 0xfa, 0x16, 0x41, 0xdf, 0xd0, 0x11, 0x4a, 0xe4, 0x19, 0x75, 0xa8, - 0xa9, 0xf8, 0x5c, 0x8c, 0x51, 0xa1, 0x61, 0x42, 0x79, 0xcc, 0x99, 0x18, 0x37, 0xa7, 0xef, 0x95, - 0x9f, 0x8b, 0xb6, 0x32, 0xcf, 0x33, 0xf8, 0xb8, 0x65, 0x35, 0xe1, 0x67, 0x25, 0x1f, 0x7d, 0x3b, - 0xde, 0x88, 0xf3, 0x28, 0x4a, 0x44, 0xc2, 0xdd, 0xd8, 0x49, 0xa2, 0x4b, 0x1a, 0x76, 0xde, 0x2f, - 0xdb, 0xec, 0x2e, 0x4d, 0x9e, 0x19, 0xcc, 0x6b, 0x84, 0xa0, 0xcd, 0x16, 0x65, 0xe2, 0xb3, 0x06, - 0x2c, 0xea, 0xe0, 0xc3, 0xfa, 0x08, 0x96, 0xc7, 0xc3, 0x6b, 0xd2, 0x81, 0xc5, 0x58, 0xe5, 0x06, - 0x32, 0x5e, 0x6f, 0xd9, 0x66, 0x68, 0x3d, 0x86, 0xa5, 0xb1, 0x30, 0x9a, 0xec, 0x02, 0x30, 0x8f, - 0x86, 0x09, 0xbb, 0x60, 0x94, 0xeb, 0xe8, 0xbe, 0x40, 0xb1, 0x4e, 0x61, 0xfb, 0xfa, 0x38, 0x99, - 0xfc, 0x29, 0xac, 0x57, 0xc6, 0xda, 0x6a, 0xd5, 0xb5, 0x78, 0x72, 0x8a, 0xf5, 0x18, 0xb6, 0xae, - 0x8d, 0x87, 0x09, 0x81, 0xf9, 0x42, 0x06, 0x23, 0x7f, 0x5b, 0x03, 0xe8, 0x5c, 0x17, 0xda, 0x92, - 0x7b, 0xd0, 0xcc, 0xf7, 0x2a, 0x3a, 0xb5, 0x7b, 0x73, 0x98, 0x9c, 0x14, 0x48, 0xe4, 0x23, 0x58, - 0x2d, 0x58, 0x29, 0xe1, 0x44, 0xa1, 0x3f, 0x92, 0xe9, 0x49, 0xdd, 0x5e, 0xc9, 0x4d, 0x8e, 0x38, - 0x0d, 0xfd, 0x91, 0xf5, 0x09, 0xac, 0x4e, 0x04, 0xba, 0xa8, 0xcb, 0x3f, 0xa4, 0x94, 0x33, 0x6a, - 0xc4, 0x9b, 0xa1, 0xf5, 0x04, 0x96, 0xc6, 0x82, 0x52, 0xcc, 0x95, 0x74, 0xf8, 0xa6, 0xce, 0x56, - 0x69, 0xa1, 0xa9, 0x68, 0xf2, 0xd8, 0xac, 0xef, 0x00, 0xf2, 0x20, 0x98, 0xb4, 0x61, 0x2e, 0x66, - 0xa1, 0xfe, 0x5a, 0xfc, 0x89, 0xab, 0x05, 0x54, 0x08, 0xb7, 0xaf, 0x72, 0xa8, 0x86, 0x6d, 0x86, - 0x28, 0x3c, 0x1e, 0x44, 0x21, 0x75, 0xc2, 0x34, 0x38, 0xa7, 0x5c, 0xa6, 0x47, 0x0d, 0xbb, 0x29, - 0x69, 0xaf, 0x24, 0xc9, 0xfa, 0xdb, 0x1a, 0x34, 0x0b, 0x61, 0x6e, 0x85, 0xf8, 0x8f, 0x81, 0xc4, - 0x9c, 0x0a, 0xca, 0x87, 0xd4, 0x91, 0x5e, 0x3a, 0xf6, 0xdd, 0x50, 0xab, 0xa3, 0x6d, 0x38, 0x87, - 0x6e, 0xe2, 0x9e, 0xf9, 0x6e, 0x48, 0xbe, 0x80, 0x8e, 0xc7, 0x84, 0xeb, 0xfb, 0xd1, 0x15, 0x9e, - 0xec, 0xf7, 0x2c, 0x60, 0xc9, 0xc8, 0x11, 0x34, 0x49, 0x63, 0xb9, 0x7c, 0xdd, 0xde, 0x34, 0xfc, - 0x33, 0xc3, 0xee, 0x22, 0xd7, 0xfa, 0x97, 0x1a, 0xb4, 0xcb, 0xf1, 0x32, 0xf9, 0x10, 0xda, 0x1e, - 0x15, 0x09, 0x0b, 0x95, 0xa3, 0x08, 0xdd, 0xc0, 0xa4, 0x93, 0x2b, 0x05, 0xfa, 0x2b, 0x37, 0xa0, - 0xe4, 0x09, 0x6c, 0x14, 0xa1, 0x26, 0x45, 0xf1, 0xb4, 0x52, 0xd6, 0x0a, 0x4c, 0x7d, 0x62, 0x1e, - 0xd9, 0x81, 0x06, 0x9a, 0x2e, 0x27, 0x61, 0x01, 0xd5, 0xda, 0xa9, 0x23, 0xe1, 0x35, 0x0b, 0x28, - 0xd9, 0x86, 0x7a, 0x66, 0x80, 0xe7, 0x15, 0xcf, 0x8c, 0xad, 0x7d, 0x68, 0x15, 0xa3, 0x72, 0x7d, - 0xa9, 0xf1, 0x3e, 0x3a, 0x63, 0xb1, 0x7c, 0x4d, 0x7e, 0xf2, 0x9a, 0xe6, 0x15, 0xa7, 0x58, 0x8f, - 0x61, 0x75, 0x22, 0x26, 0xc7, 0x35, 0x31, 0xee, 0x2e, 0x7c, 0x67, 0x36, 0xb6, 0x4e, 0xf1, 0x1e, - 0x64, 0xf1, 0xf6, 0x14, 0x24, 0x79, 0x1f, 0x96, 0x2f, 0x22, 0xde, 0xc3, 0xc4, 0xc6, 0xa7, 0xd2, - 0x2e, 0xa9, 0xe3, 0x5a, 0x92, 0xd4, 0x43, 0x4d, 0xb4, 0x18, 0x2c, 0x8f, 0x07, 0xe4, 0xc5, 0xab, - 0x54, 0x9b, 0x7e, 0x95, 0x66, 0x27, 0xae, 0x12, 0xee, 0xe8, 0x22, 0x8a, 0x92, 0x30, 0x4a, 0x32, - 0x5d, 0x9a, 0xb1, 0xf5, 0xef, 0x73, 0x40, 0x26, 0x63, 0x76, 0xf2, 0x33, 0x58, 0x61, 0x49, 0x1a, - 0x52, 0xe1, 0x88, 0x24, 0xe2, 0xf2, 0xb4, 0x70, 0xdd, 0x39, 0x7b, 0x49, 0x91, 0xbb, 0x48, 0x3d, - 0xf6, 0x4a, 0x16, 0x67, 0xb6, 0x6c, 0x71, 0xc8, 0x57, 0xb0, 0x18, 0xc5, 0x4a, 0xe3, 0x73, 0xe5, - 0x4c, 0x7a, 0x72, 0xd9, 0x53, 0x05, 0xb5, 0xcd, 0x1c, 0xfc, 0xb8, 0xc0, 0x0d, 0xd9, 0x05, 0x66, - 0x73, 0x29, 0xf7, 0xf5, 0x69, 0x37, 0x0d, 0xed, 0x0d, 0xf7, 0xf1, 0x22, 0xaa, 0xa7, 0x1f, 0xd0, - 0x30, 0x71, 0x2e, 0x7c, 0xb7, 0x2f, 0x64, 0xd2, 0x3e, 0x67, 0x4c, 0x02, 0xd2, 0x5f, 0x20, 0x99, - 0x9c, 0xc2, 0xd2, 0x78, 0xe4, 0xb6, 0x50, 0x8e, 0xdc, 0x26, 0xb7, 0x34, 0x16, 0x96, 0xd9, 0xe3, - 0xf3, 0xc9, 0x0b, 0x80, 0x42, 0x44, 0xb6, 0x78, 0x8d, 0x8b, 0xa9, 0x8c, 0xb8, 0xec, 0xc2, 0x4c, - 0xf2, 0x39, 0xdc, 0xee, 0x0d, 0xdc, 0xb0, 0x4f, 0x9d, 0xc2, 0xa7, 0x08, 0xf4, 0x72, 0x32, 0xed, - 0x6e, 0xd8, 0x1b, 0x8a, 0x7d, 0x92, 0x71, 0xbb, 0xc8, 0xb4, 0x0e, 0x61, 0xeb, 0x5a, 0x25, 0x92, - 0x0f, 0x60, 0x25, 0x4e, 0x79, 0x6f, 0x80, 0x79, 0x74, 0x40, 0x93, 0x41, 0x64, 0x8e, 0x70, 0xd9, - 0x90, 0x4f, 0x24, 0xd5, 0xba, 0x0f, 0x7b, 0x37, 0x7c, 0xb7, 0xb5, 0x0b, 0x77, 0xa6, 0x7d, 0x8c, - 0xf5, 0x7f, 0xb5, 0x0c, 0x50, 0xed, 0x30, 0x1f, 0x41, 0xdd, 0x1c, 0x9a, 0xdc, 0xc5, 0x58, 0xe8, - 0x7d, 0xa2, 0x39, 0x76, 0x86, 0x99, 0x38, 0xf8, 0xd9, 0xc9, 0x83, 0xff, 0x35, 0x6c, 0x17, 0x21, - 0x4e, 0xcc, 0x42, 0xe9, 0xb6, 0x7a, 0x94, 0x27, 0x78, 0xdb, 0xe6, 0x1e, 0xb6, 0xec, 0xdb, 0x85, - 0x09, 0x67, 0x8a, 0x7f, 0x80, 0x6c, 0x72, 0x0c, 0xf7, 0x0d, 0x9e, 0xd3, 0x61, 0x64, 0xe2, 0xfa, - 0x01, 0xed, 0x5d, 0x3a, 0xe8, 0x8a, 0x19, 0xa7, 0xca, 0xb6, 0xd4, 0xed, 0x5d, 0x0d, 0xb4, 0x33, - 0xdc, 0x01, 0xc2, 0x6c, 0x8d, 0xb2, 0x8e, 0xa1, 0x6e, 0x3e, 0x80, 0x7c, 0x05, 0xcb, 0xd9, 0x9e, - 0x58, 0x42, 0x03, 0xe5, 0x66, 0xc6, 0xb2, 0x1b, 0x83, 0x3d, 0x4e, 0x68, 0x60, 0x2f, 0x05, 0x85, - 0x91, 0xb0, 0xfa, 0xd0, 0x2a, 0xb2, 0xc9, 0x07, 0xb0, 0xe0, 0x0a, 0x41, 0x13, 0x23, 0x66, 0xa5, - 0x10, 0x6c, 0x21, 0xdd, 0xd6, 0x6c, 0xa9, 0x5e, 0x9a, 0xb8, 0xe8, 0x05, 0x74, 0xb9, 0xae, 0xa8, - 0x5e, 0xcd, 0xb1, 0x33, 0x8c, 0xf5, 0x0f, 0x35, 0xb8, 0x25, 0x25, 0xa0, 0x93, 0xbe, 0x64, 0x61, - 0xe6, 0xa4, 0xf1, 0x37, 0xd9, 0x82, 0x7a, 0xe0, 0x3d, 0x75, 0x04, 0xfb, 0x41, 0x39, 0xae, 0x39, - 0x7b, 0x31, 0xf0, 0x9e, 0x76, 0xd9, 0x0f, 0xd2, 0xa7, 0x07, 0xde, 0x53, 0xa5, 0xde, 0x86, 0x2d, - 0x7f, 0xa3, 0x67, 0xca, 0xdf, 0x26, 0xfe, 0x24, 0x7b, 0xd0, 0x14, 0x03, 0xf7, 0xc9, 0xd3, 0xcf, - 0x95, 0x0c, 0xf5, 0x1c, 0x41, 0x91, 0xa4, 0x98, 0x0e, 0x2c, 0xaa, 0x91, 0xe8, 0x2c, 0x28, 0x3f, - 0xac, 0x87, 0xd6, 0xff, 0xd6, 0xa0, 0x6e, 0x36, 0x4c, 0x7e, 0x0e, 0xab, 0xe7, 0x69, 0xe8, 0xf9, - 0x68, 0x7f, 0x4a, 0x61, 0x4d, 0x5b, 0x31, 0x8e, 0x73, 0x53, 0xf3, 0x3e, 0x2c, 0x6b, 0xf0, 0x90, - 0x72, 0x61, 0x6c, 0x6b, 0xc3, 0x5e, 0x52, 0xd4, 0xb7, 0x8a, 0x48, 0x3e, 0x82, 0x5b, 0xea, 0x64, - 0xe6, 0xa4, 0x4a, 0x0b, 0x15, 0x94, 0x67, 0x4a, 0x62, 0x78, 0x11, 0xd9, 0x0a, 0x92, 0x29, 0x67, - 0xbe, 0xa0, 0x9c, 0x6d, 0xa8, 0x8b, 0xf4, 0x3c, 0x61, 0x89, 0x2e, 0x0e, 0xa2, 0x63, 0xd2, 0x63, - 0xb2, 0x0e, 0xb7, 0x14, 0x63, 0x41, 0x32, 0xd4, 0x80, 0x58, 0xb0, 0x84, 0x6a, 0x70, 0x58, 0xe8, - 0x9c, 0x8f, 0x8c, 0xa1, 0x98, 0xb3, 0x9b, 0x48, 0x3c, 0x0e, 0x9f, 0x21, 0xc9, 0xfa, 0x3d, 0x40, - 0xbe, 0xfc, 0x1f, 0xe3, 0xbb, 0xad, 0xbf, 0x82, 0xb5, 0x8a, 0x8a, 0xc7, 0x4d, 0x21, 0x23, 0x5a, - 0x91, 0x72, 0x25, 0x45, 0x89, 0x5f, 0xe6, 0x63, 0x82, 0xac, 0x5f, 0xc1, 0x66, 0x75, 0xe5, 0xe3, - 0xe6, 0xb8, 0xce, 0xfa, 0x14, 0x56, 0x27, 0xaa, 0x1b, 0x37, 0x06, 0xb3, 0xdf, 0xc2, 0x4a, 0xa9, - 0x8a, 0x41, 0xee, 0x02, 0xe8, 0x8a, 0x87, 0x93, 0xc5, 0x9d, 0x0d, 0x4d, 0x39, 0xf6, 0x50, 0x53, - 0xb2, 0xc8, 0xa1, 0x1e, 0x7b, 0x6e, 0x56, 0x96, 0x72, 0xea, 0x1b, 0xee, 0x5b, 0x5f, 0xc0, 0x7a, - 0x55, 0x45, 0xe3, 0x1d, 0xbe, 0xe3, 0x9f, 0xe7, 0x61, 0xbd, 0xaa, 0x5a, 0x45, 0x5e, 0xc2, 0x03, - 0x71, 0xc9, 0x62, 0x27, 0xe6, 0x2c, 0x70, 0xb9, 0x0e, 0xbb, 0x9c, 0xac, 0xfe, 0xc5, 0xa9, 0xf2, - 0x47, 0x2a, 0x28, 0xd9, 0x43, 0xe8, 0x99, 0x42, 0xca, 0x08, 0xcc, 0x88, 0xd4, 0x30, 0xf2, 0x16, - 0x3e, 0xc4, 0xec, 0xa3, 0x5a, 0x98, 0x2b, 0x1c, 0x4e, 0xfb, 0xa9, 0xef, 0x72, 0x55, 0x28, 0x54, - 0x01, 0xc6, 0x03, 0x41, 0x93, 0x0a, 0x91, 0xfb, 0xc2, 0x56, 0x58, 0x19, 0xb9, 0x74, 0xe1, 0x03, - 0x2f, 0x0a, 0x75, 0xa2, 0x1b, 0x47, 0x71, 0xea, 0x63, 0x8e, 0x66, 0x96, 0x31, 0x0b, 0xb0, 0xf0, - 0x22, 0xd2, 0xa6, 0xd1, 0x42, 0x38, 0xa6, 0xb5, 0x67, 0x1a, 0xac, 0x97, 0xd0, 0xd2, 0xe5, 0x5d, - 0xfe, 0x25, 0x6c, 0xc9, 0x28, 0xba, 0x52, 0xcc, 0x2d, 0x15, 0x78, 0x22, 0xa0, 0x7a, 0x6a, 0x79, - 0xd6, 0x45, 0xea, 0xfb, 0x2a, 0xd8, 0x54, 0x4f, 0x6c, 0x33, 0x1e, 0x9b, 0xf6, 0x22, 0xf5, 0x7d, - 0x19, 0x73, 0x56, 0x4c, 0x95, 0x55, 0x58, 0x39, 0x75, 0xb1, 0x6a, 0x2a, 0x6a, 0x40, 0x4e, 0xfd, - 0x0e, 0xb6, 0xa4, 0x02, 0xb4, 0x5a, 0x65, 0xbe, 0xaf, 0x65, 0x18, 0xa3, 0x51, 0x28, 0x26, 0xe0, - 0xd7, 0x2b, 0x8d, 0x22, 0x50, 0xcb, 0x12, 0xf6, 0xa6, 0x5b, 0x49, 0xb7, 0xfe, 0xae, 0x06, 0x9b, - 0xd5, 0x53, 0xf0, 0xf2, 0x8a, 0x41, 0xc4, 0x93, 0x62, 0x2c, 0xdd, 0x90, 0x14, 0xb9, 0xad, 0x1d, - 0x68, 0xe4, 0x1f, 0x3f, 0xab, 0xa3, 0x38, 0xf3, 0xb9, 0x0f, 0x60, 0xc9, 0x44, 0xc0, 0xce, 0xc0, - 0x15, 0x03, 0x19, 0x6c, 0xb5, 0xec, 0x96, 0x21, 0x1e, 0xb9, 0x62, 0x40, 0x36, 0x61, 0x61, 0xc0, - 0x3c, 0x8f, 0x86, 0xfa, 0xf4, 0xf4, 0xc8, 0xe2, 0xd0, 0x2a, 0x96, 0xdc, 0xde, 0x39, 0xf6, 0xdb, - 0x81, 0x86, 0xac, 0xc1, 0x15, 0x5e, 0x52, 0x5d, 0x12, 0xd0, 0x3b, 0xdf, 0x05, 0x50, 0x4c, 0xd9, - 0x68, 0x52, 0x51, 0xa7, 0x82, 0xbf, 0x1e, 0xc5, 0xd4, 0x1a, 0x41, 0xb3, 0x50, 0xa8, 0x2b, 0xa1, - 0x6b, 0x25, 0x74, 0xd5, 0x8e, 0x66, 0xab, 0x76, 0x84, 0x6a, 0x40, 0x73, 0x27, 0x12, 0x0c, 0xa0, - 0x98, 0xa7, 0xd7, 0x6d, 0xe5, 0xc4, 0x63, 0xcf, 0xfa, 0x25, 0xd4, 0x4d, 0xad, 0x8f, 0x7c, 0x52, - 0xa8, 0x08, 0x2a, 0x17, 0xbb, 0x3a, 0x51, 0x11, 0xcc, 0xcb, 0x81, 0xd6, 0x7f, 0xd4, 0x61, 0x51, - 0x53, 0xd1, 0x37, 0xa0, 0x93, 0x30, 0x8e, 0x13, 0x7f, 0x93, 0x2f, 0xb3, 0x96, 0x49, 0x76, 0x4a, - 0x15, 0x9d, 0x17, 0x3c, 0x31, 0x23, 0x5b, 0xf7, 0x4d, 0xe4, 0x21, 0x3e, 0x85, 0xfa, 0x20, 0x12, - 0x89, 0x9c, 0x3a, 0x57, 0x2e, 0xd8, 0x1e, 0x69, 0x4e, 0xb6, 0x29, 0x03, 0x25, 0xcf, 0x60, 0x69, - 0x18, 0xe1, 0x9a, 0x3c, 0x72, 0x03, 0x16, 0xf6, 0x75, 0x6f, 0xac, 0x50, 0x48, 0x7b, 0x8b, 0x6c, - 0x5b, 0x71, 0xcd, 0xfc, 0xd6, 0xb0, 0x40, 0x24, 0xdf, 0x40, 0x1b, 0x75, 0x14, 0x85, 0xae, 0xef, - 0x0c, 0xa2, 0x44, 0xc4, 0x51, 0xa2, 0x3b, 0x5f, 0x85, 0xab, 0x7e, 0xa6, 0x11, 0x47, 0x0a, 0x60, - 0x24, 0xad, 0xc4, 0xe3, 0x74, 0xf2, 0x05, 0x34, 0xae, 0x5c, 0xdf, 0x8f, 0xdd, 0x98, 0x72, 0x1d, - 0x62, 0x17, 0x8a, 0x59, 0xdf, 0x1a, 0x96, 0x99, 0x9f, 0x83, 0xc9, 0x9f, 0x43, 0x4b, 0x26, 0xb2, - 0xe6, 0x4b, 0x16, 0xcb, 0x05, 0x21, 0xcc, 0x66, 0x4b, 0x1f, 0xd2, 0xf4, 0x72, 0x1a, 0x2e, 0x7d, - 0xee, 0xa7, 0x34, 0x89, 0xa2, 0x64, 0xa0, 0x3b, 0x56, 0x85, 0xa5, 0x9f, 0x19, 0x56, 0xb6, 0x74, - 0x06, 0x26, 0xbf, 0x83, 0xcd, 0x6b, 0x0a, 0xad, 0x8d, 0x72, 0x58, 0x5f, 0x19, 0x02, 0x1b, 0x91, - 0x1b, 0x6e, 0x65, 0x7d, 0xf5, 0x4b, 0x68, 0x06, 0x5e, 0xe0, 0x98, 0x5c, 0x08, 0xca, 0x37, 0xe3, - 0xe4, 0xf0, 0x44, 0xc7, 0xed, 0xd9, 0xcd, 0x08, 0xbc, 0xc0, 0x84, 0xf2, 0x14, 0xb6, 0x4d, 0x2f, - 0x4d, 0x36, 0xe3, 0x9c, 0x3e, 0x77, 0x7b, 0xd4, 0x89, 0x29, 0x67, 0x91, 0xa7, 0x9b, 0x5b, 0x0f, - 0x0b, 0x07, 0xa5, 0xb1, 0x2f, 0xa3, 0xde, 0xe5, 0x6f, 0x10, 0x79, 0x26, 0x81, 0x46, 0xf2, 0xed, - 0xb8, 0x9a, 0x4f, 0xbe, 0x83, 0xcd, 0xc0, 0xfd, 0x9e, 0x05, 0x69, 0x80, 0xb9, 0xb2, 0x74, 0x6c, - 0xd2, 0x6a, 0x9a, 0xce, 0xd7, 0xfb, 0xc5, 0x28, 0x56, 0xe2, 0x6c, 0x0d, 0x43, 0xe3, 0x99, 0xed, - 0x7c, 0x3d, 0xa8, 0x60, 0x92, 0xbf, 0x80, 0x0d, 0x8f, 0xb9, 0xfd, 0x30, 0x12, 0x09, 0xeb, 0x39, - 0x22, 0x3d, 0x0f, 0x98, 0x90, 0xd1, 0xca, 0x52, 0x59, 0xf6, 0x61, 0x06, 0xeb, 0x66, 0xa8, 0x4c, - 0xb6, 0x57, 0xc1, 0xc4, 0x27, 0xe0, 0xc6, 0xb1, 0xe3, 0x86, 0xae, 0x3f, 0x4a, 0x58, 0x4f, 0xe8, - 0xee, 0xd8, 0x78, 0xb3, 0x67, 0xdf, 0x70, 0xb3, 0x27, 0xe0, 0x16, 0x88, 0xe4, 0x02, 0xb6, 0xae, - 0x2f, 0xf1, 0xaf, 0x94, 0x13, 0xc5, 0xeb, 0x32, 0x25, 0x23, 0xbb, 0xe3, 0x5e, 0x97, 0x4a, 0x3d, - 0x86, 0xb5, 0x8a, 0xf7, 0x88, 0x11, 0xb1, 0xea, 0xb8, 0x79, 0x3a, 0x0a, 0x30, 0x43, 0xeb, 0x09, - 0x6c, 0x56, 0xbf, 0xbc, 0x29, 0x73, 0xfe, 0x0c, 0xda, 0xe5, 0x77, 0x86, 0xc1, 0x29, 0x0b, 0x4c, - 0x01, 0xa1, 0x65, 0xab, 0x01, 0x52, 0xaf, 0x06, 0x94, 0x9b, 0x40, 0x5f, 0x0d, 0xac, 0x47, 0x40, - 0x26, 0x9f, 0xda, 0x94, 0xf5, 0x3e, 0x86, 0x76, 0xf9, 0x71, 0x4d, 0x41, 0xff, 0x7d, 0x0d, 0xee, - 0x4c, 0x7b, 0x44, 0x37, 0x06, 0xa5, 0x6f, 0xaf, 0x7d, 0xac, 0xca, 0xe4, 0xee, 0xdd, 0xf0, 0x58, - 0xaf, 0x79, 0xa5, 0xd6, 0xdf, 0xd4, 0x60, 0xef, 0x86, 0x93, 0xbd, 0x71, 0x6f, 0xcf, 0xe0, 0xee, - 0xd8, 0xdd, 0x71, 0x3c, 0x55, 0x57, 0xc2, 0x50, 0x24, 0xcb, 0xcf, 0x5a, 0xf6, 0xce, 0x18, 0xe8, - 0x30, 0xc3, 0xa0, 0xda, 0xad, 0x27, 0xb0, 0x51, 0xdd, 0xa6, 0xd9, 0x82, 0xfa, 0x30, 0x0e, 0x8b, - 0x7f, 0x0c, 0x59, 0x1c, 0xc6, 0xe1, 0x9b, 0x94, 0x79, 0xd6, 0x67, 0xa6, 0xde, 0x59, 0x70, 0x2f, - 0x98, 0x88, 0x15, 0x1d, 0x92, 0xde, 0x6d, 0xee, 0x73, 0xac, 0x4f, 0x60, 0xa5, 0xe4, 0x59, 0x30, - 0xc1, 0xc9, 0xdc, 0x90, 0xae, 0x5f, 0x99, 0xb1, 0xf5, 0x5b, 0x58, 0x9d, 0xb0, 0x54, 0xe4, 0xe9, - 0xb8, 0x6d, 0xab, 0x95, 0x3b, 0xd3, 0xf9, 0x8c, 0xa2, 0x51, 0xb3, 0x3c, 0x80, 0x9c, 0x43, 0xde, - 0xc2, 0x43, 0xd9, 0x29, 0xd0, 0x9d, 0x55, 0x34, 0x72, 0xb2, 0x16, 0x49, 0x3d, 0xe7, 0x6a, 0xc0, - 0x7c, 0xea, 0x88, 0x34, 0xa6, 0x7c, 0xc8, 0x44, 0x76, 0x9d, 0xde, 0xcb, 0xf1, 0x68, 0xc8, 0xf6, - 0x15, 0xfa, 0x5b, 0x04, 0x77, 0x33, 0xac, 0xf5, 0x3b, 0xd8, 0x9d, 0x6e, 0x0e, 0xc9, 0xaf, 0xa7, - 0x1a, 0x57, 0x15, 0xf9, 0x5c, 0x67, 0x32, 0xad, 0x2e, 0xec, 0x4c, 0x31, 0x85, 0xe4, 0xb3, 0x6b, - 0x2d, 0xaa, 0x92, 0x5b, 0x69, 0x2a, 0xad, 0x5f, 0xc0, 0xce, 0x14, 0x1b, 0x38, 0xe5, 0x61, 0x3d, - 0x96, 0x39, 0x5e, 0xd9, 0xd0, 0x4d, 0x99, 0x70, 0x00, 0x7b, 0x37, 0x34, 0x2b, 0xdf, 0x21, 0xeb, - 0xf9, 0x1a, 0xee, 0x4c, 0xeb, 0x3d, 0xbe, 0x83, 0x84, 0x3e, 0x6c, 0x5f, 0xdf, 0x4f, 0x7c, 0x87, - 0xbe, 0xc0, 0x07, 0xb0, 0xa2, 0xff, 0x1b, 0x91, 0x35, 0x2c, 0x55, 0xda, 0xb3, 0xac, 0xc8, 0x46, - 0x94, 0xf5, 0xd7, 0x35, 0x58, 0xab, 0x68, 0x2b, 0x92, 0x0f, 0xa1, 0xdd, 0x4b, 0x39, 0xc7, 0xe3, - 0xc9, 0x2a, 0xcb, 0xba, 0x9a, 0xad, 0xe9, 0x19, 0xf4, 0x3e, 0xb4, 0x42, 0x7a, 0x95, 0xc3, 0x74, - 0x65, 0x2a, 0xa4, 0x57, 0x19, 0x64, 0x0f, 0x9a, 0xaa, 0xce, 0x1e, 0xf1, 0x28, 0x10, 0xba, 0xba, - 0x0e, 0x92, 0x74, 0x8a, 0x14, 0xeb, 0x33, 0xd8, 0xac, 0x6e, 0x42, 0x8e, 0x95, 0xb6, 0x6b, 0xa5, - 0xd2, 0xf6, 0x29, 0xac, 0x57, 0x75, 0x17, 0x31, 0x12, 0xed, 0x17, 0xfa, 0x2c, 0xf8, 0x7b, 0x32, - 0x21, 0x98, 0x9d, 0x4c, 0x08, 0xd0, 0x4b, 0x94, 0x3b, 0x81, 0xe4, 0x23, 0x58, 0x54, 0xad, 0x43, - 0x13, 0x10, 0xb7, 0x0b, 0xff, 0x54, 0x91, 0x0c, 0xdb, 0x00, 0xac, 0x11, 0x2c, 0xe8, 0x59, 0x7b, - 0xd0, 0x8c, 0x79, 0xe4, 0xa5, 0x3d, 0xd5, 0xc8, 0xd3, 0x76, 0x46, 0x93, 0xbe, 0xa1, 0x23, 0x59, - 0x8c, 0xd4, 0x80, 0xf1, 0x2a, 0xc5, 0xb2, 0x26, 0x9b, 0xf2, 0x8c, 0xcc, 0xd1, 0xf5, 0xff, 0x4c, - 0xa4, 0x4d, 0xd4, 0x31, 0xbc, 0xf9, 0xd3, 0xc0, 0xbe, 0x24, 0x5a, 0x1f, 0xc3, 0x7a, 0x55, 0x13, - 0x13, 0xdd, 0x99, 0x2c, 0xa5, 0xeb, 0x8b, 0xae, 0x06, 0xd6, 0x4b, 0x20, 0x93, 0xcd, 0x49, 0xf2, - 0x39, 0xdc, 0xbe, 0x60, 0x7e, 0x42, 0x79, 0xde, 0xd5, 0x74, 0xe2, 0x88, 0x85, 0x89, 0xb9, 0x63, - 0x1b, 0x8a, 0x9d, 0x4d, 0x39, 0x93, 0x4c, 0xeb, 0xc7, 0x1a, 0x90, 0xc9, 0xce, 0x24, 0xda, 0xe6, - 0x4b, 0x3a, 0x2a, 0x66, 0x30, 0x8b, 0x97, 0x74, 0x24, 0xf3, 0x97, 0x43, 0x68, 0xe7, 0x9d, 0x4e, - 0xd5, 0x41, 0xd2, 0x9e, 0xaa, 0x10, 0xe1, 0x67, 0xc2, 0x54, 0xf3, 0xc1, 0x5e, 0xc9, 0xa6, 0x28, - 0x02, 0xea, 0x10, 0x6f, 0x5e, 0x8f, 0x72, 0xbc, 0xf7, 0x3d, 0x57, 0x57, 0xf3, 0x5b, 0xf6, 0x72, - 0x48, 0xaf, 0x0e, 0x72, 0x2a, 0xf9, 0x1a, 0xee, 0x70, 0x1a, 0xfb, 0x23, 0x87, 0x86, 0x3d, 0x3e, - 0xd2, 0x95, 0x9b, 0xc2, 0xac, 0x79, 0x39, 0x6b, 0x5b, 0x62, 0x9e, 0x67, 0x90, 0x82, 0x04, 0xeb, - 0x9f, 0x6a, 0xb0, 0x52, 0xda, 0xcf, 0xb4, 0xab, 0xa9, 0x5a, 0x51, 0x68, 0x8c, 0x29, 0x9e, 0xbf, - 0x43, 0xbf, 0x8f, 0x23, 0x9e, 0xe8, 0x3b, 0xd7, 0xd6, 0x9c, 0x6f, 0xe8, 0xe8, 0xb9, 0xa4, 0x93, - 0xaf, 0x60, 0x67, 0x12, 0x9d, 0xbf, 0x28, 0x75, 0xe0, 0x9d, 0xf2, 0x34, 0x73, 0xdf, 0xad, 0x2f, - 0x61, 0x75, 0xa2, 0xaf, 0x8a, 0xca, 0x29, 0x77, 0x63, 0xd5, 0x26, 0x97, 0xcf, 0xc7, 0x80, 0xd6, - 0x7f, 0xd7, 0x60, 0xc9, 0xa6, 0x22, 0xf5, 0x13, 0xf3, 0x8f, 0x4b, 0x02, 0xf3, 0xa9, 0x57, 0xe8, - 0x53, 0x7a, 0x6c, 0xf2, 0x5f, 0x98, 0xb3, 0x93, 0xff, 0xc2, 0x7c, 0x0a, 0x4d, 0xca, 0x79, 0xc4, - 0x9d, 0xde, 0xc0, 0x65, 0xe1, 0x64, 0x39, 0xf1, 0x39, 0x32, 0x0f, 0x90, 0x67, 0x03, 0xcd, 0x7e, - 0x5b, 0x5d, 0x58, 0xe8, 0x26, 0x6e, 0x92, 0x0a, 0xd2, 0x86, 0xd6, 0x7e, 0xef, 0x32, 0x8c, 0xae, - 0x7c, 0xea, 0xf5, 0xa9, 0xd7, 0x9e, 0x21, 0x0d, 0xb8, 0x25, 0x67, 0xb5, 0x6b, 0x64, 0x13, 0x88, - 0xfe, 0xd7, 0xe6, 0x0b, 0xd9, 0xbd, 0x54, 0xf4, 0x59, 0x52, 0x87, 0xf9, 0x63, 0xcf, 0xa7, 0xed, - 0x39, 0x02, 0xb0, 0xf0, 0x2a, 0x4a, 0x5e, 0x45, 0x57, 0xed, 0x79, 0xeb, 0xdf, 0x6a, 0x00, 0xf9, - 0x7a, 0xe4, 0x53, 0xd8, 0xf0, 0xa3, 0x9e, 0xeb, 0xb3, 0x1f, 0xa8, 0xe7, 0x78, 0x54, 0xf4, 0x38, - 0x8b, 0xb3, 0x02, 0x53, 0xc3, 0x5e, 0xcf, 0x98, 0x87, 0x39, 0x0f, 0x7d, 0x55, 0x2a, 0x1c, 0x1a, - 0xf6, 0x7d, 0x26, 0x06, 0x63, 0xb3, 0xd4, 0xc7, 0xaf, 0xa7, 0xe2, 0xb9, 0x62, 0x16, 0x67, 0xdd, - 0x87, 0x96, 0xd2, 0x82, 0x17, 0x05, 0x4a, 0x0d, 0x52, 0x51, 0x92, 0x76, 0x28, 0x49, 0x98, 0xdc, - 0x6b, 0x45, 0x45, 0x9e, 0xba, 0x7c, 0xb7, 0xec, 0x86, 0xd2, 0x48, 0xe4, 0xd1, 0x67, 0xed, 0xff, - 0xfc, 0x69, 0xb7, 0xf6, 0x5f, 0x3f, 0xed, 0xd6, 0x7e, 0xfc, 0x69, 0xb7, 0xf6, 0x8f, 0xff, 0xb3, - 0x3b, 0x73, 0xbe, 0x20, 0x15, 0xf8, 0xe9, 0xff, 0x07, 0x00, 0x00, 0xff, 0xff, 0xcc, 0xaf, 0xde, - 0x66, 0x32, 0x2b, 0x00, 0x00, -} - -func (m *CommandPayload) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *CommandPayload) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *CommandPayload) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if m.Command != nil { - { - size, err := m.Command.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if len(m.CommandUuid) > 0 { - i -= len(m.CommandUuid) - copy(dAtA[i:], m.CommandUuid) - i = encodeVarintMdm(dAtA, i, uint64(len(m.CommandUuid))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *Command) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Command) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Command) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if m.Request != nil { - { - size := m.Request.Size() - i -= size - if _, err := m.Request.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - } - } - if len(m.RequestType) > 0 { - i -= len(m.RequestType) - copy(dAtA[i:], m.RequestType) - i = encodeVarintMdm(dAtA, i, uint64(len(m.RequestType))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *Command_InstallProfile) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Command_InstallProfile) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.InstallProfile != nil { - { - size, err := m.InstallProfile.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - return len(dAtA) - i, nil -} -func (m *Command_RemoveProfile) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Command_RemoveProfile) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.RemoveProfile != nil { - { - size, err := m.RemoveProfile.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - return len(dAtA) - i, nil -} -func (m *Command_InstallProvisioningProfile) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Command_InstallProvisioningProfile) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.InstallProvisioningProfile != nil { - { - size, err := m.InstallProvisioningProfile.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - return len(dAtA) - i, nil -} -func (m *Command_RemoveProfisioningProfile) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Command_RemoveProfisioningProfile) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.RemoveProfisioningProfile != nil { - { - size, err := m.RemoveProfisioningProfile.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - } - return len(dAtA) - i, nil -} -func (m *Command_InstalledApplicationList) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Command_InstalledApplicationList) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.InstalledApplicationList != nil { - { - size, err := m.InstalledApplicationList.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x32 - } - return len(dAtA) - i, nil -} -func (m *Command_DeviceInformation) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Command_DeviceInformation) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.DeviceInformation != nil { - { - size, err := m.DeviceInformation.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x3a - } - return len(dAtA) - i, nil -} -func (m *Command_DeviceLock) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Command_DeviceLock) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.DeviceLock != nil { - { - size, err := m.DeviceLock.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x42 - } - return len(dAtA) - i, nil -} -func (m *Command_ClearPasscode) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Command_ClearPasscode) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.ClearPasscode != nil { - { - size, err := m.ClearPasscode.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x4a - } - return len(dAtA) - i, nil -} -func (m *Command_EraseDevice) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Command_EraseDevice) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.EraseDevice != nil { - { - size, err := m.EraseDevice.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x52 - } - return len(dAtA) - i, nil -} -func (m *Command_RequestMirroring) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Command_RequestMirroring) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.RequestMirroring != nil { - { - size, err := m.RequestMirroring.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x5a - } - return len(dAtA) - i, nil -} -func (m *Command_Restrictions) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Command_Restrictions) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.Restrictions != nil { - { - size, err := m.Restrictions.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x62 - } - return len(dAtA) - i, nil -} -func (m *Command_UnlockUserAccount) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Command_UnlockUserAccount) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.UnlockUserAccount != nil { - { - size, err := m.UnlockUserAccount.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6a - } - return len(dAtA) - i, nil -} -func (m *Command_DeleteUser) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Command_DeleteUser) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.DeleteUser != nil { - { - size, err := m.DeleteUser.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x72 - } - return len(dAtA) - i, nil -} -func (m *Command_EnableLostMode) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Command_EnableLostMode) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.EnableLostMode != nil { - { - size, err := m.EnableLostMode.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x7a - } - return len(dAtA) - i, nil -} -func (m *Command_InstallApplication) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Command_InstallApplication) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.InstallApplication != nil { - { - size, err := m.InstallApplication.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0x82 - } - return len(dAtA) - i, nil -} -func (m *Command_AccountConfiguration) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Command_AccountConfiguration) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.AccountConfiguration != nil { - { - size, err := m.AccountConfiguration.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0x8a - } - return len(dAtA) - i, nil -} -func (m *Command_ApplyRedemptionCode) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Command_ApplyRedemptionCode) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.ApplyRedemptionCode != nil { - { - size, err := m.ApplyRedemptionCode.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0x92 - } - return len(dAtA) - i, nil -} -func (m *Command_ManagedApplicationList) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Command_ManagedApplicationList) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.ManagedApplicationList != nil { - { - size, err := m.ManagedApplicationList.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0x9a - } - return len(dAtA) - i, nil -} -func (m *Command_RemoveApplication) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Command_RemoveApplication) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.RemoveApplication != nil { - { - size, err := m.RemoveApplication.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0xa2 - } - return len(dAtA) - i, nil -} -func (m *Command_InviteToProgram) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Command_InviteToProgram) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.InviteToProgram != nil { - { - size, err := m.InviteToProgram.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0xaa - } - return len(dAtA) - i, nil -} -func (m *Command_ValidataApplications) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Command_ValidataApplications) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.ValidataApplications != nil { - { - size, err := m.ValidataApplications.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0xb2 - } - return len(dAtA) - i, nil -} -func (m *Command_InstallMedia) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Command_InstallMedia) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.InstallMedia != nil { - { - size, err := m.InstallMedia.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0xba - } - return len(dAtA) - i, nil -} -func (m *Command_RemoveMedia) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Command_RemoveMedia) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.RemoveMedia != nil { - { - size, err := m.RemoveMedia.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0xc2 - } - return len(dAtA) - i, nil -} -func (m *Command_Settings) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Command_Settings) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.Settings != nil { - { - size, err := m.Settings.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0xca - } - return len(dAtA) - i, nil -} -func (m *Command_ManagedApplicationConfiguration) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Command_ManagedApplicationConfiguration) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.ManagedApplicationConfiguration != nil { - { - size, err := m.ManagedApplicationConfiguration.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0xd2 - } - return len(dAtA) - i, nil -} -func (m *Command_ManagedApplicationAttributes) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Command_ManagedApplicationAttributes) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.ManagedApplicationAttributes != nil { - { - size, err := m.ManagedApplicationAttributes.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0xda - } - return len(dAtA) - i, nil -} -func (m *Command_ManagedApplicationFeedback) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Command_ManagedApplicationFeedback) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.ManagedApplicationFeedback != nil { - { - size, err := m.ManagedApplicationFeedback.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0xe2 - } - return len(dAtA) - i, nil -} -func (m *Command_SetFirmwarePassword) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Command_SetFirmwarePassword) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.SetFirmwarePassword != nil { - { - size, err := m.SetFirmwarePassword.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0xea - } - return len(dAtA) - i, nil -} -func (m *Command_VerifyFirmwarePassword) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Command_VerifyFirmwarePassword) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.VerifyFirmwarePassword != nil { - { - size, err := m.VerifyFirmwarePassword.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0xf2 - } - return len(dAtA) - i, nil -} -func (m *Command_SetAutoAdminPassword) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Command_SetAutoAdminPassword) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.SetAutoAdminPassword != nil { - { - size, err := m.SetAutoAdminPassword.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0xfa - } - return len(dAtA) - i, nil -} -func (m *Command_ScheduleOsUpdate) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Command_ScheduleOsUpdate) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.ScheduleOsUpdate != nil { - { - size, err := m.ScheduleOsUpdate.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2 - i-- - dAtA[i] = 0x82 - } - return len(dAtA) - i, nil -} -func (m *Command_ScheduleOsUpdateScan) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Command_ScheduleOsUpdateScan) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.ScheduleOsUpdateScan != nil { - { - size, err := m.ScheduleOsUpdateScan.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2 - i-- - dAtA[i] = 0x8a - } - return len(dAtA) - i, nil -} -func (m *Command_ActiveNsExtensions) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Command_ActiveNsExtensions) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.ActiveNsExtensions != nil { - { - size, err := m.ActiveNsExtensions.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2 - i-- - dAtA[i] = 0x92 - } - return len(dAtA) - i, nil -} -func (m *Command_RotateFilevaultKey) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Command_RotateFilevaultKey) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.RotateFilevaultKey != nil { - { - size, err := m.RotateFilevaultKey.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2 - i-- - dAtA[i] = 0x9a - } - return len(dAtA) - i, nil -} -func (m *Command_InstallEnterpriseApplication) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Command_InstallEnterpriseApplication) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.InstallEnterpriseApplication != nil { - { - size, err := m.InstallEnterpriseApplication.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2 - i-- - dAtA[i] = 0xa2 - } - return len(dAtA) - i, nil -} -func (m *Command_SetBootstrapToken) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Command_SetBootstrapToken) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.SetBootstrapToken != nil { - { - size, err := m.SetBootstrapToken.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2 - i-- - dAtA[i] = 0xaa - } - return len(dAtA) - i, nil -} -func (m *InstallProfile) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *InstallProfile) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *InstallProfile) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.Payload) > 0 { - i -= len(m.Payload) - copy(dAtA[i:], m.Payload) - i = encodeVarintMdm(dAtA, i, uint64(len(m.Payload))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *RemoveProfile) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *RemoveProfile) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *RemoveProfile) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.Identifier) > 0 { - i -= len(m.Identifier) - copy(dAtA[i:], m.Identifier) - i = encodeVarintMdm(dAtA, i, uint64(len(m.Identifier))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *InstallProvisioningProfile) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *InstallProvisioningProfile) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *InstallProvisioningProfile) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.ProvisioningProfile) > 0 { - i -= len(m.ProvisioningProfile) - copy(dAtA[i:], m.ProvisioningProfile) - i = encodeVarintMdm(dAtA, i, uint64(len(m.ProvisioningProfile))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *RemoveProvisioningProfile) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *RemoveProvisioningProfile) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *RemoveProvisioningProfile) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.Uuid) > 0 { - i -= len(m.Uuid) - copy(dAtA[i:], m.Uuid) - i = encodeVarintMdm(dAtA, i, uint64(len(m.Uuid))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *InstalledApplicationList) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *InstalledApplicationList) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *InstalledApplicationList) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if m.ManagedAppsOnly { - i-- - if m.ManagedAppsOnly { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x10 - } - if len(m.Identifiers) > 0 { - for iNdEx := len(m.Identifiers) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Identifiers[iNdEx]) - copy(dAtA[i:], m.Identifiers[iNdEx]) - i = encodeVarintMdm(dAtA, i, uint64(len(m.Identifiers[iNdEx]))) - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *DeviceInformation) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *DeviceInformation) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *DeviceInformation) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.Queries) > 0 { - for iNdEx := len(m.Queries) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Queries[iNdEx]) - copy(dAtA[i:], m.Queries[iNdEx]) - i = encodeVarintMdm(dAtA, i, uint64(len(m.Queries[iNdEx]))) - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *ClearPasscode) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ClearPasscode) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ClearPasscode) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.UnlockToken) > 0 { - i -= len(m.UnlockToken) - copy(dAtA[i:], m.UnlockToken) - i = encodeVarintMdm(dAtA, i, uint64(len(m.UnlockToken))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *DeviceLock) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *DeviceLock) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *DeviceLock) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.PhoneNumber) > 0 { - i -= len(m.PhoneNumber) - copy(dAtA[i:], m.PhoneNumber) - i = encodeVarintMdm(dAtA, i, uint64(len(m.PhoneNumber))) - i-- - dAtA[i] = 0x1a - } - if len(m.Message) > 0 { - i -= len(m.Message) - copy(dAtA[i:], m.Message) - i = encodeVarintMdm(dAtA, i, uint64(len(m.Message))) - i-- - dAtA[i] = 0x12 - } - if len(m.Pin) > 0 { - i -= len(m.Pin) - copy(dAtA[i:], m.Pin) - i = encodeVarintMdm(dAtA, i, uint64(len(m.Pin))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *EraseDevice) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *EraseDevice) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *EraseDevice) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if m.DisallowProximitySetup { - i-- - if m.DisallowProximitySetup { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x18 - } - if m.PreserveDataPlan { - i-- - if m.PreserveDataPlan { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x10 - } - if len(m.Pin) > 0 { - i -= len(m.Pin) - copy(dAtA[i:], m.Pin) - i = encodeVarintMdm(dAtA, i, uint64(len(m.Pin))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *RequestMirroring) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *RequestMirroring) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *RequestMirroring) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.Password) > 0 { - i -= len(m.Password) - copy(dAtA[i:], m.Password) - i = encodeVarintMdm(dAtA, i, uint64(len(m.Password))) - i-- - dAtA[i] = 0x22 - } - if len(m.ScanTime) > 0 { - i -= len(m.ScanTime) - copy(dAtA[i:], m.ScanTime) - i = encodeVarintMdm(dAtA, i, uint64(len(m.ScanTime))) - i-- - dAtA[i] = 0x1a - } - if len(m.DestinationDeviceId) > 0 { - i -= len(m.DestinationDeviceId) - copy(dAtA[i:], m.DestinationDeviceId) - i = encodeVarintMdm(dAtA, i, uint64(len(m.DestinationDeviceId))) - i-- - dAtA[i] = 0x12 - } - if len(m.DestinationName) > 0 { - i -= len(m.DestinationName) - copy(dAtA[i:], m.DestinationName) - i = encodeVarintMdm(dAtA, i, uint64(len(m.DestinationName))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *Restrictions) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Restrictions) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Restrictions) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if m.ProfileRestrictions { - i-- - if m.ProfileRestrictions { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *UnlockUserAccount) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *UnlockUserAccount) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *UnlockUserAccount) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.Username) > 0 { - i -= len(m.Username) - copy(dAtA[i:], m.Username) - i = encodeVarintMdm(dAtA, i, uint64(len(m.Username))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *DeleteUser) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *DeleteUser) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *DeleteUser) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if m.ForceDeletion { - i-- - if m.ForceDeletion { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x10 - } - if len(m.Username) > 0 { - i -= len(m.Username) - copy(dAtA[i:], m.Username) - i = encodeVarintMdm(dAtA, i, uint64(len(m.Username))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *EnableLostMode) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *EnableLostMode) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *EnableLostMode) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.Footnote) > 0 { - i -= len(m.Footnote) - copy(dAtA[i:], m.Footnote) - i = encodeVarintMdm(dAtA, i, uint64(len(m.Footnote))) - i-- - dAtA[i] = 0x1a - } - if len(m.PhoneNumber) > 0 { - i -= len(m.PhoneNumber) - copy(dAtA[i:], m.PhoneNumber) - i = encodeVarintMdm(dAtA, i, uint64(len(m.PhoneNumber))) - i-- - dAtA[i] = 0x12 - } - if len(m.Message) > 0 { - i -= len(m.Message) - copy(dAtA[i:], m.Message) - i = encodeVarintMdm(dAtA, i, uint64(len(m.Message))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *InstallApplication) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *InstallApplication) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *InstallApplication) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.ChangeManagementState) > 0 { - i -= len(m.ChangeManagementState) - copy(dAtA[i:], m.ChangeManagementState) - i = encodeVarintMdm(dAtA, i, uint64(len(m.ChangeManagementState))) - i-- - dAtA[i] = 0x42 - } - if m.Attributes != nil { - { - size, err := m.Attributes.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x3a - } - if m.Configuration != nil { - { - size, err := m.Configuration.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x32 - } - if m.ManagementFlags != 0 { - i = encodeVarintMdm(dAtA, i, uint64(m.ManagementFlags)) - i-- - dAtA[i] = 0x28 - } - if len(m.ManifestUrl) > 0 { - i -= len(m.ManifestUrl) - copy(dAtA[i:], m.ManifestUrl) - i = encodeVarintMdm(dAtA, i, uint64(len(m.ManifestUrl))) - i-- - dAtA[i] = 0x22 - } - if m.Options != nil { - { - size, err := m.Options.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - if len(m.Identifier) > 0 { - i -= len(m.Identifier) - copy(dAtA[i:], m.Identifier) - i = encodeVarintMdm(dAtA, i, uint64(len(m.Identifier))) - i-- - dAtA[i] = 0x12 - } - if m.ItunesStoreId != 0 { - i = encodeVarintMdm(dAtA, i, uint64(m.ItunesStoreId)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *InstallApplicationOptions) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *InstallApplicationOptions) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *InstallApplicationOptions) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if m.PurchaseMethod != 0 { - i = encodeVarintMdm(dAtA, i, uint64(m.PurchaseMethod)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *InstallApplicationConfiguration) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *InstallApplicationConfiguration) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *InstallApplicationConfiguration) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - return len(dAtA) - i, nil -} - -func (m *InstallApplicationAttributes) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *InstallApplicationAttributes) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *InstallApplicationAttributes) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - return len(dAtA) - i, nil -} - -func (m *InstallEnterpriseApplication) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *InstallEnterpriseApplication) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *InstallEnterpriseApplication) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if m.PinningRevocationCheckRequired { - i-- - if m.PinningRevocationCheckRequired { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x20 - } - if len(m.ManifestUrlPinningCerts) > 0 { - for iNdEx := len(m.ManifestUrlPinningCerts) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.ManifestUrlPinningCerts[iNdEx]) - copy(dAtA[i:], m.ManifestUrlPinningCerts[iNdEx]) - i = encodeVarintMdm(dAtA, i, uint64(len(m.ManifestUrlPinningCerts[iNdEx]))) - i-- - dAtA[i] = 0x1a - } - } - if len(m.ManifestUrl) > 0 { - i -= len(m.ManifestUrl) - copy(dAtA[i:], m.ManifestUrl) - i = encodeVarintMdm(dAtA, i, uint64(len(m.ManifestUrl))) - i-- - dAtA[i] = 0x12 - } - if m.Manifest != nil { - { - size, err := m.Manifest.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *Manifest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Manifest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Manifest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.ManifestItems) > 0 { - for iNdEx := len(m.ManifestItems) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.ManifestItems[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *ManifestItem) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ManifestItem) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ManifestItem) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if m.Metadata != nil { - { - size, err := m.Metadata.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if len(m.Assets) > 0 { - for iNdEx := len(m.Assets) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Assets[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *Asset) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Asset) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Asset) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.Sha256S) > 0 { - for iNdEx := len(m.Sha256S) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Sha256S[iNdEx]) - copy(dAtA[i:], m.Sha256S[iNdEx]) - i = encodeVarintMdm(dAtA, i, uint64(len(m.Sha256S[iNdEx]))) - i-- - dAtA[i] = 0x32 - } - } - if m.Sha256Size != 0 { - i = encodeVarintMdm(dAtA, i, uint64(m.Sha256Size)) - i-- - dAtA[i] = 0x28 - } - if len(m.Url) > 0 { - i -= len(m.Url) - copy(dAtA[i:], m.Url) - i = encodeVarintMdm(dAtA, i, uint64(len(m.Url))) - i-- - dAtA[i] = 0x22 - } - if len(m.Md5S) > 0 { - for iNdEx := len(m.Md5S) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Md5S[iNdEx]) - copy(dAtA[i:], m.Md5S[iNdEx]) - i = encodeVarintMdm(dAtA, i, uint64(len(m.Md5S[iNdEx]))) - i-- - dAtA[i] = 0x1a - } - } - if m.Md5Size != 0 { - i = encodeVarintMdm(dAtA, i, uint64(m.Md5Size)) - i-- - dAtA[i] = 0x10 - } - if len(m.Kind) > 0 { - i -= len(m.Kind) - copy(dAtA[i:], m.Kind) - i = encodeVarintMdm(dAtA, i, uint64(len(m.Kind))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *Metadata) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Metadata) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Metadata) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if m.SizeInBytes != 0 { - i = encodeVarintMdm(dAtA, i, uint64(m.SizeInBytes)) - i-- - dAtA[i] = 0x38 - } - if len(m.Title) > 0 { - i -= len(m.Title) - copy(dAtA[i:], m.Title) - i = encodeVarintMdm(dAtA, i, uint64(len(m.Title))) - i-- - dAtA[i] = 0x32 - } - if len(m.Subtitle) > 0 { - i -= len(m.Subtitle) - copy(dAtA[i:], m.Subtitle) - i = encodeVarintMdm(dAtA, i, uint64(len(m.Subtitle))) - i-- - dAtA[i] = 0x2a - } - if len(m.Kind) > 0 { - i -= len(m.Kind) - copy(dAtA[i:], m.Kind) - i = encodeVarintMdm(dAtA, i, uint64(len(m.Kind))) - i-- - dAtA[i] = 0x22 - } - if len(m.Items) > 0 { - for iNdEx := len(m.Items) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Items[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - } - if len(m.BundleVersion) > 0 { - i -= len(m.BundleVersion) - copy(dAtA[i:], m.BundleVersion) - i = encodeVarintMdm(dAtA, i, uint64(len(m.BundleVersion))) - i-- - dAtA[i] = 0x12 - } - if len(m.BundleIdentifier) > 0 { - i -= len(m.BundleIdentifier) - copy(dAtA[i:], m.BundleIdentifier) - i = encodeVarintMdm(dAtA, i, uint64(len(m.BundleIdentifier))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *BundleInfo) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *BundleInfo) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *BundleInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.BundleVersion) > 0 { - i -= len(m.BundleVersion) - copy(dAtA[i:], m.BundleVersion) - i = encodeVarintMdm(dAtA, i, uint64(len(m.BundleVersion))) - i-- - dAtA[i] = 0x12 - } - if len(m.BundleIdentifier) > 0 { - i -= len(m.BundleIdentifier) - copy(dAtA[i:], m.BundleIdentifier) - i = encodeVarintMdm(dAtA, i, uint64(len(m.BundleIdentifier))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *ApplyRedemptionCode) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ApplyRedemptionCode) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ApplyRedemptionCode) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.RedemptionCode) > 0 { - i -= len(m.RedemptionCode) - copy(dAtA[i:], m.RedemptionCode) - i = encodeVarintMdm(dAtA, i, uint64(len(m.RedemptionCode))) - i-- - dAtA[i] = 0x12 - } - if len(m.Identifier) > 0 { - i -= len(m.Identifier) - copy(dAtA[i:], m.Identifier) - i = encodeVarintMdm(dAtA, i, uint64(len(m.Identifier))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *ManagedApplicationList) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ManagedApplicationList) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ManagedApplicationList) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.Identifiers) > 0 { - for iNdEx := len(m.Identifiers) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Identifiers[iNdEx]) - copy(dAtA[i:], m.Identifiers[iNdEx]) - i = encodeVarintMdm(dAtA, i, uint64(len(m.Identifiers[iNdEx]))) - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *RemoveApplication) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *RemoveApplication) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *RemoveApplication) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.Identifier) > 0 { - i -= len(m.Identifier) - copy(dAtA[i:], m.Identifier) - i = encodeVarintMdm(dAtA, i, uint64(len(m.Identifier))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *InviteToProgram) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *InviteToProgram) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *InviteToProgram) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.InvitationUrl) > 0 { - i -= len(m.InvitationUrl) - copy(dAtA[i:], m.InvitationUrl) - i = encodeVarintMdm(dAtA, i, uint64(len(m.InvitationUrl))) - i-- - dAtA[i] = 0x12 - } - if len(m.ProgramId) > 0 { - i -= len(m.ProgramId) - copy(dAtA[i:], m.ProgramId) - i = encodeVarintMdm(dAtA, i, uint64(len(m.ProgramId))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *ValidateApplications) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ValidateApplications) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ValidateApplications) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.Identifiers) > 0 { - for iNdEx := len(m.Identifiers) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Identifiers[iNdEx]) - copy(dAtA[i:], m.Identifiers[iNdEx]) - i = encodeVarintMdm(dAtA, i, uint64(len(m.Identifiers[iNdEx]))) - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *AccountConfiguration) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *AccountConfiguration) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *AccountConfiguration) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.PrimaryAccountUserName) > 0 { - i -= len(m.PrimaryAccountUserName) - copy(dAtA[i:], m.PrimaryAccountUserName) - i = encodeVarintMdm(dAtA, i, uint64(len(m.PrimaryAccountUserName))) - i-- - dAtA[i] = 0x3a - } - if len(m.PrimaryAccountFullName) > 0 { - i -= len(m.PrimaryAccountFullName) - copy(dAtA[i:], m.PrimaryAccountFullName) - i = encodeVarintMdm(dAtA, i, uint64(len(m.PrimaryAccountFullName))) - i-- - dAtA[i] = 0x32 - } - if m.LockPrimaryAccountInfo { - i-- - if m.LockPrimaryAccountInfo { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x28 - } - if m.DontAutoPopulatePrimaryAccountInfo { - i-- - if m.DontAutoPopulatePrimaryAccountInfo { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x20 - } - if len(m.AutoSetupAdminAccounts) > 0 { - for iNdEx := len(m.AutoSetupAdminAccounts) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.AutoSetupAdminAccounts[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - } - if m.SetPrimarySetupAccountAsRegularUser { - i-- - if m.SetPrimarySetupAccountAsRegularUser { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x10 - } - if m.SkipPrimarySetupAccountCreation { - i-- - if m.SkipPrimarySetupAccountCreation { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *AutoSetupAdminAccounts) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *AutoSetupAdminAccounts) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *AutoSetupAdminAccounts) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if m.Hidden { - i-- - if m.Hidden { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x20 - } - if len(m.PasswordHash) > 0 { - i -= len(m.PasswordHash) - copy(dAtA[i:], m.PasswordHash) - i = encodeVarintMdm(dAtA, i, uint64(len(m.PasswordHash))) - i-- - dAtA[i] = 0x1a - } - if len(m.FullName) > 0 { - i -= len(m.FullName) - copy(dAtA[i:], m.FullName) - i = encodeVarintMdm(dAtA, i, uint64(len(m.FullName))) - i-- - dAtA[i] = 0x12 - } - if len(m.ShortName) > 0 { - i -= len(m.ShortName) - copy(dAtA[i:], m.ShortName) - i = encodeVarintMdm(dAtA, i, uint64(len(m.ShortName))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *InstallMedia) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *InstallMedia) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *InstallMedia) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.MediaType) > 0 { - i -= len(m.MediaType) - copy(dAtA[i:], m.MediaType) - i = encodeVarintMdm(dAtA, i, uint64(len(m.MediaType))) - i-- - dAtA[i] = 0x1a - } - if len(m.MediaUrl) > 0 { - i -= len(m.MediaUrl) - copy(dAtA[i:], m.MediaUrl) - i = encodeVarintMdm(dAtA, i, uint64(len(m.MediaUrl))) - i-- - dAtA[i] = 0x12 - } - if m.ItunesStoreId != 0 { - i = encodeVarintMdm(dAtA, i, uint64(m.ItunesStoreId)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *RemoveMedia) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *RemoveMedia) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *RemoveMedia) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.PersistentId) > 0 { - i -= len(m.PersistentId) - copy(dAtA[i:], m.PersistentId) - i = encodeVarintMdm(dAtA, i, uint64(len(m.PersistentId))) - i-- - dAtA[i] = 0x1a - } - if m.ItunesStoreId != 0 { - i = encodeVarintMdm(dAtA, i, uint64(m.ItunesStoreId)) - i-- - dAtA[i] = 0x10 - } - if len(m.MediaType) > 0 { - i -= len(m.MediaType) - copy(dAtA[i:], m.MediaType) - i = encodeVarintMdm(dAtA, i, uint64(len(m.MediaType))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *Settings) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Settings) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Settings) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.Settings) > 0 { - for iNdEx := len(m.Settings) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Settings[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *Setting) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Setting) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Setting) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if m.ApplicationConfiguration != nil { - { - size, err := m.ApplicationConfiguration.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x7a - } - if m.AppAnalytics != nil { - { - size, err := m.AppAnalytics.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x72 - } - if m.DiagnosticSubmission != nil { - { - size, err := m.DiagnosticSubmission.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6a - } - if m.MaximumResidentUsers != nil { - { - size, err := m.MaximumResidentUsers.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x62 - } - if m.PasscodeLockGracePeriod != nil { - { - size, err := m.PasscodeLockGracePeriod.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x5a - } - if m.MdmOptions != nil { - { - size, err := m.MdmOptions.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x52 - } - if m.ApplicationAttributes != nil { - { - size, err := m.ApplicationAttributes.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x4a - } - if m.Bluetooth != nil { - { - size, err := m.Bluetooth.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x42 - } - if m.DataRoaming != nil { - { - size, err := m.DataRoaming.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x3a - } - if m.Wallpaper != nil { - { - size, err := m.Wallpaper.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x32 - } - if m.PersonalHotspot != nil { - { - size, err := m.PersonalHotspot.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - } - if m.VoiceRoaming != nil { - { - size, err := m.VoiceRoaming.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - if m.Hostname != nil { - { - size, err := m.Hostname.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - if m.DeviceName != nil { - { - size, err := m.DeviceName.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if len(m.Item) > 0 { - i -= len(m.Item) - copy(dAtA[i:], m.Item) - i = encodeVarintMdm(dAtA, i, uint64(len(m.Item))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *VoiceRoamingSetting) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *VoiceRoamingSetting) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *VoiceRoamingSetting) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if m.Enabled { - i-- - if m.Enabled { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *PersonalHotspotSetting) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *PersonalHotspotSetting) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *PersonalHotspotSetting) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if m.Enabled { - i-- - if m.Enabled { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *WallpaperSetting) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *WallpaperSetting) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *WallpaperSetting) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if m.Where != 0 { - i = encodeVarintMdm(dAtA, i, uint64(m.Where)) - i-- - dAtA[i] = 0x10 - } - if len(m.Image) > 0 { - i -= len(m.Image) - copy(dAtA[i:], m.Image) - i = encodeVarintMdm(dAtA, i, uint64(len(m.Image))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *DataRoamingSetting) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *DataRoamingSetting) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *DataRoamingSetting) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if m.Enabled { - i-- - if m.Enabled { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *BluetoothSetting) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *BluetoothSetting) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *BluetoothSetting) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if m.Enabled { - i-- - if m.Enabled { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *ApplicationAttributesSetting) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ApplicationAttributesSetting) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ApplicationAttributesSetting) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if m.ApplicationAttributes != nil { - { - size, err := m.ApplicationAttributes.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if len(m.Identifier) > 0 { - i -= len(m.Identifier) - copy(dAtA[i:], m.Identifier) - i = encodeVarintMdm(dAtA, i, uint64(len(m.Identifier))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *ApplicationConfigurationSetting) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ApplicationConfigurationSetting) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ApplicationConfigurationSetting) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.ConfigurationDictionaryData) > 0 { - i -= len(m.ConfigurationDictionaryData) - copy(dAtA[i:], m.ConfigurationDictionaryData) - i = encodeVarintMdm(dAtA, i, uint64(len(m.ConfigurationDictionaryData))) - i-- - dAtA[i] = 0x12 - } - if len(m.Identifier) > 0 { - i -= len(m.Identifier) - copy(dAtA[i:], m.Identifier) - i = encodeVarintMdm(dAtA, i, uint64(len(m.Identifier))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *ApplicationAttributes) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ApplicationAttributes) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ApplicationAttributes) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.VpnUuid) > 0 { - i -= len(m.VpnUuid) - copy(dAtA[i:], m.VpnUuid) - i = encodeVarintMdm(dAtA, i, uint64(len(m.VpnUuid))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *DeviceNameSetting) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *DeviceNameSetting) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *DeviceNameSetting) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.DeviceName) > 0 { - i -= len(m.DeviceName) - copy(dAtA[i:], m.DeviceName) - i = encodeVarintMdm(dAtA, i, uint64(len(m.DeviceName))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *HostnameSetting) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *HostnameSetting) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *HostnameSetting) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.Hostname) > 0 { - i -= len(m.Hostname) - copy(dAtA[i:], m.Hostname) - i = encodeVarintMdm(dAtA, i, uint64(len(m.Hostname))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MDMOptionsSetting) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MDMOptionsSetting) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MDMOptionsSetting) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if m.MdmOptions != nil { - { - size, err := m.MdmOptions.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MDMOptions) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MDMOptions) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MDMOptions) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if m.ActivationLockAllowedWhileSupervised { - i-- - if m.ActivationLockAllowedWhileSupervised { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *PasscodeLockGracePeriodSetting) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *PasscodeLockGracePeriodSetting) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *PasscodeLockGracePeriodSetting) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if m.PasscodeLockGracePeriod != 0 { - i = encodeVarintMdm(dAtA, i, uint64(m.PasscodeLockGracePeriod)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *MaximumResidentUsersSetting) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *MaximumResidentUsersSetting) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MaximumResidentUsersSetting) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if m.MaximumResidentUsers != 0 { - i = encodeVarintMdm(dAtA, i, uint64(m.MaximumResidentUsers)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *DiagnosticSubmissionSetting) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *DiagnosticSubmissionSetting) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *DiagnosticSubmissionSetting) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if m.Enabled { - i-- - if m.Enabled { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *AppAnalyticsSetting) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *AppAnalyticsSetting) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *AppAnalyticsSetting) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if m.Enabled { - i-- - if m.Enabled { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *ManagedApplicationConfiguration) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ManagedApplicationConfiguration) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ManagedApplicationConfiguration) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.Identifiers) > 0 { - for iNdEx := len(m.Identifiers) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Identifiers[iNdEx]) - copy(dAtA[i:], m.Identifiers[iNdEx]) - i = encodeVarintMdm(dAtA, i, uint64(len(m.Identifiers[iNdEx]))) - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *ManagedApplicationAttributes) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ManagedApplicationAttributes) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ManagedApplicationAttributes) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.Identifiers) > 0 { - for iNdEx := len(m.Identifiers) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Identifiers[iNdEx]) - copy(dAtA[i:], m.Identifiers[iNdEx]) - i = encodeVarintMdm(dAtA, i, uint64(len(m.Identifiers[iNdEx]))) - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *ManagedApplicationFeedback) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ManagedApplicationFeedback) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ManagedApplicationFeedback) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if m.DeleteFeedback { - i-- - if m.DeleteFeedback { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x10 - } - if len(m.Identifiers) > 0 { - for iNdEx := len(m.Identifiers) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Identifiers[iNdEx]) - copy(dAtA[i:], m.Identifiers[iNdEx]) - i = encodeVarintMdm(dAtA, i, uint64(len(m.Identifiers[iNdEx]))) - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *SetFirmwarePassword) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *SetFirmwarePassword) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *SetFirmwarePassword) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if m.AllowOroms { - i-- - if m.AllowOroms { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x18 - } - if len(m.NewPassword) > 0 { - i -= len(m.NewPassword) - copy(dAtA[i:], m.NewPassword) - i = encodeVarintMdm(dAtA, i, uint64(len(m.NewPassword))) - i-- - dAtA[i] = 0x12 - } - if len(m.CurrentPassword) > 0 { - i -= len(m.CurrentPassword) - copy(dAtA[i:], m.CurrentPassword) - i = encodeVarintMdm(dAtA, i, uint64(len(m.CurrentPassword))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *VerifyFirmwarePassword) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *VerifyFirmwarePassword) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *VerifyFirmwarePassword) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.Password) > 0 { - i -= len(m.Password) - copy(dAtA[i:], m.Password) - i = encodeVarintMdm(dAtA, i, uint64(len(m.Password))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *SetAutoAdminPassword) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *SetAutoAdminPassword) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *SetAutoAdminPassword) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.PasswordHash) > 0 { - i -= len(m.PasswordHash) - copy(dAtA[i:], m.PasswordHash) - i = encodeVarintMdm(dAtA, i, uint64(len(m.PasswordHash))) - i-- - dAtA[i] = 0x12 - } - if len(m.Guid) > 0 { - i -= len(m.Guid) - copy(dAtA[i:], m.Guid) - i = encodeVarintMdm(dAtA, i, uint64(len(m.Guid))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *ScheduleOSUpdate) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ScheduleOSUpdate) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ScheduleOSUpdate) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.Updates) > 0 { - for iNdEx := len(m.Updates) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Updates[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *Update) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Update) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Update) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.InstallAction) > 0 { - i -= len(m.InstallAction) - copy(dAtA[i:], m.InstallAction) - i = encodeVarintMdm(dAtA, i, uint64(len(m.InstallAction))) - i-- - dAtA[i] = 0x1a - } - if len(m.ProductVersion) > 0 { - i -= len(m.ProductVersion) - copy(dAtA[i:], m.ProductVersion) - i = encodeVarintMdm(dAtA, i, uint64(len(m.ProductVersion))) - i-- - dAtA[i] = 0x12 - } - if len(m.ProductKey) > 0 { - i -= len(m.ProductKey) - copy(dAtA[i:], m.ProductKey) - i = encodeVarintMdm(dAtA, i, uint64(len(m.ProductKey))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *ScheduleOSUpdateScan) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ScheduleOSUpdateScan) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ScheduleOSUpdateScan) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if m.Force { - i-- - if m.Force { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *ActiveNSExtensions) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ActiveNSExtensions) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ActiveNSExtensions) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.FilterExtensionPoints) > 0 { - for iNdEx := len(m.FilterExtensionPoints) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.FilterExtensionPoints[iNdEx]) - copy(dAtA[i:], m.FilterExtensionPoints[iNdEx]) - i = encodeVarintMdm(dAtA, i, uint64(len(m.FilterExtensionPoints[iNdEx]))) - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *RotateFileVaultKey) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *RotateFileVaultKey) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *RotateFileVaultKey) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.ReplyEncryptionCertificate) > 0 { - i -= len(m.ReplyEncryptionCertificate) - copy(dAtA[i:], m.ReplyEncryptionCertificate) - i = encodeVarintMdm(dAtA, i, uint64(len(m.ReplyEncryptionCertificate))) - i-- - dAtA[i] = 0x22 - } - if len(m.NewCertificate) > 0 { - i -= len(m.NewCertificate) - copy(dAtA[i:], m.NewCertificate) - i = encodeVarintMdm(dAtA, i, uint64(len(m.NewCertificate))) - i-- - dAtA[i] = 0x1a - } - if m.FilevaultUnlock != nil { - { - size, err := m.FilevaultUnlock.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if len(m.KeyType) > 0 { - i -= len(m.KeyType) - copy(dAtA[i:], m.KeyType) - i = encodeVarintMdm(dAtA, i, uint64(len(m.KeyType))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *FileVaultUnlock) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *FileVaultUnlock) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *FileVaultUnlock) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.PrivateKeyExportPassword) > 0 { - i -= len(m.PrivateKeyExportPassword) - copy(dAtA[i:], m.PrivateKeyExportPassword) - i = encodeVarintMdm(dAtA, i, uint64(len(m.PrivateKeyExportPassword))) - i-- - dAtA[i] = 0x1a - } - if len(m.PrivateKeyExport) > 0 { - i -= len(m.PrivateKeyExport) - copy(dAtA[i:], m.PrivateKeyExport) - i = encodeVarintMdm(dAtA, i, uint64(len(m.PrivateKeyExport))) - i-- - dAtA[i] = 0x12 - } - if len(m.Password) > 0 { - i -= len(m.Password) - copy(dAtA[i:], m.Password) - i = encodeVarintMdm(dAtA, i, uint64(len(m.Password))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *SetBootstrapToken) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *SetBootstrapToken) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *SetBootstrapToken) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.BootstrapToken) > 0 { - i -= len(m.BootstrapToken) - copy(dAtA[i:], m.BootstrapToken) - i = encodeVarintMdm(dAtA, i, uint64(len(m.BootstrapToken))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *ResultPayload) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ResultPayload) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ResultPayload) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if len(m.ErrorChain) > 0 { - for iNdEx := len(m.ErrorChain) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.ErrorChain[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintMdm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - } - if len(m.CommandUuid) > 0 { - i -= len(m.CommandUuid) - copy(dAtA[i:], m.CommandUuid) - i = encodeVarintMdm(dAtA, i, uint64(len(m.CommandUuid))) - i-- - dAtA[i] = 0x12 - } - if len(m.Udid) > 0 { - i -= len(m.Udid) - copy(dAtA[i:], m.Udid) - i = encodeVarintMdm(dAtA, i, uint64(len(m.Udid))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *ErrorChain) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ErrorChain) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ErrorChain) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.XXX_unrecognized != nil { - i -= len(m.XXX_unrecognized) - copy(dAtA[i:], m.XXX_unrecognized) - } - if m.ErrorCode != 0 { - i = encodeVarintMdm(dAtA, i, uint64(m.ErrorCode)) - i-- - dAtA[i] = 0x20 - } - if len(m.ErrorDomain) > 0 { - i -= len(m.ErrorDomain) - copy(dAtA[i:], m.ErrorDomain) - i = encodeVarintMdm(dAtA, i, uint64(len(m.ErrorDomain))) - i-- - dAtA[i] = 0x1a - } - if len(m.UsEnglishDescription) > 0 { - i -= len(m.UsEnglishDescription) - copy(dAtA[i:], m.UsEnglishDescription) - i = encodeVarintMdm(dAtA, i, uint64(len(m.UsEnglishDescription))) - i-- - dAtA[i] = 0x12 - } - if len(m.LocalizedDescription) > 0 { - i -= len(m.LocalizedDescription) - copy(dAtA[i:], m.LocalizedDescription) - i = encodeVarintMdm(dAtA, i, uint64(len(m.LocalizedDescription))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func encodeVarintMdm(dAtA []byte, offset int, v uint64) int { - offset -= sovMdm(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *CommandPayload) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.CommandUuid) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - if m.Command != nil { - l = m.Command.Size() - n += 1 + l + sovMdm(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *Command) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.RequestType) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - if m.Request != nil { - n += m.Request.Size() - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *Command_InstallProfile) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.InstallProfile != nil { - l = m.InstallProfile.Size() - n += 1 + l + sovMdm(uint64(l)) - } - return n -} -func (m *Command_RemoveProfile) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.RemoveProfile != nil { - l = m.RemoveProfile.Size() - n += 1 + l + sovMdm(uint64(l)) - } - return n -} -func (m *Command_InstallProvisioningProfile) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.InstallProvisioningProfile != nil { - l = m.InstallProvisioningProfile.Size() - n += 1 + l + sovMdm(uint64(l)) - } - return n -} -func (m *Command_RemoveProfisioningProfile) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.RemoveProfisioningProfile != nil { - l = m.RemoveProfisioningProfile.Size() - n += 1 + l + sovMdm(uint64(l)) - } - return n -} -func (m *Command_InstalledApplicationList) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.InstalledApplicationList != nil { - l = m.InstalledApplicationList.Size() - n += 1 + l + sovMdm(uint64(l)) - } - return n -} -func (m *Command_DeviceInformation) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.DeviceInformation != nil { - l = m.DeviceInformation.Size() - n += 1 + l + sovMdm(uint64(l)) - } - return n -} -func (m *Command_DeviceLock) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.DeviceLock != nil { - l = m.DeviceLock.Size() - n += 1 + l + sovMdm(uint64(l)) - } - return n -} -func (m *Command_ClearPasscode) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.ClearPasscode != nil { - l = m.ClearPasscode.Size() - n += 1 + l + sovMdm(uint64(l)) - } - return n -} -func (m *Command_EraseDevice) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.EraseDevice != nil { - l = m.EraseDevice.Size() - n += 1 + l + sovMdm(uint64(l)) - } - return n -} -func (m *Command_RequestMirroring) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.RequestMirroring != nil { - l = m.RequestMirroring.Size() - n += 1 + l + sovMdm(uint64(l)) - } - return n -} -func (m *Command_Restrictions) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Restrictions != nil { - l = m.Restrictions.Size() - n += 1 + l + sovMdm(uint64(l)) - } - return n -} -func (m *Command_UnlockUserAccount) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.UnlockUserAccount != nil { - l = m.UnlockUserAccount.Size() - n += 1 + l + sovMdm(uint64(l)) - } - return n -} -func (m *Command_DeleteUser) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.DeleteUser != nil { - l = m.DeleteUser.Size() - n += 1 + l + sovMdm(uint64(l)) - } - return n -} -func (m *Command_EnableLostMode) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.EnableLostMode != nil { - l = m.EnableLostMode.Size() - n += 1 + l + sovMdm(uint64(l)) - } - return n -} -func (m *Command_InstallApplication) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.InstallApplication != nil { - l = m.InstallApplication.Size() - n += 2 + l + sovMdm(uint64(l)) - } - return n -} -func (m *Command_AccountConfiguration) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.AccountConfiguration != nil { - l = m.AccountConfiguration.Size() - n += 2 + l + sovMdm(uint64(l)) - } - return n -} -func (m *Command_ApplyRedemptionCode) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.ApplyRedemptionCode != nil { - l = m.ApplyRedemptionCode.Size() - n += 2 + l + sovMdm(uint64(l)) - } - return n -} -func (m *Command_ManagedApplicationList) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.ManagedApplicationList != nil { - l = m.ManagedApplicationList.Size() - n += 2 + l + sovMdm(uint64(l)) - } - return n -} -func (m *Command_RemoveApplication) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.RemoveApplication != nil { - l = m.RemoveApplication.Size() - n += 2 + l + sovMdm(uint64(l)) - } - return n -} -func (m *Command_InviteToProgram) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.InviteToProgram != nil { - l = m.InviteToProgram.Size() - n += 2 + l + sovMdm(uint64(l)) - } - return n -} -func (m *Command_ValidataApplications) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.ValidataApplications != nil { - l = m.ValidataApplications.Size() - n += 2 + l + sovMdm(uint64(l)) - } - return n -} -func (m *Command_InstallMedia) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.InstallMedia != nil { - l = m.InstallMedia.Size() - n += 2 + l + sovMdm(uint64(l)) - } - return n -} -func (m *Command_RemoveMedia) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.RemoveMedia != nil { - l = m.RemoveMedia.Size() - n += 2 + l + sovMdm(uint64(l)) - } - return n -} -func (m *Command_Settings) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Settings != nil { - l = m.Settings.Size() - n += 2 + l + sovMdm(uint64(l)) - } - return n -} -func (m *Command_ManagedApplicationConfiguration) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.ManagedApplicationConfiguration != nil { - l = m.ManagedApplicationConfiguration.Size() - n += 2 + l + sovMdm(uint64(l)) - } - return n -} -func (m *Command_ManagedApplicationAttributes) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.ManagedApplicationAttributes != nil { - l = m.ManagedApplicationAttributes.Size() - n += 2 + l + sovMdm(uint64(l)) - } - return n -} -func (m *Command_ManagedApplicationFeedback) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.ManagedApplicationFeedback != nil { - l = m.ManagedApplicationFeedback.Size() - n += 2 + l + sovMdm(uint64(l)) - } - return n -} -func (m *Command_SetFirmwarePassword) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.SetFirmwarePassword != nil { - l = m.SetFirmwarePassword.Size() - n += 2 + l + sovMdm(uint64(l)) - } - return n -} -func (m *Command_VerifyFirmwarePassword) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.VerifyFirmwarePassword != nil { - l = m.VerifyFirmwarePassword.Size() - n += 2 + l + sovMdm(uint64(l)) - } - return n -} -func (m *Command_SetAutoAdminPassword) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.SetAutoAdminPassword != nil { - l = m.SetAutoAdminPassword.Size() - n += 2 + l + sovMdm(uint64(l)) - } - return n -} -func (m *Command_ScheduleOsUpdate) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.ScheduleOsUpdate != nil { - l = m.ScheduleOsUpdate.Size() - n += 2 + l + sovMdm(uint64(l)) - } - return n -} -func (m *Command_ScheduleOsUpdateScan) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.ScheduleOsUpdateScan != nil { - l = m.ScheduleOsUpdateScan.Size() - n += 2 + l + sovMdm(uint64(l)) - } - return n -} -func (m *Command_ActiveNsExtensions) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.ActiveNsExtensions != nil { - l = m.ActiveNsExtensions.Size() - n += 2 + l + sovMdm(uint64(l)) - } - return n -} -func (m *Command_RotateFilevaultKey) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.RotateFilevaultKey != nil { - l = m.RotateFilevaultKey.Size() - n += 2 + l + sovMdm(uint64(l)) - } - return n -} -func (m *Command_InstallEnterpriseApplication) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.InstallEnterpriseApplication != nil { - l = m.InstallEnterpriseApplication.Size() - n += 2 + l + sovMdm(uint64(l)) - } - return n -} -func (m *Command_SetBootstrapToken) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.SetBootstrapToken != nil { - l = m.SetBootstrapToken.Size() - n += 2 + l + sovMdm(uint64(l)) - } - return n -} -func (m *InstallProfile) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Payload) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *RemoveProfile) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Identifier) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *InstallProvisioningProfile) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.ProvisioningProfile) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *RemoveProvisioningProfile) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Uuid) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *InstalledApplicationList) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Identifiers) > 0 { - for _, s := range m.Identifiers { - l = len(s) - n += 1 + l + sovMdm(uint64(l)) - } - } - if m.ManagedAppsOnly { - n += 2 - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *DeviceInformation) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Queries) > 0 { - for _, s := range m.Queries { - l = len(s) - n += 1 + l + sovMdm(uint64(l)) - } - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *ClearPasscode) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.UnlockToken) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *DeviceLock) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Pin) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - l = len(m.Message) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - l = len(m.PhoneNumber) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *EraseDevice) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Pin) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - if m.PreserveDataPlan { - n += 2 - } - if m.DisallowProximitySetup { - n += 2 - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *RequestMirroring) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.DestinationName) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - l = len(m.DestinationDeviceId) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - l = len(m.ScanTime) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - l = len(m.Password) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *Restrictions) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.ProfileRestrictions { - n += 2 - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *UnlockUserAccount) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Username) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *DeleteUser) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Username) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - if m.ForceDeletion { - n += 2 - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *EnableLostMode) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Message) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - l = len(m.PhoneNumber) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - l = len(m.Footnote) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *InstallApplication) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.ItunesStoreId != 0 { - n += 1 + sovMdm(uint64(m.ItunesStoreId)) - } - l = len(m.Identifier) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - if m.Options != nil { - l = m.Options.Size() - n += 1 + l + sovMdm(uint64(l)) - } - l = len(m.ManifestUrl) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - if m.ManagementFlags != 0 { - n += 1 + sovMdm(uint64(m.ManagementFlags)) - } - if m.Configuration != nil { - l = m.Configuration.Size() - n += 1 + l + sovMdm(uint64(l)) - } - if m.Attributes != nil { - l = m.Attributes.Size() - n += 1 + l + sovMdm(uint64(l)) - } - l = len(m.ChangeManagementState) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *InstallApplicationOptions) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.PurchaseMethod != 0 { - n += 1 + sovMdm(uint64(m.PurchaseMethod)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *InstallApplicationConfiguration) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *InstallApplicationAttributes) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *InstallEnterpriseApplication) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Manifest != nil { - l = m.Manifest.Size() - n += 1 + l + sovMdm(uint64(l)) - } - l = len(m.ManifestUrl) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - if len(m.ManifestUrlPinningCerts) > 0 { - for _, b := range m.ManifestUrlPinningCerts { - l = len(b) - n += 1 + l + sovMdm(uint64(l)) - } - } - if m.PinningRevocationCheckRequired { - n += 2 - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *Manifest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.ManifestItems) > 0 { - for _, e := range m.ManifestItems { - l = e.Size() - n += 1 + l + sovMdm(uint64(l)) - } - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *ManifestItem) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Assets) > 0 { - for _, e := range m.Assets { - l = e.Size() - n += 1 + l + sovMdm(uint64(l)) - } - } - if m.Metadata != nil { - l = m.Metadata.Size() - n += 1 + l + sovMdm(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *Asset) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Kind) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - if m.Md5Size != 0 { - n += 1 + sovMdm(uint64(m.Md5Size)) - } - if len(m.Md5S) > 0 { - for _, s := range m.Md5S { - l = len(s) - n += 1 + l + sovMdm(uint64(l)) - } - } - l = len(m.Url) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - if m.Sha256Size != 0 { - n += 1 + sovMdm(uint64(m.Sha256Size)) - } - if len(m.Sha256S) > 0 { - for _, s := range m.Sha256S { - l = len(s) - n += 1 + l + sovMdm(uint64(l)) - } - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *Metadata) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.BundleIdentifier) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - l = len(m.BundleVersion) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - if len(m.Items) > 0 { - for _, e := range m.Items { - l = e.Size() - n += 1 + l + sovMdm(uint64(l)) - } - } - l = len(m.Kind) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - l = len(m.Subtitle) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - l = len(m.Title) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - if m.SizeInBytes != 0 { - n += 1 + sovMdm(uint64(m.SizeInBytes)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *BundleInfo) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.BundleIdentifier) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - l = len(m.BundleVersion) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *ApplyRedemptionCode) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Identifier) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - l = len(m.RedemptionCode) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *ManagedApplicationList) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Identifiers) > 0 { - for _, s := range m.Identifiers { - l = len(s) - n += 1 + l + sovMdm(uint64(l)) - } - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *RemoveApplication) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Identifier) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *InviteToProgram) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.ProgramId) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - l = len(m.InvitationUrl) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *ValidateApplications) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Identifiers) > 0 { - for _, s := range m.Identifiers { - l = len(s) - n += 1 + l + sovMdm(uint64(l)) - } - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *AccountConfiguration) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.SkipPrimarySetupAccountCreation { - n += 2 - } - if m.SetPrimarySetupAccountAsRegularUser { - n += 2 - } - if len(m.AutoSetupAdminAccounts) > 0 { - for _, e := range m.AutoSetupAdminAccounts { - l = e.Size() - n += 1 + l + sovMdm(uint64(l)) - } - } - if m.DontAutoPopulatePrimaryAccountInfo { - n += 2 - } - if m.LockPrimaryAccountInfo { - n += 2 - } - l = len(m.PrimaryAccountFullName) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - l = len(m.PrimaryAccountUserName) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *AutoSetupAdminAccounts) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.ShortName) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - l = len(m.FullName) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - l = len(m.PasswordHash) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - if m.Hidden { - n += 2 - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *InstallMedia) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.ItunesStoreId != 0 { - n += 1 + sovMdm(uint64(m.ItunesStoreId)) - } - l = len(m.MediaUrl) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - l = len(m.MediaType) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *RemoveMedia) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.MediaType) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - if m.ItunesStoreId != 0 { - n += 1 + sovMdm(uint64(m.ItunesStoreId)) - } - l = len(m.PersistentId) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *Settings) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Settings) > 0 { - for _, e := range m.Settings { - l = e.Size() - n += 1 + l + sovMdm(uint64(l)) - } - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *Setting) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Item) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - if m.DeviceName != nil { - l = m.DeviceName.Size() - n += 1 + l + sovMdm(uint64(l)) - } - if m.Hostname != nil { - l = m.Hostname.Size() - n += 1 + l + sovMdm(uint64(l)) - } - if m.VoiceRoaming != nil { - l = m.VoiceRoaming.Size() - n += 1 + l + sovMdm(uint64(l)) - } - if m.PersonalHotspot != nil { - l = m.PersonalHotspot.Size() - n += 1 + l + sovMdm(uint64(l)) - } - if m.Wallpaper != nil { - l = m.Wallpaper.Size() - n += 1 + l + sovMdm(uint64(l)) - } - if m.DataRoaming != nil { - l = m.DataRoaming.Size() - n += 1 + l + sovMdm(uint64(l)) - } - if m.Bluetooth != nil { - l = m.Bluetooth.Size() - n += 1 + l + sovMdm(uint64(l)) - } - if m.ApplicationAttributes != nil { - l = m.ApplicationAttributes.Size() - n += 1 + l + sovMdm(uint64(l)) - } - if m.MdmOptions != nil { - l = m.MdmOptions.Size() - n += 1 + l + sovMdm(uint64(l)) - } - if m.PasscodeLockGracePeriod != nil { - l = m.PasscodeLockGracePeriod.Size() - n += 1 + l + sovMdm(uint64(l)) - } - if m.MaximumResidentUsers != nil { - l = m.MaximumResidentUsers.Size() - n += 1 + l + sovMdm(uint64(l)) - } - if m.DiagnosticSubmission != nil { - l = m.DiagnosticSubmission.Size() - n += 1 + l + sovMdm(uint64(l)) - } - if m.AppAnalytics != nil { - l = m.AppAnalytics.Size() - n += 1 + l + sovMdm(uint64(l)) - } - if m.ApplicationConfiguration != nil { - l = m.ApplicationConfiguration.Size() - n += 1 + l + sovMdm(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *VoiceRoamingSetting) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Enabled { - n += 2 - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *PersonalHotspotSetting) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Enabled { - n += 2 - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *WallpaperSetting) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Image) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - if m.Where != 0 { - n += 1 + sovMdm(uint64(m.Where)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *DataRoamingSetting) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Enabled { - n += 2 - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *BluetoothSetting) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Enabled { - n += 2 - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *ApplicationAttributesSetting) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Identifier) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - if m.ApplicationAttributes != nil { - l = m.ApplicationAttributes.Size() - n += 1 + l + sovMdm(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *ApplicationConfigurationSetting) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Identifier) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - l = len(m.ConfigurationDictionaryData) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *ApplicationAttributes) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.VpnUuid) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *DeviceNameSetting) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.DeviceName) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *HostnameSetting) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Hostname) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *MDMOptionsSetting) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.MdmOptions != nil { - l = m.MdmOptions.Size() - n += 1 + l + sovMdm(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *MDMOptions) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.ActivationLockAllowedWhileSupervised { - n += 2 - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *PasscodeLockGracePeriodSetting) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.PasscodeLockGracePeriod != 0 { - n += 1 + sovMdm(uint64(m.PasscodeLockGracePeriod)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *MaximumResidentUsersSetting) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.MaximumResidentUsers != 0 { - n += 1 + sovMdm(uint64(m.MaximumResidentUsers)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *DiagnosticSubmissionSetting) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Enabled { - n += 2 - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *AppAnalyticsSetting) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Enabled { - n += 2 - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *ManagedApplicationConfiguration) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Identifiers) > 0 { - for _, s := range m.Identifiers { - l = len(s) - n += 1 + l + sovMdm(uint64(l)) - } - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *ManagedApplicationAttributes) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Identifiers) > 0 { - for _, s := range m.Identifiers { - l = len(s) - n += 1 + l + sovMdm(uint64(l)) - } - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *ManagedApplicationFeedback) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Identifiers) > 0 { - for _, s := range m.Identifiers { - l = len(s) - n += 1 + l + sovMdm(uint64(l)) - } - } - if m.DeleteFeedback { - n += 2 - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *SetFirmwarePassword) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.CurrentPassword) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - l = len(m.NewPassword) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - if m.AllowOroms { - n += 2 - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *VerifyFirmwarePassword) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Password) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *SetAutoAdminPassword) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Guid) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - l = len(m.PasswordHash) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *ScheduleOSUpdate) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Updates) > 0 { - for _, e := range m.Updates { - l = e.Size() - n += 1 + l + sovMdm(uint64(l)) - } - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *Update) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.ProductKey) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - l = len(m.ProductVersion) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - l = len(m.InstallAction) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *ScheduleOSUpdateScan) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Force { - n += 2 - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *ActiveNSExtensions) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.FilterExtensionPoints) > 0 { - for _, s := range m.FilterExtensionPoints { - l = len(s) - n += 1 + l + sovMdm(uint64(l)) - } - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *RotateFileVaultKey) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.KeyType) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - if m.FilevaultUnlock != nil { - l = m.FilevaultUnlock.Size() - n += 1 + l + sovMdm(uint64(l)) - } - l = len(m.NewCertificate) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - l = len(m.ReplyEncryptionCertificate) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *FileVaultUnlock) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Password) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - l = len(m.PrivateKeyExport) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - l = len(m.PrivateKeyExportPassword) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *SetBootstrapToken) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.BootstrapToken) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *ResultPayload) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Udid) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - l = len(m.CommandUuid) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - if len(m.ErrorChain) > 0 { - for _, e := range m.ErrorChain { - l = e.Size() - n += 1 + l + sovMdm(uint64(l)) - } - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func (m *ErrorChain) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.LocalizedDescription) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - l = len(m.UsEnglishDescription) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - l = len(m.ErrorDomain) - if l > 0 { - n += 1 + l + sovMdm(uint64(l)) - } - if m.ErrorCode != 0 { - n += 1 + sovMdm(uint64(m.ErrorCode)) - } - if m.XXX_unrecognized != nil { - n += len(m.XXX_unrecognized) - } - return n -} - -func sovMdm(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozMdm(x uint64) (n int) { - return sovMdm(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *CommandPayload) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: CommandPayload: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: CommandPayload: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CommandUuid", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.CommandUuid = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Command", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Command == nil { - m.Command = &Command{} - } - if err := m.Command.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Command) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Command: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Command: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestType", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.RequestType = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field InstallProfile", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &InstallProfile{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Request = &Command_InstallProfile{v} - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RemoveProfile", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &RemoveProfile{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Request = &Command_RemoveProfile{v} - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field InstallProvisioningProfile", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &InstallProvisioningProfile{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Request = &Command_InstallProvisioningProfile{v} - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RemoveProfisioningProfile", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &RemoveProvisioningProfile{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Request = &Command_RemoveProfisioningProfile{v} - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field InstalledApplicationList", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &InstalledApplicationList{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Request = &Command_InstalledApplicationList{v} - iNdEx = postIndex - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DeviceInformation", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &DeviceInformation{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Request = &Command_DeviceInformation{v} - iNdEx = postIndex - case 8: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DeviceLock", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &DeviceLock{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Request = &Command_DeviceLock{v} - iNdEx = postIndex - case 9: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ClearPasscode", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &ClearPasscode{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Request = &Command_ClearPasscode{v} - iNdEx = postIndex - case 10: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field EraseDevice", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &EraseDevice{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Request = &Command_EraseDevice{v} - iNdEx = postIndex - case 11: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestMirroring", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &RequestMirroring{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Request = &Command_RequestMirroring{v} - iNdEx = postIndex - case 12: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Restrictions", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &Restrictions{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Request = &Command_Restrictions{v} - iNdEx = postIndex - case 13: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UnlockUserAccount", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &UnlockUserAccount{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Request = &Command_UnlockUserAccount{v} - iNdEx = postIndex - case 14: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DeleteUser", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &DeleteUser{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Request = &Command_DeleteUser{v} - iNdEx = postIndex - case 15: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field EnableLostMode", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &EnableLostMode{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Request = &Command_EnableLostMode{v} - iNdEx = postIndex - case 16: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field InstallApplication", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &InstallApplication{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Request = &Command_InstallApplication{v} - iNdEx = postIndex - case 17: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AccountConfiguration", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &AccountConfiguration{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Request = &Command_AccountConfiguration{v} - iNdEx = postIndex - case 18: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ApplyRedemptionCode", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &ApplyRedemptionCode{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Request = &Command_ApplyRedemptionCode{v} - iNdEx = postIndex - case 19: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ManagedApplicationList", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &ManagedApplicationList{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Request = &Command_ManagedApplicationList{v} - iNdEx = postIndex - case 20: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RemoveApplication", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &RemoveApplication{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Request = &Command_RemoveApplication{v} - iNdEx = postIndex - case 21: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field InviteToProgram", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &InviteToProgram{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Request = &Command_InviteToProgram{v} - iNdEx = postIndex - case 22: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ValidataApplications", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &ValidateApplications{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Request = &Command_ValidataApplications{v} - iNdEx = postIndex - case 23: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field InstallMedia", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &InstallMedia{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Request = &Command_InstallMedia{v} - iNdEx = postIndex - case 24: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RemoveMedia", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &RemoveMedia{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Request = &Command_RemoveMedia{v} - iNdEx = postIndex - case 25: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Settings", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &Settings{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Request = &Command_Settings{v} - iNdEx = postIndex - case 26: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ManagedApplicationConfiguration", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &ManagedApplicationConfiguration{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Request = &Command_ManagedApplicationConfiguration{v} - iNdEx = postIndex - case 27: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ManagedApplicationAttributes", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &ManagedApplicationAttributes{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Request = &Command_ManagedApplicationAttributes{v} - iNdEx = postIndex - case 28: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ManagedApplicationFeedback", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &ManagedApplicationFeedback{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Request = &Command_ManagedApplicationFeedback{v} - iNdEx = postIndex - case 29: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SetFirmwarePassword", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &SetFirmwarePassword{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Request = &Command_SetFirmwarePassword{v} - iNdEx = postIndex - case 30: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field VerifyFirmwarePassword", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &VerifyFirmwarePassword{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Request = &Command_VerifyFirmwarePassword{v} - iNdEx = postIndex - case 31: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SetAutoAdminPassword", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &SetAutoAdminPassword{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Request = &Command_SetAutoAdminPassword{v} - iNdEx = postIndex - case 32: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ScheduleOsUpdate", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &ScheduleOSUpdate{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Request = &Command_ScheduleOsUpdate{v} - iNdEx = postIndex - case 33: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ScheduleOsUpdateScan", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &ScheduleOSUpdateScan{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Request = &Command_ScheduleOsUpdateScan{v} - iNdEx = postIndex - case 34: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ActiveNsExtensions", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &ActiveNSExtensions{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Request = &Command_ActiveNsExtensions{v} - iNdEx = postIndex - case 35: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RotateFilevaultKey", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &RotateFileVaultKey{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Request = &Command_RotateFilevaultKey{v} - iNdEx = postIndex - case 36: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field InstallEnterpriseApplication", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &InstallEnterpriseApplication{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Request = &Command_InstallEnterpriseApplication{v} - iNdEx = postIndex - case 37: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SetBootstrapToken", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &SetBootstrapToken{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Request = &Command_SetBootstrapToken{v} - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *InstallProfile) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: InstallProfile: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: InstallProfile: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Payload", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Payload = append(m.Payload[:0], dAtA[iNdEx:postIndex]...) - if m.Payload == nil { - m.Payload = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *RemoveProfile) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: RemoveProfile: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: RemoveProfile: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Identifier", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Identifier = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *InstallProvisioningProfile) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: InstallProvisioningProfile: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: InstallProvisioningProfile: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProvisioningProfile", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ProvisioningProfile = append(m.ProvisioningProfile[:0], dAtA[iNdEx:postIndex]...) - if m.ProvisioningProfile == nil { - m.ProvisioningProfile = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *RemoveProvisioningProfile) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: RemoveProvisioningProfile: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: RemoveProvisioningProfile: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Uuid", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Uuid = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *InstalledApplicationList) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: InstalledApplicationList: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: InstalledApplicationList: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Identifiers", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Identifiers = append(m.Identifiers, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ManagedAppsOnly", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.ManagedAppsOnly = bool(v != 0) - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *DeviceInformation) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: DeviceInformation: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: DeviceInformation: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Queries", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Queries = append(m.Queries, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ClearPasscode) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ClearPasscode: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ClearPasscode: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UnlockToken", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.UnlockToken = append(m.UnlockToken[:0], dAtA[iNdEx:postIndex]...) - if m.UnlockToken == nil { - m.UnlockToken = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *DeviceLock) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: DeviceLock: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: DeviceLock: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pin", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Pin = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Message", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Message = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PhoneNumber", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.PhoneNumber = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *EraseDevice) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: EraseDevice: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: EraseDevice: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pin", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Pin = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field PreserveDataPlan", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.PreserveDataPlan = bool(v != 0) - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field DisallowProximitySetup", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.DisallowProximitySetup = bool(v != 0) - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *RequestMirroring) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: RequestMirroring: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: RequestMirroring: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DestinationName", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.DestinationName = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DestinationDeviceId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.DestinationDeviceId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ScanTime", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ScanTime = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Password", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Password = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Restrictions) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Restrictions: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Restrictions: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ProfileRestrictions", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.ProfileRestrictions = bool(v != 0) - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *UnlockUserAccount) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: UnlockUserAccount: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: UnlockUserAccount: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Username", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Username = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *DeleteUser) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: DeleteUser: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: DeleteUser: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Username", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Username = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ForceDeletion", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.ForceDeletion = bool(v != 0) - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *EnableLostMode) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: EnableLostMode: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: EnableLostMode: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Message", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Message = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PhoneNumber", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.PhoneNumber = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Footnote", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Footnote = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *InstallApplication) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: InstallApplication: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: InstallApplication: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ItunesStoreId", wireType) - } - m.ItunesStoreId = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.ItunesStoreId |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Identifier", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Identifier = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Options", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Options == nil { - m.Options = &InstallApplicationOptions{} - } - if err := m.Options.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ManifestUrl", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ManifestUrl = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ManagementFlags", wireType) - } - m.ManagementFlags = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.ManagementFlags |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Configuration", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Configuration == nil { - m.Configuration = &InstallApplicationConfiguration{} - } - if err := m.Configuration.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Attributes", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Attributes == nil { - m.Attributes = &InstallApplicationAttributes{} - } - if err := m.Attributes.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 8: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChangeManagementState", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ChangeManagementState = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *InstallApplicationOptions) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: InstallApplicationOptions: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: InstallApplicationOptions: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field PurchaseMethod", wireType) - } - m.PurchaseMethod = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.PurchaseMethod |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *InstallApplicationConfiguration) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: InstallApplicationConfiguration: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: InstallApplicationConfiguration: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *InstallApplicationAttributes) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: InstallApplicationAttributes: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: InstallApplicationAttributes: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *InstallEnterpriseApplication) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: InstallEnterpriseApplication: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: InstallEnterpriseApplication: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Manifest", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Manifest == nil { - m.Manifest = &Manifest{} - } - if err := m.Manifest.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ManifestUrl", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ManifestUrl = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ManifestUrlPinningCerts", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ManifestUrlPinningCerts = append(m.ManifestUrlPinningCerts, make([]byte, postIndex-iNdEx)) - copy(m.ManifestUrlPinningCerts[len(m.ManifestUrlPinningCerts)-1], dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field PinningRevocationCheckRequired", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.PinningRevocationCheckRequired = bool(v != 0) - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Manifest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Manifest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Manifest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ManifestItems", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ManifestItems = append(m.ManifestItems, &ManifestItem{}) - if err := m.ManifestItems[len(m.ManifestItems)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ManifestItem) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ManifestItem: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ManifestItem: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Assets", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Assets = append(m.Assets, &Asset{}) - if err := m.Assets[len(m.Assets)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Metadata == nil { - m.Metadata = &Metadata{} - } - if err := m.Metadata.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Asset) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Asset: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Asset: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Kind", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Kind = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Md5Size", wireType) - } - m.Md5Size = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Md5Size |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Md5S", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Md5S = append(m.Md5S, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Url", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Url = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Sha256Size", wireType) - } - m.Sha256Size = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Sha256Size |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Sha256S", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Sha256S = append(m.Sha256S, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Metadata) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Metadata: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Metadata: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BundleIdentifier", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.BundleIdentifier = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BundleVersion", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.BundleVersion = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Items", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Items = append(m.Items, &BundleInfo{}) - if err := m.Items[len(m.Items)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Kind", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Kind = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Subtitle", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Subtitle = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Title", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Title = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 7: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field SizeInBytes", wireType) - } - m.SizeInBytes = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.SizeInBytes |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *BundleInfo) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: BundleInfo: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: BundleInfo: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BundleIdentifier", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.BundleIdentifier = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BundleVersion", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.BundleVersion = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ApplyRedemptionCode) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ApplyRedemptionCode: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ApplyRedemptionCode: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Identifier", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Identifier = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RedemptionCode", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.RedemptionCode = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ManagedApplicationList) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ManagedApplicationList: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ManagedApplicationList: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Identifiers", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Identifiers = append(m.Identifiers, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *RemoveApplication) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: RemoveApplication: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: RemoveApplication: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Identifier", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Identifier = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *InviteToProgram) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: InviteToProgram: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: InviteToProgram: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProgramId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ProgramId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field InvitationUrl", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.InvitationUrl = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ValidateApplications) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ValidateApplications: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ValidateApplications: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Identifiers", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Identifiers = append(m.Identifiers, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *AccountConfiguration) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: AccountConfiguration: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: AccountConfiguration: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field SkipPrimarySetupAccountCreation", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.SkipPrimarySetupAccountCreation = bool(v != 0) - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field SetPrimarySetupAccountAsRegularUser", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.SetPrimarySetupAccountAsRegularUser = bool(v != 0) - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AutoSetupAdminAccounts", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.AutoSetupAdminAccounts = append(m.AutoSetupAdminAccounts, &AutoSetupAdminAccounts{}) - if err := m.AutoSetupAdminAccounts[len(m.AutoSetupAdminAccounts)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field DontAutoPopulatePrimaryAccountInfo", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.DontAutoPopulatePrimaryAccountInfo = bool(v != 0) - case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field LockPrimaryAccountInfo", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.LockPrimaryAccountInfo = bool(v != 0) - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PrimaryAccountFullName", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.PrimaryAccountFullName = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PrimaryAccountUserName", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.PrimaryAccountUserName = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *AutoSetupAdminAccounts) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: AutoSetupAdminAccounts: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: AutoSetupAdminAccounts: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ShortName", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ShortName = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FullName", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.FullName = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PasswordHash", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.PasswordHash = append(m.PasswordHash[:0], dAtA[iNdEx:postIndex]...) - if m.PasswordHash == nil { - m.PasswordHash = []byte{} - } - iNdEx = postIndex - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Hidden", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.Hidden = bool(v != 0) - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *InstallMedia) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: InstallMedia: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: InstallMedia: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ItunesStoreId", wireType) - } - m.ItunesStoreId = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.ItunesStoreId |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MediaUrl", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.MediaUrl = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MediaType", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.MediaType = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *RemoveMedia) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: RemoveMedia: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: RemoveMedia: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MediaType", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.MediaType = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ItunesStoreId", wireType) - } - m.ItunesStoreId = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.ItunesStoreId |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PersistentId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.PersistentId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Settings) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Settings: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Settings: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Settings", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Settings = append(m.Settings, &Setting{}) - if err := m.Settings[len(m.Settings)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Setting) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Setting: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Setting: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Item", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Item = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DeviceName", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.DeviceName == nil { - m.DeviceName = &DeviceNameSetting{} - } - if err := m.DeviceName.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Hostname", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Hostname == nil { - m.Hostname = &HostnameSetting{} - } - if err := m.Hostname.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field VoiceRoaming", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.VoiceRoaming == nil { - m.VoiceRoaming = &VoiceRoamingSetting{} - } - if err := m.VoiceRoaming.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PersonalHotspot", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.PersonalHotspot == nil { - m.PersonalHotspot = &PersonalHotspotSetting{} - } - if err := m.PersonalHotspot.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Wallpaper", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Wallpaper == nil { - m.Wallpaper = &WallpaperSetting{} - } - if err := m.Wallpaper.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DataRoaming", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.DataRoaming == nil { - m.DataRoaming = &DataRoamingSetting{} - } - if err := m.DataRoaming.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 8: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Bluetooth", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Bluetooth == nil { - m.Bluetooth = &BluetoothSetting{} - } - if err := m.Bluetooth.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 9: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ApplicationAttributes", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.ApplicationAttributes == nil { - m.ApplicationAttributes = &ApplicationAttributesSetting{} - } - if err := m.ApplicationAttributes.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 10: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MdmOptions", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.MdmOptions == nil { - m.MdmOptions = &MDMOptionsSetting{} - } - if err := m.MdmOptions.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 11: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PasscodeLockGracePeriod", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.PasscodeLockGracePeriod == nil { - m.PasscodeLockGracePeriod = &PasscodeLockGracePeriodSetting{} - } - if err := m.PasscodeLockGracePeriod.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 12: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MaximumResidentUsers", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.MaximumResidentUsers == nil { - m.MaximumResidentUsers = &MaximumResidentUsersSetting{} - } - if err := m.MaximumResidentUsers.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 13: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DiagnosticSubmission", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.DiagnosticSubmission == nil { - m.DiagnosticSubmission = &DiagnosticSubmissionSetting{} - } - if err := m.DiagnosticSubmission.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 14: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AppAnalytics", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.AppAnalytics == nil { - m.AppAnalytics = &AppAnalyticsSetting{} - } - if err := m.AppAnalytics.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 15: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ApplicationConfiguration", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.ApplicationConfiguration == nil { - m.ApplicationConfiguration = &ApplicationConfigurationSetting{} - } - if err := m.ApplicationConfiguration.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *VoiceRoamingSetting) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: VoiceRoamingSetting: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: VoiceRoamingSetting: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Enabled", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.Enabled = bool(v != 0) - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *PersonalHotspotSetting) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: PersonalHotspotSetting: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: PersonalHotspotSetting: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Enabled", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.Enabled = bool(v != 0) - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *WallpaperSetting) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: WallpaperSetting: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: WallpaperSetting: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Image", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Image = append(m.Image[:0], dAtA[iNdEx:postIndex]...) - if m.Image == nil { - m.Image = []byte{} - } - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Where", wireType) - } - m.Where = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Where |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *DataRoamingSetting) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: DataRoamingSetting: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: DataRoamingSetting: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Enabled", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.Enabled = bool(v != 0) - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *BluetoothSetting) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: BluetoothSetting: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: BluetoothSetting: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Enabled", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.Enabled = bool(v != 0) - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ApplicationAttributesSetting) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ApplicationAttributesSetting: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ApplicationAttributesSetting: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Identifier", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Identifier = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ApplicationAttributes", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.ApplicationAttributes == nil { - m.ApplicationAttributes = &ApplicationAttributes{} - } - if err := m.ApplicationAttributes.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ApplicationConfigurationSetting) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ApplicationConfigurationSetting: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ApplicationConfigurationSetting: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Identifier", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Identifier = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ConfigurationDictionaryData", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ConfigurationDictionaryData = append(m.ConfigurationDictionaryData[:0], dAtA[iNdEx:postIndex]...) - if m.ConfigurationDictionaryData == nil { - m.ConfigurationDictionaryData = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ApplicationAttributes) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ApplicationAttributes: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ApplicationAttributes: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field VpnUuid", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.VpnUuid = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *DeviceNameSetting) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: DeviceNameSetting: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: DeviceNameSetting: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DeviceName", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.DeviceName = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *HostnameSetting) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: HostnameSetting: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: HostnameSetting: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Hostname", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Hostname = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MDMOptionsSetting) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MDMOptionsSetting: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MDMOptionsSetting: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MdmOptions", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.MdmOptions == nil { - m.MdmOptions = &MDMOptions{} - } - if err := m.MdmOptions.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MDMOptions) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MDMOptions: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MDMOptions: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ActivationLockAllowedWhileSupervised", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.ActivationLockAllowedWhileSupervised = bool(v != 0) - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *PasscodeLockGracePeriodSetting) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: PasscodeLockGracePeriodSetting: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: PasscodeLockGracePeriodSetting: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field PasscodeLockGracePeriod", wireType) - } - m.PasscodeLockGracePeriod = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.PasscodeLockGracePeriod |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MaximumResidentUsersSetting) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: MaximumResidentUsersSetting: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MaximumResidentUsersSetting: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MaximumResidentUsers", wireType) - } - m.MaximumResidentUsers = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MaximumResidentUsers |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *DiagnosticSubmissionSetting) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: DiagnosticSubmissionSetting: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: DiagnosticSubmissionSetting: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Enabled", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.Enabled = bool(v != 0) - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *AppAnalyticsSetting) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: AppAnalyticsSetting: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: AppAnalyticsSetting: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Enabled", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.Enabled = bool(v != 0) - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ManagedApplicationConfiguration) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ManagedApplicationConfiguration: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ManagedApplicationConfiguration: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Identifiers", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Identifiers = append(m.Identifiers, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ManagedApplicationAttributes) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ManagedApplicationAttributes: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ManagedApplicationAttributes: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Identifiers", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Identifiers = append(m.Identifiers, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ManagedApplicationFeedback) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ManagedApplicationFeedback: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ManagedApplicationFeedback: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Identifiers", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Identifiers = append(m.Identifiers, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field DeleteFeedback", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.DeleteFeedback = bool(v != 0) - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *SetFirmwarePassword) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: SetFirmwarePassword: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: SetFirmwarePassword: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CurrentPassword", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.CurrentPassword = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field NewPassword", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.NewPassword = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field AllowOroms", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.AllowOroms = bool(v != 0) - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *VerifyFirmwarePassword) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: VerifyFirmwarePassword: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: VerifyFirmwarePassword: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Password", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Password = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *SetAutoAdminPassword) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: SetAutoAdminPassword: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: SetAutoAdminPassword: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Guid", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Guid = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PasswordHash", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.PasswordHash = append(m.PasswordHash[:0], dAtA[iNdEx:postIndex]...) - if m.PasswordHash == nil { - m.PasswordHash = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ScheduleOSUpdate) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ScheduleOSUpdate: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ScheduleOSUpdate: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Updates", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Updates = append(m.Updates, &Update{}) - if err := m.Updates[len(m.Updates)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Update) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Update: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Update: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProductKey", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ProductKey = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProductVersion", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ProductVersion = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field InstallAction", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.InstallAction = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ScheduleOSUpdateScan) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ScheduleOSUpdateScan: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ScheduleOSUpdateScan: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Force", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.Force = bool(v != 0) - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ActiveNSExtensions) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ActiveNSExtensions: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ActiveNSExtensions: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FilterExtensionPoints", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.FilterExtensionPoints = append(m.FilterExtensionPoints, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *RotateFileVaultKey) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: RotateFileVaultKey: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: RotateFileVaultKey: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field KeyType", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.KeyType = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FilevaultUnlock", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.FilevaultUnlock == nil { - m.FilevaultUnlock = &FileVaultUnlock{} - } - if err := m.FilevaultUnlock.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field NewCertificate", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.NewCertificate = append(m.NewCertificate[:0], dAtA[iNdEx:postIndex]...) - if m.NewCertificate == nil { - m.NewCertificate = []byte{} - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ReplyEncryptionCertificate", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ReplyEncryptionCertificate = append(m.ReplyEncryptionCertificate[:0], dAtA[iNdEx:postIndex]...) - if m.ReplyEncryptionCertificate == nil { - m.ReplyEncryptionCertificate = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *FileVaultUnlock) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: FileVaultUnlock: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: FileVaultUnlock: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Password", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Password = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PrivateKeyExport", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.PrivateKeyExport = append(m.PrivateKeyExport[:0], dAtA[iNdEx:postIndex]...) - if m.PrivateKeyExport == nil { - m.PrivateKeyExport = []byte{} - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PrivateKeyExportPassword", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.PrivateKeyExportPassword = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *SetBootstrapToken) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: SetBootstrapToken: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: SetBootstrapToken: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BootstrapToken", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.BootstrapToken = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ResultPayload) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ResultPayload: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ResultPayload: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Udid", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Udid = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CommandUuid", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.CommandUuid = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ErrorChain", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ErrorChain = append(m.ErrorChain, &ErrorChain{}) - if err := m.ErrorChain[len(m.ErrorChain)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ErrorChain) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ErrorChain: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ErrorChain: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field LocalizedDescription", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.LocalizedDescription = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UsEnglishDescription", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.UsEnglishDescription = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ErrorDomain", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMdm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMdm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ErrorDomain = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ErrorCode", wireType) - } - m.ErrorCode = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMdm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.ErrorCode |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipMdm(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthMdm - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipMdm(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowMdm - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowMdm - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowMdm - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthMdm - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupMdm - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthMdm - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthMdm = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowMdm = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupMdm = fmt.Errorf("proto: unexpected end of group") -) diff --git a/mdm/mdm/internal/mdmproto/mdm.proto b/mdm/mdm/internal/mdmproto/mdm.proto deleted file mode 100644 index db8b9f6a..00000000 --- a/mdm/mdm/internal/mdmproto/mdm.proto +++ /dev/null @@ -1,429 +0,0 @@ -syntax = "proto3"; - -package mdmproto; - -message CommandPayload { - string command_uuid = 1; - Command command = 2; -} - -message Command { - string request_type = 1; - /* - Request Types that do not have additional fields: - - ProfileList - - ProvisioningProfileList - - CertificateList", - - SecurityInfo - - RestartDevice - - ShutDownDevice - - StopMirroring - - ClearRestrictionsPassword - - UserList - - LogOutUser - - PlayLostModeSound - - DisableLostMode - - DeviceLocation - - ManagedMediaList - - DeviceConfigured - - AvailableOSUpdates - - NSExtensionMappings - - EnableRemoteDesktop - - DisableRemoteDesktop - - ActivationLockBypassCode - */ - oneof request { - InstallProfile install_profile = 2; - RemoveProfile remove_profile = 3; - InstallProvisioningProfile install_provisioning_profile = 4; - RemoveProvisioningProfile remove_profisioning_profile = 5; - InstalledApplicationList installed_application_list = 6; - DeviceInformation device_information = 7; - DeviceLock device_lock = 8; - ClearPasscode clear_passcode = 9; - EraseDevice erase_device = 10; - RequestMirroring request_mirroring = 11; - Restrictions restrictions = 12; - UnlockUserAccount unlock_user_account = 13; - DeleteUser delete_user = 14; - EnableLostMode enable_lost_mode = 15; - InstallApplication install_application = 16; - AccountConfiguration account_configuration = 17; - ApplyRedemptionCode apply_redemption_code = 18; - ManagedApplicationList managed_application_list = 19; - RemoveApplication remove_application = 20; - InviteToProgram invite_to_program = 21; - ValidateApplications validata_applications = 22; - InstallMedia install_media = 23; - RemoveMedia remove_media = 24; - Settings settings = 25; - ManagedApplicationConfiguration managed_application_configuration = 26; - ManagedApplicationAttributes managed_application_attributes = 27; - ManagedApplicationFeedback managed_application_feedback = 28; - SetFirmwarePassword set_firmware_password = 29; - VerifyFirmwarePassword verify_firmware_password = 30; - SetAutoAdminPassword set_auto_admin_password = 31; - ScheduleOSUpdate schedule_os_update = 32; - ScheduleOSUpdateScan schedule_os_update_scan = 33; - ActiveNSExtensions active_ns_extensions = 34; - RotateFileVaultKey rotate_filevault_key = 35; - InstallEnterpriseApplication install_enterprise_application = 36; - SetBootstrapToken set_bootstrap_token = 37; - } -} - -message InstallProfile { - bytes payload = 1; // The mobileconfig data. -} - -message RemoveProfile { - string identifier = 1; -} - -message InstallProvisioningProfile { - bytes provisioning_profile = 1; -} - -message RemoveProvisioningProfile { - string uuid = 1; -} - -message InstalledApplicationList { - repeated string identifiers = 1; - bool managed_apps_only = 2; -} - -message DeviceInformation { - repeated string queries = 1; -} - -message ClearPasscode { - bytes unlock_token = 1; -} - -message DeviceLock { - string pin = 1; - string message = 2; - string phone_number = 3; -} - -message EraseDevice { - string pin = 1; - bool preserve_data_plan = 2; - bool disallow_proximity_setup = 3; -} - -message RequestMirroring { - string destination_name = 1; - string destination_device_id = 2; - string scan_time = 3; - string password = 4; -} - -message Restrictions { - bool profile_restrictions = 1; -} - -message UnlockUserAccount { - string username = 1; -} - -message DeleteUser { - string username = 1; - bool force_deletion = 2; -} - -message EnableLostMode { - string message = 1; - string phone_number = 2; - string footnote = 3; -} - -message InstallApplication { - int64 itunes_store_id = 1; - string identifier = 2; - InstallApplicationOptions options = 3; - string manifest_url = 4; - int64 management_flags = 5; // bitwise OR - InstallApplicationConfiguration configuration = 6; - InstallApplicationAttributes attributes = 7; - string change_management_state = 8; -} - -message InstallApplicationOptions { - int64 purchase_method = 1; -} - -message InstallApplicationConfiguration {} - -message InstallApplicationAttributes {} - - -message InstallEnterpriseApplication { - Manifest manifest = 1; - string manifest_url = 2; - repeated bytes manifest_url_pinning_certs = 3; - bool pinning_revocation_check_required = 4; -} - -message Manifest { - repeated ManifestItem manifest_items = 1; -} - -message ManifestItem { - repeated Asset assets = 1; - Metadata metadata = 2; -} - -message Asset { - string kind = 1; - int64 md5_size = 2; - repeated string md5s = 3; - string url = 4; - int64 sha256_size = 5; - repeated string sha256s = 6; -} - -message Metadata { - string bundle_identifier = 1; - string bundle_version = 2; - repeated BundleInfo items = 3; - string kind = 4; - string subtitle = 5; - string title = 6; - int64 size_in_bytes = 7; -} - -message BundleInfo { - string bundle_identifier = 1; - string bundle_version = 2; -} - -message ApplyRedemptionCode { - string identifier = 1; - string redemption_code = 2; -} - -message ManagedApplicationList { - repeated string identifiers = 1; -} - -message RemoveApplication { - string identifier = 1; -} - -message InviteToProgram { - string program_id = 1; - string invitation_url = 2; -} - -message ValidateApplications { - repeated string identifiers = 1; -} - -message AccountConfiguration { - bool skip_primary_setup_account_creation = 1; - bool set_primary_setup_account_as_regular_user = 2; - bool dont_auto_populate_primary_account_info = 4; - bool lock_primary_account_info = 5; - string primary_account_full_name = 6; - string primary_account_user_name = 7; - repeated AutoSetupAdminAccounts auto_setup_admin_accounts = 3; -} - -message AutoSetupAdminAccounts { - string short_name = 1; - string full_name = 2; - bytes password_hash = 3; - bool hidden = 4; -} - - -message InstallMedia { - int64 itunes_store_id = 1; - string media_url = 2; - string media_type = 3; -} - -message RemoveMedia { - string media_type = 1; - int64 itunes_store_id = 2; - string persistent_id = 3; -} - -message Settings { - repeated Setting settings = 1; -} - -message Setting { - string item = 1; - DeviceNameSetting device_name = 2; - HostnameSetting hostname = 3; - VoiceRoamingSetting voice_roaming = 4; - PersonalHotspotSetting personal_hotspot = 5; - WallpaperSetting wallpaper = 6; - DataRoamingSetting data_roaming = 7; - BluetoothSetting bluetooth = 8; - ApplicationAttributesSetting application_attributes = 9; - MDMOptionsSetting mdm_options = 10; - PasscodeLockGracePeriodSetting passcode_lock_grace_period = 11; - MaximumResidentUsersSetting maximum_resident_users = 12; - DiagnosticSubmissionSetting diagnostic_submission = 13; - AppAnalyticsSetting app_analytics = 14; - ApplicationConfigurationSetting application_configuration = 15; -} - -message VoiceRoamingSetting { - bool enabled = 1; -} - -message PersonalHotspotSetting { - bool enabled = 1; -} - -message WallpaperSetting { - bytes image = 1; - int64 where = 2; -} - -message DataRoamingSetting { - bool enabled = 1; -} - -message BluetoothSetting { - bool enabled = 1; -} - -message ApplicationAttributesSetting { - string identifier = 1; - ApplicationAttributes application_attributes = 2; -} - -message ApplicationConfigurationSetting { - string identifier = 1; - bytes configuration_dictionary_data = 2; // A serialized plist of the dictionary. -} - -message ApplicationAttributes { - string vpn_uuid = 1; -} - -message DeviceNameSetting { - string device_name = 1; -} - -message HostnameSetting { - string hostname = 1; -} - -message MDMOptionsSetting { - MDMOptions mdm_options = 1; -} - -message MDMOptions { - bool activation_lock_allowed_while_supervised = 1; -} - -message PasscodeLockGracePeriodSetting { - int64 passcode_lock_grace_period = 1; -} - -message MaximumResidentUsersSetting { - int64 maximum_resident_users = 1; -} - -message DiagnosticSubmissionSetting { - bool enabled = 1; -} - -message AppAnalyticsSetting { - bool enabled = 1; -} - -message ManagedApplicationConfiguration { - repeated string identifiers = 1; -} - -message ManagedApplicationAttributes { - repeated string identifiers = 1; -} - -message ManagedApplicationFeedback { - repeated string identifiers = 1; - bool delete_feedback = 2; -} - -message SetFirmwarePassword { - string current_password = 1; - string new_password = 2; - bool allow_oroms = 3; -} - -message VerifyFirmwarePassword { - string password = 1; -} - -message SetAutoAdminPassword { - string guid = 1; - bytes password_hash = 2; -} - -message ScheduleOSUpdate { - repeated Update updates = 1; -} - -message Update { - string product_key = 1; - string product_version = 2; - string install_action = 3; -} - -message ScheduleOSUpdateScan { - bool force = 1; -} - -message ActiveNSExtensions { - repeated string filter_extension_points = 1; -} - -message RotateFileVaultKey { - string key_type = 1; - FileVaultUnlock filevault_unlock = 2; - bytes new_certificate = 3; - bytes reply_encryption_certificate = 4; -} - -message FileVaultUnlock { - string password = 1; - bytes private_key_export = 2; - string private_key_export_password = 3; -} - -message SetBootstrapToken { - string bootstrap_token = 1; -} - - -message ResultPayload { - enum Status { - Acknowledged = 0; - Error = 1; - CommandFormatError = 2; - Idle = 3; - NotNow = 4; - } - string udid = 1; - string command_uuid = 2; - repeated ErrorChain error_chain = 3; -} - -message ErrorChain { - string localized_description = 1; - string us_english_description = 2; - - // The ErrorDomain and ErrorCode keys contain internal codes used by Apple - // that may be useful for diagnostics. Your host should not rely on these - // values, as they may change between software releases. - string error_domain = 3; - int32 error_code = 4; -} diff --git a/mdm/mdm/marshal_json.go b/mdm/mdm/marshal_json.go deleted file mode 100644 index b1d08707..00000000 --- a/mdm/mdm/marshal_json.go +++ /dev/null @@ -1,364 +0,0 @@ -package mdm - -import ( - "encoding/json" - "fmt" -) - -func (c *Command) MarshalJSON() ([]byte, error) { - switch c.RequestType { - case "ProfileList", - "ProvisioningProfileList", - "CertificateList", - "SecurityInfo", - "RestartDevice", - "ShutDownDevice", - "StopMirroring", - "ClearRestrictionsPassword", - "UserList", - "LogOutUser", - "PlayLostModeSound", - "DisableLostMode", - "DeviceLocation", - "ManagedMediaList", - "DeviceConfigured", - "AvailableOSUpdates", - "NSExtensionMappings", - "OSUpdateStatus", - "EnableRemoteDesktop", - "DisableRemoteDesktop", - "ActivationLockBypassCode": - var x = struct { - RequestType string `json:"request_type"` - }{ - RequestType: c.RequestType, - } - return json.Marshal(&x) - case "InstallProfile": - var x = struct { - RequestType string `json:"request_type"` - *InstallProfile - }{ - RequestType: c.RequestType, - InstallProfile: c.InstallProfile, - } - return json.Marshal(&x) - case "RemoveProfile": - var x = struct { - RequestType string `json:"request_type"` - *RemoveProfile - }{ - RequestType: c.RequestType, - RemoveProfile: c.RemoveProfile, - } - return json.Marshal(&x) - case "InstallProvisioningProfile": - var x = struct { - RequestType string `json:"request_type"` - *InstallProvisioningProfile - }{ - RequestType: c.RequestType, - InstallProvisioningProfile: c.InstallProvisioningProfile, - } - return json.Marshal(&x) - case "RemoveProvisioningProfile": - var x = struct { - RequestType string `json:"request_type"` - *RemoveProvisioningProfile - }{ - RequestType: c.RequestType, - RemoveProvisioningProfile: c.RemoveProvisioningProfile, - } - return json.Marshal(&x) - case "InstalledApplicationList": - var x = struct { - RequestType string `json:"request_type"` - *InstalledApplicationList - }{ - RequestType: c.RequestType, - InstalledApplicationList: c.InstalledApplicationList, - } - return json.Marshal(&x) - case "DeviceInformation": - var x = struct { - RequestType string `json:"request_type"` - *DeviceInformation - }{ - RequestType: c.RequestType, - DeviceInformation: c.DeviceInformation, - } - return json.Marshal(&x) - case "DeviceLock": - var x = struct { - RequestType string `json:"request_type"` - *DeviceLock - }{ - RequestType: c.RequestType, - DeviceLock: c.DeviceLock, - } - return json.Marshal(&x) - case "ClearPasscode": - var x = struct { - RequestType string `json:"request_type"` - *ClearPasscode - }{ - RequestType: c.RequestType, - ClearPasscode: c.ClearPasscode, - } - return json.Marshal(&x) - case "EraseDevice": - var x = struct { - RequestType string `json:"request_type"` - *EraseDevice - }{ - RequestType: c.RequestType, - EraseDevice: c.EraseDevice, - } - return json.Marshal(&x) - case "RequestMirroring": - var x = struct { - RequestType string `json:"request_type"` - *RequestMirroring - }{ - RequestType: c.RequestType, - RequestMirroring: c.RequestMirroring, - } - return json.Marshal(&x) - case "Restrictions": - var x = struct { - RequestType string `json:"request_type"` - *Restrictions - }{ - RequestType: c.RequestType, - Restrictions: c.Restrictions, - } - return json.Marshal(&x) - case "UnlockUserAccount": - var x = struct { - RequestType string `json:"request_type"` - *UnlockUserAccount - }{ - RequestType: c.RequestType, - UnlockUserAccount: c.UnlockUserAccount, - } - return json.Marshal(&x) - case "DeleteUser": - var x = struct { - RequestType string `json:"request_type"` - *DeleteUser - }{ - RequestType: c.RequestType, - DeleteUser: c.DeleteUser, - } - return json.Marshal(&x) - case "EnableLostMode": - var x = struct { - RequestType string `json:"request_type"` - *EnableLostMode - }{ - RequestType: c.RequestType, - EnableLostMode: c.EnableLostMode, - } - return json.Marshal(&x) - case "InstallApplication": - var x = struct { - RequestType string `json:"request_type"` - *InstallApplication - }{ - RequestType: c.RequestType, - InstallApplication: c.InstallApplication, - } - return json.Marshal(&x) - case "InstallEnterpriseApplication": - var x = struct { - RequestType string `json:"request_type"` - *InstallEnterpriseApplication - }{ - RequestType: c.RequestType, - InstallEnterpriseApplication: c.InstallEnterpriseApplication, - } - return json.Marshal(&x) - case "AccountConfiguration": - var x = struct { - RequestType string `json:"request_type"` - *AccountConfiguration - }{ - RequestType: c.RequestType, - AccountConfiguration: c.AccountConfiguration, - } - return json.Marshal(&x) - case "ApplyRedemptionCode": - var x = struct { - RequestType string `json:"request_type"` - *ApplyRedemptionCode - }{ - RequestType: c.RequestType, - ApplyRedemptionCode: c.ApplyRedemptionCode, - } - return json.Marshal(&x) - case "ManagedApplicationList": - var x = struct { - RequestType string `json:"request_type"` - *ManagedApplicationList - }{ - RequestType: c.RequestType, - ManagedApplicationList: c.ManagedApplicationList, - } - return json.Marshal(&x) - case "RemoveApplication": - var x = struct { - RequestType string `json:"request_type"` - *RemoveApplication - }{ - RequestType: c.RequestType, - RemoveApplication: c.RemoveApplication, - } - return json.Marshal(&x) - case "InviteToProgram": - var x = struct { - RequestType string `json:"request_type"` - *InviteToProgram - }{ - RequestType: c.RequestType, - InviteToProgram: c.InviteToProgram, - } - return json.Marshal(&x) - case "ValidateApplications": - var x = struct { - RequestType string `json:"request_type"` - *ValidateApplications - }{ - RequestType: c.RequestType, - ValidateApplications: c.ValidateApplications, - } - return json.Marshal(&x) - case "InstallMedia": - var x = struct { - RequestType string `json:"request_type"` - *InstallMedia - }{ - RequestType: c.RequestType, - InstallMedia: c.InstallMedia, - } - return json.Marshal(&x) - case "RemoveMedia": - var x = struct { - RequestType string `json:"request_type"` - *RemoveMedia - }{ - RequestType: c.RequestType, - RemoveMedia: c.RemoveMedia, - } - return json.Marshal(&x) - case "Settings": - var x = struct { - RequestType string `json:"request_type"` - *Settings - }{ - RequestType: c.RequestType, - Settings: c.Settings, - } - return json.Marshal(&x) - case "ManagedApplicationConfiguration": - var x = struct { - RequestType string `json:"request_type"` - *ManagedApplicationConfiguration - }{ - RequestType: c.RequestType, - ManagedApplicationConfiguration: c.ManagedApplicationConfiguration, - } - return json.Marshal(&x) - case "ManagedApplicationAttributes": - var x = struct { - RequestType string `json:"request_type"` - *ManagedApplicationAttributes - }{ - RequestType: c.RequestType, - ManagedApplicationAttributes: c.ManagedApplicationAttributes, - } - return json.Marshal(&x) - case "ManagedApplicationFeedback": - var x = struct { - RequestType string `json:"request_type"` - *ManagedApplicationFeedback - }{ - RequestType: c.RequestType, - ManagedApplicationFeedback: c.ManagedApplicationFeedback, - } - return json.Marshal(&x) - case "SetFirmwarePassword": - var x = struct { - RequestType string `json:"request_type"` - *SetFirmwarePassword - }{ - RequestType: c.RequestType, - SetFirmwarePassword: c.SetFirmwarePassword, - } - return json.Marshal(&x) - case "VerifyFirmwarePassword": - var x = struct { - RequestType string `json:"request_type"` - *VerifyFirmwarePassword - }{ - RequestType: c.RequestType, - VerifyFirmwarePassword: c.VerifyFirmwarePassword, - } - return json.Marshal(&x) - case "SetAutoAdminPassword": - var x = struct { - RequestType string `json:"request_type"` - *SetAutoAdminPassword - }{ - RequestType: c.RequestType, - SetAutoAdminPassword: c.SetAutoAdminPassword, - } - return json.Marshal(&x) - case "ScheduleOSUpdate": - var x = struct { - RequestType string `json:"request_type"` - *ScheduleOSUpdate - }{ - RequestType: c.RequestType, - ScheduleOSUpdate: c.ScheduleOSUpdate, - } - return json.Marshal(&x) - case "ScheduleOSUpdateScan": - var x = struct { - RequestType string `json:"request_type"` - *ScheduleOSUpdateScan - }{ - RequestType: c.RequestType, - ScheduleOSUpdateScan: c.ScheduleOSUpdateScan, - } - return json.Marshal(&x) - case "ActiveNSExtensions": - var x = struct { - RequestType string `json:"request_type"` - *ActiveNSExtensions - }{ - RequestType: c.RequestType, - ActiveNSExtensions: c.ActiveNSExtensions, - } - return json.Marshal(&x) - case "RotateFileVaultKey": - var x = struct { - RequestType string `json:"request_type"` - *RotateFileVaultKey - }{ - RequestType: c.RequestType, - RotateFileVaultKey: c.RotateFileVaultKey, - } - return json.Marshal(&x) - case "SetBootstrapToken": - var x = struct { - RequestType string `json:"request_type"` - *SetBootstrapToken - }{ - RequestType: c.RequestType, - SetBootstrapToken: c.SetBootstrapToken, - } - return json.Marshal(&x) - default: - return nil, fmt.Errorf("mdm: unknown RequestType: %s", c.RequestType) - } -} diff --git a/mdm/mdm/marshal_plist.go b/mdm/mdm/marshal_plist.go deleted file mode 100644 index 95cf0143..00000000 --- a/mdm/mdm/marshal_plist.go +++ /dev/null @@ -1,341 +0,0 @@ -package mdm - -import ( - "fmt" - - "github.com/groob/plist" - "github.com/pkg/errors" -) - -func (c *Command) MarshalPlist() (interface{}, error) { - switch c.RequestType { - case "ProfileList", - "ProvisioningProfileList", - "CertificateList", - "SecurityInfo", - "RestartDevice", - "ShutDownDevice", - "StopMirroring", - "ClearRestrictionsPassword", - "UserList", - "LogOutUser", - "PlayLostModeSound", - "DisableLostMode", - "DeviceLocation", - "ManagedMediaList", - "DeviceConfigured", - "AvailableOSUpdates", - "NSExtensionMappings", - "OSUpdateStatus", - "EnableRemoteDesktop", - "DisableRemoteDesktop", - "ActivationLockBypassCode": - return &struct { - RequestType string - }{ - RequestType: c.RequestType, - }, nil - - case "InstallProfile": - return &struct { - RequestType string - *InstallProfile - }{ - RequestType: c.RequestType, - InstallProfile: c.InstallProfile, - }, nil - case "RemoveProfile": - return &struct { - RequestType string - *RemoveProfile - }{ - RequestType: c.RequestType, - RemoveProfile: c.RemoveProfile, - }, nil - case "InstallProvisioningProfile": - return &struct { - RequestType string - *InstallProvisioningProfile - }{ - RequestType: c.RequestType, - InstallProvisioningProfile: c.InstallProvisioningProfile, - }, nil - case "RemoveProvisioningProfile": - return &struct { - RequestType string - *RemoveProvisioningProfile - }{ - RequestType: c.RequestType, - RemoveProvisioningProfile: c.RemoveProvisioningProfile, - }, nil - case "InstalledApplicationList": - return &struct { - RequestType string - *InstalledApplicationList - }{ - RequestType: c.RequestType, - InstalledApplicationList: c.InstalledApplicationList, - }, nil - case "DeviceInformation": - return &struct { - RequestType string - *DeviceInformation - }{ - RequestType: c.RequestType, - DeviceInformation: c.DeviceInformation, - }, nil - case "DeviceLock": - return &struct { - RequestType string - *DeviceLock - }{ - RequestType: c.RequestType, - DeviceLock: c.DeviceLock, - }, nil - case "ClearPasscode": - return &struct { - RequestType string - *ClearPasscode - }{ - RequestType: c.RequestType, - ClearPasscode: c.ClearPasscode, - }, nil - case "EraseDevice": - return &struct { - RequestType string - *EraseDevice - }{ - RequestType: c.RequestType, - EraseDevice: c.EraseDevice, - }, nil - case "RequestMirroring": - return &struct { - RequestType string - *RequestMirroring - }{ - RequestType: c.RequestType, - RequestMirroring: c.RequestMirroring, - }, nil - case "Restrictions": - return &struct { - RequestType string - *Restrictions - }{ - RequestType: c.RequestType, - Restrictions: c.Restrictions, - }, nil - case "UnlockUserAccount": - return &struct { - RequestType string - *UnlockUserAccount - }{ - RequestType: c.RequestType, - UnlockUserAccount: c.UnlockUserAccount, - }, nil - case "DeleteUser": - return &struct { - RequestType string - *DeleteUser - }{ - RequestType: c.RequestType, - DeleteUser: c.DeleteUser, - }, nil - case "EnableLostMode": - return &struct { - RequestType string - *EnableLostMode - }{ - RequestType: c.RequestType, - EnableLostMode: c.EnableLostMode, - }, nil - case "InstallApplication": - return &struct { - RequestType string - *InstallApplication - }{ - RequestType: c.RequestType, - InstallApplication: c.InstallApplication, - }, nil - case "InstallEnterpriseApplication": - return &struct { - RequestType string - *InstallEnterpriseApplication - }{ - RequestType: c.RequestType, - InstallEnterpriseApplication: c.InstallEnterpriseApplication, - }, nil - case "AccountConfiguration": - return &struct { - RequestType string - *AccountConfiguration - }{ - RequestType: c.RequestType, - AccountConfiguration: c.AccountConfiguration, - }, nil - case "ApplyRedemptionCode": - return &struct { - RequestType string - *ApplyRedemptionCode - }{ - RequestType: c.RequestType, - ApplyRedemptionCode: c.ApplyRedemptionCode, - }, nil - case "ManagedApplicationList": - return &struct { - RequestType string - *ManagedApplicationList - }{ - RequestType: c.RequestType, - ManagedApplicationList: c.ManagedApplicationList, - }, nil - case "RemoveApplication": - return &struct { - RequestType string - *RemoveApplication - }{ - RequestType: c.RequestType, - RemoveApplication: c.RemoveApplication, - }, nil - case "InviteToProgram": - return &struct { - RequestType string - *InviteToProgram - }{ - RequestType: c.RequestType, - InviteToProgram: c.InviteToProgram, - }, nil - case "ValidateApplications": - return &struct { - RequestType string - *ValidateApplications - }{ - RequestType: c.RequestType, - ValidateApplications: c.ValidateApplications, - }, nil - case "InstallMedia": - return &struct { - RequestType string - *InstallMedia - }{ - RequestType: c.RequestType, - InstallMedia: c.InstallMedia, - }, nil - case "RemoveMedia": - return &struct { - RequestType string - *RemoveMedia - }{ - RequestType: c.RequestType, - RemoveMedia: c.RemoveMedia, - }, nil - case "Settings": - // convert all the data plists into the dictionary inside settings before serialization. - for i, set := range c.Settings.Settings { - if len(set.ConfigurationData) > 0 { - var configuration map[string]interface{} - if err := plist.Unmarshal(set.ConfigurationData, &configuration); err != nil { - return nil, errors.Wrap(err, "turning the configuration data plist into a dictionary") - } - set.Configuration = configuration - c.Settings.Settings[i] = set - } - } - return &struct { - RequestType string - *Settings - }{ - RequestType: c.RequestType, - Settings: c.Settings, - }, nil - case "ManagedApplicationConfiguration": - return &struct { - RequestType string - *ManagedApplicationConfiguration - }{ - RequestType: c.RequestType, - ManagedApplicationConfiguration: c.ManagedApplicationConfiguration, - }, nil - case "ManagedApplicationAttributes": - return &struct { - RequestType string - *ManagedApplicationAttributes - }{ - RequestType: c.RequestType, - ManagedApplicationAttributes: c.ManagedApplicationAttributes, - }, nil - case "ManagedApplicationFeedback": - return &struct { - RequestType string - *ManagedApplicationFeedback - }{ - RequestType: c.RequestType, - ManagedApplicationFeedback: c.ManagedApplicationFeedback, - }, nil - case "SetFirmwarePassword": - return &struct { - RequestType string - *SetFirmwarePassword - }{ - RequestType: c.RequestType, - SetFirmwarePassword: c.SetFirmwarePassword, - }, nil - case "VerifyFirmwarePassword": - return &struct { - RequestType string - *VerifyFirmwarePassword - }{ - RequestType: c.RequestType, - VerifyFirmwarePassword: c.VerifyFirmwarePassword, - }, nil - case "SetAutoAdminPassword": - return &struct { - RequestType string - *SetAutoAdminPassword - }{ - RequestType: c.RequestType, - SetAutoAdminPassword: c.SetAutoAdminPassword, - }, nil - case "ScheduleOSUpdate": - return &struct { - RequestType string - *ScheduleOSUpdate - }{ - RequestType: c.RequestType, - ScheduleOSUpdate: c.ScheduleOSUpdate, - }, nil - case "ScheduleOSUpdateScan": - return &struct { - RequestType string - *ScheduleOSUpdateScan - }{ - RequestType: c.RequestType, - ScheduleOSUpdateScan: c.ScheduleOSUpdateScan, - }, nil - case "ActiveNSExtensions": - return &struct { - RequestType string - *ActiveNSExtensions - }{ - RequestType: c.RequestType, - ActiveNSExtensions: c.ActiveNSExtensions, - }, nil - case "RotateFileVaultKey": - return &struct { - RequestType string - *RotateFileVaultKey - }{ - RequestType: c.RequestType, - RotateFileVaultKey: c.RotateFileVaultKey, - }, nil - case "SetBootstrapToken": - return &struct { - RequestType string - *SetBootstrapToken - }{ - RequestType: c.RequestType, - SetBootstrapToken: c.SetBootstrapToken, - }, nil - default: - return nil, fmt.Errorf("mdm: unknown command RequestType, %s", c.RequestType) - } -} diff --git a/mdm/mdm/marshal_proto.go b/mdm/mdm/marshal_proto.go deleted file mode 100644 index e6179767..00000000 --- a/mdm/mdm/marshal_proto.go +++ /dev/null @@ -1,498 +0,0 @@ -package mdm - -import ( - "fmt" - - "github.com/gogo/protobuf/proto" - "github.com/micromdm/micromdm/mdm/mdm/internal/mdmproto" -) - -func MarshalCommandPayload(cmd *CommandPayload) ([]byte, error) { - cmdToProto, err := commandToProto(cmd.Command) - if err != nil { - return nil, err - } - cmdproto := mdmproto.CommandPayload{ - CommandUuid: cmd.CommandUUID, - Command: cmdToProto, - } - pb, err := proto.Marshal(&cmdproto) - return pb, err -} - -func commandToProto(cmd *Command) (*mdmproto.Command, error) { - cmdproto := mdmproto.Command{ - RequestType: cmd.RequestType, - } - switch cmd.RequestType { - case "ProfileList", - "ProvisioningProfileList", - "CertificateList", - "SecurityInfo", - "RestartDevice", - "ShutDownDevice", - "StopMirroring", - "ClearRestrictionsPassword", - "UserList", - "LogOutUser", - "PlayLostModeSound", - "DisableLostMode", - "DeviceLocation", - "ManagedMediaList", - "DeviceConfigured", - "AvailableOSUpdates", - "NSExtensionMappings", - "OSUpdateStatus", - "EnableRemoteDesktop", - "DisableRemoteDesktop", - "ActivationLockBypassCode": - - case "InstallProfile": - if cmd.InstallProfile == nil { - break - } - cmdproto.Request = &mdmproto.Command_InstallProfile{ - InstallProfile: &mdmproto.InstallProfile{ - Payload: cmd.InstallProfile.Payload, - }, - } - case "RemoveProfile": - if cmd.RemoveProfile == nil { - break - } - cmdproto.Request = &mdmproto.Command_RemoveProfile{ - RemoveProfile: &mdmproto.RemoveProfile{ - Identifier: cmd.RemoveProfile.Identifier, - }, - } - case "InstallProvisioningProfile": - cmdproto.Request = &mdmproto.Command_InstallProvisioningProfile{ - InstallProvisioningProfile: &mdmproto.InstallProvisioningProfile{ - ProvisioningProfile: cmd.InstallProvisioningProfile.ProvisioningProfile, - }, - } - case "RemoveProvisioningProfile": - cmdproto.Request = &mdmproto.Command_RemoveProfisioningProfile{ - RemoveProfisioningProfile: &mdmproto.RemoveProvisioningProfile{ - Uuid: cmd.RemoveProvisioningProfile.UUID, - }, - } - case "InstalledApplicationList": - cmdproto.Request = &mdmproto.Command_InstalledApplicationList{ - InstalledApplicationList: &mdmproto.InstalledApplicationList{ - Identifiers: cmd.InstalledApplicationList.Identifiers, - ManagedAppsOnly: cmd.InstalledApplicationList.ManagedAppsOnly, - }, - } - case "DeviceInformation": - if cmd.DeviceInformation == nil { - break - } - cmdproto.Request = &mdmproto.Command_DeviceInformation{ - DeviceInformation: &mdmproto.DeviceInformation{ - Queries: cmd.DeviceInformation.Queries, - }, - } - case "DeviceLock": - cmdproto.Request = &mdmproto.Command_DeviceLock{ - DeviceLock: &mdmproto.DeviceLock{ - Pin: cmd.DeviceLock.PIN, - Message: cmd.DeviceLock.Message, - PhoneNumber: cmd.DeviceLock.PhoneNumber, - }, - } - case "ClearPasscode": - cmdproto.Request = &mdmproto.Command_ClearPasscode{ - ClearPasscode: &mdmproto.ClearPasscode{ - UnlockToken: cmd.ClearPasscode.UnlockToken, - }, - } - case "EraseDevice": - cmdproto.Request = &mdmproto.Command_EraseDevice{ - EraseDevice: &mdmproto.EraseDevice{ - Pin: cmd.EraseDevice.PIN, - PreserveDataPlan: cmd.EraseDevice.PreserveDataPlan, - DisallowProximitySetup: cmd.EraseDevice.DisallowProximitySetup, - }, - } - case "RequestMirroring": - cmdproto.Request = &mdmproto.Command_RequestMirroring{ - RequestMirroring: &mdmproto.RequestMirroring{ - DestinationName: cmd.RequestMirroring.DestinationName, - DestinationDeviceId: cmd.RequestMirroring.DestinationDeviceID, - ScanTime: cmd.RequestMirroring.ScanTime, - Password: cmd.RequestMirroring.Password, - }, - } - case "Restrictions": - cmdproto.Request = &mdmproto.Command_Restrictions{ - Restrictions: &mdmproto.Restrictions{ - ProfileRestrictions: cmd.Restrictions.ProfileRestrictions, - }, - } - case "UnlockUserAccount": - cmdproto.Request = &mdmproto.Command_UnlockUserAccount{ - UnlockUserAccount: &mdmproto.UnlockUserAccount{ - Username: cmd.UnlockUserAccount.UserName, - }, - } - case "DeleteUser": - cmdproto.Request = &mdmproto.Command_DeleteUser{ - DeleteUser: &mdmproto.DeleteUser{ - Username: cmd.DeleteUser.UserName, - ForceDeletion: cmd.DeleteUser.ForceDeletion, - }, - } - case "EnableLostMode": - cmdproto.Request = &mdmproto.Command_EnableLostMode{ - EnableLostMode: &mdmproto.EnableLostMode{ - Message: cmd.EnableLostMode.Message, - PhoneNumber: cmd.EnableLostMode.PhoneNumber, - Footnote: cmd.EnableLostMode.Footnote, - }, - } - case "InstallEnterpriseApplication": - var pbManifest *mdmproto.Manifest - if cmd.InstallEnterpriseApplication.Manifest != nil { - pbManifest = &(mdmproto.Manifest{}) - for _, item := range cmd.InstallEnterpriseApplication.Manifest.ManifestItems { - var pbManifestItem mdmproto.ManifestItem - for _, asset := range item.Assets { - pbAsset := mdmproto.Asset{ - Kind: asset.Kind, - Md5Size: asset.MD5Size, - Md5S: asset.MD5s, - Sha256Size: asset.SHA256Size, - Sha256S: asset.SHA256s, - Url: asset.URL, - } - pbManifestItem.Assets = append(pbManifestItem.Assets, &pbAsset) - } - if item.Metadata != nil { - pbManifestItem.Metadata = &(mdmproto.Metadata{ - BundleIdentifier: item.Metadata.BundleInfo.BundleIdentifier, - BundleVersion: item.Metadata.BundleInfo.BundleVersion, - Kind: item.Metadata.Kind, - SizeInBytes: item.Metadata.SizeInBytes, - Title: item.Metadata.Title, - Subtitle: item.Metadata.Subtitle, - }) - for _, bundleInfo := range item.Metadata.Items { - bpBundleInfo := &(mdmproto.BundleInfo{ - BundleIdentifier: bundleInfo.BundleIdentifier, - BundleVersion: bundleInfo.BundleVersion, - }) - pbManifestItem.Metadata.Items = append(pbManifestItem.Metadata.Items, bpBundleInfo) - } - } - if len(pbManifestItem.Assets) > 0 || pbManifestItem.Metadata != nil { - pbManifest.ManifestItems = append(pbManifest.ManifestItems, &pbManifestItem) - } - } - } - cmdproto.Request = &mdmproto.Command_InstallEnterpriseApplication{ - InstallEnterpriseApplication: &mdmproto.InstallEnterpriseApplication{ - Manifest: pbManifest, - ManifestUrl: emptyStringIfNil(cmd.InstallEnterpriseApplication.ManifestURL), - ManifestUrlPinningCerts: cmd.InstallEnterpriseApplication.ManifestURLPinningCerts, - PinningRevocationCheckRequired: falseIfNil(cmd.InstallEnterpriseApplication.PinningRevocationCheckRequired), - }, - } - case "InstallApplication": - var ( - options *mdmproto.InstallApplicationOptions - configuration *mdmproto.InstallApplicationConfiguration - attributes *mdmproto.InstallApplicationAttributes - ) - if cmd.InstallApplication.Options != nil { - options = &mdmproto.InstallApplicationOptions{ - PurchaseMethod: zeroInt64IfNil(cmd.InstallApplication.Options.PurchaseMethod), - } - } - if cmd.InstallApplication.Configuration != nil { - configuration = &mdmproto.InstallApplicationConfiguration{} - } - if cmd.InstallApplication.Attributes != nil { - attributes = &mdmproto.InstallApplicationAttributes{} - } - cmdproto.Request = &mdmproto.Command_InstallApplication{ - InstallApplication: &mdmproto.InstallApplication{ - ItunesStoreId: zeroInt64IfNil(cmd.InstallApplication.ITunesStoreID), - Identifier: emptyStringIfNil(cmd.InstallApplication.Identifier), - ManagementFlags: int64(zeroIntIfNil(cmd.InstallApplication.ManagementFlags)), - ChangeManagementState: emptyStringIfNil(cmd.InstallApplication.ChangeManagementState), - ManifestUrl: emptyStringIfNil(cmd.InstallApplication.ManifestURL), - Options: options, - Configuration: configuration, - Attributes: attributes, - }, - } - case "AccountConfiguration": - var autosetupadminaccounts []*mdmproto.AutoSetupAdminAccounts - for _, acct := range cmd.AccountConfiguration.AutoSetupAdminAccounts { - autosetupadminaccounts = append(autosetupadminaccounts, &mdmproto.AutoSetupAdminAccounts{ - ShortName: acct.ShortName, - FullName: acct.FullName, - PasswordHash: acct.PasswordHash, - Hidden: acct.Hidden, - }) - } - cmdproto.Request = &mdmproto.Command_AccountConfiguration{ - AccountConfiguration: &mdmproto.AccountConfiguration{ - SkipPrimarySetupAccountCreation: cmd.AccountConfiguration.SkipPrimarySetupAccountCreation, - SetPrimarySetupAccountAsRegularUser: cmd.AccountConfiguration.SetPrimarySetupAccountAsRegularUser, - DontAutoPopulatePrimaryAccountInfo: cmd.AccountConfiguration.DontAutoPopulatePrimaryAccountInfo, - LockPrimaryAccountInfo: cmd.AccountConfiguration.LockPrimaryAccountInfo, - PrimaryAccountFullName: cmd.AccountConfiguration.PrimaryAccountFullName, - PrimaryAccountUserName: cmd.AccountConfiguration.PrimaryAccountUserName, - AutoSetupAdminAccounts: autosetupadminaccounts, - }, - } - case "ApplyRedemptionCode": - cmdproto.Request = &mdmproto.Command_ApplyRedemptionCode{ - ApplyRedemptionCode: &mdmproto.ApplyRedemptionCode{ - Identifier: cmd.ApplyRedemptionCode.Identifier, - RedemptionCode: cmd.ApplyRedemptionCode.RedemptionCode, - }, - } - case "ManagedApplicationList": - cmdproto.Request = &mdmproto.Command_ManagedApplicationList{ - ManagedApplicationList: &mdmproto.ManagedApplicationList{ - Identifiers: cmd.ManagedApplicationList.Identifiers, - }, - } - case "RemoveApplication": - cmdproto.Request = &mdmproto.Command_RemoveApplication{ - RemoveApplication: &mdmproto.RemoveApplication{ - Identifier: cmd.RemoveApplication.Identifier, - }, - } - case "InviteToProgram": - cmdproto.Request = &mdmproto.Command_InviteToProgram{ - InviteToProgram: &mdmproto.InviteToProgram{ - ProgramId: cmd.InviteToProgram.ProgramID, - InvitationUrl: cmd.InviteToProgram.InvitationURL, - }, - } - case "ValidateApplications": - cmdproto.Request = &mdmproto.Command_ValidataApplications{ - ValidataApplications: &mdmproto.ValidateApplications{ - Identifiers: cmd.ValidateApplications.Identifiers, - }, - } - case "InstallMedia": - cmdproto.Request = &mdmproto.Command_InstallMedia{ - InstallMedia: &mdmproto.InstallMedia{ - ItunesStoreId: zeroInt64IfNil(cmd.InstallMedia.ITunesStoreID), - MediaType: cmd.InstallMedia.MediaType, - MediaUrl: cmd.InstallMedia.MediaURL, - }, - } - case "RemoveMedia": - cmdproto.Request = &mdmproto.Command_RemoveMedia{ - RemoveMedia: &mdmproto.RemoveMedia{ - ItunesStoreId: zeroInt64IfNil(cmd.RemoveMedia.ITunesStoreID), - MediaType: cmd.RemoveMedia.MediaType, - PersistentId: cmd.RemoveMedia.PersistentID, - }, - } - case "Settings": - var settings []*mdmproto.Setting - for _, s := range cmd.Settings.Settings { - settings = append(settings, settingToProto(s)) - } - cmdproto.Request = &mdmproto.Command_Settings{ - Settings: &mdmproto.Settings{Settings: settings}, - } - case "ManagedApplicationConfiguration": - cmdproto.Request = &mdmproto.Command_ManagedApplicationConfiguration{ - ManagedApplicationConfiguration: &mdmproto.ManagedApplicationConfiguration{ - Identifiers: cmd.ManagedApplicationConfiguration.Identifiers, - }, - } - case "ManagedApplicationAttributes": - cmdproto.Request = &mdmproto.Command_ManagedApplicationAttributes{ - ManagedApplicationAttributes: &mdmproto.ManagedApplicationAttributes{ - Identifiers: cmd.ManagedApplicationAttributes.Identifiers, - }, - } - case "ManagedApplicationFeedback": - cmdproto.Request = &mdmproto.Command_ManagedApplicationFeedback{ - ManagedApplicationFeedback: &mdmproto.ManagedApplicationFeedback{ - Identifiers: cmd.ManagedApplicationFeedback.Identifiers, - DeleteFeedback: cmd.ManagedApplicationFeedback.DeleteFeedback, - }, - } - case "SetFirmwarePassword": - cmdproto.Request = &mdmproto.Command_SetFirmwarePassword{ - SetFirmwarePassword: &mdmproto.SetFirmwarePassword{ - CurrentPassword: cmd.SetFirmwarePassword.CurrentPassword, - NewPassword: cmd.SetFirmwarePassword.NewPassword, - AllowOroms: cmd.SetFirmwarePassword.AllowOroms, - }, - } - case "SetBootstrapToken": - cmdproto.Request = &mdmproto.Command_SetBootstrapToken{ - SetBootstrapToken: &mdmproto.SetBootstrapToken{ - BootstrapToken: cmd.SetBootstrapToken.BootstrapToken, - }, - } - case "VerifyFirmwarePassword": - cmdproto.Request = &mdmproto.Command_VerifyFirmwarePassword{ - VerifyFirmwarePassword: &mdmproto.VerifyFirmwarePassword{ - Password: cmd.VerifyFirmwarePassword.Password, - }, - } - case "SetAutoAdminPassword": - cmdproto.Request = &mdmproto.Command_SetAutoAdminPassword{ - SetAutoAdminPassword: &mdmproto.SetAutoAdminPassword{ - Guid: cmd.SetAutoAdminPassword.GUID, - PasswordHash: cmd.SetAutoAdminPassword.PasswordHash, - }, - } - case "ScheduleOSUpdate": - var updates []*mdmproto.Update - for _, u := range cmd.ScheduleOSUpdate.Updates { - updates = append(updates, &mdmproto.Update{ - ProductKey: u.ProductKey, - InstallAction: u.InstallAction, - }) - } - cmdproto.Request = &mdmproto.Command_ScheduleOsUpdate{ - ScheduleOsUpdate: &mdmproto.ScheduleOSUpdate{ - Updates: updates, - }, - } - case "ScheduleOSUpdateScan": - cmdproto.Request = &mdmproto.Command_ScheduleOsUpdateScan{ - ScheduleOsUpdateScan: &mdmproto.ScheduleOSUpdateScan{ - Force: cmd.ScheduleOSUpdateScan.Force, - }, - } - case "ActiveNSExtensions": - cmdproto.Request = &mdmproto.Command_ActiveNsExtensions{ - ActiveNsExtensions: &mdmproto.ActiveNSExtensions{ - FilterExtensionPoints: cmd.ActiveNSExtensions.FilterExtensionPoints, - }, - } - case "RotateFileVaultKey": - fvunlock := cmd.RotateFileVaultKey.FileVaultUnlock - cmdproto.Request = &mdmproto.Command_RotateFilevaultKey{ - RotateFilevaultKey: &mdmproto.RotateFileVaultKey{ - KeyType: cmd.RotateFileVaultKey.KeyType, - NewCertificate: cmd.RotateFileVaultKey.NewCertificate, - ReplyEncryptionCertificate: cmd.RotateFileVaultKey.ReplyEncryptionCertificate, - FilevaultUnlock: &mdmproto.FileVaultUnlock{ - Password: fvunlock.Password, - PrivateKeyExport: fvunlock.PrivateKeyExport, - PrivateKeyExportPassword: fvunlock.PrivateKeyExportPassword, - }, - }, - } - default: - return nil, fmt.Errorf("unknown command type %s", cmd.RequestType) - } - return &cmdproto, nil -} - -func settingToProto(s Setting) *mdmproto.Setting { - pbs := mdmproto.Setting{Item: s.Item} - switch s.Item { - case "ApplicationConfiguration": - pbs.ApplicationConfiguration = &mdmproto.ApplicationConfigurationSetting{ - Identifier: emptyStringIfNil(s.Identifier), - ConfigurationDictionaryData: s.ConfigurationData, - } - case "VoiceRoaming": - pbs.VoiceRoaming = &mdmproto.VoiceRoamingSetting{ - Enabled: falseIfNil(s.Enabled), - } - case "PersonalHotspot": - pbs.PersonalHotspot = &mdmproto.PersonalHotspotSetting{ - Enabled: falseIfNil(s.Enabled), - } - case "Wallpaper": - pbs.Wallpaper = &mdmproto.WallpaperSetting{ - Image: s.Image, - Where: int64(zeroIntIfNil(s.Where)), - } - case "DataRoaming": - pbs.DataRoaming = &mdmproto.DataRoamingSetting{ - Enabled: falseIfNil(s.Enabled), - } - case "Bluetooth": - pbs.Bluetooth = &mdmproto.BluetoothSetting{ - Enabled: falseIfNil(s.Enabled), - } - case "ApplicationAttributes": - var attributes *mdmproto.ApplicationAttributes - if v, ok := s.Attributes["VPNUUID"]; ok { - attributes.VpnUuid = v - } - pbs.ApplicationAttributes = &mdmproto.ApplicationAttributesSetting{ - Identifier: emptyStringIfNil(s.Identifier), - ApplicationAttributes: attributes, - } - case "DeviceName": - pbs.DeviceName = &mdmproto.DeviceNameSetting{ - DeviceName: emptyStringIfNil(s.DeviceName), - } - case "HostName": - pbs.Hostname = &mdmproto.HostnameSetting{ - Hostname: emptyStringIfNil(s.HostName), - } - case "MDMOptions": - options := &mdmproto.MDMOptions{} - if v, ok := s.MDMOptions["ActivationLockAllowedWhileSupervised"]; ok { - options.ActivationLockAllowedWhileSupervised = v.(bool) - } - pbs.MdmOptions = &mdmproto.MDMOptionsSetting{ - MdmOptions: options, - } - case "PasscodeLockGracePeriod": - pbs.PasscodeLockGracePeriod = &mdmproto.PasscodeLockGracePeriodSetting{ - PasscodeLockGracePeriod: int64(zeroIntIfNil(s.PasscodeLockGracePeriod)), - } - case "MaximumResidentUsers": - pbs.MaximumResidentUsers = &mdmproto.MaximumResidentUsersSetting{ - MaximumResidentUsers: int64(zeroIntIfNil(s.MaximumResidentUsers)), - } - case "DiagnosticSubmission": - pbs.DiagnosticSubmission = &mdmproto.DiagnosticSubmissionSetting{ - Enabled: falseIfNil(s.Enabled), - } - case "AppAnalytics": - pbs.AppAnalytics = &mdmproto.AppAnalyticsSetting{ - Enabled: falseIfNil(s.Enabled), - } - } - return &pbs -} - -func falseIfNil(b *bool) bool { - if b == nil { - return false - } - return *b -} - -func zeroInt64IfNil(n *int64) int64 { - if n == nil { - return 0 - } - return *n -} - -func zeroIntIfNil(n *int) int { - if n == nil { - return 0 - } - return *n -} - -func emptyStringIfNil(s *string) string { - if s == nil { - return "" - } - return *s -} diff --git a/mdm/mdm/mdm_command_test.go b/mdm/mdm/mdm_command_test.go deleted file mode 100644 index 083711b0..00000000 --- a/mdm/mdm/mdm_command_test.go +++ /dev/null @@ -1,277 +0,0 @@ -package mdm - -import ( - "bytes" - "encoding/json" - "fmt" - "io/ioutil" - "path/filepath" - "reflect" - "testing" - - "github.com/groob/plist" -) - -/* -Last Verified against PDF: April 7 2018 -Fully tested commands (with a 10.13.4 mac): - - ProfileList - - InstallProfile - - RemoveProfile - - ProvisioningProfileList - - CertificateList - --- -Not tested end to end but checked against pdf: - - InstallProvisioningProfile - - RemoveProvisioningProfile -*/ - -func TestMarshalCommand(t *testing.T) { - var tests = []struct { - Command Command - }{ - { - Command: Command{ - RequestType: "ProfileList", - }, - }, - { - Command: Command{ - RequestType: "InstallProfile", - InstallProfile: &InstallProfile{ - Payload: []byte("foobarbaz"), - }, - }, - }, - { - Command: Command{ - RequestType: "RemoveProfile", - RemoveProfile: &RemoveProfile{ - Identifier: "foobarbaz", - }, - }, - }, - { - Command: Command{ - RequestType: "EnableRemoteDesktop", - }, - }, - { - Command: Command{ - RequestType: "DisableRemoteDesktop", - }, - }, - } - for _, tt := range tests { - t.Run(tt.Command.RequestType+"_json", func(t *testing.T) { - payload := CommandPayload{CommandUUID: "abcd", Command: &tt.Command} - buf := new(bytes.Buffer) - enc := json.NewEncoder(buf) - enc.SetIndent("", " ") - if err := enc.Encode(&payload); err != nil { - t.Fatal(err) - } - }) - - t.Run(tt.Command.RequestType+"_plist", func(t *testing.T) { - payload := CommandPayload{CommandUUID: "abcd", Command: &tt.Command} - buf := new(bytes.Buffer) - enc := plist.NewEncoder(buf) - enc.Indent(" ") - if err := enc.Encode(&payload); err != nil { - t.Fatal(err) - } - }) - } -} - -func TestUnmarshalCommandPayload(t *testing.T) { - var tests = []struct { - RequestType string - }{ - {RequestType: "InstallProfile"}, - } - - for _, tt := range tests { - t.Run(tt.RequestType+"_json", func(t *testing.T) { - filename := fmt.Sprintf("%s.json", tt.RequestType) - data := mustLoadFile(t, filename) - var payload CommandPayload - testCommandUnmarshal(t, tt.RequestType, json.Unmarshal, data, &payload) - }) - - t.Run(tt.RequestType+"_plist", func(t *testing.T) { - filename := fmt.Sprintf("%s.plist", tt.RequestType) - data := mustLoadFile(t, filename) - var payload CommandPayload - testCommandUnmarshal(t, tt.RequestType, plist.Unmarshal, data, &payload) - }) - } -} - -func mustLoadFile(t *testing.T, filename string) []byte { - t.Helper() - data, err := ioutil.ReadFile(filepath.Join("testdata", filename)) - if err != nil { - t.Fatalf("could not read test file %s: %s", filename, err) - } - return data -} - -type unmarshalFunc func([]byte, interface{}) error - -func testCommandUnmarshal( - t *testing.T, - requestType string, - unmarshal unmarshalFunc, - data []byte, - payload *CommandPayload, -) { - t.Helper() - if err := unmarshal(data, payload); err != nil { - t.Fatalf("unmarshal command type %s: %s", requestType, err) - } - - if payload.CommandUUID == "" { - t.Errorf("missing CommandUUID") - } - - if have, want := payload.Command.RequestType, requestType; have != want { - t.Errorf("have %s, want %s", have, want) - } -} - -func TestEndToEnd(t *testing.T) { - var tests = []struct { - name string - requestBytes []byte - testFn func(t *testing.T, parts endToEndParts) - }{ - { - name: "Settings_ApplicationConfiguration", - requestBytes: []byte( - `{"udid":"BC5E2DA4-7FB6-5E70-9928-4981680DAFBF","request_type":"Settings","settings":[{"item":"ApplicationConfiguration","identifier":"anidentifier","configuration":"PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPCFET0NUWVBFIHBsaXN0IFBVQkxJQyAiLS8vQXBwbGUvL0RURCBQTElTVCAxLjAvL0VOIiAiaHR0cDovL3d3dy5hcHBsZS5jb20vRFREcy9Qcm9wZXJ0eUxpc3QtMS4wLmR0ZCI+CjxwbGlzdCB2ZXJzaW9uPSIxLjAiPgogIDxkaWN0PgogICAgPGtleT5iYXo8L2tleT4KICAgIDxzdHJpbmc+cXV4PC9zdHJpbmc+CiAgICA8a2V5PmNvdW50PC9rZXk+CiAgICA8aW50ZWdlcj4xPC9pbnRlZ2VyPgogICAgPGtleT5mb288L2tleT4KICAgIDxzdHJpbmc+YmFyPC9zdHJpbmc+CiAgPC9kaWN0Pgo8L3BsaXN0Pgo="}]}`, - ), - testFn: func(t *testing.T, parts endToEndParts) { - if len(parts.req.Command.Settings.Settings) == 0 { - t.Error("expected settings command to include at least one setting") - } - - if len(parts.fromProto.Command.Settings.Settings) == 0 { - t.Error("expected settings command from proto to include at least one setting") - } - - // unmarshal plist and check that the settings in the configuration dictionary are there - var cmd struct { - Command struct{ Settings []map[string]interface{} } - } - if err := plist.Unmarshal(parts.plistData, &cmd); err != nil { - t.Fatal(err) - } - setting := cmd.Command.Settings[0]["Configuration"].(map[string]interface{}) - if have, want := setting["foo"], "bar"; have != want { - t.Errorf("have key %s, want key %s", have, want) - } - - }, - }, - - { - name: "InstallProfile", - requestBytes: []byte( - `{"udid": "BC5E2DA4-7FB6-5E70-9928-4981680DAFBF", "payload":"PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPCFET0NUWVBFIHBsaXN0IFBVQkxJQyAiLS8vQXBwbGUvL0RURCBQTElTVCAxLjAvL0VOIiAiaHR0cDovL3d3dy5hcHBsZS5jb20vRFREcy9Qcm9wZXJ0eUxpc3QtMS4wLmR0ZCI+CjxwbGlzdCB2ZXJzaW9uPSIxLjAiPgo8ZGljdD4KCTxrZXk+UGF5bG9hZENvbnRlbnQ8L2tleT4KCTxhcnJheT4KCQk8ZGljdD4KCQkJPGtleT5QYXlsb2FkQ29udGVudDwva2V5PgoJCQk8ZGljdD4KCQkJCTxrZXk+Y29tLmFwcGxlLmFzc2lzdGFudC5zdXBwb3J0PC9rZXk+CgkJCQk8ZGljdD4KCQkJCQk8a2V5PkZvcmNlZDwva2V5PgoJCQkJCTxhcnJheT4KCQkJCQkJPGRpY3Q+CgkJCQkJCQk8a2V5Pm1jeF9wcmVmZXJlbmNlX3NldHRpbmdzPC9rZXk+CgkJCQkJCQk8ZGljdD4KCQkJCQkJCQk8a2V5PkFzc2lzdGFudCBFbmFibGVkPC9rZXk+CgkJCQkJCQkJPGZhbHNlLz4KCQkJCQkJCTwvZGljdD4KCQkJCQkJPC9kaWN0PgoJCQkJCTwvYXJyYXk+CgkJCQk8L2RpY3Q+CgkJCTwvZGljdD4KCQkJPGtleT5QYXlsb2FkRW5hYmxlZDwva2V5PgoJCQk8dHJ1ZS8+CgkJCTxrZXk+UGF5bG9hZElkZW50aWZpZXI8L2tleT4KCQkJPHN0cmluZz5NQ1hUb1Byb2ZpbGUuOWM3MzgwZDItNWJmZS00ZTYwLWJhZDMtMjVhZDg2ZDYxNTBkLmFsYWNhcnRlLmN1c3RvbXNldHRpbmdzLmZiOTU4ZDk2LWE0MzEtNDUzNi04NGQwLTFiZTQ4MjM4NWZiMjwvc3RyaW5nPgoJCQk8a2V5PlBheWxvYWRUeXBlPC9rZXk+CgkJCTxzdHJpbmc+Y29tLmFwcGxlLk1hbmFnZWRDbGllbnQucHJlZmVyZW5jZXM8L3N0cmluZz4KCQkJPGtleT5QYXlsb2FkVVVJRDwva2V5PgoJCQk8c3RyaW5nPmZiOTU4ZDk2LWE0MzEtNDUzNi04NGQwLTFiZTQ4MjM4NWZiMjwvc3RyaW5nPgoJCQk8a2V5PlBheWxvYWRWZXJzaW9uPC9rZXk+CgkJCTxpbnRlZ2VyPjE8L2ludGVnZXI+CgkJPC9kaWN0PgoJPC9hcnJheT4KCTxrZXk+UGF5bG9hZERlc2NyaXB0aW9uPC9rZXk+Cgk8c3RyaW5nPlN0b3BzIFNpcmkgZnJvbSBiZWluZyBlbmFibGVkLjwvc3RyaW5nPgoJPGtleT5QYXlsb2FkRGlzcGxheU5hbWU8L2tleT4KCTxzdHJpbmc+RGlzYWJsZSBTaXJpPC9zdHJpbmc+Cgk8a2V5PlBheWxvYWRJZGVudGlmaWVyPC9rZXk+Cgk8c3RyaW5nPkRpc2FibGVTaXJpPC9zdHJpbmc+Cgk8a2V5PlBheWxvYWRPcmdhbml6YXRpb248L2tleT4KCTxzdHJpbmc+PC9zdHJpbmc+Cgk8a2V5PlBheWxvYWRSZW1vdmFsRGlzYWxsb3dlZDwva2V5PgoJPHRydWUvPgoJPGtleT5QYXlsb2FkU2NvcGU8L2tleT4KCTxzdHJpbmc+U3lzdGVtPC9zdHJpbmc+Cgk8a2V5PlBheWxvYWRUeXBlPC9rZXk+Cgk8c3RyaW5nPkNvbmZpZ3VyYXRpb248L3N0cmluZz4KCTxrZXk+UGF5bG9hZFVVSUQ8L2tleT4KCTxzdHJpbmc+OWM3MzgwZDItNWJmZS00ZTYwLWJhZDMtMjVhZDg2ZDYxNTBkPC9zdHJpbmc+Cgk8a2V5PlBheWxvYWRWZXJzaW9uPC9rZXk+Cgk8aW50ZWdlcj4xPC9pbnRlZ2VyPgo8L2RpY3Q+CjwvcGxpc3Q+Cg==", "request_type": "InstallProfile"}`, - ), - testFn: func(t *testing.T, parts endToEndParts) { - if len(parts.req.Command.InstallProfile.Payload) == 0 { - t.Error("InstallProfile payload is empty after json unmarshal") - } - if len(parts.fromProto.Command.InstallProfile.Payload) == 0 { - t.Error("unmarshaled proto payload is missing payload") - } - if !bytes.Contains(parts.plistData, []byte(`PD94bWwgdm`)) { - t.Error("marshaled plist does not contain the required payload") - } - }, - }, - - { - name: "InstallEnterpriseApplication", - requestBytes: []byte( - `{"udid":"B59A5A44-EC36-4244-AB52-C40F6100528A","request_type":"InstallEnterpriseApplication","manifest":{"items":[{"metadata":{"items":[{"bundle-version":"1.7.5","bundle-identifier":"com.myenterprise.MyAppNotMAS"}],"bundle-version":"1.1","bundle-identifier":"com.myenterprise.MyAppPackage","kind":"display-image","sizeInBytes":1234,"title":"Test Title","subtitle":"Test Subtitle"},"Assets":[{"sha256-size":1234,"sha256s":["2a8a98c146c35ce29f8b9af4cf8218d2c026058e7eb35adb4a00236997593471"],"url":"https://example.com/p.pkg","kind":"software-package","md5-size":1234,"md5s":["cfdc14fa22a79bab2a8b423daca2c076"]}]}]}}`, - ), - testFn: func(t *testing.T, parts endToEndParts) { - needToSee := [][]byte{ - []byte(`cfdc14fa22a79bab2a8b423daca2c076`), - []byte(`https://example.com/p.pkg`), - []byte(`com.myenterprise.MyAppPackage`), - []byte(`1.1`), - []byte(`1234`), - []byte(`2a8a98c146c35ce29f8b9af4cf8218d2c026058e7eb35adb4a00236997593471`), - []byte(`com.myenterprise.MyAppPackage`), - []byte(`com.myenterprise.MyAppNotMAS`), - []byte(`1.7.5`), - []byte(`software-package`), - []byte(`display-image`), - []byte(`Test Title`), - []byte(`Test Subtitle`), - } - for _, b := range needToSee { - if !bytes.Contains(parts.plistData, b) { - t.Error(fmt.Sprintf("marshaled plist does not contain required bytes: '%s'", string(b))) - } - } - }, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - parts := endToEnd(t, tt.requestBytes) - tt.testFn(t, parts) - }) - } -} - -type endToEndParts struct { - requestBytes []byte // some json, our API request - req CommandRequest // after unmarshal - payload *CommandPayload // new payload - protoData []byte // stored as - fromProto CommandPayload // back from proto - plistData []byte // final representation -} - -func endToEnd(t *testing.T, requestBytes []byte) endToEndParts { - t.Helper() - var ( - err error - parts = endToEndParts{requestBytes: requestBytes} - ) - - if err = json.Unmarshal(parts.requestBytes, &parts.req); err != nil { - t.Fatal(err) - } - - if parts.payload, err = NewCommandPayload(&parts.req); err != nil { - t.Fatal(err) - } - - if parts.protoData, err = MarshalCommandPayload(parts.payload); err != nil { - t.Fatal(err) - } - - if err := UnmarshalCommandPayload(parts.protoData, &parts.fromProto); err != nil { - t.Fatal(err) - } - - if !reflect.DeepEqual(*parts.payload, parts.fromProto) { - t.Errorf("command from json request does not match command from proto") - } - - if parts.plistData, err = plist.MarshalIndent(parts.fromProto, " "); err != nil { - t.Fatal(err) - } - - return parts -} diff --git a/mdm/mdm/testdata/InstallProfile.json b/mdm/mdm/testdata/InstallProfile.json deleted file mode 100644 index a8144f10..00000000 --- a/mdm/mdm/testdata/InstallProfile.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "command_uuid": "7e761ec5-9e20-42d1-9072-3d5a611e3ac5", - "command": { - "request_type":"InstallProfile", - "payload": "Zm9vYmFyYmF6" - } -} diff --git a/mdm/mdm/testdata/InstallProfile.plist b/mdm/mdm/testdata/InstallProfile.plist deleted file mode 100755 index 63f7bd8c..00000000 --- a/mdm/mdm/testdata/InstallProfile.plist +++ /dev/null @@ -1,15 +0,0 @@ - - - - - Command - - Payload - Zm9vYmFyYmF6 - RequestType - InstallProfile - - CommandUUID - 7e761ec5-9e20-42d1-9072-3d5a611e3ac5 - - diff --git a/mdm/mdm/unmarshal_json.go b/mdm/mdm/unmarshal_json.go deleted file mode 100644 index 5324672a..00000000 --- a/mdm/mdm/unmarshal_json.go +++ /dev/null @@ -1,310 +0,0 @@ -package mdm - -import ( - "encoding/json" - "fmt" - - "github.com/pkg/errors" -) - -func (c *CommandRequest) UnmarshalJSON(data []byte) error { - var request = struct { - UDID string `json:"udid"` - RequestType string `json:"request_type"` - }{} - if err := json.Unmarshal(data, &request); err != nil { - return errors.Wrap(err, "mdm: unmarshal json command request") - } - c.UDID = request.UDID - c.Command = &Command{} - return c.Command.UnmarshalJSON(data) -} - -func (c *Command) UnmarshalJSON(data []byte) error { - var request = struct { - RequestType string `json:"request_type"` - }{} - if err := json.Unmarshal(data, &request); err != nil { - return errors.Wrap(err, "mdm: unmarshal json command request") - } - c.RequestType = request.RequestType - - switch c.RequestType { - case "ProfileList", - "ProvisioningProfileList", - "CertificateList", - "SecurityInfo", - "RestartDevice", - "ShutDownDevice", - "StopMirroring", - "ClearRestrictionsPassword", - "UserList", - "LogOutUser", - "PlayLostModeSound", - "DisableLostMode", - "DeviceLocation", - "ManagedMediaList", - "DeviceConfigured", - "AvailableOSUpdates", - "NSExtensionMappings", - "OSUpdateStatus", - "EnableRemoteDesktop", - "DisableRemoteDesktop", - "ActivationLockBypassCode": - return nil - case "InstallProfile": - var payload InstallProfile - if err := json.Unmarshal(data, &payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command json", c.RequestType) - } - c.InstallProfile = &payload - return nil - case "RemoveProfile": - var payload RemoveProfile - if err := json.Unmarshal(data, &payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command json", c.RequestType) - } - c.RemoveProfile = &payload - return nil - case "InstallProvisioningProfile": - var payload InstallProvisioningProfile - if err := json.Unmarshal(data, &payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command json", c.RequestType) - } - c.InstallProvisioningProfile = &payload - return nil - case "RemoveProvisioningProfile": - var payload RemoveProvisioningProfile - if err := json.Unmarshal(data, &payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command json", c.RequestType) - } - c.RemoveProvisioningProfile = &payload - return nil - case "InstalledApplicationList": - var payload InstalledApplicationList - if err := json.Unmarshal(data, &payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command json", c.RequestType) - } - c.InstalledApplicationList = &payload - return nil - case "DeviceInformation": - var payload DeviceInformation - if err := json.Unmarshal(data, &payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command json", c.RequestType) - } - c.DeviceInformation = &payload - return nil - case "DeviceLock": - var payload DeviceLock - if err := json.Unmarshal(data, &payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command json", c.RequestType) - } - c.DeviceLock = &payload - return nil - case "ClearPasscode": - var payload ClearPasscode - if err := json.Unmarshal(data, &payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command json", c.RequestType) - } - c.ClearPasscode = &payload - return nil - case "EraseDevice": - var payload EraseDevice - if err := json.Unmarshal(data, &payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command json", c.RequestType) - } - c.EraseDevice = &payload - return nil - case "RequestMirroring": - var payload RequestMirroring - if err := json.Unmarshal(data, &payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command json", c.RequestType) - } - c.RequestMirroring = &payload - return nil - case "Restrictions": - var payload Restrictions - if err := json.Unmarshal(data, &payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command json", c.RequestType) - } - c.Restrictions = &payload - return nil - case "UnlockUserAccount": - var payload UnlockUserAccount - if err := json.Unmarshal(data, &payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command json", c.RequestType) - } - c.UnlockUserAccount = &payload - return nil - case "DeleteUser": - var payload DeleteUser - if err := json.Unmarshal(data, &payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command json", c.RequestType) - } - c.DeleteUser = &payload - return nil - case "EnableLostMode": - var payload EnableLostMode - if err := json.Unmarshal(data, &payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command json", c.RequestType) - } - c.EnableLostMode = &payload - return nil - case "InstallEnterpriseApplication": - var payload InstallEnterpriseApplication - if err := json.Unmarshal(data, &payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command json", c.RequestType) - } - c.InstallEnterpriseApplication = &payload - return nil - case "InstallApplication": - var payload InstallApplication - if err := json.Unmarshal(data, &payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command json", c.RequestType) - } - c.InstallApplication = &payload - return nil - case "AccountConfiguration": - var payload AccountConfiguration - if err := json.Unmarshal(data, &payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command json", c.RequestType) - } - c.AccountConfiguration = &payload - return nil - case "ApplyRedemptionCode": - var payload ApplyRedemptionCode - if err := json.Unmarshal(data, &payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command json", c.RequestType) - } - c.ApplyRedemptionCode = &payload - return nil - case "ManagedApplicationList": - var payload ManagedApplicationList - if err := json.Unmarshal(data, &payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command json", c.RequestType) - } - c.ManagedApplicationList = &payload - return nil - case "RemoveApplication": - var payload RemoveApplication - if err := json.Unmarshal(data, &payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command json", c.RequestType) - } - c.RemoveApplication = &payload - return nil - case "InviteToProgram": - var payload InviteToProgram - if err := json.Unmarshal(data, &payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command json", c.RequestType) - } - c.InviteToProgram = &payload - return nil - case "ValidateApplications": - var payload ValidateApplications - if err := json.Unmarshal(data, &payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command json", c.RequestType) - } - c.ValidateApplications = &payload - return nil - case "InstallMedia": - var payload InstallMedia - if err := json.Unmarshal(data, &payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command json", c.RequestType) - } - c.InstallMedia = &payload - return nil - case "RemoveMedia": - var payload RemoveMedia - if err := json.Unmarshal(data, &payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command json", c.RequestType) - } - c.RemoveMedia = &payload - return nil - case "Settings": - var payload Settings - if err := json.Unmarshal(data, &payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command json", c.RequestType) - } - c.Settings = &payload - return nil - case "ManagedApplicationConfiguration": - var payload ManagedApplicationConfiguration - if err := json.Unmarshal(data, &payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command json", c.RequestType) - } - c.ManagedApplicationConfiguration = &payload - return nil - case "ManagedApplicationAttributes": - var payload ManagedApplicationAttributes - if err := json.Unmarshal(data, &payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command json", c.RequestType) - } - c.ManagedApplicationAttributes = &payload - return nil - case "ManagedApplicationFeedback": - var payload ManagedApplicationFeedback - if err := json.Unmarshal(data, &payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command json", c.RequestType) - } - c.ManagedApplicationFeedback = &payload - return nil - case "SetFirmwarePassword": - var payload SetFirmwarePassword - if err := json.Unmarshal(data, &payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command json", c.RequestType) - } - c.SetFirmwarePassword = &payload - return nil - case "VerifyFirmwarePassword": - var payload VerifyFirmwarePassword - if err := json.Unmarshal(data, &payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command json", c.RequestType) - } - c.VerifyFirmwarePassword = &payload - return nil - case "SetAutoAdminPassword": - var payload SetAutoAdminPassword - if err := json.Unmarshal(data, &payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command json", c.RequestType) - } - c.SetAutoAdminPassword = &payload - return nil - case "ScheduleOSUpdate": - var payload ScheduleOSUpdate - if err := json.Unmarshal(data, &payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command json", c.RequestType) - } - c.ScheduleOSUpdate = &payload - return nil - case "ScheduleOSUpdateScan": - var payload ScheduleOSUpdateScan - if err := json.Unmarshal(data, &payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command json", c.RequestType) - } - c.ScheduleOSUpdateScan = &payload - return nil - case "ActiveNSExtensions": - var payload ActiveNSExtensions - if err := json.Unmarshal(data, &payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command json", c.RequestType) - } - c.ActiveNSExtensions = &payload - return nil - case "RotateFileVaultKey": - var payload RotateFileVaultKey - if err := json.Unmarshal(data, &payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command json", c.RequestType) - } - c.RotateFileVaultKey = &payload - return nil - case "SetBootstrapToken": - var payload SetBootstrapToken - if err := json.Unmarshal(data, &payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command json", c.RequestType) - } - c.SetBootstrapToken = &payload - return nil - default: - return fmt.Errorf("mdm: unknown RequestType: %s", c.RequestType) - } -} diff --git a/mdm/mdm/unmarshal_plist.go b/mdm/mdm/unmarshal_plist.go deleted file mode 100644 index 706c7d3a..00000000 --- a/mdm/mdm/unmarshal_plist.go +++ /dev/null @@ -1,296 +0,0 @@ -package mdm - -import ( - "fmt" - - "github.com/pkg/errors" -) - -func (c *Command) UnmarshalPlist(unmarshal func(i interface{}) error) error { - var requestType = struct { - RequestType string - }{} - if err := unmarshal(&requestType); err != nil { - return errors.Wrap(err, "mdm: unmarshal request type") - } - c.RequestType = requestType.RequestType - - switch requestType.RequestType { - case "ProfileList", - "ProvisioningProfileList", - "CertificateList", - "SecurityInfo", - "RestartDevice", - "ShutDownDevice", - "StopMirroring", - "ClearRestrictionsPassword", - "UserList", - "LogOutUser", - "PlayLostModeSound", - "DisableLostMode", - "DeviceLocation", - "ManagedMediaList", - "DeviceConfigured", - "AvailableOSUpdates", - "NSExtensionMappings", - "OSUpdateStatus", - "EnableRemoteDesktop", - "DisableRemoteDesktop", - "ActivationLockBypassCode": - return nil - case "InstallProfile": - var payload InstallProfile - if err := unmarshal(&payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command plist", requestType.RequestType) - } - c.InstallProfile = &payload - return nil - case "RemoveProfile": - var payload RemoveProfile - if err := unmarshal(&payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command plist", requestType.RequestType) - } - c.RemoveProfile = &payload - return nil - case "InstallProvisioningProfile": - var payload InstallProvisioningProfile - if err := unmarshal(&payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command plist", requestType.RequestType) - } - c.InstallProvisioningProfile = &payload - return nil - case "RemoveProvisioningProfile": - var payload RemoveProvisioningProfile - if err := unmarshal(&payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command plist", requestType.RequestType) - } - c.RemoveProvisioningProfile = &payload - return nil - case "InstalledApplicationList": - var payload InstalledApplicationList - if err := unmarshal(&payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command plist", requestType.RequestType) - } - c.InstalledApplicationList = &payload - return nil - case "DeviceInformation": - var payload DeviceInformation - if err := unmarshal(&payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command plist", requestType.RequestType) - } - c.DeviceInformation = &payload - return nil - case "DeviceLock": - var payload DeviceLock - if err := unmarshal(&payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command plist", requestType.RequestType) - } - c.DeviceLock = &payload - return nil - case "ClearPasscode": - var payload ClearPasscode - if err := unmarshal(&payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command plist", requestType.RequestType) - } - c.ClearPasscode = &payload - return nil - case "EraseDevice": - var payload EraseDevice - if err := unmarshal(&payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command plist", requestType.RequestType) - } - c.EraseDevice = &payload - return nil - case "RequestMirroring": - var payload RequestMirroring - if err := unmarshal(&payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command plist", requestType.RequestType) - } - c.RequestMirroring = &payload - return nil - case "Restrictions": - var payload Restrictions - if err := unmarshal(&payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command plist", requestType.RequestType) - } - c.Restrictions = &payload - return nil - case "UnlockUserAccount": - var payload UnlockUserAccount - if err := unmarshal(&payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command plist", requestType.RequestType) - } - c.UnlockUserAccount = &payload - return nil - case "DeleteUser": - var payload DeleteUser - if err := unmarshal(&payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command plist", requestType.RequestType) - } - c.DeleteUser = &payload - return nil - case "EnableLostMode": - var payload EnableLostMode - if err := unmarshal(&payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command plist", requestType.RequestType) - } - c.EnableLostMode = &payload - return nil - case "InstallEnterpriseApplication": - var payload InstallEnterpriseApplication - if err := unmarshal(&payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command plist", requestType.RequestType) - } - c.InstallEnterpriseApplication = &payload - return nil - case "InstallApplication": - var payload InstallApplication - if err := unmarshal(&payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command plist", requestType.RequestType) - } - c.InstallApplication = &payload - return nil - case "AccountConfiguration": - var payload AccountConfiguration - if err := unmarshal(&payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command plist", requestType.RequestType) - } - c.AccountConfiguration = &payload - return nil - case "ApplyRedemptionCode": - var payload ApplyRedemptionCode - if err := unmarshal(&payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command plist", requestType.RequestType) - } - c.ApplyRedemptionCode = &payload - return nil - case "ManagedApplicationList": - var payload ManagedApplicationList - if err := unmarshal(&payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command plist", requestType.RequestType) - } - c.ManagedApplicationList = &payload - return nil - case "RemoveApplication": - var payload RemoveApplication - if err := unmarshal(&payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command plist", requestType.RequestType) - } - c.RemoveApplication = &payload - return nil - case "InviteToProgram": - var payload InviteToProgram - if err := unmarshal(&payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command plist", requestType.RequestType) - } - c.InviteToProgram = &payload - return nil - case "ValidateApplications": - var payload ValidateApplications - if err := unmarshal(&payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command plist", requestType.RequestType) - } - c.ValidateApplications = &payload - return nil - case "InstallMedia": - var payload InstallMedia - if err := unmarshal(&payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command plist", requestType.RequestType) - } - c.InstallMedia = &payload - return nil - case "RemoveMedia": - var payload RemoveMedia - if err := unmarshal(&payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command plist", requestType.RequestType) - } - c.RemoveMedia = &payload - return nil - case "Settings": - var payload Settings - if err := unmarshal(&payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command plist", requestType.RequestType) - } - c.Settings = &payload - return nil - case "ManagedApplicationConfiguration": - var payload ManagedApplicationConfiguration - if err := unmarshal(&payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command plist", requestType.RequestType) - } - c.ManagedApplicationConfiguration = &payload - return nil - case "ManagedApplicationAttributes": - var payload ManagedApplicationAttributes - if err := unmarshal(&payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command plist", requestType.RequestType) - } - c.ManagedApplicationAttributes = &payload - return nil - case "ManagedApplicationFeedback": - var payload ManagedApplicationFeedback - if err := unmarshal(&payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command plist", requestType.RequestType) - } - c.ManagedApplicationFeedback = &payload - return nil - case "SetFirmwarePassword": - var payload SetFirmwarePassword - if err := unmarshal(&payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command plist", requestType.RequestType) - } - c.SetFirmwarePassword = &payload - return nil - case "VerifyFirmwarePassword": - var payload VerifyFirmwarePassword - if err := unmarshal(&payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command plist", requestType.RequestType) - } - c.VerifyFirmwarePassword = &payload - return nil - case "SetAutoAdminPassword": - var payload SetAutoAdminPassword - if err := unmarshal(&payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command plist", requestType.RequestType) - } - c.SetAutoAdminPassword = &payload - return nil - case "ScheduleOSUpdate": - var payload ScheduleOSUpdate - if err := unmarshal(&payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command plist", requestType.RequestType) - } - c.ScheduleOSUpdate = &payload - return nil - case "ScheduleOSUpdateScan": - var payload ScheduleOSUpdateScan - if err := unmarshal(&payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command plist", requestType.RequestType) - } - c.ScheduleOSUpdateScan = &payload - return nil - case "ActiveNSExtensions": - var payload ActiveNSExtensions - if err := unmarshal(&payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command plist", requestType.RequestType) - } - c.ActiveNSExtensions = &payload - return nil - case "RotateFileVaultKey": - var payload RotateFileVaultKey - if err := unmarshal(&payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command plist", requestType.RequestType) - } - c.RotateFileVaultKey = &payload - return nil - case "SetBootstrapToken": - var payload SetBootstrapToken - if err := unmarshal(&payload); err != nil { - return errors.Wrapf(err, "mdm: unmarshal %s command plist", requestType.RequestType) - } - c.SetBootstrapToken = &payload - return nil - default: - return fmt.Errorf("mdm: unknown RequestType: %s", requestType.RequestType) - } -} diff --git a/mdm/mdm/unmarshal_proto.go b/mdm/mdm/unmarshal_proto.go deleted file mode 100644 index 98bd6e04..00000000 --- a/mdm/mdm/unmarshal_proto.go +++ /dev/null @@ -1,458 +0,0 @@ -package mdm - -import ( - "github.com/gogo/protobuf/proto" - "github.com/micromdm/micromdm/mdm/appmanifest" - "github.com/micromdm/micromdm/mdm/mdm/internal/mdmproto" -) - -func protoToCommand(pb *mdmproto.Command) *Command { - cmd := Command{ - RequestType: pb.RequestType, - } - switch pb.RequestType { - case "ProfileList", - "ProvisioningProfileList", - "CertificateList", - "SecurityInfo", - "RestartDevice", - "ShutDownDevice", - "StopMirroring", - "ClearRestrictionsPassword", - "UserList", - "LogOutUser", - "PlayLostModeSound", - "DisableLostMode", - "DeviceLocation", - "ManagedMediaList", - "DeviceConfigured", - "AvailableOSUpdates", - "NSExtensionMappings", - "OSUpdateStatus", - "EnableRemoteDesktop", - "DisableRemoteDesktop", - "ActivationLockBypassCode": - - case "InstallProfile": - cmd.InstallProfile = &InstallProfile{ - Payload: pb.GetInstallProfile().GetPayload(), - } - case "RemoveProfile": - cmd.RemoveProfile = &RemoveProfile{ - Identifier: pb.GetRemoveProfile().GetIdentifier(), - } - case "InstallProvisioningProfile": - cmd.InstallProvisioningProfile = &InstallProvisioningProfile{ - ProvisioningProfile: pb.GetInstallProvisioningProfile().GetProvisioningProfile(), - } - case "RemoveProvisioningProfile": - cmd.RemoveProvisioningProfile = &RemoveProvisioningProfile{ - UUID: pb.GetRemoveProfisioningProfile().GetUuid(), - } - case "InstalledApplicationList": - pbcmd := pb.GetInstalledApplicationList() - cmd.InstalledApplicationList = &InstalledApplicationList{ - Identifiers: pbcmd.GetIdentifiers(), - ManagedAppsOnly: pbcmd.GetManagedAppsOnly(), - } - case "DeviceInformation": - cmd.DeviceInformation = &DeviceInformation{ - Queries: pb.GetDeviceInformation().GetQueries(), - } - case "DeviceLock": - pbc := pb.GetDeviceLock() - cmd.DeviceLock = &DeviceLock{ - PIN: pbc.GetPin(), - Message: pbc.GetMessage(), - PhoneNumber: pbc.GetPhoneNumber(), - } - case "ClearPasscode": - pbc := pb.GetClearPasscode() - cmd.ClearPasscode = &ClearPasscode{ - UnlockToken: pbc.GetUnlockToken(), - } - case "EraseDevice": - pbc := pb.GetEraseDevice() - cmd.EraseDevice = &EraseDevice{ - PIN: pbc.GetPin(), - PreserveDataPlan: pbc.GetPreserveDataPlan(), - DisallowProximitySetup: pbc.GetDisallowProximitySetup(), - } - case "RequestMirroring": - pbc := pb.GetRequestMirroring() - cmd.RequestMirroring = &RequestMirroring{ - DestinationName: pbc.GetDestinationName(), - DestinationDeviceID: pbc.GetDestinationDeviceId(), - ScanTime: pbc.GetScanTime(), - Password: pbc.GetPassword(), - } - case "Restrictions": - pbc := pb.GetRestrictions() - cmd.Restrictions = &Restrictions{ - ProfileRestrictions: pbc.GetProfileRestrictions(), - } - case "UnlockUserAccount": - pbc := pb.GetUnlockUserAccount() - cmd.UnlockUserAccount = &UnlockUserAccount{ - UserName: pbc.GetUsername(), - } - case "DeleteUser": - pbc := pb.GetDeleteUser() - cmd.DeleteUser = &DeleteUser{ - UserName: pbc.GetUsername(), - ForceDeletion: pbc.GetForceDeletion(), - } - case "EnableLostMode": - pbc := pb.GetEnableLostMode() - cmd.EnableLostMode = &EnableLostMode{ - Message: pbc.GetMessage(), - PhoneNumber: pbc.GetPhoneNumber(), - Footnote: pbc.GetFootnote(), - } - case "InstallEnterpriseApplication": - pbc := pb.GetInstallEnterpriseApplication() - var manifest *appmanifest.Manifest - if pbManifest := pbc.GetManifest(); pbManifest != nil { - manifest = &(appmanifest.Manifest{}) - if pbManifestItems := pbManifest.GetManifestItems(); pbManifestItems != nil { - for _, pbManifestItem := range pbManifestItems { - var manifestItem appmanifest.Item - if pbAssets := pbManifestItem.GetAssets(); pbAssets != nil { - for _, pbAsset := range pbAssets { - asset := appmanifest.Asset{ - Kind: pbAsset.Kind, - MD5s: pbAsset.Md5S, - MD5Size: pbAsset.Md5Size, - URL: pbAsset.Url, - SHA256s: pbAsset.Sha256S, - SHA256Size: pbAsset.Sha256Size, - } - manifestItem.Assets = append(manifestItem.Assets, asset) - } - } - if pbMetadata := pbManifestItem.GetMetadata(); pbMetadata != nil { - manifestItem.Metadata = &(appmanifest.Metadata{ - Kind: pbMetadata.Kind, - SizeInBytes: pbMetadata.SizeInBytes, - Title: pbMetadata.Title, - Subtitle: pbMetadata.Subtitle, - BundleInfo: appmanifest.BundleInfo{ - BundleIdentifier: pbMetadata.BundleIdentifier, - BundleVersion: pbMetadata.BundleVersion, - }, - }) - if pbMetadataItems := pbMetadata.GetItems(); pbMetadataItems != nil { - for _, pbMetadataItem := range pbMetadataItems { - bundleInfo := appmanifest.BundleInfo{ - BundleIdentifier: pbMetadataItem.BundleIdentifier, - BundleVersion: pbMetadataItem.BundleVersion, - } - manifestItem.Metadata.Items = append(manifestItem.Metadata.Items, bundleInfo) - } - } - } - if len(manifestItem.Assets) > 0 || manifestItem.Metadata != nil { - manifest.ManifestItems = append(manifest.ManifestItems, manifestItem) - } - } - } - } - - cmd.InstallEnterpriseApplication = &InstallEnterpriseApplication{ - Manifest: manifest, - ManifestURL: nilIfEmptyString(pbc.GetManifestUrl()), - ManifestURLPinningCerts: pbc.GetManifestUrlPinningCerts(), - PinningRevocationCheckRequired: nilIfFalse(pbc.GetPinningRevocationCheckRequired()), - } - case "InstallApplication": - pbc := pb.GetInstallApplication() - var mgmt *int - mgmtFlags := nilIfZeroInt64(pbc.GetManagementFlags()) - if mgmtFlags != nil { - mgmti := int(*mgmtFlags) - mgmt = &mgmti - } - - var ( - options *InstallApplicationOptions - configuration *InstallApplicationConfiguration - attributes *InstallApplicationAttributes - ) - - pboptions := pbc.GetOptions() - if pboptions != nil { - options = &InstallApplicationOptions{ - PurchaseMethod: new(int64), - } - *options.PurchaseMethod = pboptions.GetPurchaseMethod() - } - - pbconfig := pbc.GetConfiguration() - if pbconfig != nil { - configuration = &InstallApplicationConfiguration{} - } - - pbattributes := pbc.GetAttributes() - if pbattributes != nil { - attributes = &InstallApplicationAttributes{} - } - - cmd.InstallApplication = &InstallApplication{ - ITunesStoreID: nilIfZeroInt64(pbc.GetItunesStoreId()), - Identifier: nilIfEmptyString(pbc.GetIdentifier()), - ManagementFlags: mgmt, - ChangeManagementState: nilIfEmptyString(pbc.GetChangeManagementState()), - ManifestURL: nilIfEmptyString(pbc.GetManifestUrl()), - Options: options, - Configuration: configuration, - Attributes: attributes, - } - case "AccountConfiguration": - pbc := pb.GetAccountConfiguration() - var autosetupadminaccounts []AdminAccount - for _, acct := range pbc.GetAutoSetupAdminAccounts() { - autosetupadminaccounts = append(autosetupadminaccounts, AdminAccount{ - ShortName: acct.GetShortName(), - FullName: acct.GetFullName(), - PasswordHash: acct.GetPasswordHash(), - Hidden: acct.GetHidden(), - }) - } - cmd.AccountConfiguration = &AccountConfiguration{ - SkipPrimarySetupAccountCreation: pbc.GetSkipPrimarySetupAccountCreation(), - SetPrimarySetupAccountAsRegularUser: pbc.GetSetPrimarySetupAccountAsRegularUser(), - DontAutoPopulatePrimaryAccountInfo: pbc.GetDontAutoPopulatePrimaryAccountInfo(), - LockPrimaryAccountInfo: pbc.GetLockPrimaryAccountInfo(), - PrimaryAccountFullName: pbc.GetPrimaryAccountFullName(), - PrimaryAccountUserName: pbc.GetPrimaryAccountUserName(), - AutoSetupAdminAccounts: autosetupadminaccounts, - } - case "ApplyRedemptionCode": - pbc := pb.GetApplyRedemptionCode() - cmd.ApplyRedemptionCode = &ApplyRedemptionCode{ - Identifier: pbc.GetIdentifier(), - RedemptionCode: pbc.GetRedemptionCode(), - } - case "ManagedApplicationList": - pbc := pb.GetManagedApplicationList() - cmd.ManagedApplicationList = &ManagedApplicationList{ - Identifiers: pbc.GetIdentifiers(), - } - case "RemoveApplication": - pbc := pb.GetRemoveApplication() - cmd.RemoveApplication = &RemoveApplication{ - Identifier: pbc.GetIdentifier(), - } - case "InviteToProgram": - pbc := pb.GetInviteToProgram() - cmd.InviteToProgram = &InviteToProgram{ - ProgramID: pbc.GetProgramId(), - InvitationURL: pbc.GetInvitationUrl(), - } - case "ValidateApplications": - pbc := pb.GetValidataApplications() - cmd.ValidateApplications = &ValidateApplications{ - Identifiers: pbc.GetIdentifiers(), - } - case "InstallMedia": - pbc := pb.GetInstallMedia() - cmd.InstallMedia = &InstallMedia{ - ITunesStoreID: nilIfZeroInt64(pbc.GetItunesStoreId()), - MediaType: pbc.GetMediaType(), - MediaURL: pbc.GetMediaUrl(), - } - case "RemoveMedia": - pbc := pb.GetRemoveMedia() - cmd.RemoveMedia = &RemoveMedia{ - ITunesStoreID: nilIfZeroInt64(pbc.GetItunesStoreId()), - MediaType: pbc.GetMediaType(), - PersistentID: pbc.GetPersistentId(), - } - case "Settings": - pbc := pb.GetSettings() - var settings []Setting - for _, s := range pbc.GetSettings() { - settings = append(settings, protoToSetting(s)) - } - cmd.Settings = &Settings{ - Settings: settings, - } - case "ManagedApplicationConfiguration": - pbc := pb.GetManagedApplicationConfiguration() - cmd.ManagedApplicationConfiguration = &ManagedApplicationConfiguration{ - Identifiers: pbc.GetIdentifiers(), - } - case "ManagedApplicationAttributes": - pbc := pb.GetManagedApplicationAttributes() - cmd.ManagedApplicationAttributes = &ManagedApplicationAttributes{ - Identifiers: pbc.GetIdentifiers(), - } - case "ManagedApplicationFeedback": - pbc := pb.GetManagedApplicationFeedback() - cmd.ManagedApplicationFeedback = &ManagedApplicationFeedback{ - Identifiers: pbc.GetIdentifiers(), - DeleteFeedback: pbc.GetDeleteFeedback(), - } - case "SetFirmwarePassword": - pbc := pb.GetSetFirmwarePassword() - cmd.SetFirmwarePassword = &SetFirmwarePassword{ - CurrentPassword: pbc.GetCurrentPassword(), - NewPassword: pbc.GetNewPassword(), - AllowOroms: pbc.GetAllowOroms(), - } - case "SetBootstrapToken": - pbc := pb.GetSetBootstrapToken() - cmd.SetBootstrapToken = &SetBootstrapToken{ - BootstrapToken: pbc.GetBootstrapToken(), - } - case "VerifyFirmwarePassword": - pbc := pb.GetVerifyFirmwarePassword() - cmd.VerifyFirmwarePassword = &VerifyFirmwarePassword{ - Password: pbc.GetPassword(), - } - case "SetAutoAdminPassword": - pbc := pb.GetSetAutoAdminPassword() - cmd.SetAutoAdminPassword = &SetAutoAdminPassword{ - GUID: pbc.GetGuid(), - PasswordHash: pbc.GetPasswordHash(), - } - case "ScheduleOSUpdate": - pbc := pb.GetScheduleOsUpdate() - var updates []OSUpdate - for _, up := range pbc.GetUpdates() { - updates = append(updates, OSUpdate{ - ProductKey: up.GetProductKey(), - InstallAction: up.GetInstallAction(), - }) - } - cmd.ScheduleOSUpdate = &ScheduleOSUpdate{ - Updates: updates, - } - case "ScheduleOSUpdateScan": - pbc := pb.GetScheduleOsUpdateScan() - cmd.ScheduleOSUpdateScan = &ScheduleOSUpdateScan{ - Force: pbc.GetForce(), - } - case "ActiveNSExtensions": - pbc := pb.GetActiveNsExtensions() - cmd.ActiveNSExtensions = &ActiveNSExtensions{ - FilterExtensionPoints: pbc.GetFilterExtensionPoints(), - } - case "RotateFileVaultKey": - pbc := pb.GetRotateFilevaultKey() - fvunlock := pbc.GetFilevaultUnlock() - cmd.RotateFileVaultKey = &RotateFileVaultKey{ - KeyType: pbc.GetKeyType(), - NewCertificate: pbc.GetNewCertificate(), - ReplyEncryptionCertificate: pbc.GetReplyEncryptionCertificate(), - FileVaultUnlock: FileVaultUnlock{ - Password: fvunlock.GetPassword(), - PrivateKeyExport: fvunlock.GetPrivateKeyExport(), - PrivateKeyExportPassword: fvunlock.GetPrivateKeyExportPassword(), - }, - } - - } - return &cmd -} - -func protoToSetting(s *mdmproto.Setting) Setting { - setting := Setting{ - Item: s.GetItem(), - } - switch s.Item { - case "ApplicationConfiguration": - pbs := s.GetApplicationConfiguration() - setting.Identifier = nilIfEmptyString(pbs.GetIdentifier()) - setting.ConfigurationData = pbs.GetConfigurationDictionaryData() - case "VoiceRoaming": - pbs := s.GetVoiceRoaming() - setting.Enabled = nilIfFalse(pbs.GetEnabled()) - case "PersonalHotspot": - pbs := s.GetPersonalHotspot() - setting.Enabled = nilIfFalse(pbs.GetEnabled()) - case "Wallpaper": - pbs := s.GetWallpaper() - setting.Image = pbs.GetImage() - setting.Where = nilIfZeroInt(int(pbs.GetWhere())) - case "DataRoaming": - pbs := s.GetDataRoaming() - setting.Enabled = nilIfFalse(pbs.GetEnabled()) - case "Bluetooth": - pbs := s.GetBluetooth() - setting.Enabled = nilIfFalse(pbs.GetEnabled()) - case "ApplicationAttributes": - pbs := s.GetApplicationAttributes() - attr := pbs.GetApplicationAttributes() - vpnUUID := attr.GetVpnUuid() - if vpnUUID != "" { - setting.Attributes = map[string]string{"VPNUUID": vpnUUID} - } - setting.Identifier = nilIfEmptyString(pbs.GetIdentifier()) - case "DeviceName": - pbs := s.GetDeviceName() - setting.DeviceName = nilIfEmptyString(pbs.GetDeviceName()) - case "HostName": - pbs := s.GetHostname() - setting.HostName = nilIfEmptyString(pbs.GetHostname()) - case "MDMOptions": - pbs := s.GetMdmOptions() - activationLockAllowed := pbs.GetMdmOptions().GetActivationLockAllowedWhileSupervised() - setting.MDMOptions = map[string]interface { - }{ - "ActivationLockAllowedWhileSupervised": activationLockAllowed, - } - case "PasscodeLockGracePeriod": - pbs := s.GetPasscodeLockGracePeriod() - setting.PasscodeLockGracePeriod = nilIfZeroInt(int(pbs.GetPasscodeLockGracePeriod())) - case "MaximumResidentUsers": - pbs := s.GetMaximumResidentUsers() - setting.MaximumResidentUsers = nilIfZeroInt(int(pbs.GetMaximumResidentUsers())) - case "DiagnosticSubmission": - pbs := s.GetDiagnosticSubmission() - setting.Enabled = nilIfFalse(pbs.GetEnabled()) - case "AppAnalytics": - pbs := s.GetAppAnalytics() - setting.Enabled = nilIfFalse(pbs.GetEnabled()) - } - return setting -} - -func UnmarshalCommandPayload(data []byte, payload *CommandPayload) error { - var pb mdmproto.CommandPayload - if err := proto.Unmarshal(data, &pb); err != nil { - return err - } - payload.CommandUUID = pb.CommandUuid - payload.Command = protoToCommand(pb.Command) - return nil -} - -func nilIfZeroInt64(n int64) *int64 { - if n == 0 { - return nil - } - return &n -} - -func nilIfZeroInt(n int) *int { - if n == 0 { - return nil - } - return &n -} - -func nilIfEmptyString(s string) *string { - if s == "" { - return nil - } - return &s -} - -func nilIfFalse(b bool) *bool { - if !b { - return nil - - } - return &b -} diff --git a/mdm/server.go b/mdm/server.go deleted file mode 100644 index f19c75e0..00000000 --- a/mdm/server.go +++ /dev/null @@ -1,179 +0,0 @@ -package mdm - -import ( - "bytes" - "context" - "crypto/x509" - "encoding/base64" - "io/ioutil" - "net/http" - - "github.com/fullsailor/pkcs7" - "github.com/go-kit/kit/endpoint" - "github.com/go-kit/kit/log" - httptransport "github.com/go-kit/kit/transport/http" - "github.com/gorilla/mux" - "github.com/groob/plist" - "github.com/pkg/errors" -) - -type Endpoints struct { - CheckinEndpoint endpoint.Endpoint - AcknowledgeEndpoint endpoint.Endpoint -} - -func MakeServerEndpoints(s Service) Endpoints { - return Endpoints{ - CheckinEndpoint: MakeCheckinEndpoint(s), - AcknowledgeEndpoint: MakeAcknowledgeEndpoint(s), - } -} - -func RegisterHTTPHandlers(r *mux.Router, e Endpoints, logger log.Logger) { - options := []httptransport.ServerOption{ - httptransport.ServerErrorEncoder(encodeError), - httptransport.ServerErrorLogger(logger), - httptransport.ServerBefore(httptransport.PopulateRequestContext), - httptransport.ServerBefore(populateDeviceCertificateFromSignRequestHeader), - } - - r.Methods(http.MethodPut).Path("/mdm/checkin").Handler(httptransport.NewServer( - e.CheckinEndpoint, - decodeCheckinRequest, - encodeResponse, - options..., - )) - - r.Methods(http.MethodPut).Path("/mdm/connect").Handler(httptransport.NewServer( - e.AcknowledgeEndpoint, - decodeAcknowledgeRequest, - encodeResponse, - options..., - )) -} - -type contextKey int - -const ( - ContextKeyDeviceCertificate contextKey = iota - ContextKeyDeviceCertificateVerifyError -) - -func DeviceCertificateFromContext(ctx context.Context) (*x509.Certificate, error) { - cert := ctx.Value(ContextKeyDeviceCertificate).(*x509.Certificate) - err, _ := ctx.Value(ContextKeyDeviceCertificateVerifyError).(error) - return cert, err -} - -func populateDeviceCertificateFromSignRequestHeader(ctx context.Context, r *http.Request) context.Context { - bodyReader := r.Body - defer bodyReader.Close() - - // We can't gracefully bubble up errors from this function, - // so we silently disregard them (terrible) - body, _ := ioutil.ReadAll(r.Body) - - // Replace our body object with a fully buffered response - r.Body = ioutil.NopCloser(bytes.NewBuffer(body)) - - cert, err := verifySignature(r.Header.Get("Mdm-Signature"), body) - ctx = context.WithValue(ctx, ContextKeyDeviceCertificate, cert) - ctx = context.WithValue(ctx, ContextKeyDeviceCertificateVerifyError, err) - - return ctx -} - -// TODO: If we ever use Go client cert auth we can use -// r.TLS.PeerCertificates to return the client cert. Unnecessary -// now as default config is uses Mdm-Signature header method instead -// (for better compatilibity with proxies, etc.) -// func populateDeviceCertificateFromTLSPeerCertificates() - -// Extract (raw) body bytes, parse property list -func mdmRequestBody(r *http.Request, s interface{}) ([]byte, error) { - defer r.Body.Close() - - body, err := ioutil.ReadAll(r.Body) - if err != nil { - return nil, errors.Wrap(err, "reading MDM acknowledge HTTP body") - } - - err = plist.Unmarshal(body, s) - if err != nil { - return body, errors.Wrap(err, "unmarshal MDM acknowledge plist") - } - - return body, nil -} - -// Verify MDM header signature. Note: does NOT verify device certificate -func verifySignature(header string, body []byte) (*x509.Certificate, error) { - if header == "" { - return nil, errors.New("signature missing") - } - sig, err := base64.StdEncoding.DecodeString(header) - if err != nil { - return nil, errors.Wrap(err, "decode MDM SignMessage header") - } - p7, err := pkcs7.Parse(sig) - if err != nil { - return nil, errors.Wrap(err, "CMS parse decoded MDM SignMessage signature") - } - p7.Content = body - if err := p7.Verify(); err != nil { - return nil, errors.Wrap(err, "CMS verify MDM Signed Message") - } - cert := p7.GetOnlySigner() - if cert == nil { - return nil, errors.New("invalid or missing CMS signer") - } - return cert, nil -} - -// According to the MDM Check-in protocol, the server must respond with 200 OK -// to successful Check-in requests. -func encodeResponse(ctx context.Context, w http.ResponseWriter, response interface{}) error { - type failer interface { - Failed() error - } - - if e, ok := response.(failer); ok && e.Failed() != nil { - encodeError(ctx, e.Failed(), w) - return nil - } - - w.WriteHeader(http.StatusOK) - - type payloader interface { - Response() []byte - } - - var err error - if r, ok := response.(payloader); ok { - _, err = w.Write(r.Response()) - } - return errors.Wrap(err, "write acknowledge response") -} - -func encodeError(ctx context.Context, err error, w http.ResponseWriter) { - err = errors.Cause(err) - type rejectUserAuthError interface { - error - UserAuthReject() bool - } - if e, ok := err.(rejectUserAuthError); ok && e.UserAuthReject() { - w.WriteHeader(http.StatusGone) - return - } - - type checkoutErr interface { - error - Checkout() bool - } - if e, ok := err.(checkoutErr); ok && e.Checkout() { - w.WriteHeader(http.StatusUnauthorized) - return - } - - w.WriteHeader(http.StatusInternalServerError) -} diff --git a/mdm/server_test.go b/mdm/server_test.go deleted file mode 100644 index 47e2c7d5..00000000 --- a/mdm/server_test.go +++ /dev/null @@ -1,56 +0,0 @@ -package mdm - -import ( - "bytes" - "context" - "crypto/x509" - "encoding/base64" - "net/http/httptest" - "testing" - - "github.com/fullsailor/pkcs7" - "github.com/micromdm/micromdm/pkg/crypto" -) - -// imitate a Mdm-Signature header -func mdmSignRequest(body []byte) (*x509.Certificate, string, error) { - key, cert, err := crypto.SimpleSelfSignedRSAKeypair("test", 365) - if err != nil { - return nil, "", err - } - - sd, err := pkcs7.NewSignedData(body) - if err != nil { - return nil, "", err - } - - sd.AddSigner(cert, key, pkcs7.SignerInfoConfig{}) - sd.Detach() - sig, err := sd.Finish() - if err != nil { - return nil, "", err - } - - return cert, base64.StdEncoding.EncodeToString(sig), nil -} - -func Test_mdmMdmSignatureHeader(t *testing.T) { - // test that url values from checkin and acknowledge requests are passed to the event. - req := httptest.NewRequest("GET", "/mdm/checkin", bytes.NewReader([]byte(sampleCheckinRequest))) - cert, b64sig, err := mdmSignRequest([]byte(sampleCheckinRequest)) - if err != nil { - t.Fatal(err) - } - req.Header.Set("Mdm-Signature", b64sig) - - ctx := context.Background() - ctx = populateDeviceCertificateFromSignRequestHeader(ctx, req) - - reqcert, err := DeviceCertificateFromContext(ctx) - if err != nil { - t.Fatal(err) - } - if 0 != bytes.Compare(cert.Raw, reqcert.Raw) { - t.Error("certificate mismatch") - } -} diff --git a/mdm/service.go b/mdm/service.go deleted file mode 100644 index d71fa3c5..00000000 --- a/mdm/service.go +++ /dev/null @@ -1,38 +0,0 @@ -package mdm - -import ( - "context" - - "github.com/micromdm/micromdm/platform/pubsub" -) - -type Service interface { - Checkin(ctx context.Context, event CheckinEvent) error - Acknowledge(ctx context.Context, event AcknowledgeEvent) (payload []byte, err error) -} - -type Middleware func(Service) Service - -const ( - ConnectTopic = "mdm.Connect" - AuthenticateTopic = "mdm.Authenticate" - TokenUpdateTopic = "mdm.TokenUpdate" - CheckoutTopic = "mdm.CheckOut" -) - -// Queue is an MDM Command Queue. -type Queue interface { - Next(context.Context, Response) ([]byte, error) -} - -type MDMService struct { - pub pubsub.Publisher - queue Queue -} - -func NewService(pub pubsub.Publisher, queue Queue) *MDMService { - return &MDMService{ - pub: pub, - queue: queue, - } -} diff --git a/pg/migrations/00001_tables.sql b/pg/migrations/00001_tables.sql deleted file mode 100644 index cf9d993d..00000000 --- a/pg/migrations/00001_tables.sql +++ /dev/null @@ -1,42 +0,0 @@ --- +goose Up -CREATE TABLE IF NOT EXISTS devices ( - uuid TEXT PRIMARY KEY, - udid TEXT DEFAULT '', - serial_number TEXT DEFAULT '', - os_version TEXT DEFAULT '', - build_version TEXT DEFAULT '', - product_name TEXT DEFAULT '', - imei TEXT DEFAULT '', - meid TEXT DEFAULT '', - push_magic TEXT DEFAULT '', - awaiting_configuration BOOLEAN DEFAULT false, - token TEXT DEFAULT '', - unlock_token TEXT DEFAULT '', - enrolled BOOLEAN DEFAULT false, - description TEXT DEFAULT '', - model TEXT DEFAULT '', - model_name TEXT DEFAULT '', - device_name TEXT DEFAULT '', - color TEXT DEFAULT '', - asset_tag TEXT DEFAULT '', - dep_profile_status TEXT DEFAULT '', - dep_profile_uuid TEXT DEFAULT '', - dep_profile_assign_time TIMESTAMP DEFAULT '1970-01-01 00:00:00', - dep_profile_push_time TIMESTAMP DEFAULT '1970-01-01 00:00:00', - dep_profile_assigned_date TIMESTAMP DEFAULT '1970-01-01 00:00:00', - dep_profile_assigned_by TEXT DEFAULT '', - last_seen TIMESTAMP DEFAULT '1970-01-01 00:00:00' -); - - -CREATE TABLE IF NOT EXISTS push_info ( - udid TEXT PRIMARY KEY, - token TEXT DEFAULT '', - push_magic TEXT DEFAULT '', - mdm_topic TEXT DEFAULT '' -); - - --- +goose Down -DROP TABLE IF EXISTS devices; -DROP TABLE IF EXISTS push_info; diff --git a/pkg/activationlock/activationlock.go b/pkg/activationlock/activationlock.go deleted file mode 100644 index 18c128ef..00000000 --- a/pkg/activationlock/activationlock.go +++ /dev/null @@ -1,107 +0,0 @@ -// Package activationlock supports Apple device activation locking and unlocking. -// https://developer.apple.com/documentation/devicemanagement/activation_lock_a_device -package activationlock - -import ( - "crypto/rand" - "crypto/sha256" - "encoding/hex" - "fmt" - "strings" - - "golang.org/x/crypto/pbkdf2" -) - -// The available character set for a bypass code string. -const charset = "0123456789ACDEFGHJKLMNPQRTUVWXYZ" - -var ( - // Positions to insert "-" in the bypass code string. - dashPositions = []int{5, 10, 14, 18, 22} - - // The salt for the hash is always the same. - salt = []uint8{0, 0, 0, 0} -) - -// BypassCode is the ActivationLock code. -type BypassCode struct { - Key [16]byte - - format string -} - -// Create generates a usable bypass code. -func Create(key []byte) (BypassCode, error) { - var code BypassCode - - if key == nil { - key = make([]byte, 16) - if _, err := rand.Read(key); err != nil { - return code, err - } - } - - copy(code.Key[:], key) - - // Format human readable version of key. - values, err := convertBits(key, 8, 5) - if err != nil { - return code, err - } - - dashIdx := 0 - var str strings.Builder - for i, p := range values { - if dashIdx < len(dashPositions) && i == dashPositions[dashIdx] { - str.WriteString("-") - dashIdx++ - } - str.WriteByte(charset[p]) - } - code.format = str.String() - - return code, nil -} - -// Hash returns a PBKKDF2 derived hash of the bypass code. -// The hex encoded string is sent to Apple to lock a device. -func (c BypassCode) Hash() string { - return hex.EncodeToString(pbkdf2.Key(c.Key[:], salt, 50000, sha256.Size, sha256.New)) -} - -// String returns the bypass code in human readable format. -func (c BypassCode) String() string { - return c.format -} - -// convert binary data from one bits-per-byte arrangement to another. -// Ex: re-arrange 8 bit bytes to groups of 5 when converting to base32. -// This is a modified helper from a Go implementation of the bech32 format. -// https://github.com/FiloSottile/age/blob/c9a35c072716b5ac6cd815366999c9e189b0c317/internal/bech32/bech32.go#L79-L105 -func convertBits(data []byte, frombits, tobits byte) ([]byte, error) { - var ret []byte - acc := uint32(0) - bits := byte(0) - maxv := byte(1<>frombits != 0 { - return nil, fmt.Errorf("invalid data range: data[%d]=%d (frombits=%d)", idx, value, frombits) - } - acc = acc<= tobits { - bits -= tobits - ret = append(ret, byte(acc>>bits)&maxv) - } - } - - // zero out most significant bits of the last value, until we get to remaining bits - if bits > 0 { - for bit := frombits; bit >= bits; bit-- { - acc = acc &^ (1 << bit) - } - ret = append(ret, byte(acc)&maxv) - } - - return ret, nil -} diff --git a/pkg/activationlock/activationlock_test.go b/pkg/activationlock/activationlock_test.go deleted file mode 100644 index a940faba..00000000 --- a/pkg/activationlock/activationlock_test.go +++ /dev/null @@ -1,51 +0,0 @@ -package activationlock - -import ( - "encoding/hex" - "testing" -) - -func TestBypassCode(t *testing.T) { - tests := []struct { - key string - humanReadable string - hash string - }{ - { - key: "1ea841db5edfafe6075b5ae0d845d254", - humanReadable: "3UM43-PUYVY-QYD1-UVCC-HEHJ-FKA4", - hash: "6ab40d5eabe7218ec04182f461005600c7e3426bddd82cdb405bde9a1e0014b5", - }, - { - key: "44ebe63375969fec2da67e87e7317946", - humanReadable: "8LNYD-DVNKU-GYRC-E6GU-3YFD-CT86", - hash: "c1968cb4c013ea893f1922bb5c39f81e35012c0bd9ce3c01cc2a05873a2499e6", - }, - { - key: "cb84798c3ca85a674194550a2e96aed8", - humanReadable: "TF27L-31WN1-E6FH-DMAM-52X5-NFV0", - hash: "23cf8b7873425fd8efe31dc5b6ab9c357eb98a2a59c82ea1084ca8af58cc480a", - }, - } - - for _, tt := range tests { - tt := tt - t.Run(tt.key, func(t *testing.T) { - t.Parallel() - - key, _ := hex.DecodeString(tt.key) - code, err := Create(key) - if err != nil { - t.Fatal(err) - } - - if got, want := code.Hash(), tt.hash; got != want { - t.Errorf("Hash(): got %q, want %q", got, want) - } - - if got, want := code.String(), tt.humanReadable; got != want { - t.Errorf("Human Readable String: got %q, want %q", got, want) - } - }) - } -} diff --git a/pkg/crypto/apple.go b/pkg/crypto/apple.go deleted file mode 100644 index c602728c..00000000 --- a/pkg/crypto/apple.go +++ /dev/null @@ -1,109 +0,0 @@ -package crypto - -import ( - "crypto/x509" - "encoding/pem" - "fmt" -) - -/* -These certificates are not currently used but they represent the chain -of certificates to verify a device's certificate in DEP & OTA requests. - -const appleRootCAPEM = `-----BEGIN CERTIFICATE----- -MIIEuzCCA6OgAwIBAgIBAjANBgkqhkiG9w0BAQUFADBiMQswCQYDVQQGEwJVUzET -MBEGA1UEChMKQXBwbGUgSW5jLjEmMCQGA1UECxMdQXBwbGUgQ2VydGlmaWNhdGlv -biBBdXRob3JpdHkxFjAUBgNVBAMTDUFwcGxlIFJvb3QgQ0EwHhcNMDYwNDI1MjE0 -MDM2WhcNMzUwMjA5MjE0MDM2WjBiMQswCQYDVQQGEwJVUzETMBEGA1UEChMKQXBw -bGUgSW5jLjEmMCQGA1UECxMdQXBwbGUgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkx -FjAUBgNVBAMTDUFwcGxlIFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw -ggEKAoIBAQDkkakJH5HbHkdQ6wXtXnmELes2oldMVeyLGYne+Uts9QerIjAC6Bg+ -+FAJ039BqJj50cpmnCRrEdCju+QbKsMflZ56DKRHi1vUFjczy8QPTc4UadHJGXL1 -XQ7Vf1+b8iUDulWPTV0N8WQ1IxVLFVkds5T39pyez1C6wVhQZ48ItCD3y6wsIG9w -tj8BMIy3Q88PnT3zK0koGsj+zrW5DtleHNbLPbU6rfQPDgCSC7EhFi501TwN22IW -q6NxkkdTVcGvL0Gz+PvjcM3mo0xFfh9Ma1CWQYnEdGILEINBhzOKgbEwWOxaBDKM -aLOPHd5lc/9nXmW8Sdh2nzMUZaF3lMktAgMBAAGjggF6MIIBdjAOBgNVHQ8BAf8E -BAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUK9BpR5R2Cf70a40uQKb3 -R01/CF4wHwYDVR0jBBgwFoAUK9BpR5R2Cf70a40uQKb3R01/CF4wggERBgNVHSAE -ggEIMIIBBDCCAQAGCSqGSIb3Y2QFATCB8jAqBggrBgEFBQcCARYeaHR0cHM6Ly93 -d3cuYXBwbGUuY29tL2FwcGxlY2EvMIHDBggrBgEFBQcCAjCBthqBs1JlbGlhbmNl -IG9uIHRoaXMgY2VydGlmaWNhdGUgYnkgYW55IHBhcnR5IGFzc3VtZXMgYWNjZXB0 -YW5jZSBvZiB0aGUgdGhlbiBhcHBsaWNhYmxlIHN0YW5kYXJkIHRlcm1zIGFuZCBj -b25kaXRpb25zIG9mIHVzZSwgY2VydGlmaWNhdGUgcG9saWN5IGFuZCBjZXJ0aWZp -Y2F0aW9uIHByYWN0aWNlIHN0YXRlbWVudHMuMA0GCSqGSIb3DQEBBQUAA4IBAQBc -NplMLXi37Yyb3PN3m/J20ncwT8EfhYOFG5k9RzfyqZtAjizUsZAS2L70c5vu0mQP -y3lPNNiiPvl4/2vIB+x9OYOLUyDTOMSxv5pPCmv/K/xZpwUJfBdAVhEedNO3iyM7 -R6PVbyTi69G3cN8PReEnyvFteO3ntRcXqNx+IjXKJdXZD9Zr1KIkIxH3oayPc4Fg -xhtbCS+SsvhESPBgOJ4V9T0mZyCKM2r3DYLP3uujL/lTaltkwGMzd/c6ByxW69oP -IQ7aunMZT7XZNn/Bh1XZp5m5MkL72NVxnn6hUrcbvZNCJBIqxw8dtk2cXmPIS4AX -UKqK1drk/NAJBzewdXUh ------END CERTIFICATE----- -` - -const appleiPhoneCertificateAuthorityPEM = `-----BEGIN CERTIFICATE----- -MIID8zCCAtugAwIBAgIBFzANBgkqhkiG9w0BAQUFADBiMQswCQYDVQQGEwJVUzET -MBEGA1UEChMKQXBwbGUgSW5jLjEmMCQGA1UECxMdQXBwbGUgQ2VydGlmaWNhdGlv -biBBdXRob3JpdHkxFjAUBgNVBAMTDUFwcGxlIFJvb3QgQ0EwHhcNMDcwNDEyMTc0 -MzI4WhcNMjIwNDEyMTc0MzI4WjB5MQswCQYDVQQGEwJVUzETMBEGA1UEChMKQXBw -bGUgSW5jLjEmMCQGA1UECxMdQXBwbGUgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkx -LTArBgNVBAMTJEFwcGxlIGlQaG9uZSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCC -ASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKMevvBHwLSeEFtGpLghuE+G -IXAoRWBcHMPICmRjiPv8ae74VPzpW7cGTgQvw2szr0RM6kuACbSH9lu0/WTds3Lg -E7P9F9m856jtwoxhwir57M6lXtZp62QLjQiPuKBQRgncGeTlsJRtu/eZmMTom0FO -1PFl4xtSetzoA9luHdoQVYakKVhJDOpH1xU0M/bAoERKcL4stSowN4wuFevR5GyX -OFVWsTUrWOpEoyaF7shmSuTPifA9Y60p3q26WrPcpaOapwlOgBY1ZaSFDWN7PmOK -2n1KRuyjORg0ucYoZRi8E2Ccf1esFMmJ7aG2h2hStoROuMiD7PmeGauzwQuGx58C -AwEAAaOBnDCBmTAOBgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAdBgNV -HQ4EFgQU5zQqLiLeOWBrtJTOd4NhLzGgfDUwHwYDVR0jBBgwFoAUK9BpR5R2Cf70 -a40uQKb3R01/CF4wNgYDVR0fBC8wLTAroCmgJ4YlaHR0cDovL3d3dy5hcHBsZS5j -b20vYXBwbGVjYS9yb290LmNybDANBgkqhkiG9w0BAQUFAAOCAQEAHdHVe910TtcX -/IItDJmbXkJy8mnc1WteDQxrSz57FCXes5TooPoPgInyFz0AAqKRkb50V9yvmp+h -Cn0wvgAqzCFZ6/1JrG51GeiaegPRhvbn9rAOS0n6o7dButfR41ahfYOrl674UUom -wYVCEyaNA1RmEF5ghAUSMStrVMCgyEG8VB7nVK0TANJKx7vBiq+BCI7wRgq/J6a+ -3M85OoBwGSMyo2tmXZ5NqEdJsntFtVEzp3RnCU62bG9I9yy5MwVEa0W+dEtvsoaR -tD4lKCWes8JRhvxP5a87qrtELAFJ4nSzNPpE7xTCEfItGRpRidMISkFsWFbemzrh -BVflYs/SDw== ------END CERTIFICATE----- -` -*/ - -// TODO: This certificate expired 2014, but is required. -const appleiPhoneDeviceCAPEM = `-----BEGIN CERTIFICATE----- -MIIDaTCCAlGgAwIBAgIBATANBgkqhkiG9w0BAQUFADB5MQswCQYDVQQGEwJVUzET -MBEGA1UEChMKQXBwbGUgSW5jLjEmMCQGA1UECxMdQXBwbGUgQ2VydGlmaWNhdGlv -biBBdXRob3JpdHkxLTArBgNVBAMTJEFwcGxlIGlQaG9uZSBDZXJ0aWZpY2F0aW9u -IEF1dGhvcml0eTAeFw0wNzA0MTYyMjU0NDZaFw0xNDA0MTYyMjU0NDZaMFoxCzAJ -BgNVBAYTAlVTMRMwEQYDVQQKEwpBcHBsZSBJbmMuMRUwEwYDVQQLEwxBcHBsZSBp -UGhvbmUxHzAdBgNVBAMTFkFwcGxlIGlQaG9uZSBEZXZpY2UgQ0EwgZ8wDQYJKoZI -hvcNAQEBBQADgY0AMIGJAoGBAPGUSsnquloYYK3Lok1NTlQZaRdZB2bLl+hmmkdf -Rq5nerVKc1SxywT2vTa4DFU4ioSDMVJl+TPhl3ecK0wmsCU/6TKqewh0lOzBSzgd -Z04IUpRai1mjXNeT9KD+VYW7TEaXXm6yd0UvZ1y8Cxi/WblshvcqdXbSGXH0KWO5 -JQuvAgMBAAGjgZ4wgZswDgYDVR0PAQH/BAQDAgGGMA8GA1UdEwEB/wQFMAMBAf8w -HQYDVR0OBBYEFLL+ISNEhpVqedWBJo5zENinTI50MB8GA1UdIwQYMBaAFOc0Ki4i -3jlga7SUzneDYS8xoHw1MDgGA1UdHwQxMC8wLaAroCmGJ2h0dHA6Ly93d3cuYXBw -bGUuY29tL2FwcGxlY2EvaXBob25lLmNybDANBgkqhkiG9w0BAQUFAAOCAQEAd13P -Z3pMViukVHe9WUg8Hum+0I/0kHKvjhwVd/IMwGlXyU7DhUYWdja2X/zqj7W24Aq5 -7dEKm3fqqxK5XCFVGY5HI0cRsdENyTP7lxSiiTRYj2mlPedheCn+k6T5y0U4Xr40 -FXwWb2nWqCF1AgIudhgvVbxlvqcxUm8Zz7yDeJ0JFovXQhyO5fLUHRLCQFssAbf8 -B4i8rYYsBUhYTspVJcxVpIIltkYpdIRSIARA49HNvKK4hzjzMS/OhKQpVKw+OCEZ -xptCVeN2pjbdt9uzi175oVo/u6B2ArKAW17u6XEHIdDMOe7cb33peVI6TD15W4MI -pyQPbp8orlXe+tA8JA== ------END CERTIFICATE----- -` - -// VerifyFromAppleDeviceCA verifies a certificate was signed by Apple's iPhone Device CA. -// TODO: We want to have more intensive verification (like the whole provided chain). -// TODO: Implement some sort of cache so we don't need to parse PEM & DER every invocation. -func VerifyFromAppleDeviceCA(c *x509.Certificate) error { - block, _ := pem.Decode([]byte(appleiPhoneDeviceCAPEM)) - if block == nil || block.Type != "CERTIFICATE" { - panic("appleiPhoneDeviceCAPEM: invalid PEM block") - } - parent, err := x509.ParseCertificate(block.Bytes) - if err != nil { - panic(fmt.Sprintf("appleiPhoneDeviceCAPEM: err parsing: %s", err)) - } - // Note we CheckSignatureFrom() as we cannot Verify the certificate chain - // (known expired intermediate) - return c.CheckSignatureFrom(parent) -} diff --git a/pkg/crypto/helpers.go b/pkg/crypto/helpers.go deleted file mode 100644 index 02978186..00000000 --- a/pkg/crypto/helpers.go +++ /dev/null @@ -1,194 +0,0 @@ -package crypto - -import ( - "crypto/rand" - "crypto/rsa" - "crypto/x509" - "crypto/x509/pkix" - "encoding/asn1" - "encoding/pem" - "errors" - "fmt" - "io/ioutil" - "math/big" - "os" - "strings" - "time" -) - -func GenerateRandomCertificateSerialNumber() (*big.Int, error) { - limit := new(big.Int).Lsh(big.NewInt(1), 128) - return rand.Int(rand.Reader, limit) -} - -func SimpleSelfSignedRSAKeypair(cn string, days int) (key *rsa.PrivateKey, cert *x509.Certificate, err error) { - key, err = rsa.GenerateKey(rand.Reader, 2048) - if err != nil { - return key, cert, err - } - - serialNumber, err := GenerateRandomCertificateSerialNumber() - if err != nil { - return key, cert, err - } - timeNow := time.Now() - template := x509.Certificate{ - SerialNumber: serialNumber, - Subject: pkix.Name{ - CommonName: cn, - }, - NotBefore: timeNow, - NotAfter: timeNow.Add(time.Duration(days) * 24 * time.Hour), - KeyUsage: x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature, - ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth}, - BasicConstraintsValid: true, - DNSNames: []string{cn}, - } - certBytes, err := x509.CreateCertificate(rand.Reader, &template, &template, &key.PublicKey, key) - if err != nil { - return key, cert, err - } - cert, err = x509.ParseCertificate(certBytes) - if err != nil { - return key, cert, err - } - - return key, cert, err -} - -func ReadPEMCertificateFile(path string) (*x509.Certificate, error) { - certs, err := ReadPEMCertificatesFile(path) - if err != nil { - return nil, err - } - if len(certs) != 1 { - return nil, errors.New("incorrect number of certificates") - } - return certs[0], nil -} - -const ( - rsaPrivateKeyPEMBlockType = "RSA PRIVATE KEY" - certificatePEMBlockType = "CERTIFICATE" -) - -func ReadPEMCertificatesFile(path string) ([]*x509.Certificate, error) { - pemData, err := ioutil.ReadFile(path) - if err != nil { - return nil, err - } - var asn1data []byte - rest := pemData - for { - var block *pem.Block - block, rest = pem.Decode(rest) - if block == nil || block.Type != certificatePEMBlockType { - return nil, errors.New("failed to decode PEM block containing certificate") - } - asn1data = append(asn1data, block.Bytes...) - if len(rest) == 0 { - break - } - } - return x509.ParseCertificates(asn1data) -} - -func ReadPEMRSAKeyFile(path string) (*rsa.PrivateKey, error) { - return ReadEncryptedPEMRSAKeyFile(path, nil) -} - -func ReadEncryptedPEMRSAKeyFile(path string, password []byte) (*rsa.PrivateKey, error) { - pemData, err := ioutil.ReadFile(path) - if err != nil { - return nil, err - } - - pemBlock, _ := pem.Decode(pemData) - if pemBlock == nil { - return nil, errors.New("PEM decode failed") - } - if pemBlock.Type != rsaPrivateKeyPEMBlockType { - return nil, fmt.Errorf("expecting PEM type of %s, but got %s", rsaPrivateKeyPEMBlockType, pemBlock.Type) - } - - if x509.IsEncryptedPEMBlock(pemBlock) { - if password == nil { - return nil, errors.New("no supplied password for encrypted PEM") - } - derBytes, err := x509.DecryptPEMBlock(pemBlock, password) - if err != nil { - return nil, err - } - return x509.ParsePKCS1PrivateKey(derBytes) - } else if password != nil { - return nil, errors.New("supplied PEM password, but not encrypted") - } - - return x509.ParsePKCS1PrivateKey(pemBlock.Bytes) -} - -func WritePEMCertificateFile(cert *x509.Certificate, path string) error { - file, err := os.Create(path) - if err != nil { - return err - } - defer file.Close() - - return pem.Encode( - file, - &pem.Block{ - Type: certificatePEMBlockType, - Bytes: cert.Raw, - }) -} - -func WritePEMRSAKeyFile(key *rsa.PrivateKey, path string) error { - file, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0700) - if err != nil { - return err - } - defer file.Close() - - return pem.Encode( - file, - &pem.Block{ - Type: rsaPrivateKeyPEMBlockType, - Bytes: x509.MarshalPKCS1PrivateKey(key), - }) -} - -func WriteEncryptedPEMRSAKeyFile(key *rsa.PrivateKey, password []byte, path string) error { - file, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0700) - if err != nil { - return err - } - defer file.Close() - - encPemBlock, err := x509.EncryptPEMBlock( - rand.Reader, - rsaPrivateKeyPEMBlockType, - x509.MarshalPKCS1PrivateKey(key), - password, - x509.PEMCipher3DES) - if err != nil { - return err - } - - return pem.Encode(file, encPemBlock) -} - -// TopicFromCert extracts the push certificate topic from the provided certificate. -func TopicFromCert(cert *x509.Certificate) (string, error) { - var oidASN1UserID = asn1.ObjectIdentifier{0, 9, 2342, 19200300, 100, 1, 1} - for _, v := range cert.Subject.Names { - if v.Type.Equal(oidASN1UserID) { - uid, ok := v.Value.(string) - if ok && strings.HasPrefix(uid, "com.apple.mgmt") { - return uid, nil - } - return "", errors.New("invalid Push Topic (UserID OID) in certificate. Must start with 'com.apple.mgmt', was: " + uid) - } - } - - return "", errors.New("could not find Push Topic (UserID OID) in certificate") -} diff --git a/pkg/crypto/helpers_test.go b/pkg/crypto/helpers_test.go deleted file mode 100644 index f6f1348e..00000000 --- a/pkg/crypto/helpers_test.go +++ /dev/null @@ -1,29 +0,0 @@ -package crypto - -import ( - "testing" -) - -func TestTopicFromValidCert(t *testing.T) { - certificate, _ := ReadPEMCertificateFile("testdata/mock_push_cert.pem") - pushTopic, err := TopicFromCert(certificate) - if err != nil { - t.Fatalf("fail %s", err) - } - - if have, want := pushTopic, "com.apple.mgmt.External.18a16429-886b-41f1-9c30-2bd04ae4fc37"; have != want { - t.Errorf("have %s, want %s", have, want) - } -} - -func TestTopicFromInvalidCert(t *testing.T) { - certFileNames := []string{"mock_push_cert_wrong_uid_prefix.pem", "mock_push_cert_wrong_uid_prefix.pem"} - for _, certFileName := range certFileNames { - certificate, _ := ReadPEMCertificateFile("testdata/" + certFileName) - _, err := TopicFromCert(certificate) - - if err == nil { - t.Errorf("expected error for invalid push certificate") - } - } -} diff --git a/pkg/crypto/mdmcertutil/certutil.go b/pkg/crypto/mdmcertutil/certutil.go deleted file mode 100644 index 79c3180a..00000000 --- a/pkg/crypto/mdmcertutil/certutil.go +++ /dev/null @@ -1,285 +0,0 @@ -// Package mdmcertutil contains helpers for requesting MDM Push Certifificates. -// The process is described by Apple at -// https://developer.apple.com/library/content/documentation/Miscellaneous/Reference/MobileDeviceManagementProtocolRef/7-MDMVendorCSRSigningOverview/MDMVendorCSRSigningOverview.html#//apple_ref/doc/uid/TP40017387-CH6-SW4 -package mdmcertutil - -import ( - "crypto" - "crypto/rand" - "crypto/rsa" - "crypto/sha1" - "crypto/x509" - "crypto/x509/pkix" - "encoding/base64" - "encoding/pem" - "fmt" - "io/ioutil" - "net/http" - "strings" - - "github.com/groob/plist" - "github.com/pkg/errors" -) - -// CSRConfig defines arguments required to create a new CSR. -type CSRConfig struct { - CommonName, Country, Email string - PrivateKeyPassword []byte - PrivateKeyPath, CSRPath string -} - -// CreateCSR creates a new private key and CSR, saving both as PEM encoded files. -func CreateCSR(req *CSRConfig) error { - key, err := rsa.GenerateKey(rand.Reader, 2048) - if err != nil { - return err - } - pemKey, err := encryptedKey(key, req.PrivateKeyPassword) - if err != nil { - return err - } - - if err := ioutil.WriteFile(req.PrivateKeyPath, pemKey, 0600); err != nil { - return err - } - - derBytes, err := NewCSR(key, strings.ToLower(req.Email), strings.ToUpper(req.Country), req.CommonName) - if err != nil { - return err - } - pemCSR := PemCSR(derBytes) - return ioutil.WriteFile(req.CSRPath, pemCSR, 0600) -} - -// The PushCertificateRequest structure required by identity.apple.com -// to create an MDM Push certificate. -type PushCertificateRequest struct { - PushCertRequestCSR string - PushCertCertificateChain string - PushCertSignature string -} - -// Encode marshals a PushCertificateRequest to an XML Plist file and returns a base64 encoded byte representation -// of the request. -func (p *PushCertificateRequest) Encode() ([]byte, error) { - data, err := plist.MarshalIndent(p, " ") - if err != nil { - return nil, errors.Wrap(err, "marshal PushCertificateRequest") - } - encoded := make([]byte, base64.StdEncoding.EncodedLen(len(data))) - base64.StdEncoding.Encode(encoded, data) - return encoded, nil -} - -const ( - wwdrIntermediaryURL = "https://developer.apple.com/certificationauthority/AppleWWDRCA.cer" - appleRootCAURL = "http://www.apple.com/appleca/AppleIncRootCertificate.cer" -) - -// CreatePushCertificateRequest creates a request structure required by identity.apple.com. -// It requires a "MDM CSR" certificate (the vendor certificate), a push CSR (the customer specific CSR), -// and the vendor private key. -func CreatePushCertificateRequest(mdmCertPath, pushCSRPath, pKeyPath string, pKeyPass []byte) (*PushCertificateRequest, error) { - // private key of the mdm vendor cert - key, err := loadKeyFromFile(pKeyPath, pKeyPass) - if err != nil { - return nil, errors.Wrapf(err, "load private key from %s", pKeyPath) - } - - // push csr - csr, err := loadCSRfromFile(pushCSRPath) - if err != nil { - return nil, errors.Wrapf(err, "load push CSR from %s", pushCSRPath) - } - - // csr signature - signature, err := signPushCSR(csr.Raw, key) - if err != nil { - return nil, errors.Wrapf(err, "sign push CSR with private key") - } - - // vendor cert - mdmCertBytes, err := loadDERCertFromFile(mdmCertPath) - if err != nil { - return nil, errors.Wrapf(err, "load vendor certificate from path %s", mdmCertPath) - } - mdmPEM := pemCert(mdmCertBytes) - - // wwdr cert - wwdrCertBytes, err := loadCertfromHTTP(wwdrIntermediaryURL) - if err != nil { - return nil, errors.Wrapf(err, "load WWDR certificate from %s", wwdrIntermediaryURL) - } - wwdrPEM := pemCert(wwdrCertBytes) - - // apple root certificate - rootCertBytes, err := loadCertfromHTTP(appleRootCAURL) - if err != nil { - return nil, errors.Wrapf(err, "load root certificate from %s", appleRootCAURL) - } - rootPEM := pemCert(rootCertBytes) - - csrB64 := base64.StdEncoding.EncodeToString(csr.Raw) - sig64 := base64.StdEncoding.EncodeToString(signature) - pushReq := &PushCertificateRequest{ - PushCertRequestCSR: csrB64, - PushCertCertificateChain: makeCertChain(mdmPEM, wwdrPEM, rootPEM), - PushCertSignature: sig64, - } - return pushReq, nil -} - -func makeCertChain(mdmPEM, wwdrPEM, rootPEM []byte) string { - return string(mdmPEM) + string(wwdrPEM) + string(rootPEM) -} - -func signPushCSR(csrData []byte, key *rsa.PrivateKey) ([]byte, error) { - h := sha1.New() - h.Write(csrData) - signature, err := rsa.SignPKCS1v15(rand.Reader, key, crypto.SHA1, h.Sum(nil)) - return signature, errors.Wrap(err, "signing push CSR") -} - -const ( - csrPEMBlockType = "CERTIFICATE REQUEST" -) - -// create a CSR using the same parameters as Keychain Access would produce -func NewCSR(priv *rsa.PrivateKey, email, country, cname string) ([]byte, error) { - subj := pkix.Name{ - Country: []string{country}, - CommonName: cname, - ExtraNames: []pkix.AttributeTypeAndValue{{ - Type: []int{1, 2, 840, 113549, 1, 9, 1}, - Value: email, - }}, - } - template := &x509.CertificateRequest{ - Subject: subj, - } - return x509.CreateCertificateRequest(rand.Reader, template, priv) -} - -// convert DER to PEM format -func PemCSR(derBytes []byte) []byte { - pemBlock := &pem.Block{ - Type: csrPEMBlockType, - Headers: nil, - Bytes: derBytes, - } - out := pem.EncodeToMemory(pemBlock) - return out -} - -// load PEM encoded CSR from file -func loadCSRfromFile(path string) (*x509.CertificateRequest, error) { - data, err := ioutil.ReadFile(path) - if err != nil { - return nil, err - } - pemBlock, _ := pem.Decode(data) - if pemBlock == nil { - return nil, errors.New("cannot find the next PEM formatted block") - } - if pemBlock.Type != csrPEMBlockType || len(pemBlock.Headers) != 0 { - return nil, errors.New("unmatched type or headers") - } - return x509.ParseCertificateRequest(pemBlock.Bytes) -} - -const ( - rsaPrivateKeyPEMBlockType = "RSA PRIVATE KEY" -) - -// protect an rsa key with a password -func encryptedKey(key *rsa.PrivateKey, password []byte) ([]byte, error) { - privBytes := x509.MarshalPKCS1PrivateKey(key) - privPEMBlock, err := x509.EncryptPEMBlock(rand.Reader, rsaPrivateKeyPEMBlockType, privBytes, password, x509.PEMCipher3DES) - if err != nil { - return nil, err - } - - out := pem.EncodeToMemory(privPEMBlock) - return out, nil -} - -// load an encrypted private key from disk -func loadKeyFromFile(path string, password []byte) (*rsa.PrivateKey, error) { - data, err := ioutil.ReadFile(path) - if err != nil { - return nil, err - } - - pemBlock, _ := pem.Decode(data) - if pemBlock == nil { - return nil, errors.New("PEM decode failed") - } - if pemBlock.Type != rsaPrivateKeyPEMBlockType { - return nil, errors.New("unmatched type or headers") - } - - if string(password) != "" { - b, err := x509.DecryptPEMBlock(pemBlock, password) - if err != nil { - return nil, err - } - return x509.ParsePKCS1PrivateKey(b) - } - return x509.ParsePKCS1PrivateKey(pemBlock.Bytes) -} - -const ( - certificatePEMBlockType = "CERTIFICATE" -) - -func pemCert(derBytes []byte) []byte { - pemBlock := &pem.Block{ - Type: certificatePEMBlockType, - Headers: nil, - Bytes: derBytes, - } - out := pem.EncodeToMemory(pemBlock) - return out -} - -func loadDERCertFromFile(path string) ([]byte, error) { - data, err := ioutil.ReadFile(path) - if err != nil { - return nil, err - } - - crt, err := x509.ParseCertificate(data) - if err != nil { - return nil, err - } - return crt.Raw, nil -} - -func loadCertfromHTTP(url string) ([]byte, error) { - req, err := http.NewRequest("GET", url, nil) - if err != nil { - return nil, errors.Wrapf(err, "create GET request for %s", url) - } - req.Header.Set("Accept", "*/*") // required by Apple at some point. - - resp, err := http.DefaultClient.Do(req) - if err != nil { - return nil, errors.Wrapf(err, "GET request to %s", url) - } - defer resp.Body.Close() - - if resp.StatusCode != http.StatusOK { - return nil, fmt.Errorf("got %s when trying to http.Get %s", resp.Status, url) - } - - data, err := ioutil.ReadAll(resp.Body) - if err != nil { - return nil, errors.Wrap(err, "reading get certificate request response body") - } - - crt, err := x509.ParseCertificate(data) - if err != nil { - return nil, errors.Wrap(err, "parse wwdr intermediate certificate") - } - return crt.Raw, nil -} diff --git a/pkg/crypto/password/password.go b/pkg/crypto/password/password.go deleted file mode 100644 index d940efa8..00000000 --- a/pkg/crypto/password/password.go +++ /dev/null @@ -1,74 +0,0 @@ -// Package password provides utilities for creating and verifying macOS -// passwords for MDM account configuration. -package password - -import ( - "crypto/rand" - "crypto/sha512" - "crypto/subtle" - "errors" - "math/big" - - "golang.org/x/crypto/pbkdf2" -) - -// macKeyLen is the length of a PBKDF2 salt. -const macKeyLen = 128 - -// ErrNoMatch is returned by Verify if the password does not match. -var ErrNoMatch = errors.New("password does not match") - -// SaltedSha512PBKDF2Dictionary is a SHA512 PBKDF2 dictionary. -type SaltedSHA512PBKDF2Dictionary struct { - Iterations int `plist:"iterations"` - Salt []byte `plist:"salt"` - Entropy []byte `plist:"entropy"` -} - -// SaltedSHA512PBKDF2 creates a SALTED-SHA512-PBKDF2 dictionary -// from a plaintext password. The hash function will use a 128 bit -// salt. -func SaltedSHA512PBKDF2(plaintext string) (SaltedSHA512PBKDF2Dictionary, error) { - salt := make([]byte, 32) - _, err := rand.Read(salt) - if err != nil { - return SaltedSHA512PBKDF2Dictionary{}, err - } - iterations, err := secureRandInt(20000, 40000) - if err != nil { - return SaltedSHA512PBKDF2Dictionary{}, err - } - return SaltedSHA512PBKDF2Dictionary{ - Iterations: iterations, - Salt: salt, - Entropy: pbkdf2.Key([]byte(plaintext), - salt, iterations, macKeyLen, sha512.New), - }, nil -} - -// Verify verifies a plaintext password against a existing SALTED-SHA512-PBKDF2 -// password dictionary. -func Verify(plaintext string, h SaltedSHA512PBKDF2Dictionary) error { - hashed := pbkdf2.Key([]byte(plaintext), h.Salt, h.Iterations, macKeyLen, sha512.New) - if 1 != subtle.ConstantTimeCompare(h.Entropy, hashed) { - return ErrNoMatch - } - return nil -} - -// CCCalibratePBKDF uses a pseudorandom value returned within 100 milliseconds. -// Use a random int from crypto/rand between 20,000 and 40,000 instead. -func secureRandInt(min, max int64) (int, error) { - var random int - for { - iter, err := rand.Int(rand.Reader, big.NewInt(max)) - if err != nil { - return 0, err - } - if iter.Int64() >= min { - random = int(iter.Int64()) - break - } - } - return random, nil -} diff --git a/pkg/crypto/profileutil/sign.go b/pkg/crypto/profileutil/sign.go deleted file mode 100644 index d98467af..00000000 --- a/pkg/crypto/profileutil/sign.go +++ /dev/null @@ -1,25 +0,0 @@ -// Package profileutil signs configuration profiles. -package profileutil - -import ( - "crypto" - "crypto/x509" - - "github.com/fullsailor/pkcs7" - "github.com/pkg/errors" -) - -// Sign takes an unsigned payload and signs it with the provided private key and certificate. -func Sign(key crypto.PrivateKey, cert *x509.Certificate, mobileconfig []byte) ([]byte, error) { - sd, err := pkcs7.NewSignedData(mobileconfig) - if err != nil { - return nil, errors.Wrap(err, "create signed data for mobileconfig") - } - - if err := sd.AddSigner(cert, key, pkcs7.SignerInfoConfig{}); err != nil { - return nil, errors.Wrap(err, "add crypto signer to mobileconfig signed data") - } - - signedMobileconfig, err := sd.Finish() - return signedMobileconfig, errors.Wrap(err, "complete mobileconfig signing") -} diff --git a/pkg/crypto/testdata/create_mock_push_cert.sh b/pkg/crypto/testdata/create_mock_push_cert.sh deleted file mode 100755 index 934e17a4..00000000 --- a/pkg/crypto/testdata/create_mock_push_cert.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -openssl req -newkey rsa:2048 -nodes -keyout key.pem -x509 -days 18262 -out certificate.pem -subj "/UID=com.apple.mgmt.External.18a16429-886b-41f1-9c30-2bd04ae4fc37/CN=APSP:17a16429-886b-41f1-8c90-3bd02ae9fc57/C=US" diff --git a/pkg/crypto/testdata/mock_push_cert.pem b/pkg/crypto/testdata/mock_push_cert.pem deleted file mode 100644 index 54e9fe16..00000000 --- a/pkg/crypto/testdata/mock_push_cert.pem +++ /dev/null @@ -1,22 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDnjCCAoYCCQDH9mV3O1n7SzANBgkqhkiG9w0BAQsFADCBjzFMMEoGCgmSJomT -8ixkAQEMPGNvbS5hcHBsZS5tZ210LkV4dGVybmFsLjE4YTE2NDI5LTg4NmItNDFm -MS05YzMwLTJiZDA0YWU0ZmMzNzEyMDAGA1UEAwwpQVBTUDoxN2ExNjQyOS04ODZi -LTQxZjEtOGM5MC0zYmQwMmFlOWZjNTcxCzAJBgNVBAYTAlVTMCAXDTE4MDEyNTA4 -MzMyNVoYDzIwNjgwMTI1MDgzMzI1WjCBjzFMMEoGCgmSJomT8ixkAQEMPGNvbS5h -cHBsZS5tZ210LkV4dGVybmFsLjE4YTE2NDI5LTg4NmItNDFmMS05YzMwLTJiZDA0 -YWU0ZmMzNzEyMDAGA1UEAwwpQVBTUDoxN2ExNjQyOS04ODZiLTQxZjEtOGM5MC0z -YmQwMmFlOWZjNTcxCzAJBgNVBAYTAlVTMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A -MIIBCgKCAQEA5KOum54Ck9myiqS1bE4aVzO1fCV7jNOTRRXkLaG3+02hjFhrFdAa -SXzd5GDBIFzW309M4vcXFAftllrcopIuU8NblFv6/ckE6/E19kHGQqzNz6OcB+gW -XuuA4KxuczYGM8rWfLXDPUzN1lhuaidtjKBx6qVjwjnbLLnrjAGfBg5BMV+yLOiu -9zl7aKgYuKsYF6/rBxRFWvDSztWmnhNCR/ihyfKNGUI8DYGgShA5Lrz6zGExmcra -JVcAyKeTtE/QNLl/pzjhgbZOOyc+tZ2lek5JAZPYfOFMqVWLVF9YGEzX5fMUyskC -XHR39cMZE5vge7eUTkavaSXxNgcxWxlIywIDAQABMA0GCSqGSIb3DQEBCwUAA4IB -AQBNY2IL4rrc3C9g9JCSqtmlXhPsXSnW/kLuM+/8NYPxxprGDIUQ1jN4xppKuqZp -zLsudS46riabkaPzl01eyThjp/kW8It7cu3t9LVZx4RTp4wAl98Z9DdvmfFgTbcp -7bgLVSao0cZo/VCEbukaiVLEI1iesn092tpKVJa/7hfusYjRsgBentldu0nHgtqF -s2vCLlpQ8WoXiRuzhzUMnocJC6d/5xfMYDoMVuR44u2podrQ+NNqJHfYCBnMQqAM -ZjZAUOEZE9HpWzwasHq/AXnlIJQ5C+c+DfCNaSWF3RkDf/HUH6TerFZdvZfrLLgB -NTSFWl0lMlVtiVNb+W9zTsIe ------END CERTIFICATE----- diff --git a/pkg/crypto/testdata/mock_push_cert_no_uid.pem b/pkg/crypto/testdata/mock_push_cert_no_uid.pem deleted file mode 100644 index c75a3667..00000000 --- a/pkg/crypto/testdata/mock_push_cert_no_uid.pem +++ /dev/null @@ -1,19 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDIjCCAgoCCQCKvtUmOiEMjTANBgkqhkiG9w0BAQsFADBSMQ8wDQYDVQQDDAZu -by51aWQxMjAwBgNVBAMMKUFQU1A6MTdhMTY0MjktODg2Yi00MWYxLThjOTAtM2Jk -MDJhZTlmYzU3MQswCQYDVQQGEwJVUzAgFw0xODAxMjUwODQzNDhaGA8yMDY4MDEy -NTA4NDM0OFowUjEPMA0GA1UEAwwGbm8udWlkMTIwMAYDVQQDDClBUFNQOjE3YTE2 -NDI5LTg4NmItNDFmMS04YzkwLTNiZDAyYWU5ZmM1NzELMAkGA1UEBhMCVVMwggEi -MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCwWYI1/95LnpUXmO8Z17WkobUL -/PpNW4m0bXwp6BPIorOpjUSBonx7UHkNpBuwypT0hfSYej47yGuL5uPaWB9gR1RZ -a1j8MFoxj6p3Le7HJlYkRF4iFBpTy5yxlsycS7FO52+B51g45b4v6LDkY7ym7uOr -zZwyee6ssQ+JcfqaT4Tp0fo2iSugWoJ0hxpaIZPhBgtCw+WEiIkeowh+kqiCyI5r -gh2vOfDy+9Vb6sjbAo8BvQ4Cx7JHuoNinVbJ5iv+p1/CUyX9dz5u8wdGHgzCxSS0 -zSPxIBAIewvo/UdHb7XGBQXzsP+7cy7ZbodICklUIiTqjnwGO2G0752MiyChAgMB -AAEwDQYJKoZIhvcNAQELBQADggEBAIrBQDrWbC24FTuhxDXFwCJFU0ihZ4gHcVYW -jpqeSLPIo8hHM+rZhj2GHqDInt7pnnhndr0P60vTsBhMcxujyjZrYvxXZriLRwKk -2cyA8aZTjxb2mlE6P/pAyYK+i6AekHMCslEU6jtc5ghnxbCvT2bnF3Lp/M/oB6EM -DMREUBd0mefVArskB+PS1bWa41XeLUtJWaqpZkgo2S+Y1VhXzkV1CBiSHMApGdek -OcR+wt+HhWC7JcmZ40kZYTO6q+FciX6SjZkvrF0Bk8sipXiTjf9yaX1sKEbE/+GT -PoVVmCFv8TLzwfdIqFEywZ7DUAW8delJe3GI2/1BN4TOtH4R1us= ------END CERTIFICATE----- diff --git a/pkg/crypto/testdata/mock_push_cert_wrong_uid_prefix.pem b/pkg/crypto/testdata/mock_push_cert_wrong_uid_prefix.pem deleted file mode 100644 index e134cb7a..00000000 --- a/pkg/crypto/testdata/mock_push_cert_wrong_uid_prefix.pem +++ /dev/null @@ -1,21 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDiDCCAnACCQCUcbmeNX3CoDANBgkqhkiG9w0BAQsFADCBhDFBMD8GCgmSJomT -8ixkAQEMMXdyb25nLnByZWZpeC4xOGExNjQyOS04ODZiLTQxZjEtOWMzMC0yYmQw -NGFlNGZjMzcxMjAwBgNVBAMMKUFQU1A6MTdhMTY0MjktODg2Yi00MWYxLThjOTAt -M2JkMDJhZTlmYzU3MQswCQYDVQQGEwJVUzAgFw0xODAxMjUwODQyMzlaGA8yMDY4 -MDEyNTA4NDIzOVowgYQxQTA/BgoJkiaJk/IsZAEBDDF3cm9uZy5wcmVmaXguMThh -MTY0MjktODg2Yi00MWYxLTljMzAtMmJkMDRhZTRmYzM3MTIwMAYDVQQDDClBUFNQ -OjE3YTE2NDI5LTg4NmItNDFmMS04YzkwLTNiZDAyYWU5ZmM1NzELMAkGA1UEBhMC -VVMwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQChKxRTPfjlB9RDaNOd -wlzljXx5Sj83iFqa2dLVmn6v3cC9fJZ2x4g1ANixpkUiYBjymNQ8zJ0z4q8g3bht -8Kky5vzoah4H6c1dCb+P6F5ihj9StUv0Dqzcl8sYt3G1qcNLlDmIrizsCuxbvznU -FxFTKcqa4LZdV1DcOjQZvdtuxibWesMMfB5prziu1AJKCEDvrGT6BCuqYLRpDkrK -CbHLfvEHpDcSr31wQvLgyk8w47ZchceCqMmJto4/5DHmAdnXjfRooUaERWdA0q+p -wsld/lviSjUuoXIKZ8nIJH0rfoRyT8OI2SPEnk9eLlwgQffrJzLCYk93WE/ejhnx -u2fJAgMBAAEwDQYJKoZIhvcNAQELBQADggEBADDU8360OHApqgQg7QxRCj8xvKDL -2BcX4oOnx/lsHDfdzT9pNmTSwTEXF5Qum/OzWQik1YJkpcYFzFHh5+eA9e/KWwXw -tvFZlQuS743xL+DGN4Ukd+cfhRJIjfjUgYFueDNDP95ABwsSxkETY760rMoxM2Gh -uvxZZ3Zo3qckxgOMy6R3jOudaVWtDHojTxyk+cv50vBhlu/I29RhIsAD7N+3sZEU -wvhQ23LRWPRa3fo7hf7V3MZIJ1sD48W9AWlgM+jDM7eWNdZ5vjp/avVZcCNrnDr1 -Hh6ki6KQTEy4Y3cYc9KgpZL1wro5a8b/ubXsxtw0X7xU0BiqDwjIsxeVxok= ------END CERTIFICATE----- diff --git a/pkg/httputil/httputil.go b/pkg/httputil/httputil.go deleted file mode 100644 index 8c1cc053..00000000 --- a/pkg/httputil/httputil.go +++ /dev/null @@ -1,140 +0,0 @@ -package httputil - -import ( - "context" - "crypto/subtle" - "encoding/json" - "errors" - "fmt" - "net/http" - "net/url" - "strings" - - "github.com/go-kit/kit/log" - httptransport "github.com/go-kit/kit/transport/http" - "github.com/gorilla/mux" -) - -func NewRouter(logger log.Logger) (*mux.Router, []httptransport.ServerOption) { - r := mux.NewRouter() - options := []httptransport.ServerOption{ - httptransport.ServerErrorEncoder(ErrorEncoder), - httptransport.ServerErrorLogger(logger), - httptransport.ServerBefore(httptransport.PopulateRequestContext), - } - return r, options -} - -func EncodeJSONResponse(ctx context.Context, w http.ResponseWriter, response interface{}) error { - if f, ok := response.(failer); ok && f.Failed() != nil { - ErrorEncoder(ctx, f.Failed(), w) - return nil - } - if headerer, ok := response.(httptransport.Headerer); ok { - for k, values := range headerer.Headers() { - for _, v := range values { - w.Header().Add(k, v) - } - } - } - w.Header().Set("Content-Type", "application/json; charset=utf-8") - - code := http.StatusOK - if sc, ok := response.(httptransport.StatusCoder); ok { - code = sc.StatusCode() - } - w.WriteHeader(code) - - enc := json.NewEncoder(w) - enc.SetIndent("", " ") - return enc.Encode(response) -} - -func ErrorEncoder(_ context.Context, err error, w http.ResponseWriter) { - errMap := map[string]interface{}{"error": err.Error()} - enc := json.NewEncoder(w) - enc.SetIndent("", " ") - - if headerer, ok := err.(httptransport.Headerer); ok { - for k, values := range headerer.Headers() { - for _, v := range values { - w.Header().Add(k, v) - } - } - } - w.Header().Set("Content-Type", "application/json; charset=utf-8") - - code := http.StatusInternalServerError - if sc, ok := err.(httptransport.StatusCoder); ok { - code = sc.StatusCode() - } - w.WriteHeader(code) - - enc.Encode(errMap) -} - -// failer is an interface that should be implemented by response types. -// Response encoders can check if responses are Failer, and if so if they've -// failed, and if so encode them using a separate write path based on the error. -type failer interface { - Failed() error -} - -type errorWrapper struct { - Error string `json:"error"` -} - -func JSONErrorDecoder(r *http.Response) error { - contentType := r.Header.Get("Content-Type") - if !strings.Contains(contentType, "application/json") { - return fmt.Errorf("expected JSON formatted error, got Content-Type %s", contentType) - } - var w errorWrapper - if err := json.NewDecoder(r.Body).Decode(&w); err != nil { - return err - } - return errors.New(w.Error) -} - -func EncodeRequestWithToken(token string, next httptransport.EncodeRequestFunc) httptransport.EncodeRequestFunc { - return func(ctx context.Context, r *http.Request, request interface{}) error { - r.SetBasicAuth("micromdm", token) - return next(ctx, r, request) - } -} - -func CopyURL(base *url.URL, path string) *url.URL { - next := *base - next.Path = path - return &next -} - -func DecodeJSONRequest(r *http.Request, into interface{}) error { - defer r.Body.Close() - err := json.NewDecoder(r.Body).Decode(into) - return err -} - -func DecodeJSONResponse(r *http.Response, into interface{}) error { - defer r.Body.Close() - - if r.StatusCode != http.StatusOK { - return JSONErrorDecoder(r) - } - - err := json.NewDecoder(r.Body).Decode(into) - return err -} - -func RequireBasicAuth(h http.HandlerFunc, username, password, realm string) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - u, p, ok := r.BasicAuth() - if !ok || subtle.ConstantTimeCompare([]byte(u), []byte(username)) != 1 || subtle.ConstantTimeCompare([]byte(p), []byte(password)) != 1 { - w.Header().Set("WWW-Authenticate", `Basic realm="`+realm+`"`) - w.WriteHeader(401) - w.Write([]byte("Authorization Required\n")) - return - } - h(w, r) - } -} diff --git a/pkg/tools/tools.go b/pkg/tools/tools.go deleted file mode 100644 index d311e6e8..00000000 --- a/pkg/tools/tools.go +++ /dev/null @@ -1,7 +0,0 @@ -// +build tools - -package tools - -import ( - _ "github.com/pressly/goose/cmd/goose" -) diff --git a/platform/apns/builtin/db.go b/platform/apns/builtin/db.go deleted file mode 100644 index 6744b201..00000000 --- a/platform/apns/builtin/db.go +++ /dev/null @@ -1,77 +0,0 @@ -package builtin - -import ( - "context" - "fmt" - - "github.com/boltdb/bolt" - "github.com/pkg/errors" - - "github.com/micromdm/micromdm/platform/apns" - "github.com/micromdm/micromdm/platform/pubsub" -) - -const PushBucket = "mdm.PushInfo" - -type DB struct { - *bolt.DB -} - -func NewDB(db *bolt.DB, sub pubsub.Subscriber) (*DB, error) { - err := db.Update(func(tx *bolt.Tx) error { - _, err := tx.CreateBucketIfNotExists([]byte(PushBucket)) - return err - }) - if err != nil { - return nil, errors.Wrapf(err, "creating %s bucket", PushBucket) - } - datastore := &DB{ - DB: db, - } - return datastore, nil -} - -type notFound struct { - ResourceType string - Message string -} - -func (e *notFound) Error() string { - return fmt.Sprintf("not found: %s %s", e.ResourceType, e.Message) -} - -func (db *DB) PushInfo(ctx context.Context, udid string) (*apns.PushInfo, error) { - var info apns.PushInfo - err := db.View(func(tx *bolt.Tx) error { - b := tx.Bucket([]byte(PushBucket)) - v := b.Get([]byte(udid)) - if v == nil { - return ¬Found{"PushInfo", fmt.Sprintf("udid %s", udid)} - } - return apns.UnmarshalPushInfo(v, &info) - }) - if err != nil { - return nil, err - } - return &info, nil -} - -func (db *DB) Save(ctx context.Context, info *apns.PushInfo) error { - tx, err := db.DB.Begin(true) - if err != nil { - return errors.Wrap(err, "begin transaction") - } - bkt := tx.Bucket([]byte(PushBucket)) - if bkt == nil { - return fmt.Errorf("bucket %q not found!", PushBucket) - } - pushproto, err := apns.MarshalPushInfo(info) - if err != nil { - return errors.Wrap(err, "marshalling PushInfo") - } - key := []byte(info.UDID) - if err := bkt.Put(key, pushproto); err != nil { - return errors.Wrap(err, "put PushInfo to boltdb") - } - return tx.Commit() -} diff --git a/platform/apns/internal/pushproto/push.go b/platform/apns/internal/pushproto/push.go deleted file mode 100644 index d2cf04b3..00000000 --- a/platform/apns/internal/pushproto/push.go +++ /dev/null @@ -1,3 +0,0 @@ -package pushproto - -//go:generate protoc --go_out=. push.proto diff --git a/platform/apns/internal/pushproto/push.pb.go b/platform/apns/internal/pushproto/push.pb.go deleted file mode 100644 index 576f1429..00000000 --- a/platform/apns/internal/pushproto/push.pb.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by protoc-gen-go. -// source: push.proto -// DO NOT EDIT! - -/* -Package pushproto is a generated protocol buffer package. - -It is generated from these files: - push.proto - -It has these top-level messages: - PushInfo -*/ -package pushproto - -import proto "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package - -type PushInfo struct { - Udid string `protobuf:"bytes,1,opt,name=udid" json:"udid,omitempty"` - Token string `protobuf:"bytes,2,opt,name=token" json:"token,omitempty"` - PushMagic string `protobuf:"bytes,3,opt,name=push_magic,json=pushMagic" json:"push_magic,omitempty"` - MdmTopic string `protobuf:"bytes,4,opt,name=mdm_topic,json=mdmTopic" json:"mdm_topic,omitempty"` -} - -func (m *PushInfo) Reset() { *m = PushInfo{} } -func (m *PushInfo) String() string { return proto.CompactTextString(m) } -func (*PushInfo) ProtoMessage() {} -func (*PushInfo) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } - -func (m *PushInfo) GetUdid() string { - if m != nil { - return m.Udid - } - return "" -} - -func (m *PushInfo) GetToken() string { - if m != nil { - return m.Token - } - return "" -} - -func (m *PushInfo) GetPushMagic() string { - if m != nil { - return m.PushMagic - } - return "" -} - -func (m *PushInfo) GetMdmTopic() string { - if m != nil { - return m.MdmTopic - } - return "" -} - -func init() { - proto.RegisterType((*PushInfo)(nil), "pushproto.PushInfo") -} - -func init() { proto.RegisterFile("push.proto", fileDescriptor0) } - -var fileDescriptor0 = []byte{ - // 133 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0xe2, 0x2a, 0x28, 0x2d, 0xce, - 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x04, 0xb1, 0xc1, 0x4c, 0xa5, 0x02, 0x2e, 0x8e, - 0x80, 0xd2, 0xe2, 0x0c, 0xcf, 0xbc, 0xb4, 0x7c, 0x21, 0x21, 0x2e, 0x96, 0xd2, 0x94, 0xcc, 0x14, - 0x09, 0x46, 0x05, 0x46, 0x0d, 0xce, 0x20, 0x30, 0x5b, 0x48, 0x84, 0x8b, 0xb5, 0x24, 0x3f, 0x3b, - 0x35, 0x4f, 0x82, 0x09, 0x2c, 0x08, 0xe1, 0x08, 0xc9, 0x42, 0x8c, 0x8b, 0xcf, 0x4d, 0x4c, 0xcf, - 0x4c, 0x96, 0x60, 0x06, 0x4b, 0x81, 0x0d, 0xf5, 0x05, 0x09, 0x08, 0x49, 0x73, 0x71, 0xe6, 0xa6, - 0xe4, 0xc6, 0x97, 0xe4, 0x17, 0x64, 0x26, 0x4b, 0xb0, 0x80, 0x65, 0x39, 0x72, 0x53, 0x72, 0x43, - 0x40, 0xfc, 0x24, 0x36, 0xb0, 0xc5, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x1e, 0xd3, 0xd3, - 0x24, 0x91, 0x00, 0x00, 0x00, -} diff --git a/platform/apns/internal/pushproto/push.proto b/platform/apns/internal/pushproto/push.proto deleted file mode 100644 index b21c43b8..00000000 --- a/platform/apns/internal/pushproto/push.proto +++ /dev/null @@ -1,12 +0,0 @@ -syntax = "proto3"; - -package pushproto; - - -message PushInfo { - string udid = 1; - string token = 2; - string push_magic = 3; - string mdm_topic = 4; -} - diff --git a/platform/apns/middleware.go b/platform/apns/middleware.go deleted file mode 100644 index 368d2077..00000000 --- a/platform/apns/middleware.go +++ /dev/null @@ -1,19 +0,0 @@ -package apns - -import "github.com/go-kit/kit/log" - -type Middleware func(Service) Service - -func LoggingMiddleware(logger log.Logger) Middleware { - return func(next Service) Service { - return &loggingMiddleware{ - next: next, - logger: logger, - } - } -} - -type loggingMiddleware struct { - next Service - logger log.Logger -} diff --git a/platform/apns/pg/pg.go b/platform/apns/pg/pg.go deleted file mode 100644 index f45c69f7..00000000 --- a/platform/apns/pg/pg.go +++ /dev/null @@ -1,86 +0,0 @@ -package pg - -import ( - "context" - "database/sql" - "strings" - - "github.com/jmoiron/sqlx" - "github.com/pkg/errors" - sq "gopkg.in/Masterminds/squirrel.v1" - - "github.com/micromdm/micromdm/platform/apns" -) - -type Postgres struct{ db *sqlx.DB } - -func New(db *sqlx.DB) *Postgres { - return &Postgres{db: db} -} - -func columns() []string { - return []string{ - "udid", - "push_magic", - "token", - "mdm_topic", - } -} - -const tableName = "push_info" - -func (d *Postgres) Save(ctx context.Context, i *apns.PushInfo) error { - updateQuery, _, err := sq.StatementBuilder.PlaceholderFormat(sq.Dollar). - Update(tableName). - Prefix("ON CONFLICT (udid) DO"). - Set("udid", i.UDID). - Set("push_magic", i.PushMagic). - Set("token", i.Token). - Set("mdm_topic", i.MDMTopic). - ToSql() - if err != nil { - return errors.Wrap(err, "building update query for push_info save") - } - updateQuery = strings.Replace(updateQuery, tableName, "", -1) - - query, args, err := sq.StatementBuilder.PlaceholderFormat(sq.Dollar). - Insert(tableName). - Columns(columns()...). - Values( - i.UDID, - i.PushMagic, - i.Token, - i.MDMTopic, - ). - Suffix(updateQuery). - ToSql() - if err != nil { - return errors.Wrap(err, "building push_info save query") - } - - _, err = d.db.ExecContext(ctx, query, args...) - return errors.Wrap(err, "exec push_info save in pg") -} - -func (d *Postgres) PushInfo(ctx context.Context, udid string) (*apns.PushInfo, error) { - query, args, err := sq.StatementBuilder.PlaceholderFormat(sq.Dollar). - Select(columns()...). - From(tableName). - Where(sq.Eq{"udid": udid}). - ToSql() - if err != nil { - return nil, errors.Wrap(err, "building sql") - } - - var i apns.PushInfo - err = d.db.QueryRowxContext(ctx, query, args...).StructScan(&i) - if errors.Cause(err) == sql.ErrNoRows { - return nil, pushInfoNotFoundErr{} - } - return &i, errors.Wrap(err, "finding push_info by udid") -} - -type pushInfoNotFoundErr struct{} - -func (e pushInfoNotFoundErr) Error() string { return "push_info not found" } -func (e pushInfoNotFoundErr) NotFound() bool { return true } diff --git a/platform/apns/pg/pg_test.go b/platform/apns/pg/pg_test.go deleted file mode 100644 index a7e1e1d2..00000000 --- a/platform/apns/pg/pg_test.go +++ /dev/null @@ -1,48 +0,0 @@ -package pg - -import ( - "context" - "testing" - - "github.com/go-kit/kit/log" - "github.com/kolide/kit/dbutil" - _ "github.com/lib/pq" - "github.com/micromdm/micromdm/platform/apns" -) - -func TestPGCrud(t *testing.T) { - db := setup(t) - ctx := context.Background() - - info := apns.PushInfo{ - UDID: "UDID-foo-bar-baz", - Token: "tok", - } - err := db.Save(ctx, &info) - if err != nil { - t.Fatal(err) - } - - found, err := db.PushInfo(ctx, info.UDID) - if err != nil { - t.Fatal(err) - } - - if have, want := found.Token, info.Token; have != want { - t.Errorf("have %s, want %s", have, want) - } -} - -func setup(t *testing.T) *Postgres { - db, err := dbutil.OpenDBX( - "postgres", - "host=localhost port=5432 user=micromdm dbname=micromdm_test password=micromdm sslmode=disable", - dbutil.WithLogger(log.NewNopLogger()), - dbutil.WithMaxAttempts(1), - ) - if err != nil { - t.Fatal(err) - } - - return New(db) -} diff --git a/platform/apns/push.go b/platform/apns/push.go deleted file mode 100644 index 88adc894..00000000 --- a/platform/apns/push.go +++ /dev/null @@ -1,150 +0,0 @@ -package apns - -import ( - "context" - "encoding/json" - "fmt" - "net/http" - "strconv" - "strings" - "time" - - "github.com/RobotsAndPencils/buford/payload" - "github.com/RobotsAndPencils/buford/push" - "github.com/go-kit/kit/endpoint" - "github.com/gorilla/mux" - "github.com/pkg/errors" - - "github.com/micromdm/micromdm/pkg/httputil" -) - -type pushOpts struct { - expiration time.Time -} - -// WithExpiration sets the expiration of the APNS message. -// Apple will retry delivery until this time. The default behavior only tries once. -func WithExpiration(t time.Time) PushOption { - return func(opt *pushOpts) { - opt.expiration = t - } -} - -// PushOption adds optional parameters to the Push method. -type PushOption func(*pushOpts) - -func (svc *PushService) Push(ctx context.Context, deviceUDID string, opts ...PushOption) (string, error) { - // loop through defaults and apply user provided overrides - var opt pushOpts - for _, optFn := range opts { - optFn(&opt) - } - - headers := &push.Headers{} - if !opt.expiration.IsZero() { - headers.Expiration = opt.expiration - } - - info, err := svc.store.PushInfo(ctx, deviceUDID) - if err != nil { - return "", errors.Wrap(err, "retrieving PushInfo by UDID") - } - - p := payload.MDM{Token: info.PushMagic} - valid := push.IsDeviceTokenValid(info.Token) - if !valid { - return "", errors.New("invalid push token") - } - jsonPayload, err := json.Marshal(p) - if err != nil { - return "", errors.Wrap(err, "marshalling push notification payload") - } - - result, err := svc.pushsvc.Push(info.Token, headers, jsonPayload) - if err != nil && strings.HasSuffix(err.Error(), "remote error: tls: internal error") { - // TODO: yuck, error substring searching. see: - // https://github.com/micromdm/micromdm/issues/150 - return result, errors.Wrap(err, "push error: possibly expired or invalid APNs certificate") - } - return result, err -} - -type pushRequest struct { - UDID string - expireAt time.Time -} - -type pushResponse struct { - Status string `json:"status,omitempty"` - ID string `json:"push_notification_id,omitempty"` - Err error `json:"error,omitempty"` -} - -func (r pushResponse) Failed() error { return r.Err } - -func decodePushRequest(ctx context.Context, r *http.Request) (interface{}, error) { - vars := mux.Vars(r) - udid, ok := vars["udid"] - if !ok { - return 0, errors.New("apns: bad route") - } - - v := r.URL.Query() - exp, err := expiration(v.Get("expiration")) - if err != nil { - return nil, err - } - - return pushRequest{ - UDID: udid, - expireAt: exp, - }, nil -} - -func expiration(s string) (time.Time, error) { - if s == "" { - return time.Time{}, nil - } - - i, err := strconv.ParseInt(s, 10, 64) - if err != nil { - return time.Time{}, fmt.Errorf("parsing expiration time: %s", err) - } - return time.Unix(i, 0).UTC(), nil -} - -func decodePushResponse(_ context.Context, r *http.Response) (interface{}, error) { - var resp pushResponse - err := httputil.DecodeJSONResponse(r, &resp) - return resp, err -} - -func MakePushEndpoint(svc Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (interface{}, error) { - req := request.(pushRequest) - var opts []PushOption - if !req.expireAt.IsZero() { - opts = append(opts, WithExpiration(req.expireAt)) - } - - id, err := svc.Push(ctx, req.UDID, opts...) - if err != nil { - return pushResponse{Err: err, Status: "failure"}, nil - } - return pushResponse{Status: "success", ID: id}, nil - } -} - -func (mw loggingMiddleware) Push(ctx context.Context, udid string, opts ...PushOption) (id string, err error) { - defer func(begin time.Time) { - _ = mw.logger.Log( - "method", "Push", - "udid", udid, - "err", err, - "took", time.Since(begin), - ) - }(time.Now()) - - id, err = mw.next.Push(ctx, udid, opts...) - return -} diff --git a/platform/apns/push_info.go b/platform/apns/push_info.go deleted file mode 100644 index 08621fad..00000000 --- a/platform/apns/push_info.go +++ /dev/null @@ -1,37 +0,0 @@ -package apns - -import ( - "github.com/pkg/errors" - - "github.com/gogo/protobuf/proto" - "github.com/micromdm/micromdm/platform/apns/internal/pushproto" -) - -type PushInfo struct { - UDID string `db:"udid"` - PushMagic string `db:"push_magic"` - Token string `db:"token"` - MDMTopic string `db:"mdm_topic"` -} - -func MarshalPushInfo(p *PushInfo) ([]byte, error) { - protopush := pushproto.PushInfo{ - Udid: p.UDID, - PushMagic: p.PushMagic, - Token: p.Token, - MdmTopic: p.MDMTopic, - } - return proto.Marshal(&protopush) -} - -func UnmarshalPushInfo(data []byte, p *PushInfo) error { - var pb pushproto.PushInfo - if err := proto.Unmarshal(data, &pb); err != nil { - return errors.Wrap(err, "unmarshal proto to PushInfo") - } - p.UDID = pb.GetUdid() - p.Token = pb.GetToken() - p.PushMagic = pb.GetPushMagic() - p.MDMTopic = pb.GetMdmTopic() - return nil -} diff --git a/platform/apns/server.go b/platform/apns/server.go deleted file mode 100644 index c9324c1f..00000000 --- a/platform/apns/server.go +++ /dev/null @@ -1,38 +0,0 @@ -package apns - -import ( - "github.com/go-kit/kit/endpoint" - httptransport "github.com/go-kit/kit/transport/http" - "github.com/gorilla/mux" - - "github.com/micromdm/micromdm/pkg/httputil" -) - -type Endpoints struct { - PushEndpoint endpoint.Endpoint -} - -func MakeServerEndpoints(s Service, outer endpoint.Middleware, others ...endpoint.Middleware) Endpoints { - return Endpoints{ - PushEndpoint: endpoint.Chain(outer, others...)(MakePushEndpoint(s)), - } -} - -func RegisterHTTPHandlers(r *mux.Router, e Endpoints, options ...httptransport.ServerOption) { - // GET /push/:udid create an APNS Push notification for a managed device or user(deprecated) - // POST /v1/push/:udid create an APNS Push notification for a managed device or user - - r.Methods("GET").Path("/push/{udid}").Handler(httptransport.NewServer( - e.PushEndpoint, - decodePushRequest, - httputil.EncodeJSONResponse, - options..., - )) - - r.Methods("POST").Path("/v1/push/{udid}").Handler(httptransport.NewServer( - e.PushEndpoint, - decodePushRequest, - httputil.EncodeJSONResponse, - options..., - )) -} diff --git a/platform/apns/service.go b/platform/apns/service.go deleted file mode 100644 index ae86e678..00000000 --- a/platform/apns/service.go +++ /dev/null @@ -1,166 +0,0 @@ -package apns - -import ( - "context" - "crypto/tls" - "fmt" - "log" - "net/http" - "sync" - "time" - - "github.com/RobotsAndPencils/buford/push" - "github.com/pkg/errors" - "golang.org/x/net/http2" - - "github.com/micromdm/micromdm/platform/config" - "github.com/micromdm/micromdm/platform/pubsub" - "github.com/micromdm/micromdm/platform/queue" -) - -type Service interface { - Push(ctx context.Context, udid string, opts ...PushOption) (string, error) -} - -type Store interface { - PushInfo(ctx context.Context, udid string) (*PushInfo, error) -} - -type PushService struct { - store Store - start chan struct{} - provider PushCertificateProvider - - mu sync.RWMutex - pushsvc *push.Service -} - -type PushCertificateProvider interface { - PushCertificate() (*tls.Certificate, error) -} - -type Option func(*PushService) - -func WithPushService(svc *push.Service) Option { - return func(p *PushService) { - p.pushsvc = svc - } -} - -func New(db Store, provider PushCertificateProvider, sub pubsub.Subscriber, opts ...Option) (*PushService, error) { - pushSvc := PushService{ - store: db, - provider: provider, - start: make(chan struct{}), - } - for _, opt := range opts { - opt(&pushSvc) - } - - pushsvc, _ := NewPushService(provider) - if pushsvc != nil { - pushSvc.pushsvc = pushsvc - } - - // if there is no push service, the push certificate hasn't been provided. - // start a goroutine that delays the run of this service. - if err := updateClient(&pushSvc, sub); err != nil { - return nil, errors.Wrap(err, "wait for push service config") - } - - if err := pushSvc.startQueuedSubscriber(sub); err != nil { - return &pushSvc, err - } - return &pushSvc, nil -} - -func (svc *PushService) startQueuedSubscriber(sub pubsub.Subscriber) error { - commandQueuedEvents, err := sub.Subscribe(context.TODO(), "push-info", queue.CommandQueuedTopic) - if err != nil { - return errors.Wrapf(err, - "subscribing push to %s topic", queue.CommandQueuedTopic) - } - go func() { - if svc.pushsvc == nil { - log.Println("push: waiting for push certificate before enabling APNS service provider") - <-svc.start - log.Println("push: service started") - } - for { - select { - case event := <-commandQueuedEvents: - cq, err := queue.UnmarshalQueuedCommand(event.Message) - if err != nil { - fmt.Println(err) - continue - } - _, err = svc.Push(context.TODO(), cq.DeviceUDID) - if err != nil { - fmt.Println(err) - continue - } - } - } - }() - - return nil -} - -func updateClient(svc *PushService, sub pubsub.Subscriber) error { - configEvents, err := sub.Subscribe(context.TODO(), "push-server-configs", config.ConfigTopic) - if err != nil { - return errors.Wrap(err, "update push service client") - } - go func() { - for { - select { - case <-configEvents: - pushsvc, err := NewPushService(svc.provider) - if err != nil { - log.Printf("push: could not get push certificate %s\n", err) - continue - } - svc.mu.Lock() - svc.pushsvc = pushsvc - svc.mu.Unlock() - go func() { svc.start <- struct{}{} }() // unblock queue - } - } - }() - return nil -} - -func newClient(cert tls.Certificate) (*http.Client, error) { - config := &tls.Config{ - Certificates: []tls.Certificate{cert}, - } - config.BuildNameToCertificate() - transport := &http.Transport{ - TLSClientConfig: config, - IdleConnTimeout: 90 * time.Second, - } - - if err := http2.ConfigureTransport(transport); err != nil { - return nil, err - } - - return &http.Client{ - Transport: transport, - Timeout: 20 * time.Second, - }, nil -} - -func NewPushService(provider PushCertificateProvider) (*push.Service, error) { - cert, err := provider.PushCertificate() - if err != nil { - return nil, errors.Wrap(err, "get push certificate from store") - } - - client, err := newClient(*cert) - if err != nil { - return nil, errors.Wrap(err, "create push service client") - } - - svc := push.NewService(client, push.Production) - return svc, nil -} diff --git a/platform/apns/worker.go b/platform/apns/worker.go deleted file mode 100644 index ba8fc6fd..00000000 --- a/platform/apns/worker.go +++ /dev/null @@ -1,80 +0,0 @@ -package apns - -import ( - "context" - - "github.com/go-kit/kit/log" - "github.com/go-kit/kit/log/level" - "github.com/pkg/errors" - - "github.com/micromdm/micromdm/mdm" - "github.com/micromdm/micromdm/platform/pubsub" -) - -type WorkerStore interface { - Save(context.Context, *PushInfo) error -} - -type Worker struct { - db WorkerStore - sub pubsub.Subscriber - logger log.Logger -} - -func NewWorker(db WorkerStore, subscriber pubsub.Subscriber, logger log.Logger) *Worker { - return &Worker{ - db: db, - sub: subscriber, - logger: logger, - } -} - -func (w *Worker) Run(ctx context.Context) error { - const subscription = "pushinfo_worker" - tokenUpdateEvents, err := w.sub.Subscribe(ctx, subscription, mdm.TokenUpdateTopic) - if err != nil { - return errors.Wrapf(err, - "subscribing %s to %s topic", subscription, mdm.TokenUpdateTopic) - } - - for { - var err error - select { - case <-ctx.Done(): - return ctx.Err() - case event := <-tokenUpdateEvents: - err = w.updatePushInfoFromTokenUpdate(ctx, event.Message) - } - if err != nil { - level.Info(w.logger).Log( - "msg", "update pushinfo from event", - "err", err, - ) - continue - } - } -} - -func (w *Worker) updatePushInfoFromTokenUpdate(ctx context.Context, message []byte) error { - var ev mdm.CheckinEvent - if err := mdm.UnmarshalCheckinEvent(message, &ev); err != nil { - return errors.Wrap(err, "unmarshal pushinfo event") - } - info := PushInfo{ - UDID: ev.Command.UDID, - Token: ev.Command.Token.String(), - PushMagic: ev.Command.PushMagic, - MDMTopic: ev.Command.Topic, - } - // UDID is the primary key for storing the APNS values. - // For MDM managed users, use the UserID instead, - // and for BYOD User Enrollment, use the EnrollmentID. - if ev.Command.UserID != "" { - info.UDID = ev.Command.UserID - } - if ev.Command.EnrollmentID != "" { - info.UDID = ev.Command.EnrollmentID - } - err := w.db.Save(ctx, &info) - return errors.Wrapf(err, "saving pushinfo for udid=%s", info.UDID) -} diff --git a/platform/appstore/builtin/appstore.go b/platform/appstore/builtin/appstore.go deleted file mode 100644 index a7de159e..00000000 --- a/platform/appstore/builtin/appstore.go +++ /dev/null @@ -1,92 +0,0 @@ -// package builtin provides an abstraction for uploading files and manifests -// to a file repository. -package builtin - -import ( - "io" - "io/ioutil" - "os" - "path/filepath" - "strings" - - "github.com/groob/plist" - "github.com/pkg/errors" - - "github.com/micromdm/micromdm/mdm/appmanifest" -) - -type Repo struct { - Path string -} - -func (r *Repo) SaveFile(name string, f io.Reader) error { - fname := filepath.Join(r.Path, name) - file, err := os.Create(fname) - if err != nil { - return errors.Wrapf(err, "saving file %s", name) - } - defer file.Close() - - _, err = io.Copy(file, f) - return err -} - -func (r *Repo) Manifest(name string) (*appmanifest.Manifest, error) { - manifestName := name - if !strings.HasSuffix(name, ".plist") { - manifestName = name + ".plist" - - } - fname := filepath.Join(r.Path, manifestName) - file, err := os.Open(fname) - if err != nil { - return nil, errors.Wrapf(err, "reading manifest %s", name) - } - defer file.Close() - - var m appmanifest.Manifest - if err := plist.NewDecoder(file).Decode(&m); err != nil { - return nil, errors.Wrap(err, "decoding manifest file") - } - - return &m, nil -} - -func (r *Repo) Apps(name string) (map[string]appmanifest.Manifest, error) { - manifests := make(map[string]appmanifest.Manifest) - if name != "" { - mf, err := os.Open(filepath.Join(r.Path, name)) - if err != nil { - return nil, err - } - var m appmanifest.Manifest - if err := plist.NewDecoder(mf).Decode(&m); err != nil { - return nil, err - } - manifests[name] = m - return manifests, nil - } - - files, err := ioutil.ReadDir(r.Path) - if err != nil { - return nil, err - } - - for _, file := range files { - manifestName := file.Name() - if file.IsDir() || filepath.Ext(manifestName) != ".plist" { - continue - } - mf, err := os.Open(filepath.Join(r.Path, manifestName)) - if err != nil { - return nil, err - } - var m appmanifest.Manifest - if err := plist.NewDecoder(mf).Decode(&m); err != nil { - return nil, err - } - manifests[manifestName] = m - } - - return manifests, nil -} diff --git a/platform/appstore/client.go b/platform/appstore/client.go deleted file mode 100644 index 31c8f992..00000000 --- a/platform/appstore/client.go +++ /dev/null @@ -1,45 +0,0 @@ -package appstore - -import ( - "net/url" - - "github.com/go-kit/kit/endpoint" - "github.com/go-kit/kit/log" - httptransport "github.com/go-kit/kit/transport/http" - - "github.com/micromdm/micromdm/pkg/httputil" -) - -func NewHTTPClient(instance, token string, logger log.Logger, opts ...httptransport.ClientOption) (Service, error) { - u, err := url.Parse(instance) - if err != nil { - return nil, err - } - - var appUploadEndpoint endpoint.Endpoint - { - appUploadEndpoint = httptransport.NewClient( - "PUT", - httputil.CopyURL(u, "/v1/apps"), - httputil.EncodeRequestWithToken(token, encodeUploadAppRequest), - decodeUploadAppResponse, - opts..., - ).Endpoint() - } - - var listAppsEndpoint endpoint.Endpoint - { - listAppsEndpoint = httptransport.NewClient( - "POST", - httputil.CopyURL(u, "/v1/apps"), - httputil.EncodeRequestWithToken(token, httptransport.EncodeJSONRequest), - decodeListAppsResponse, - opts..., - ).Endpoint() - } - - return Endpoints{ - AppUploadEndpoint: appUploadEndpoint, - ListAppsEndpoint: listAppsEndpoint, - }, nil -} diff --git a/platform/appstore/get_apps.go b/platform/appstore/get_apps.go deleted file mode 100644 index b42b9419..00000000 --- a/platform/appstore/get_apps.go +++ /dev/null @@ -1,86 +0,0 @@ -package appstore - -import ( - "context" - "net/http" - - "github.com/go-kit/kit/endpoint" - "github.com/groob/plist" - "github.com/micromdm/micromdm/pkg/httputil" - "github.com/pkg/errors" -) - -type ListAppsOption struct { - FilterName []string `json:"filter_name"` -} - -type AppDTO struct { - Name string `json:"name"` - Payload []byte `json:"payload,omitempty"` -} - -func (svc *AppService) ListApplications(ctx context.Context, opts ListAppsOption) ([]AppDTO, error) { - var filter string - if len(opts.FilterName) == 1 { - filter = opts.FilterName[0] - } - apps, err := svc.store.Apps(filter) - if err != nil { - return nil, err - } - var appList []AppDTO - for name, app := range apps { - payload, err := plist.MarshalIndent(&app, " ") - if err != nil { - return nil, errors.Wrap(err, "create dto payload") - } - appList = append(appList, AppDTO{ - Name: name, - Payload: payload, - }) - } - return appList, nil -} - -type appListRequest struct { - Opts ListAppsOption -} - -type appListResponse struct { - Apps []AppDTO `json:"apps,omitempty"` - Err error `json:"err,omitempty"` -} - -func (r appListResponse) Failed() error { return r.Err } - -func decodeListAppsRequest(ctx context.Context, r *http.Request) (interface{}, error) { - var req appListRequest - err := httputil.DecodeJSONRequest(r, &req) - return req, err -} - -func decodeListAppsResponse(_ context.Context, r *http.Response) (interface{}, error) { - var resp appListResponse - err := httputil.DecodeJSONResponse(r, &resp) - return resp, err -} - -func MakeListAppsEndpoint(svc Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (response interface{}, err error) { - req := request.(appListRequest) - apps, err := svc.ListApplications(ctx, req.Opts) - return appListResponse{ - Apps: apps, - Err: err, - }, nil - } -} - -func (e Endpoints) ListApplications(ctx context.Context, opts ListAppsOption) ([]AppDTO, error) { - request := appListRequest{opts} - response, err := e.ListAppsEndpoint(ctx, request.Opts) - if err != nil { - return nil, err - } - return response.(appListResponse).Apps, response.(appListResponse).Err -} diff --git a/platform/appstore/server.go b/platform/appstore/server.go deleted file mode 100644 index 8465e7b0..00000000 --- a/platform/appstore/server.go +++ /dev/null @@ -1,40 +0,0 @@ -package appstore - -import ( - "github.com/go-kit/kit/endpoint" - httptransport "github.com/go-kit/kit/transport/http" - "github.com/gorilla/mux" - - "github.com/micromdm/micromdm/pkg/httputil" -) - -type Endpoints struct { - AppUploadEndpoint endpoint.Endpoint - ListAppsEndpoint endpoint.Endpoint -} - -func MakeServerEndpoints(s Service, outer endpoint.Middleware, others ...endpoint.Middleware) Endpoints { - return Endpoints{ - AppUploadEndpoint: endpoint.Chain(outer, others...)(MakeUploadAppEndpiont(s)), - ListAppsEndpoint: endpoint.Chain(outer, others...)(MakeListAppsEndpoint(s)), - } -} - -func RegisterHTTPHandlers(r *mux.Router, e Endpoints, options ...httptransport.ServerOption) { - // PUT /v1/apps upload an app to the server - // POST /v1/apps list apps managed by the server - - r.Methods("PUT").Path("/v1/apps").Handler(httptransport.NewServer( - e.AppUploadEndpoint, - decodeAppUploadRequest, - httputil.EncodeJSONResponse, - options..., - )) - - r.Methods("POST").Path("/v1/apps").Handler(httptransport.NewServer( - e.ListAppsEndpoint, - decodeListAppsRequest, - httputil.EncodeJSONResponse, - options..., - )) -} diff --git a/platform/appstore/service.go b/platform/appstore/service.go deleted file mode 100644 index 8f6dae7a..00000000 --- a/platform/appstore/service.go +++ /dev/null @@ -1,27 +0,0 @@ -package appstore - -import ( - "context" - "io" - - "github.com/micromdm/micromdm/mdm/appmanifest" -) - -type Service interface { - UploadApp(ctx context.Context, manifestName string, manifest io.Reader, pkgName string, pkg io.Reader) error - ListApplications(ctx context.Context, opt ListAppsOption) ([]AppDTO, error) -} - -type AppService struct { - store Store -} - -type Store interface { - SaveFile(name string, f io.Reader) error - Manifest(name string) (*appmanifest.Manifest, error) - Apps(name string) (map[string]appmanifest.Manifest, error) -} - -func New(store Store) *AppService { - return &AppService{store: store} -} diff --git a/platform/appstore/upload_app.go b/platform/appstore/upload_app.go deleted file mode 100644 index 5c8df24c..00000000 --- a/platform/appstore/upload_app.go +++ /dev/null @@ -1,133 +0,0 @@ -package appstore - -import ( - "bytes" - "context" - "io" - "io/ioutil" - "mime/multipart" - "net/http" - - "github.com/go-kit/kit/endpoint" - "github.com/pkg/errors" - - "github.com/micromdm/micromdm/pkg/httputil" -) - -func (svc *AppService) UploadApp(ctx context.Context, manifestName string, manifest io.Reader, pkgName string, pkg io.Reader) error { - if manifestName != "" { - if err := svc.store.SaveFile(manifestName, manifest); err != nil { - return err - } - } - - if pkgName != "" { - if err := svc.store.SaveFile(pkgName, pkg); err != nil { - return err - } - } - - return nil -} - -type appUploadRequest struct { - ManifestName string - ManifestFile io.Reader - - PKGFilename string - PKGFile io.Reader -} - -type appUploadResponse struct { - Err error `json:"err,omitempty"` -} - -func (r appUploadResponse) Failed() error { return r.Err } - -func decodeAppUploadRequest(ctx context.Context, r *http.Request) (interface{}, error) { - defer r.Body.Close() - appManifestFilename := r.FormValue("app_manifest_filename") - manifestFile, _, err := r.FormFile("app_manifest_filedata") - if err != nil && err != http.ErrMissingFile { - return nil, errors.Wrap(err, "manifest file") - } - pkgFilename := r.FormValue("pkg_name") - pkgFile, _, err := r.FormFile("pkg_filedata") - if err != nil && err != http.ErrMissingFile { - return nil, err - } - - return appUploadRequest{ - ManifestName: appManifestFilename, - ManifestFile: manifestFile, - PKGFilename: pkgFilename, - PKGFile: pkgFile, - }, nil -} - -func encodeUploadAppRequest(_ context.Context, r *http.Request, request interface{}) error { - req := request.(appUploadRequest) - body := new(bytes.Buffer) - writer := multipart.NewWriter(body) - - if req.ManifestName != "" { - partManifest, err := writer.CreateFormFile("app_manifest_filedata", req.ManifestName) - if err != nil { - return err - } - _, err = io.Copy(partManifest, req.ManifestFile) - if err != nil { - return errors.Wrap(err, "copying appmanifest file to multipart writer") - } - writer.WriteField("app_manifest_filename", req.ManifestName) - } - - if req.PKGFilename != "" { - partPkg, err := writer.CreateFormFile("pkg_filedata", req.PKGFilename) - if err != nil { - return err - } - _, err = io.Copy(partPkg, req.PKGFile) - if err != nil { - return errors.Wrap(err, "copying pkg file to multipart writer") - } - writer.WriteField("pkg_name", req.PKGFilename) - } - if err := writer.Close(); err != nil { - return errors.Wrap(err, "closing multipart writer") - } - - r.Header.Set("Content-Type", writer.FormDataContentType()) - r.Body = ioutil.NopCloser(body) - return nil -} - -func decodeUploadAppResponse(_ context.Context, r *http.Response) (interface{}, error) { - var resp appUploadResponse - err := httputil.DecodeJSONResponse(r, &resp) - return resp, err -} - -func MakeUploadAppEndpiont(svc Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (response interface{}, err error) { - req := request.(appUploadRequest) - err = svc.UploadApp(ctx, req.ManifestName, req.ManifestFile, req.PKGFilename, req.PKGFile) - return &appUploadResponse{ - Err: err, - }, nil - } -} - -func (e Endpoints) UploadApp(ctx context.Context, manifestName string, manifest io.Reader, pkgName string, pkg io.Reader) error { - request := appUploadRequest{ - ManifestName: manifestName, - ManifestFile: manifest, - PKGFilename: pkgName, - PKGFile: pkg, - } - resp, err := e.AppUploadEndpoint(ctx, request) - if err != nil { - return err - } - return resp.(appUploadResponse).Err -} diff --git a/platform/appstore/upload_app_test.go b/platform/appstore/upload_app_test.go deleted file mode 100644 index e1124336..00000000 --- a/platform/appstore/upload_app_test.go +++ /dev/null @@ -1,65 +0,0 @@ -package appstore - -import ( - "bytes" - "context" - "io" - "mime/multipart" - "net/http/httptest" - "testing" -) - -func TestDecodeUploadRequest(t *testing.T) { - var aFile, bFile bytes.Buffer - aFile.Write([]byte("hello")) - bFile.Write([]byte("world")) - - body := new(bytes.Buffer) - writer := multipart.NewWriter(body) - - part, err := writer.CreateFormFile("app_manifest_filedata", "manifest.plist") - if err != nil { - t.Fatal(err) - } - _, err = io.Copy(part, &aFile) - if err != nil { - t.Fatal(err) - } - writer.WriteField("app_manifest_filename", "manifest.plist") - - partPkg, err := writer.CreateFormFile("pkg_filedata", "foo.pkg") - if err != nil { - t.Fatal(err) - } - _, err = io.Copy(partPkg, &bFile) - if err != nil { - t.Fatal(err) - } - writer.WriteField("pkg_name", "hello.pkg") - writer.Close() - - req := httptest.NewRequest("POST", "https://mdm.acme.co/", body) - req.Header.Set("Content-Type", writer.FormDataContentType()) - request, err := decodeAppUploadRequest(context.Background(), req) - if err != nil { - t.Fatal(err) - } - decoded := request.(appUploadRequest) - - if have, want := decoded.ManifestName, "manifest.plist"; have != want { - t.Errorf("have %s, want %s", have, want) - } - if have, want := decoded.PKGFilename, "hello.pkg"; have != want { - t.Errorf("have %s, want %s", have, want) - } - - var a, b bytes.Buffer - io.Copy(&a, decoded.ManifestFile) - io.Copy(&b, decoded.PKGFile) - if have, want := a.String(), "hello"; have != want { - t.Errorf("have %s, want %s", have, want) - } - if have, want := b.String(), "world"; have != want { - t.Errorf("have %s, want %s", have, want) - } -} diff --git a/platform/blueprint/apply_blueprint.go b/platform/blueprint/apply_blueprint.go deleted file mode 100644 index 7060b08e..00000000 --- a/platform/blueprint/apply_blueprint.go +++ /dev/null @@ -1,54 +0,0 @@ -package blueprint - -import ( - "context" - "net/http" - - "github.com/go-kit/kit/endpoint" - "github.com/micromdm/micromdm/pkg/httputil" -) - -func (svc *BlueprintService) ApplyBlueprint(ctx context.Context, bp *Blueprint) error { - return svc.store.Save(bp) -} - -type applyBlueprintRequest struct { - Blueprint *Blueprint `json:"blueprint"` -} - -type applyBlueprintResponse struct { - Err error `json:"err,omitempty"` -} - -func (r applyBlueprintResponse) Failed() error { return r.Err } - -func decodeApplyBlueprintRequest(ctx context.Context, r *http.Request) (interface{}, error) { - var req applyBlueprintRequest - err := httputil.DecodeJSONRequest(r, &req) - return req, err -} - -func decodeApplyBlueprintResponse(_ context.Context, r *http.Response) (interface{}, error) { - var resp applyBlueprintResponse - err := httputil.DecodeJSONResponse(r, &resp) - return resp, err -} - -func MakeApplyBlueprintEndpoint(svc Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (response interface{}, err error) { - req := request.(applyBlueprintRequest) - err = svc.ApplyBlueprint(ctx, req.Blueprint) - return applyBlueprintResponse{ - Err: err, - }, nil - } -} - -func (e Endpoints) ApplyBlueprint(ctx context.Context, bp *Blueprint) error { - request := applyBlueprintRequest{Blueprint: bp} - resp, err := e.ApplyBlueprintEndpoint(ctx, request) - if err != nil { - return err - } - return resp.(applyBlueprintResponse).Err -} diff --git a/platform/blueprint/blueprint.go b/platform/blueprint/blueprint.go deleted file mode 100644 index c0088171..00000000 --- a/platform/blueprint/blueprint.go +++ /dev/null @@ -1,65 +0,0 @@ -package blueprint - -import ( - "errors" - - "github.com/gogo/protobuf/proto" - "github.com/micromdm/micromdm/platform/blueprint/internal/blueprintproto" -) - -// ApplyAt is a case-insensitive string that specifies at which point the -// system should apply a Blueprint to devices. For example if a Blueprint has -// an ApplyAt of "Enroll" then that profile will be applied immediately after -// a device's enrollment in the MDM system. Currently "Enroll" is the only -// supported value but more are planned. -const ( - ApplyAtEnroll string = "Enroll" -) - -type Blueprint struct { - UUID string `json:"uuid"` - Name string `json:"name"` - ApplicationURLs []string `json:"install_application_manifest_urls"` - ProfileIdentifiers []string `json:"profile_ids"` - UserUUID []string `json:"user_uuids"` - SkipPrimarySetupAccountCreation bool `json:"skip_primary_setup_account_creation"` - SetPrimarySetupAccountAsRegularUser bool `json:"set_primary_setup_account_as_regular_user"` - ApplyAt []string `json:"apply_at"` -} - -func (bp *Blueprint) Verify() error { - if bp.Name == "" || bp.UUID == "" { - return errors.New("Blueprint must have Name and UUID") - } - return nil -} - -func MarshalBlueprint(bp *Blueprint) ([]byte, error) { - protobp := blueprintproto.Blueprint{ - Uuid: bp.UUID, - Name: bp.Name, - ManifestUrls: bp.ApplicationURLs, - ProfileIds: bp.ProfileIdentifiers, - UserUuid: bp.UserUUID, - SkipPrimarySetupAccountCreation: bp.SkipPrimarySetupAccountCreation, - SetPrimarySetupAccountAsRegularUser: bp.SetPrimarySetupAccountAsRegularUser, - ApplyAt: bp.ApplyAt, - } - return proto.Marshal(&protobp) -} - -func UnmarshalBlueprint(data []byte, bp *Blueprint) error { - var pb blueprintproto.Blueprint - if err := proto.Unmarshal(data, &pb); err != nil { - return err - } - bp.UUID = pb.GetUuid() - bp.Name = pb.GetName() - bp.ApplicationURLs = pb.GetManifestUrls() - bp.ProfileIdentifiers = pb.GetProfileIds() - bp.ApplyAt = pb.GetApplyAt() - bp.UserUUID = pb.GetUserUuid() - bp.SkipPrimarySetupAccountCreation = pb.GetSkipPrimarySetupAccountCreation() - bp.SetPrimarySetupAccountAsRegularUser = pb.GetSetPrimarySetupAccountAsRegularUser() - return nil -} diff --git a/platform/blueprint/builtin/db.go b/platform/blueprint/builtin/db.go deleted file mode 100644 index 9edd54ed..00000000 --- a/platform/blueprint/builtin/db.go +++ /dev/null @@ -1,202 +0,0 @@ -package builtin - -import ( - "context" - "fmt" - "strings" - - "github.com/boltdb/bolt" - "github.com/pkg/errors" - - "github.com/micromdm/micromdm/platform/blueprint" - "github.com/micromdm/micromdm/platform/profile" -) - -const ( - BlueprintBucket = "mdm.Blueprint" - blueprintIndexBucket = "mdm.BlueprintIdx" -) - -type DB struct { - *bolt.DB - profDB profile.Store -} - -func NewDB( - db *bolt.DB, - profDB profile.Store, -) (*DB, error) { - err := db.Update(func(tx *bolt.Tx) error { - _, err := tx.CreateBucketIfNotExists([]byte(blueprintIndexBucket)) - if err != nil { - return err - } - _, err = tx.CreateBucketIfNotExists([]byte(BlueprintBucket)) - return err - }) - if err != nil { - return nil, errors.Wrapf(err, "creating %s bucket", BlueprintBucket) - } - datastore := &DB{ - DB: db, - profDB: profDB, - } - return datastore, nil -} - -func (db *DB) List() ([]blueprint.Blueprint, error) { - // TODO add filter/limit with ForEach - var blueprints []blueprint.Blueprint - err := db.View(func(tx *bolt.Tx) error { - b := tx.Bucket([]byte(BlueprintBucket)) - c := b.Cursor() - for k, v := c.First(); k != nil; k, v = c.Next() { - var bp blueprint.Blueprint - if err := blueprint.UnmarshalBlueprint(v, &bp); err != nil { - return err - } - blueprints = append(blueprints, bp) - } - return nil - }) - return blueprints, err -} - -func (db *DB) Save(bp *blueprint.Blueprint) error { - if bp == nil { - return errors.New("no blueprint supplied") - } - ctx := context.TODO() - err := bp.Verify() - if err != nil { - return err - } - check_bp, err := db.BlueprintByName(bp.Name) - if err != nil && !isNotFound(err) { - return err - } - if err == nil && bp.UUID != check_bp.UUID { - return fmt.Errorf("Blueprint not saved: same name %s exists", bp.Name) - } - // verify that each Profile ID represents a profile we know about - for _, p := range bp.ProfileIdentifiers { - if _, err := db.profDB.ProfileById(ctx, p); err != nil { - if profile.IsNotFound(err) { - return fmt.Errorf("Profile ID %s in Blueprint %s does not exist", p, bp.Name) - } - return errors.Wrap(err, "fetching profile") - } - } - tx, err := db.DB.Begin(true) - if err != nil { - return errors.Wrap(err, "begin transaction") - } - bkt := tx.Bucket([]byte(BlueprintBucket)) - if bkt == nil { - return fmt.Errorf("bucket %q not found!", BlueprintBucket) - } - bpproto, err := blueprint.MarshalBlueprint(bp) - if err != nil { - return errors.Wrap(err, "marshalling blueprint") - } - idxBucket := tx.Bucket([]byte(blueprintIndexBucket)) - if idxBucket == nil { - return fmt.Errorf("bucket %v not found!", idxBucket) - } - key := []byte(bp.Name) - if err := idxBucket.Put(key, []byte(bp.UUID)); err != nil { - return errors.Wrap(err, "put blueprint idx to boltdb") - } - - key = []byte(bp.UUID) - if err := bkt.Put(key, bpproto); err != nil { - return errors.Wrap(err, "put blueprint to boltdb") - } - return tx.Commit() -} - -func (db *DB) BlueprintByName(name string) (*blueprint.Blueprint, error) { - var bp blueprint.Blueprint - err := db.View(func(tx *bolt.Tx) error { - b := tx.Bucket([]byte(BlueprintBucket)) - ib := tx.Bucket([]byte(blueprintIndexBucket)) - idx := ib.Get([]byte(name)) - if idx == nil { - return ¬Found{"Blueprint", fmt.Sprintf("name %s", name)} - } - v := b.Get(idx) - if idx == nil { - return ¬Found{"Blueprint", fmt.Sprintf("uuid %s", string(idx))} - } - return blueprint.UnmarshalBlueprint(v, &bp) - }) - if err != nil { - return nil, err - } - return &bp, nil -} - -func (db *DB) BlueprintsByApplyAt(ctx context.Context, name string) ([]blueprint.Blueprint, error) { - var bps []blueprint.Blueprint - err := db.View(func(tx *bolt.Tx) error { - b := tx.Bucket([]byte(BlueprintBucket)) - c := b.Cursor() - // TODO: fix this to use an index of ApplyAt strings mapping to - // an array of Blueprints or other more efficient means. Looping - // over every blueprint is quite inefficient! - for k, v := c.First(); k != nil; k, v = c.Next() { - var bp blueprint.Blueprint - err := blueprint.UnmarshalBlueprint(v, &bp) - if err != nil { - fmt.Println("could not Unmarshal Blueprint") - continue - } - for _, n := range bp.ApplyAt { - if strings.ToLower(n) == strings.ToLower(name) { - bps = append(bps, bp) - break - } - } - } - return nil - }) - return bps, err -} - -func (db *DB) Delete(name string) error { - bp, err := db.BlueprintByName(name) - if err != nil { - return err - } - err = db.Update(func(tx *bolt.Tx) error { - // TODO: reformulate into a transaction? - b := tx.Bucket([]byte(BlueprintBucket)) - i := tx.Bucket([]byte(blueprintIndexBucket)) - err := i.Delete([]byte(bp.Name)) - if err != nil { - return err - } - err = b.Delete([]byte(bp.UUID)) - if err != nil { - return err - } - return nil - }) - return err -} - -type notFound struct { - ResourceType string - Message string -} - -func (e *notFound) Error() string { - return fmt.Sprintf("not found: %s %s", e.ResourceType, e.Message) -} - -func isNotFound(err error) bool { - if _, ok := err.(*notFound); ok { - return true - } - return false -} diff --git a/platform/blueprint/builtin/db_test.go b/platform/blueprint/builtin/db_test.go deleted file mode 100644 index 1b868bbe..00000000 --- a/platform/blueprint/builtin/db_test.go +++ /dev/null @@ -1,138 +0,0 @@ -package builtin - -import ( - "context" - "io/ioutil" - "os" - "testing" - - "github.com/boltdb/bolt" - "github.com/micromdm/micromdm/platform/blueprint" - profile "github.com/micromdm/micromdm/platform/profile/builtin" -) - -func TestSave(t *testing.T) { - db := setupDB(t) - bp := &blueprint.Blueprint{} - bp.ApplyAt = []string{"Enroll"} - - if err := db.Save(bp); err == nil { - t.Fatal("blueprints are required to have an UUID and Name") - } - - bp.UUID = "" - bp.Name = "blueprint" - if err := db.Save(bp); err == nil { - t.Fatal("blueprints are required to have an UUID") - } - - bp.UUID = "a-b-c-d" - bp.Name = "" - if err := db.Save(bp); err == nil { - t.Fatal("blueprints are required to have a Name") - } - - bp.UUID = "a-b-c-d" - bp.Name = "blueprint" - if err := db.Save(bp); err != nil { - t.Fatalf("saving blueprint in datastore: %s", err) - } - - bp.UUID = "e-f-g-h" - bp.Name = "blueprint" - if err := db.Save(bp); err == nil { - t.Fatal("blueprint names must be unique") - } - - bp.UUID = "e-f-g-h" - bp.Name = "blueprint2" - if err := db.Save(bp); err != nil { - t.Fatalf("saving blueprint2 in datastore: %s", err) - } - - byName, err := db.BlueprintByName("blueprint") - if err != nil { - t.Fatalf("getting blueprint by Name: %s", err) - } - if byName == nil || byName.UUID != "a-b-c-d" { - t.Fatalf("have %s, want %s", byName.UUID, "a-b-c-d") - } - - byApplyAt, err := db.BlueprintsByApplyAt(context.Background(), "Enroll") - if err != nil { - t.Fatalf("getting blueprint by ApplyAt: %s", err) - } - if len(byApplyAt) != 2 { - t.Fatalf("multiple blueprints not saved correctly") - } -} - -func TestList(t *testing.T) { - db := setupDB(t) - bp1 := &blueprint.Blueprint{ - UUID: "a-b-c-d", - Name: "blueprint-1", - } - bp2 := &blueprint.Blueprint{ - UUID: "e-f-g-h", - Name: "blueprint-2", - } - - if err := db.Save(bp1); err != nil { - t.Fatalf("saving blueprint-1 to datastore: %s", err) - } - - if err := db.Save(bp2); err != nil { - t.Fatalf("saving blueprint-2 to datastore: %s", err) - } - - bps, err := db.List() - if err != nil { - t.Fatalf("listing blueprints: %s", err) - } - if len(bps) != 2 { - t.Fatalf("expected %d, found %d", 2, len(bps)) - } -} - -func TestDelete(t *testing.T) { - db := setupDB(t) - bp1 := &blueprint.Blueprint{ - UUID: "a-b-c-d", - Name: "blueprint", - } - - if err := db.Save(bp1); err != nil { - t.Fatalf("saving blueprint to datastore: %s", err) - } - - if err := db.Delete("blueprint"); err != nil { - t.Fatalf("deleting blueprint in datastore: %s", err) - } - - _, err := db.BlueprintByName("blueprint") - if err == nil { - t.Fatalf("expected blueprint to be deleted: %s", err) - } -} - -func setupDB(t *testing.T) *DB { - f, _ := ioutil.TempFile("", "bolt-") - f.Close() - os.Remove(f.Name()) - - db, err := bolt.Open(f.Name(), 0777, nil) - if err != nil { - t.Fatalf("couldn't open bolt, err %s\n", err) - } - profileDB, err := profile.NewDB(db) - if err != nil { - t.Fatalf("couldn't create profile DB, err %s\n", err) - } - - blueprintDB, err := NewDB(db, profileDB) - if err != nil { - t.Fatalf("couldn't create blueprint DB, err %s\n", err) - } - return blueprintDB -} diff --git a/platform/blueprint/client.go b/platform/blueprint/client.go deleted file mode 100644 index e587667c..00000000 --- a/platform/blueprint/client.go +++ /dev/null @@ -1,56 +0,0 @@ -package blueprint - -import ( - "net/url" - - "github.com/go-kit/kit/endpoint" - "github.com/go-kit/kit/log" - httptransport "github.com/go-kit/kit/transport/http" - "github.com/micromdm/micromdm/pkg/httputil" -) - -func NewHTTPClient(instance, token string, logger log.Logger, opts ...httptransport.ClientOption) (Service, error) { - u, err := url.Parse(instance) - if err != nil { - return nil, err - } - - var applyBlueprintEndpoint endpoint.Endpoint - { - applyBlueprintEndpoint = httptransport.NewClient( - "PUT", - httputil.CopyURL(u, "/v1/blueprints"), - httputil.EncodeRequestWithToken(token, httptransport.EncodeJSONRequest), - decodeApplyBlueprintResponse, - opts..., - ).Endpoint() - } - - var getBlueprintsEndpoint endpoint.Endpoint - { - getBlueprintsEndpoint = httptransport.NewClient( - "POST", - httputil.CopyURL(u, "/v1/blueprints"), - httputil.EncodeRequestWithToken(token, httptransport.EncodeJSONRequest), - decodeGetBlueprintsResponse, - opts..., - ).Endpoint() - } - - var removeBlueprintsEndpoint endpoint.Endpoint - { - removeBlueprintsEndpoint = httptransport.NewClient( - "DELETE", - httputil.CopyURL(u, "/v1/blueprints"), - httputil.EncodeRequestWithToken(token, httptransport.EncodeJSONRequest), - decodeRemoveBlueprintsResponse, - opts..., - ).Endpoint() - } - - return Endpoints{ - ApplyBlueprintEndpoint: applyBlueprintEndpoint, - GetBlueprintsEndpoint: getBlueprintsEndpoint, - RemoveBlueprintsEndpoint: removeBlueprintsEndpoint, - }, nil -} diff --git a/platform/blueprint/get_blueprints.go b/platform/blueprint/get_blueprints.go deleted file mode 100644 index ea34bca1..00000000 --- a/platform/blueprint/get_blueprints.go +++ /dev/null @@ -1,71 +0,0 @@ -package blueprint - -import ( - "context" - "encoding/json" - "net/http" - - "github.com/go-kit/kit/endpoint" - "github.com/micromdm/micromdm/pkg/httputil" -) - -func (svc *BlueprintService) GetBlueprints(ctx context.Context, opt GetBlueprintsOption) ([]Blueprint, error) { - if opt.FilterName != "" { - bp, err := svc.store.BlueprintByName(opt.FilterName) - if err != nil { - return nil, err - } - return []Blueprint{*bp}, err - } else { - bps, err := svc.store.List() - if err != nil { - return nil, err - } - return bps, nil - } -} - -type getBlueprintsRequest struct{ Opts GetBlueprintsOption } -type getBlueprintsResponse struct { - Blueprints []Blueprint `json:"blueprints"` - Err error `json:"err,omitempty"` -} - -func (r getBlueprintsResponse) Failed() error { return r.Err } - -func decodeGetBlueprintsRequest(ctx context.Context, r *http.Request) (interface{}, error) { - var opts GetBlueprintsOption - if err := json.NewDecoder(r.Body).Decode(&opts); err != nil { - return nil, err - } - req := getBlueprintsRequest{ - Opts: opts, - } - return req, nil -} - -func decodeGetBlueprintsResponse(_ context.Context, r *http.Response) (interface{}, error) { - var resp getBlueprintsResponse - err := httputil.DecodeJSONResponse(r, &resp) - return resp, err -} - -func MakeGetBlueprintsEndpoint(svc Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (response interface{}, err error) { - req := request.(getBlueprintsRequest) - blueprints, err := svc.GetBlueprints(ctx, req.Opts) - return getBlueprintsResponse{ - Blueprints: blueprints, - Err: err, - }, nil - } -} - -func (e Endpoints) GetBlueprints(ctx context.Context, opt GetBlueprintsOption) ([]Blueprint, error) { - request := getBlueprintsRequest{opt} - response, err := e.GetBlueprintsEndpoint(ctx, request.Opts) - if err != nil { - return nil, err - } - return response.(getBlueprintsResponse).Blueprints, response.(getBlueprintsResponse).Err -} diff --git a/platform/blueprint/internal/blueprintproto/blueprint.go b/platform/blueprint/internal/blueprintproto/blueprint.go deleted file mode 100644 index 649272d8..00000000 --- a/platform/blueprint/internal/blueprintproto/blueprint.go +++ /dev/null @@ -1,3 +0,0 @@ -package blueprintproto - -//go:generate protoc --go_out=. blueprint.proto diff --git a/platform/blueprint/internal/blueprintproto/blueprint.pb.go b/platform/blueprint/internal/blueprintproto/blueprint.pb.go deleted file mode 100644 index 0e3c5d17..00000000 --- a/platform/blueprint/internal/blueprintproto/blueprint.pb.go +++ /dev/null @@ -1,128 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// source: blueprint.proto - -/* -Package blueprintproto is a generated protocol buffer package. - -It is generated from these files: - blueprint.proto - -It has these top-level messages: - Blueprint -*/ -package blueprintproto - -import proto "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package - -type Blueprint struct { - Uuid string `protobuf:"bytes,1,opt,name=uuid" json:"uuid,omitempty"` - Name string `protobuf:"bytes,2,opt,name=name" json:"name,omitempty"` - ManifestUrls []string `protobuf:"bytes,3,rep,name=manifest_urls,json=manifestUrls" json:"manifest_urls,omitempty"` - ProfileIds []string `protobuf:"bytes,5,rep,name=profile_ids,json=profileIds" json:"profile_ids,omitempty"` - ApplyAt []string `protobuf:"bytes,6,rep,name=apply_at,json=applyAt" json:"apply_at,omitempty"` - UserUuid []string `protobuf:"bytes,7,rep,name=user_uuid,json=userUuid" json:"user_uuid,omitempty"` - SkipPrimarySetupAccountCreation bool `protobuf:"varint,8,opt,name=skip_primary_setup_account_creation,json=skipPrimarySetupAccountCreation" json:"skip_primary_setup_account_creation,omitempty"` - SetPrimarySetupAccountAsRegularUser bool `protobuf:"varint,9,opt,name=set_primary_setup_account_as_regular_user,json=setPrimarySetupAccountAsRegularUser" json:"set_primary_setup_account_as_regular_user,omitempty"` -} - -func (m *Blueprint) Reset() { *m = Blueprint{} } -func (m *Blueprint) String() string { return proto.CompactTextString(m) } -func (*Blueprint) ProtoMessage() {} -func (*Blueprint) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } - -func (m *Blueprint) GetUuid() string { - if m != nil { - return m.Uuid - } - return "" -} - -func (m *Blueprint) GetName() string { - if m != nil { - return m.Name - } - return "" -} - -func (m *Blueprint) GetManifestUrls() []string { - if m != nil { - return m.ManifestUrls - } - return nil -} - -func (m *Blueprint) GetProfileIds() []string { - if m != nil { - return m.ProfileIds - } - return nil -} - -func (m *Blueprint) GetApplyAt() []string { - if m != nil { - return m.ApplyAt - } - return nil -} - -func (m *Blueprint) GetUserUuid() []string { - if m != nil { - return m.UserUuid - } - return nil -} - -func (m *Blueprint) GetSkipPrimarySetupAccountCreation() bool { - if m != nil { - return m.SkipPrimarySetupAccountCreation - } - return false -} - -func (m *Blueprint) GetSetPrimarySetupAccountAsRegularUser() bool { - if m != nil { - return m.SetPrimarySetupAccountAsRegularUser - } - return false -} - -func init() { - proto.RegisterType((*Blueprint)(nil), "blueprintproto.Blueprint") -} - -func init() { proto.RegisterFile("blueprint.proto", fileDescriptor0) } - -var fileDescriptor0 = []byte{ - // 282 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x90, 0xbd, 0x4e, 0x2b, 0x31, - 0x10, 0x85, 0x95, 0xff, 0x5d, 0xdf, 0x1b, 0x40, 0xae, 0x8c, 0x28, 0x12, 0x91, 0x26, 0x34, 0x34, - 0x3c, 0x41, 0xa0, 0x02, 0x51, 0xa0, 0x45, 0xa1, 0xb5, 0xbc, 0xbb, 0xb3, 0x91, 0x85, 0xd7, 0xb6, - 0x66, 0xec, 0x22, 0xef, 0xcc, 0x43, 0x20, 0x7b, 0x13, 0x2a, 0xe8, 0x66, 0xbe, 0xf9, 0x74, 0x7c, - 0x64, 0x76, 0x59, 0x9b, 0x08, 0x1e, 0xb5, 0x0d, 0xf7, 0x1e, 0x5d, 0x70, 0xfc, 0xe2, 0x07, 0xe4, - 0xfd, 0xf6, 0x6b, 0xcc, 0xca, 0xc7, 0x33, 0xe2, 0x9c, 0x4d, 0x63, 0xd4, 0xad, 0x18, 0xad, 0x47, - 0xdb, 0xb2, 0xca, 0x73, 0x62, 0x56, 0xf5, 0x20, 0xc6, 0x03, 0x4b, 0x33, 0xdf, 0xb0, 0x65, 0xaf, - 0xac, 0xee, 0x80, 0x82, 0x8c, 0x68, 0x48, 0x4c, 0xd6, 0x93, 0x6d, 0x59, 0xfd, 0x3f, 0xc3, 0x3d, - 0x1a, 0xe2, 0x2b, 0xf6, 0xcf, 0xa3, 0xeb, 0xb4, 0x01, 0xa9, 0x5b, 0x12, 0xb3, 0xac, 0xb0, 0x13, - 0x7a, 0x6e, 0x89, 0x5f, 0xb3, 0x42, 0x79, 0x6f, 0x8e, 0x52, 0x05, 0x31, 0xcf, 0xd7, 0x45, 0xde, - 0x77, 0x81, 0xdf, 0xb0, 0x32, 0x12, 0xa0, 0xcc, 0x6d, 0x16, 0xf9, 0x56, 0x24, 0xb0, 0x4f, 0x8d, - 0x5e, 0xd9, 0x86, 0x3e, 0xb5, 0x97, 0x1e, 0x75, 0xaf, 0xf0, 0x28, 0x09, 0x42, 0xf4, 0x52, 0x35, - 0x8d, 0x8b, 0x36, 0xc8, 0x06, 0x41, 0x05, 0xed, 0xac, 0x28, 0xd6, 0xa3, 0x6d, 0x51, 0xad, 0x92, - 0xfa, 0x36, 0x98, 0xef, 0x49, 0xdc, 0x0d, 0xde, 0xd3, 0x49, 0xe3, 0x1f, 0xec, 0x8e, 0x20, 0xfc, - 0x11, 0xa6, 0x48, 0x22, 0x1c, 0xa2, 0x51, 0x28, 0xd3, 0xf3, 0xa2, 0xcc, 0x99, 0x1b, 0x82, 0xf0, - 0x4b, 0xe4, 0x8e, 0xaa, 0xc1, 0xdd, 0x13, 0xe0, 0xcb, 0xb4, 0x98, 0x5e, 0xcd, 0xaa, 0x65, 0xef, - 0x6a, 0x6d, 0xa0, 0x71, 0xb6, 0xd3, 0x07, 0xaa, 0xe7, 0xf9, 0xd7, 0x1f, 0xbe, 0x03, 0x00, 0x00, - 0xff, 0xff, 0x22, 0x48, 0x96, 0x88, 0x98, 0x01, 0x00, 0x00, -} diff --git a/platform/blueprint/internal/blueprintproto/blueprint.proto b/platform/blueprint/internal/blueprintproto/blueprint.proto deleted file mode 100644 index 8ef1dcc0..00000000 --- a/platform/blueprint/internal/blueprintproto/blueprint.proto +++ /dev/null @@ -1,17 +0,0 @@ -syntax = "proto3"; - -package blueprintproto; - -message Blueprint { - reserved 4; - reserved "mobileconfigs"; - - string uuid = 1; - string name = 2; - repeated string manifest_urls = 3; - repeated string profile_ids = 5; - repeated string apply_at = 6; - repeated string user_uuid = 7; - bool skip_primary_setup_account_creation= 8 ; - bool set_primary_setup_account_as_regular_user = 9; -} diff --git a/platform/blueprint/remove_blueprints.go b/platform/blueprint/remove_blueprints.go deleted file mode 100644 index 622527c8..00000000 --- a/platform/blueprint/remove_blueprints.go +++ /dev/null @@ -1,60 +0,0 @@ -package blueprint - -import ( - "context" - "net/http" - - "github.com/go-kit/kit/endpoint" - "github.com/micromdm/micromdm/pkg/httputil" -) - -func (svc *BlueprintService) RemoveBlueprints(ctx context.Context, names []string) error { - for _, name := range names { - err := svc.store.Delete(name) - if err != nil { - return err - } - } - return nil -} - -type removeBlueprintsRequest struct { - Names []string `json:"names"` -} - -type removeBlueprintsResponse struct { - Err error `json:"err,omitempty"` -} - -func (r removeBlueprintsResponse) Failed() error { return r.Err } - -func decodeRemoveBlueprintsRequest(ctx context.Context, r *http.Request) (interface{}, error) { - var req removeBlueprintsRequest - err := httputil.DecodeJSONRequest(r, &req) - return req, err -} - -func decodeRemoveBlueprintsResponse(_ context.Context, r *http.Response) (interface{}, error) { - var resp removeBlueprintsResponse - err := httputil.DecodeJSONResponse(r, &resp) - return resp, err -} - -func MakeRemoveBlueprintsEndpoint(svc Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (response interface{}, err error) { - req := request.(removeBlueprintsRequest) - err = svc.RemoveBlueprints(ctx, req.Names) - return removeBlueprintsResponse{ - Err: err, - }, nil - } -} - -func (e Endpoints) RemoveBlueprints(ctx context.Context, names []string) error { - request := removeBlueprintsRequest{Names: names} - resp, err := e.RemoveBlueprintsEndpoint(ctx, request) - if err != nil { - return err - } - return resp.(removeBlueprintsResponse).Err -} diff --git a/platform/blueprint/server.go b/platform/blueprint/server.go deleted file mode 100644 index cbda7337..00000000 --- a/platform/blueprint/server.go +++ /dev/null @@ -1,49 +0,0 @@ -package blueprint - -import ( - "github.com/go-kit/kit/endpoint" - httptransport "github.com/go-kit/kit/transport/http" - "github.com/gorilla/mux" - "github.com/micromdm/micromdm/pkg/httputil" -) - -type Endpoints struct { - ApplyBlueprintEndpoint endpoint.Endpoint - GetBlueprintsEndpoint endpoint.Endpoint - RemoveBlueprintsEndpoint endpoint.Endpoint -} - -func MakeServerEndpoints(s Service, outer endpoint.Middleware, others ...endpoint.Middleware) Endpoints { - return Endpoints{ - GetBlueprintsEndpoint: endpoint.Chain(outer, others...)(MakeGetBlueprintsEndpoint(s)), - ApplyBlueprintEndpoint: endpoint.Chain(outer, others...)(MakeApplyBlueprintEndpoint(s)), - RemoveBlueprintsEndpoint: endpoint.Chain(outer, others...)(MakeRemoveBlueprintsEndpoint(s)), - } -} - -func RegisterHTTPHandlers(r *mux.Router, e Endpoints, options ...httptransport.ServerOption) { - // PUT /v1/blueprints create or replace a blueprint on the server - // POST /v1/blueprints get a list of blueprints managed by the server - // DELETE /v1/blueprints remove one or more blueprints from the server - - r.Methods("PUT").Path("/v1/blueprints").Handler(httptransport.NewServer( - e.ApplyBlueprintEndpoint, - decodeApplyBlueprintRequest, - httputil.EncodeJSONResponse, - options..., - )) - - r.Methods("POST").Path("/v1/blueprints").Handler(httptransport.NewServer( - e.GetBlueprintsEndpoint, - decodeGetBlueprintsRequest, - httputil.EncodeJSONResponse, - options..., - )) - - r.Methods("DELETE").Path("/v1/blueprints").Handler(httptransport.NewServer( - e.RemoveBlueprintsEndpoint, - decodeRemoveBlueprintsRequest, - httputil.EncodeJSONResponse, - options..., - )) -} diff --git a/platform/blueprint/service.go b/platform/blueprint/service.go deleted file mode 100644 index f16c61f5..00000000 --- a/platform/blueprint/service.go +++ /dev/null @@ -1,30 +0,0 @@ -package blueprint - -import ( - "context" -) - -type GetBlueprintsOption struct { - FilterName string -} - -type Service interface { - ApplyBlueprint(ctx context.Context, bp *Blueprint) error - GetBlueprints(ctx context.Context, opt GetBlueprintsOption) ([]Blueprint, error) - RemoveBlueprints(ctx context.Context, names []string) error -} - -type Store interface { - Save(*Blueprint) error - BlueprintByName(name string) (*Blueprint, error) - List() ([]Blueprint, error) - Delete(string) error -} - -type BlueprintService struct { - store Store -} - -func New(store Store) *BlueprintService { - return &BlueprintService{store: store} -} diff --git a/platform/blueprint/worker.go b/platform/blueprint/worker.go deleted file mode 100644 index 05d0fb45..00000000 --- a/platform/blueprint/worker.go +++ /dev/null @@ -1,254 +0,0 @@ -package blueprint - -import ( - "context" - - "github.com/go-kit/kit/log" - "github.com/go-kit/kit/log/level" - "github.com/pkg/errors" - - mdmsvc "github.com/micromdm/micromdm/mdm" - "github.com/micromdm/micromdm/mdm/mdm" - "github.com/micromdm/micromdm/platform/command" - "github.com/micromdm/micromdm/platform/device" - "github.com/micromdm/micromdm/platform/profile" - "github.com/micromdm/micromdm/platform/pubsub" - "github.com/micromdm/micromdm/platform/user" -) - -type BlueprintWorkerStore interface { - BlueprintsByApplyAt(ctx context.Context, action string) ([]Blueprint, error) -} - -type UserStore interface { - User(ctx context.Context, uuid string) (*user.User, error) -} - -type ProfileStore interface { - ProfileById(ctx context.Context, id string) (*profile.Profile, error) -} - -func NewWorker( - db BlueprintWorkerStore, - userDB UserStore, - profileDB ProfileStore, - cmdsvc command.Service, - sub pubsub.Subscriber, - logger log.Logger, -) *Worker { - return &Worker{ - db: db, - userDB: userDB, - profileDB: profileDB, - ps: sub, - cmdsvc: cmdsvc, - logger: logger, - } -} - -type Worker struct { - db BlueprintWorkerStore - userDB UserStore - profileDB ProfileStore - ps pubsub.Subscriber - cmdsvc command.Service - logger log.Logger -} - -func (w *Worker) Run(ctx context.Context) error { - tokenUpdateEvents, err := w.ps.Subscribe(ctx, "applyAtEnroll", device.DeviceEnrolledTopic) - if err != nil { - return errors.Wrapf(err, "subscribing devices to %s topic", device.DeviceEnrolledTopic) - } - - for { - var err error - select { - case <-ctx.Done(): - return ctx.Err() - case ev := <-tokenUpdateEvents: - err = w.handleTokenUpdateEvent(ctx, ev.Message) - } - - if err != nil { - level.Info(w.logger).Log( - "msg", "handle blueprint action", - "err", err, - ) - continue - } - - } -} - -// TODO: See notes from here: -// https://github.com/jessepeterson/micromdm/blob/8b068ac98d06954bb3e08b1557c193007932552b/blueprint/listener.go#L73-L103 -// Also see discussion here for general direction: -// https://github.com/micromdm/micromdm/pull/149 -// Finally see discussion here for high-level goals: -// https://github.com/micromdm/micromdm/issues/110 -func (w *Worker) handleTokenUpdateEvent(ctx context.Context, message []byte) error { - var ev mdmsvc.CheckinEvent - if err := mdmsvc.UnmarshalCheckinEvent(message, &ev); err != nil { - return errors.Wrap(err, "unmarshal checkin event") - } - if ev.Command.UserID != "" { - level.Debug(w.logger).Log( - "msg", "skipping user token update in blueprint worker.", - "device_udid", ev.Command.UDID, - "user_id", ev.Command.UserID, - ) - // skip UserID token updates - return nil - } - - bps, err := w.db.BlueprintsByApplyAt(ctx, ApplyAtEnroll) - if err != nil { - return errors.Wrap(err, "get blueprints by ApplyAtEnroll") - } - - // if there are no blueprints exit early. This will ensure that DeviceConfigured is not sent. - if len(bps) == 0 { - level.Debug(w.logger).Log( - "msg", "no blueprints to apply", - "device_udid", ev.Command.UDID, - ) - return nil - } - - for _, bp := range bps { - level.Debug(w.logger).Log( - "msg", "applying blueprint", - "device_udid", ev.Command.UDID, - "blueprint_name", bp.Name, - ) - - if err := w.applyToDevice(ctx, bp, ev.Command.UDID); err != nil { - return errors.Wrapf(err, "apply blueprint to udid name=%s, udid=%s", bp.Name, ev.Command.UDID) - } - } - - if ev.Command.AwaitingConfiguration { - level.Debug(w.logger).Log( - "msg", "sending DeviceConfigured at the end of blueprint", - "device_udid", ev.Command.UDID, - ) - _, err := w.cmdsvc.NewCommand(ctx, &mdm.CommandRequest{ - Command: &mdm.Command{RequestType: "DeviceConfigured"}, - UDID: ev.Command.UDID, - }) - if err != nil { - return errors.Wrap(err, "send DeviceConfigured") - } - } - - return nil - -} - -func (w *Worker) applyToDevice(ctx context.Context, bp Blueprint, udid string) error { - var requests []*mdm.CommandRequest - for _, uuid := range bp.UserUUID { - level.Debug(w.logger).Log( - "msg", "creating mdm command request from blueprint", - "request_type", "AccountConfiguration", - "blueprint_name", bp.Name, - "user_uuid", uuid, - "device_udid", udid, - ) - - usr, err := w.userDB.User(ctx, uuid) - if err != nil { - level.Info(w.logger).Log( - "msg", "get user for AccountConfiguration request", - "blueprint_name", bp.Name, - "user_uuid", uuid, - "device_udid", udid, - "err", err, - ) - continue - } - - requests = append(requests, &mdm.CommandRequest{ - UDID: udid, - Command: &mdm.Command{ - RequestType: "AccountConfiguration", - AccountConfiguration: &mdm.AccountConfiguration{ - SkipPrimarySetupAccountCreation: bp.SkipPrimarySetupAccountCreation, - SetPrimarySetupAccountAsRegularUser: bp.SetPrimarySetupAccountAsRegularUser, - AutoSetupAdminAccounts: []mdm.AdminAccount{ - { - ShortName: usr.UserShortname, - FullName: usr.UserLongname, - PasswordHash: usr.PasswordHash, - Hidden: usr.Hidden, - }, - }, - }, - }, - }) - } - - for _, appURL := range bp.ApplicationURLs { - level.Debug(w.logger).Log( - "msg", "creating mdm command request from blueprint", - "request_type", "InstallApplication", - "blueprint_name", bp.Name, - "manifest_url", appURL, - "device_udid", udid, - ) - - requests = append(requests, &mdm.CommandRequest{ - UDID: udid, - Command: &mdm.Command{ - RequestType: "InstallApplication", - InstallApplication: &mdm.InstallApplication{ - ManifestURL: &appURL, - ManagementFlags: intPtr(1), - }, - }, - }) - } - - for _, pid := range bp.ProfileIdentifiers { - level.Debug(w.logger).Log( - "msg", "creating mdm command request from blueprint", - "request_type", "InstallProfile", - "blueprint_name", bp.Name, - "profile_identifier", pid, - "device_udid", udid, - ) - foundProfile, err := w.profileDB.ProfileById(ctx, pid) - if err != nil { - level.Info(w.logger).Log( - "msg", "retrieve profile from db", - "blueprint_name", bp.Name, - "profile_identifier", pid, - "is_not_found_err", profile.IsNotFound(err), - "err", err, - ) - continue - } - - requests = append(requests, &mdm.CommandRequest{ - UDID: udid, - Command: &mdm.Command{ - RequestType: "InstallProfile", - InstallProfile: &mdm.InstallProfile{ - Payload: foundProfile.Mobileconfig, - }, - }, - }) - } - - for _, r := range requests { - if _, err := w.cmdsvc.NewCommand(ctx, r); err != nil { - return errors.Wrap(err, "create new command from blueprint") - } - } - return nil -} - -func intPtr(i int) *int { - return &i -} diff --git a/platform/challenge/challenge.go b/platform/challenge/challenge.go deleted file mode 100644 index 565c7e25..00000000 --- a/platform/challenge/challenge.go +++ /dev/null @@ -1,22 +0,0 @@ -package challenge - -import ( - "context" - - "github.com/go-kit/kit/endpoint" -) - -type challengeResponse struct { - Challenge string `json:"string"` - Err error `json:"err,omitempty"` -} - -func (r challengeResponse) Failed() error { return r.Err } - -func MakeChallengeEndpoint(svc Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (response interface{}, err error) { - r := challengeResponse{} - r.Challenge, r.Err = svc.SCEPChallenge(ctx) - return r, nil - } -} diff --git a/platform/challenge/server.go b/platform/challenge/server.go deleted file mode 100644 index 324df967..00000000 --- a/platform/challenge/server.go +++ /dev/null @@ -1,36 +0,0 @@ -package challenge - -import ( - "context" - "net/http" - - "github.com/go-kit/kit/endpoint" - httptransport "github.com/go-kit/kit/transport/http" - "github.com/gorilla/mux" - "github.com/micromdm/micromdm/pkg/httputil" -) - -type Endpoints struct { - ChallengeEndpoint endpoint.Endpoint -} - -func MakeServerEndpoints(s Service, outer endpoint.Middleware, others ...endpoint.Middleware) Endpoints { - return Endpoints{ - ChallengeEndpoint: endpoint.Chain(outer, others...)(MakeChallengeEndpoint(s)), - } -} - -func RegisterHTTPHandlers(r *mux.Router, e Endpoints, options ...httptransport.ServerOption) { - // POST /v1/challenge Generate and return SCEP challenge - - r.Methods("POST").Path("/v1/challenge").Handler(httptransport.NewServer( - e.ChallengeEndpoint, - decodeEmptyRequest, - httputil.EncodeJSONResponse, - options..., - )) -} - -func decodeEmptyRequest(ctx context.Context, r *http.Request) (interface{}, error) { - return nil, nil -} diff --git a/platform/challenge/service.go b/platform/challenge/service.go deleted file mode 100644 index 50098af8..00000000 --- a/platform/challenge/service.go +++ /dev/null @@ -1,29 +0,0 @@ -package challenge - -import ( - "context" - "errors" - - challengestore "github.com/micromdm/scep/challenge/bolt" -) - -type Service interface { - SCEPChallenge(ctx context.Context) (string, error) -} - -type ChallengeService struct { - scepChallengeStore *challengestore.Depot -} - -func (c *ChallengeService) SCEPChallenge(ctx context.Context) (string, error) { - if c.scepChallengeStore == nil { - return "", errors.New("SCEP challenge store missing") - } - return c.scepChallengeStore.SCEPChallenge() -} - -func NewService(cs *challengestore.Depot) *ChallengeService { - return &ChallengeService{ - scepChallengeStore: cs, - } -} diff --git a/platform/command/event.go b/platform/command/event.go deleted file mode 100644 index 9c7ace35..00000000 --- a/platform/command/event.go +++ /dev/null @@ -1,63 +0,0 @@ -package command - -import ( - "time" - - "github.com/gogo/protobuf/proto" - "github.com/google/uuid" - "github.com/pkg/errors" - - "github.com/micromdm/micromdm/mdm/mdm" - "github.com/micromdm/micromdm/platform/command/internal/commandproto" -) - -type Event struct { - ID string - Time time.Time - Payload *mdm.CommandPayload - DeviceUDID string -} - -// NewEvent returns an Event with a unique ID and the current time. -func NewEvent(payload *mdm.CommandPayload, udid string) *Event { - event := Event{ - ID: uuid.New().String(), - Time: time.Now().UTC(), - Payload: payload, - DeviceUDID: udid, - } - return &event -} - -// MarshalEvent serializes an event to a protocol buffer wire format. -func MarshalEvent(e *Event) ([]byte, error) { - payloadBytes, err := mdm.MarshalCommandPayload(e.Payload) - if err != nil { - return nil, err - } - return proto.Marshal(&commandproto.Event{ - Id: e.ID, - Time: e.Time.UnixNano(), - PayloadBytes: payloadBytes, - DeviceUdid: e.DeviceUDID, - }) - -} - -// UnmarshalEvent parses a protocol buffer representation of data into -// the Event. -func UnmarshalEvent(data []byte, e *Event) error { - var pb commandproto.Event - if err := proto.Unmarshal(data, &pb); err != nil { - return errors.Wrap(err, "unmarshal pb Event") - } - var payload mdm.CommandPayload - if err := mdm.UnmarshalCommandPayload(pb.PayloadBytes, &payload); err != nil { - return err - } - e.ID = pb.Id - e.DeviceUDID = pb.DeviceUdid - e.Time = time.Unix(0, pb.Time).UTC() - e.Payload = &payload - return nil -} diff --git a/platform/command/internal/commandproto/command.go b/platform/command/internal/commandproto/command.go deleted file mode 100644 index 98a7c62d..00000000 --- a/platform/command/internal/commandproto/command.go +++ /dev/null @@ -1,3 +0,0 @@ -package commandproto - -//go:generate protoc command.proto -I. --gofast_out=. diff --git a/platform/command/internal/commandproto/command.pb.go b/platform/command/internal/commandproto/command.pb.go deleted file mode 100644 index eaa8b663..00000000 --- a/platform/command/internal/commandproto/command.pb.go +++ /dev/null @@ -1,437 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: command.proto - -/* - Package commandproto is a generated protocol buffer package. - - It is generated from these files: - command.proto - - It has these top-level messages: - Event -*/ -package commandproto - -import proto "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" - -import io "io" - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package - -type Event struct { - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Time int64 `protobuf:"varint,2,opt,name=time,proto3" json:"time,omitempty"` - DeviceUdid string `protobuf:"bytes,4,opt,name=device_udid,json=deviceUdid,proto3" json:"device_udid,omitempty"` - PayloadBytes []byte `protobuf:"bytes,5,opt,name=payload_bytes,json=payloadBytes,proto3" json:"payload_bytes,omitempty"` -} - -func (m *Event) Reset() { *m = Event{} } -func (m *Event) String() string { return proto.CompactTextString(m) } -func (*Event) ProtoMessage() {} -func (*Event) Descriptor() ([]byte, []int) { return fileDescriptorCommand, []int{0} } - -func (m *Event) GetId() string { - if m != nil { - return m.Id - } - return "" -} - -func (m *Event) GetTime() int64 { - if m != nil { - return m.Time - } - return 0 -} - -func (m *Event) GetDeviceUdid() string { - if m != nil { - return m.DeviceUdid - } - return "" -} - -func (m *Event) GetPayloadBytes() []byte { - if m != nil { - return m.PayloadBytes - } - return nil -} - -func init() { - proto.RegisterType((*Event)(nil), "commandproto.Event") -} -func (m *Event) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Event) MarshalTo(dAtA []byte) (int, error) { - var i int - _ = i - var l int - _ = l - if len(m.Id) > 0 { - dAtA[i] = 0xa - i++ - i = encodeVarintCommand(dAtA, i, uint64(len(m.Id))) - i += copy(dAtA[i:], m.Id) - } - if m.Time != 0 { - dAtA[i] = 0x10 - i++ - i = encodeVarintCommand(dAtA, i, uint64(m.Time)) - } - if len(m.DeviceUdid) > 0 { - dAtA[i] = 0x22 - i++ - i = encodeVarintCommand(dAtA, i, uint64(len(m.DeviceUdid))) - i += copy(dAtA[i:], m.DeviceUdid) - } - if len(m.PayloadBytes) > 0 { - dAtA[i] = 0x2a - i++ - i = encodeVarintCommand(dAtA, i, uint64(len(m.PayloadBytes))) - i += copy(dAtA[i:], m.PayloadBytes) - } - return i, nil -} - -func encodeVarintCommand(dAtA []byte, offset int, v uint64) int { - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return offset + 1 -} -func (m *Event) Size() (n int) { - var l int - _ = l - l = len(m.Id) - if l > 0 { - n += 1 + l + sovCommand(uint64(l)) - } - if m.Time != 0 { - n += 1 + sovCommand(uint64(m.Time)) - } - l = len(m.DeviceUdid) - if l > 0 { - n += 1 + l + sovCommand(uint64(l)) - } - l = len(m.PayloadBytes) - if l > 0 { - n += 1 + l + sovCommand(uint64(l)) - } - return n -} - -func sovCommand(x uint64) (n int) { - for { - n++ - x >>= 7 - if x == 0 { - break - } - } - return n -} -func sozCommand(x uint64) (n int) { - return sovCommand(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *Event) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommand - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Event: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Event: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommand - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthCommand - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Id = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Time", wireType) - } - m.Time = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommand - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Time |= (int64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DeviceUdid", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommand - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthCommand - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.DeviceUdid = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PayloadBytes", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCommand - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthCommand - } - postIndex := iNdEx + byteLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.PayloadBytes = append(m.PayloadBytes[:0], dAtA[iNdEx:postIndex]...) - if m.PayloadBytes == nil { - m.PayloadBytes = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipCommand(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthCommand - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipCommand(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowCommand - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowCommand - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - return iNdEx, nil - case 1: - iNdEx += 8 - return iNdEx, nil - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowCommand - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - iNdEx += length - if length < 0 { - return 0, ErrInvalidLengthCommand - } - return iNdEx, nil - case 3: - for { - var innerWire uint64 - var start int = iNdEx - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowCommand - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - innerWire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - innerWireType := int(innerWire & 0x7) - if innerWireType == 4 { - break - } - next, err := skipCommand(dAtA[start:]) - if err != nil { - return 0, err - } - iNdEx = start + next - } - return iNdEx, nil - case 4: - return iNdEx, nil - case 5: - iNdEx += 4 - return iNdEx, nil - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - } - panic("unreachable") -} - -var ( - ErrInvalidLengthCommand = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowCommand = fmt.Errorf("proto: integer overflow") -) - -func init() { proto.RegisterFile("command.proto", fileDescriptorCommand) } - -var fileDescriptorCommand = []byte{ - // 166 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x4d, 0xce, 0xcf, 0xcd, - 0x4d, 0xcc, 0x4b, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x81, 0x72, 0xc1, 0x3c, 0xa5, - 0x42, 0x2e, 0x56, 0xd7, 0xb2, 0xd4, 0xbc, 0x12, 0x21, 0x3e, 0x2e, 0xa6, 0xcc, 0x14, 0x09, 0x46, - 0x05, 0x46, 0x0d, 0xce, 0x20, 0xa6, 0xcc, 0x14, 0x21, 0x21, 0x2e, 0x96, 0x92, 0xcc, 0xdc, 0x54, - 0x09, 0x26, 0x05, 0x46, 0x0d, 0xe6, 0x20, 0x30, 0x5b, 0x48, 0x9e, 0x8b, 0x3b, 0x25, 0xb5, 0x2c, - 0x33, 0x39, 0x35, 0xbe, 0x34, 0x25, 0x33, 0x45, 0x82, 0x05, 0xac, 0x98, 0x0b, 0x22, 0x14, 0x9a, - 0x92, 0x99, 0x22, 0xa4, 0xcc, 0xc5, 0x5b, 0x90, 0x58, 0x99, 0x93, 0x9f, 0x98, 0x12, 0x9f, 0x54, - 0x59, 0x92, 0x5a, 0x2c, 0xc1, 0xaa, 0xc0, 0xa8, 0xc1, 0x13, 0xc4, 0x03, 0x15, 0x74, 0x02, 0x89, - 0x39, 0x09, 0x9c, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x33, - 0x1e, 0xcb, 0x31, 0x24, 0xb1, 0x81, 0xdd, 0x62, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0xb5, 0xca, - 0xac, 0xde, 0xaa, 0x00, 0x00, 0x00, -} diff --git a/platform/command/internal/commandproto/command.proto b/platform/command/internal/commandproto/command.proto deleted file mode 100644 index b7343968..00000000 --- a/platform/command/internal/commandproto/command.proto +++ /dev/null @@ -1,10 +0,0 @@ -syntax = "proto3"; - -package commandproto; - -message Event { - string id = 1; - int64 time = 2; - string device_udid = 4; - bytes payload_bytes = 5; -} diff --git a/platform/command/new_command.go b/platform/command/new_command.go deleted file mode 100644 index 6d880e59..00000000 --- a/platform/command/new_command.go +++ /dev/null @@ -1,71 +0,0 @@ -package command - -import ( - "net/http" - - "github.com/go-kit/kit/endpoint" - "github.com/pkg/errors" - "golang.org/x/net/context" - - "github.com/micromdm/micromdm/mdm/mdm" - "github.com/micromdm/micromdm/pkg/httputil" -) - -const ( - // CommandTopic is a PubSub topic that events are published to. - CommandTopic = "mdm.Command" -) - -func (svc *CommandService) NewCommand(ctx context.Context, request *mdm.CommandRequest) (*mdm.CommandPayload, error) { - if request == nil { - return nil, errors.New("empty CommandRequest") - } - payload, err := mdm.NewCommandPayload(request) - if err != nil { - return nil, errors.Wrap(err, "creating mdm payload") - } - event := NewEvent(payload, request.UDID) - msg, err := MarshalEvent(event) - if err != nil { - return nil, errors.Wrap(err, "marshalling mdm command event") - } - if err := svc.publisher.Publish(context.TODO(), CommandTopic, msg); err != nil { - return nil, errors.Wrapf(err, "publish mdm command on topic: %s", CommandTopic) - } - return payload, nil -} - -type newCommandRequest struct { - mdm.CommandRequest -} - -type newCommandResponse struct { - Payload *mdm.CommandPayload `json:"payload,omitempty"` - Err error `json:"error,omitempty"` -} - -func (r newCommandResponse) Failed() error { return r.Err } -func (r newCommandResponse) StatusCode() int { return http.StatusCreated } - -func decodeNewCommandRequest(ctx context.Context, r *http.Request) (interface{}, error) { - var req newCommandRequest - err := httputil.DecodeJSONRequest(r, &req) - return req, err -} - -var errEmptyRequest = errors.New("request must contain UDID of the device") - -// MakeNewCommandEndpoint creates an endpoint which creates new MDM Commands. -func MakeNewCommandEndpoint(svc Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (interface{}, error) { - req := request.(newCommandRequest) - if req.UDID == "" || req.RequestType == "" { - return newCommandResponse{Err: errEmptyRequest}, nil - } - payload, err := svc.NewCommand(ctx, &req.CommandRequest) - if err != nil { - return newCommandResponse{Err: err}, nil - } - return newCommandResponse{Payload: payload}, nil - } -} diff --git a/platform/command/server.go b/platform/command/server.go deleted file mode 100644 index ff6a63fd..00000000 --- a/platform/command/server.go +++ /dev/null @@ -1,29 +0,0 @@ -package command - -import ( - "github.com/go-kit/kit/endpoint" - httptransport "github.com/go-kit/kit/transport/http" - "github.com/gorilla/mux" - "github.com/micromdm/micromdm/pkg/httputil" -) - -type Endpoints struct { - NewCommandEndpoint endpoint.Endpoint -} - -func MakeServerEndpoints(s Service, outer endpoint.Middleware, others ...endpoint.Middleware) Endpoints { - return Endpoints{ - NewCommandEndpoint: endpoint.Chain(outer, others...)(MakeNewCommandEndpoint(s)), - } -} - -func RegisterHTTPHandlers(r *mux.Router, e Endpoints, options ...httptransport.ServerOption) { - // POST /v1/commands Add new MDM Command to device queue. - - r.Methods("POST").Path("/v1/commands").Handler(httptransport.NewServer( - e.NewCommandEndpoint, - decodeNewCommandRequest, - httputil.EncodeJSONResponse, - options..., - )) -} diff --git a/platform/command/service.go b/platform/command/service.go deleted file mode 100644 index cf297432..00000000 --- a/platform/command/service.go +++ /dev/null @@ -1,23 +0,0 @@ -// Package command provides utilities for creating MDM Payloads. -package command - -import ( - "github.com/micromdm/micromdm/mdm/mdm" - "github.com/micromdm/micromdm/platform/pubsub" - "golang.org/x/net/context" -) - -type Service interface { - NewCommand(context.Context, *mdm.CommandRequest) (*mdm.CommandPayload, error) -} - -type CommandService struct { - publisher pubsub.Publisher -} - -func New(pub pubsub.Publisher) (*CommandService, error) { - svc := CommandService{ - publisher: pub, - } - return &svc, nil -} diff --git a/platform/config/apply_deptoken.go b/platform/config/apply_deptoken.go deleted file mode 100644 index 92c7e65d..00000000 --- a/platform/config/apply_deptoken.go +++ /dev/null @@ -1,127 +0,0 @@ -package config - -import ( - "bufio" - "bytes" - "context" - "encoding/base64" - "encoding/json" - "fmt" - "io" - "net/http" - "net/textproto" - - "github.com/fullsailor/pkcs7" - "github.com/go-kit/kit/endpoint" - "github.com/micromdm/micromdm/pkg/httputil" -) - -func (svc *ConfigService) ApplyDEPToken(ctx context.Context, P7MContent []byte) error { - unwrapped, err := unwrapSMIME(P7MContent) - if err != nil { - return err - } - key, cert, err := svc.store.DEPKeypair() - if err != nil { - return err - } - p7, err := pkcs7.Parse(unwrapped) - if err != nil { - return err - } - decrypted, err := p7.Decrypt(cert, key) - if err != nil { - return err - } - tokenJSON, err := unwrapTokenJSON(decrypted) - if err != nil { - return err - } - var depToken DEPToken - err = json.Unmarshal(tokenJSON, &depToken) - if err != nil { - return err - } - err = svc.store.AddToken(depToken.ConsumerKey, tokenJSON) - if err != nil { - return err - } - fmt.Println("stored DEP token with ck", depToken.ConsumerKey) - return nil -} - -type applyDEPTokenRequest struct { - P7MContent []byte `json:"p7m_content"` -} - -type applyDEPTokenResponse struct { - Err error `json:"err,omitempty"` -} - -func (r applyDEPTokenResponse) Failed() error { return r.Err } - -func decodeApplyDEPTokensRequest(ctx context.Context, r *http.Request) (interface{}, error) { - var req applyDEPTokenRequest - err := httputil.DecodeJSONRequest(r, &req) - return req, err -} - -func decodeApplyDEPTokensResponse(_ context.Context, r *http.Response) (interface{}, error) { - var resp applyDEPTokenResponse - err := httputil.DecodeJSONResponse(r, &resp) - return resp, err -} - -func MakeApplyDEPTokensEndpoint(svc Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (response interface{}, err error) { - req := request.(applyDEPTokenRequest) - err = svc.ApplyDEPToken(ctx, req.P7MContent) - return applyDEPTokenResponse{ - Err: err, - }, nil - } -} - -func (e Endpoints) ApplyDEPToken(ctx context.Context, P7MContent []byte) error { - req := applyDEPTokenRequest{P7MContent: P7MContent} - resp, err := e.ApplyDEPTokensEndpoint(ctx, req) - if err != nil { - return err - } - return resp.(applyDEPTokenResponse).Err -} - -// unwrapSMIME removes the S/MIME-like wrapper around raw CMS/PKCS7 data -func unwrapSMIME(smime []byte) ([]byte, error) { - tr := textproto.NewReader(bufio.NewReader(bytes.NewReader(smime))) - if _, err := tr.ReadMIMEHeader(); err != nil { - return nil, err - } - dec := base64.NewDecoder(base64.StdEncoding, tr.DotReader()) - buf := new(bytes.Buffer) - io.Copy(buf, dec) - return buf.Bytes(), nil -} - -// unwrapTokenJSON removes the MIME-like headers and text surrounding the DEP token JSON -func unwrapTokenJSON(wrapped []byte) ([]byte, error) { - tr := textproto.NewReader(bufio.NewReader(bytes.NewReader(wrapped))) - if _, err := tr.ReadMIMEHeader(); err != nil { - return nil, err - } - tokenJSON := new(bytes.Buffer) - for { - line, err := tr.ReadLineBytes() - if err != nil && err == io.EOF { - break - } else if err != nil { - return nil, err - } - line = bytes.Trim(line, "-----BEGIN MESSAGE-----") - line = bytes.Trim(line, "-----END MESSAGE-----") - if _, err := tokenJSON.Write(line); err != nil { - return nil, err - } - } - return tokenJSON.Bytes(), nil -} diff --git a/platform/config/builtin/db.go b/platform/config/builtin/db.go deleted file mode 100644 index 6b19c4d7..00000000 --- a/platform/config/builtin/db.go +++ /dev/null @@ -1,143 +0,0 @@ -package builtin - -import ( - "context" - "crypto/tls" - "crypto/x509" - "encoding/pem" - "fmt" - - "github.com/boltdb/bolt" - "github.com/pkg/errors" - - "github.com/micromdm/micromdm/pkg/crypto" - "github.com/micromdm/micromdm/platform/config" - "github.com/micromdm/micromdm/platform/pubsub" -) - -const ( - ConfigBucket = "mdm.ServerConfig" -) - -// DB stores server configuration in BoltDB -type DB struct { - *bolt.DB - Publisher pubsub.Publisher -} - -func NewDB(db *bolt.DB, pub pubsub.Publisher) (*DB, error) { - err := db.Update(func(tx *bolt.Tx) error { - _, err := tx.CreateBucketIfNotExists([]byte(ConfigBucket)) - return err - }) - store := &DB{DB: db, Publisher: pub} - return store, err -} - -func (db *DB) SavePushCertificate(cert, key []byte) error { - tx, err := db.DB.Begin(true) - if err != nil { - return errors.Wrap(err, "begin transaction to store push certificate in bolt") - } - bkt := tx.Bucket([]byte(ConfigBucket)) - if bkt == nil { - return fmt.Errorf("config: bucket %q not found", ConfigBucket) - } - pb, err := config.MarshalServerConfig(&config.ServerConfig{ - PushCertificate: cert, - PrivateKey: key, - }) - if err != nil { - return errors.Wrap(err, "save push cert in bolt bucket") - } - - if err := bkt.Put([]byte("config"), pb); err != nil { - return errors.Wrap(err, "save ServerConfig in bucket") - } - if err = tx.Commit(); err != nil { - return err - } - - if err := db.Publisher.Publish(context.TODO(), config.ConfigTopic, []byte("updated")); err != nil { - return err - } - return err -} - -func (db *DB) serverConfig() (*config.ServerConfig, error) { - var conf config.ServerConfig - err := db.View(func(tx *bolt.Tx) error { - bkt := tx.Bucket([]byte(ConfigBucket)) - data := bkt.Get([]byte("config")) - if data == nil { - return ¬Found{"ServerConfig", "no config found in boltdb"} - } - return config.UnmarshalServerConfig(data, &conf) - }) - return &conf, errors.Wrap(err, "get server config from bolt") -} - -func (db *DB) GetPushCertificate() ([]byte, error) { - cert, err := db.PushCertificate() - if err != nil { - return nil, err - } - if len(cert.Certificate) > 0 { - return cert.Certificate[0], nil - } - return nil, nil -} - -func (db *DB) PushCertificate() (*tls.Certificate, error) { - conf, err := db.serverConfig() - if err != nil { - return nil, errors.Wrap(err, "get server config for push cert") - } - - // load private key - pkeyBlock, _ := pem.Decode(conf.PrivateKey) - if pkeyBlock == nil { - return nil, errors.New("decode private key for push cert") - } - - priv, err := x509.ParsePKCS1PrivateKey(pkeyBlock.Bytes) - if err != nil { - return nil, errors.Wrap(err, "parse push certificate key from server config") - } - - // load certificate - certBlock, _ := pem.Decode(conf.PushCertificate) - if certBlock == nil { - return nil, errors.New("decode push certificate PEM") - } - - pushCert, err := x509.ParseCertificate(certBlock.Bytes) - if err != nil { - return nil, errors.Wrap(err, "parse push certificate from server config") - } - - cert := tls.Certificate{ - Certificate: [][]byte{pushCert.Raw}, - PrivateKey: priv, - Leaf: pushCert, - } - return &cert, nil -} - -func (db *DB) PushTopic() (string, error) { - cert, err := db.PushCertificate() - if err != nil { - return "", errors.Wrap(err, "get push certificate for topic") - } - topic, err := crypto.TopicFromCert(cert.Leaf) - return topic, errors.Wrap(err, "get topic from push certificate") -} - -type notFound struct { - ResourceType string - Message string -} - -func (e *notFound) Error() string { - return fmt.Sprintf("not found: %s %s", e.ResourceType, e.Message) -} diff --git a/platform/config/builtin/db_deptoken.go b/platform/config/builtin/db_deptoken.go deleted file mode 100644 index e368a874..00000000 --- a/platform/config/builtin/db_deptoken.go +++ /dev/null @@ -1,127 +0,0 @@ -package builtin - -import ( - "bytes" - "context" - "crypto/rsa" - "crypto/x509" - "encoding/json" - - "github.com/boltdb/bolt" - "github.com/micromdm/micromdm/pkg/crypto" - "github.com/micromdm/micromdm/platform/config" -) - -const ( - depTokenBucket = "mdm.DEPToken" -) - -func (db *DB) AddToken(consumerKey string, json []byte) error { - err := db.Update(func(tx *bolt.Tx) error { - b, err := tx.CreateBucketIfNotExists([]byte(depTokenBucket)) - if err != nil { - return err - } - err = b.Put([]byte("last_added"), []byte(consumerKey)) - if err != nil { - return err - } - return b.Put([]byte(consumerKey), json) - }) - if err != nil { - return err - } - err = db.Publisher.Publish(context.TODO(), config.DEPTokenTopic, json) - return err -} - -func (db *DB) DEPTokens() ([]config.DEPToken, error) { - var result []config.DEPToken - var lastAdded string - err := db.View(func(tx *bolt.Tx) error { - b := tx.Bucket([]byte(depTokenBucket)) - if b == nil { - return nil - } - lastAdded = string(b.Get([]byte("last_added"))) - c := b.Cursor() - - prefix := []byte("CK_") - for k, v := c.Seek(prefix); k != nil && bytes.HasPrefix(k, prefix); k, v = c.Next() { - var depToken config.DEPToken - err := json.Unmarshal(v, &depToken) - if err != nil { - // TODO: log problematic DEP token, or remove altogether? - continue - } - if lastAdded == depToken.ConsumerKey { - // the server merely takes the first DEP token. let's - // make sure the most recent one is the one that's - // returned first - result = append([]config.DEPToken{depToken}, result...) - } else { - result = append(result, depToken) - } - } - return nil - }) - return result, err -} - -func (db *DB) DEPKeypair() (key *rsa.PrivateKey, cert *x509.Certificate, err error) { - var keyBytes, certBytes []byte - err = db.View(func(tx *bolt.Tx) error { - b := tx.Bucket([]byte(depTokenBucket)) - if b == nil { - return nil - } - keyBytes = b.Get([]byte("key")) - certBytes = b.Get([]byte("certificate")) - return nil - }) - if err != nil { - return - } - if keyBytes == nil || certBytes == nil { - // if there is no certificate or private key then generate - key, cert, err = generateAndStoreDEPKeypair(db) - } else { - key, err = x509.ParsePKCS1PrivateKey(keyBytes) - if err != nil { - return - } - cert, err = x509.ParseCertificate(certBytes) - if err != nil { - return - } - } - return -} - -func generateAndStoreDEPKeypair(db *DB) (key *rsa.PrivateKey, cert *x509.Certificate, err error) { - key, cert, err = crypto.SimpleSelfSignedRSAKeypair("micromdm-dep-token", 365) - if err != nil { - return - } - - pkBytes := x509.MarshalPKCS1PrivateKey(key) - certBytes := cert.Raw - - err = db.Update(func(tx *bolt.Tx) error { - b, err := tx.CreateBucketIfNotExists([]byte(depTokenBucket)) - if err != nil { - return err - } - err = b.Put([]byte("key"), pkBytes) - if err != nil { - return err - } - err = b.Put([]byte("certificate"), certBytes) - if err != nil { - return err - } - return nil - }) - - return -} diff --git a/platform/config/client.go b/platform/config/client.go deleted file mode 100644 index 3367544e..00000000 --- a/platform/config/client.go +++ /dev/null @@ -1,56 +0,0 @@ -package config - -import ( - "net/url" - - "github.com/go-kit/kit/endpoint" - "github.com/go-kit/kit/log" - httptransport "github.com/go-kit/kit/transport/http" - "github.com/micromdm/micromdm/pkg/httputil" -) - -func NewHTTPClient(instance, token string, logger log.Logger, opts ...httptransport.ClientOption) (Service, error) { - u, err := url.Parse(instance) - if err != nil { - return nil, err - } - - var saveEndpoint endpoint.Endpoint - { - saveEndpoint = httptransport.NewClient( - "PUT", - httputil.CopyURL(u, "/v1/config/certificate"), - httputil.EncodeRequestWithToken(token, httptransport.EncodeJSONRequest), - decodeSavePushCertificateResponse, - opts..., - ).Endpoint() - } - - var applyDEPTokensEndpoint endpoint.Endpoint - { - applyDEPTokensEndpoint = httptransport.NewClient( - "PUT", - httputil.CopyURL(u, "/v1/dep-tokens"), - httputil.EncodeRequestWithToken(token, httptransport.EncodeJSONRequest), - decodeApplyDEPTokensResponse, - opts..., - ).Endpoint() - } - - var getDEPTokensEndpoint endpoint.Endpoint - { - getDEPTokensEndpoint = httptransport.NewClient( - "GET", - httputil.CopyURL(u, "/v1/dep-tokens"), - httputil.EncodeRequestWithToken(token, httptransport.EncodeJSONRequest), - decodeGetDEPTokensResponse, - opts..., - ).Endpoint() - } - - return Endpoints{ - SavePushCertificateEndpoint: saveEndpoint, - ApplyDEPTokensEndpoint: applyDEPTokensEndpoint, - GetDEPTokensEndpoint: getDEPTokensEndpoint, - }, nil -} diff --git a/platform/config/config.go b/platform/config/config.go deleted file mode 100644 index 8830b5c4..00000000 --- a/platform/config/config.go +++ /dev/null @@ -1,35 +0,0 @@ -package config - -import ( - "github.com/gogo/protobuf/proto" - "github.com/pkg/errors" - - "github.com/micromdm/micromdm/platform/config/internal/configproto" -) - -const ConfigTopic = "mdm.ServerConfigUpdated" - -// ServerConfig holds the configuration of the MDM Server. -type ServerConfig struct { - PushCertificate []byte - PrivateKey []byte -} - -func MarshalServerConfig(conf *ServerConfig) ([]byte, error) { - pb := configproto.ServerConfig{ - PushCertificate: conf.PushCertificate, - PushCertificateKey: conf.PrivateKey, - } - data, err := proto.Marshal(&pb) - return data, errors.Wrap(err, "marshal server config to proto") -} - -func UnmarshalServerConfig(data []byte, conf *ServerConfig) error { - var pb configproto.ServerConfig - if err := proto.Unmarshal(data, &pb); err != nil { - return errors.Wrap(err, "unmarshal server config from proto") - } - conf.PushCertificate = pb.GetPushCertificate() - conf.PrivateKey = pb.GetPushCertificateKey() - return nil -} diff --git a/platform/config/deptoken.go b/platform/config/deptoken.go deleted file mode 100644 index b19a38fd..00000000 --- a/platform/config/deptoken.go +++ /dev/null @@ -1,29 +0,0 @@ -package config - -import ( - "time" - - "github.com/micromdm/micromdm/dep" -) - -const DEPTokenTopic = "mdm.TokenAdded" - -type DEPToken struct { - ConsumerKey string `json:"consumer_key"` - ConsumerSecret string `json:"consumer_secret"` - AccessToken string `json:"access_token"` - AccessSecret string `json:"access_secret"` - AccessTokenExpiry time.Time `json:"access_token_expiry"` -} - -// create a DEP client from token. -func (tok DEPToken) Client() (*dep.Client, error) { - conf := dep.OAuthParameters{ - ConsumerKey: tok.ConsumerKey, - ConsumerSecret: tok.ConsumerSecret, - AccessSecret: tok.AccessSecret, - AccessToken: tok.AccessToken, - } - client := dep.NewClient(conf) - return client, nil -} diff --git a/platform/config/get_deptoken.go b/platform/config/get_deptoken.go deleted file mode 100644 index 2cb690bb..00000000 --- a/platform/config/get_deptoken.go +++ /dev/null @@ -1,64 +0,0 @@ -package config - -import ( - "context" - "net/http" - - "github.com/go-kit/kit/endpoint" - "github.com/micromdm/micromdm/pkg/httputil" -) - -func (svc *ConfigService) GetDEPTokens(ctx context.Context) ([]DEPToken, []byte, error) { - _, cert, err := svc.store.DEPKeypair() - if err != nil { - return nil, nil, err - } - var certBytes []byte - if cert != nil { - certBytes = cert.Raw - } - - tokens, err := svc.store.DEPTokens() - if err != nil { - return nil, certBytes, err - } - - return tokens, certBytes, nil -} - -type getDEPTokenResponse struct { - DEPTokens []DEPToken `json:"dep_tokens"` - DEPPubKey []byte `json:"public_key"` - Err error `json:"err,omitempty"` -} - -func (r getDEPTokenResponse) Failed() error { return r.Err } - -func decodeGetDEPTokensRequest(ctx context.Context, r *http.Request) (interface{}, error) { - return nil, nil -} - -func decodeGetDEPTokensResponse(_ context.Context, r *http.Response) (interface{}, error) { - var resp getDEPTokenResponse - err := httputil.DecodeJSONResponse(r, &resp) - return resp, err -} - -func MakeGetDEPTokensEndpoint(svc Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (response interface{}, err error) { - tokens, pubkey, err := svc.GetDEPTokens(ctx) - return getDEPTokenResponse{ - DEPTokens: tokens, - DEPPubKey: pubkey, - Err: err, - }, nil - } -} - -func (e Endpoints) GetDEPTokens(ctx context.Context) ([]DEPToken, []byte, error) { - resp, err := e.GetDEPTokensEndpoint(ctx, nil) - if err != nil { - return nil, nil, err - } - return resp.(getDEPTokenResponse).DEPTokens, resp.(getDEPTokenResponse).DEPPubKey, nil -} diff --git a/platform/config/get_push_certificate.go b/platform/config/get_push_certificate.go deleted file mode 100644 index c825bfec..00000000 --- a/platform/config/get_push_certificate.go +++ /dev/null @@ -1,51 +0,0 @@ -package config - -import ( - "context" - "net/http" - - "github.com/go-kit/kit/endpoint" - "github.com/micromdm/micromdm/pkg/httputil" - "github.com/pkg/errors" -) - -func (svc *ConfigService) GetPushCertificate(ctx context.Context) ([]byte, error) { - cert, err := svc.store.GetPushCertificate() - if err != nil { - return cert, errors.Wrap(err, "get push certificate") - } - return cert, nil -} - -type getResponse struct { - Cert []byte `json:"cert"` - Err error `json:"err,omitempty"` -} - -func (r getResponse) Failed() error { return r.Err } - -func decodeGetPushCertificateRequest(ctx context.Context, r *http.Request) (interface{}, error) { - return nil, nil -} - -func decodeGetPushCertificateResponse(_ context.Context, r *http.Response) (interface{}, error) { - var resp getResponse - err := httputil.DecodeJSONResponse(r, &resp) - return resp, err -} - -func MakeGetPushCertificateEndpoint(svc Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (response interface{}, err error) { - cert, err := svc.GetPushCertificate(ctx) - return getResponse{Err: err, Cert: cert}, nil - } -} - -func (e Endpoints) GetPushCertificate(ctx context.Context) ([]byte, error) { - response, err := e.GetPushCertificateEndpoint(ctx, nil) - if err != nil { - return nil, err - } - - return response.(getResponse).Cert, response.(getResponse).Err -} diff --git a/platform/config/internal/configproto/config.go b/platform/config/internal/configproto/config.go deleted file mode 100644 index a814ca24..00000000 --- a/platform/config/internal/configproto/config.go +++ /dev/null @@ -1,3 +0,0 @@ -package configproto - -//go:generate protoc --go_out=. config.proto diff --git a/platform/config/internal/configproto/config.pb.go b/platform/config/internal/configproto/config.pb.go deleted file mode 100644 index 806ce106..00000000 --- a/platform/config/internal/configproto/config.pb.go +++ /dev/null @@ -1,70 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// source: config.proto - -/* -Package configproto is a generated protocol buffer package. - -It is generated from these files: - config.proto - -It has these top-level messages: - ServerConfig -*/ -package configproto - -import proto "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package - -type ServerConfig struct { - PushCertificate []byte `protobuf:"bytes,1,opt,name=push_certificate,json=pushCertificate,proto3" json:"push_certificate,omitempty"` - PushCertificateKey []byte `protobuf:"bytes,2,opt,name=push_certificate_key,json=pushCertificateKey,proto3" json:"push_certificate_key,omitempty"` -} - -func (m *ServerConfig) Reset() { *m = ServerConfig{} } -func (m *ServerConfig) String() string { return proto.CompactTextString(m) } -func (*ServerConfig) ProtoMessage() {} -func (*ServerConfig) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } - -func (m *ServerConfig) GetPushCertificate() []byte { - if m != nil { - return m.PushCertificate - } - return nil -} - -func (m *ServerConfig) GetPushCertificateKey() []byte { - if m != nil { - return m.PushCertificateKey - } - return nil -} - -func init() { - proto.RegisterType((*ServerConfig)(nil), "configproto.ServerConfig") -} - -func init() { proto.RegisterFile("config.proto", fileDescriptor0) } - -var fileDescriptor0 = []byte{ - // 115 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x49, 0xce, 0xcf, 0x4b, - 0xcb, 0x4c, 0xd7, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x86, 0xf0, 0xc0, 0x1c, 0xa5, 0x6c, - 0x2e, 0x9e, 0xe0, 0xd4, 0xa2, 0xb2, 0xd4, 0x22, 0x67, 0xb0, 0xa0, 0x90, 0x26, 0x97, 0x40, 0x41, - 0x69, 0x71, 0x46, 0x7c, 0x72, 0x6a, 0x51, 0x49, 0x66, 0x5a, 0x66, 0x72, 0x62, 0x49, 0xaa, 0x04, - 0xa3, 0x02, 0xa3, 0x06, 0x4f, 0x10, 0x3f, 0x48, 0xdc, 0x19, 0x21, 0x2c, 0x64, 0xc0, 0x25, 0x82, - 0xae, 0x34, 0x3e, 0x3b, 0xb5, 0x52, 0x82, 0x09, 0xac, 0x5c, 0x08, 0x4d, 0xb9, 0x77, 0x6a, 0x65, - 0x12, 0x1b, 0xd8, 0x4e, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0xea, 0xa7, 0xb0, 0xbc, 0x90, - 0x00, 0x00, 0x00, -} diff --git a/platform/config/internal/configproto/config.proto b/platform/config/internal/configproto/config.proto deleted file mode 100644 index d5a2ed1d..00000000 --- a/platform/config/internal/configproto/config.proto +++ /dev/null @@ -1,9 +0,0 @@ -syntax = "proto3"; - -package configproto; - -message ServerConfig { - bytes push_certificate = 1; - bytes push_certificate_key = 2; -} - diff --git a/platform/config/save_push_certificate.go b/platform/config/save_push_certificate.go deleted file mode 100644 index 6e47f5f8..00000000 --- a/platform/config/save_push_certificate.go +++ /dev/null @@ -1,60 +0,0 @@ -package config - -import ( - "context" - "net/http" - - "github.com/go-kit/kit/endpoint" - "github.com/micromdm/micromdm/pkg/httputil" - "github.com/pkg/errors" -) - -func (svc *ConfigService) SavePushCertificate(ctx context.Context, cert, key []byte) error { - err := svc.store.SavePushCertificate(cert, key) - return errors.Wrap(err, "save push certificate") -} - -type saveRequest struct { - Cert []byte `json:"cert"` - Key []byte `json:"key"` -} - -type saveResponse struct { - Err error `json:"err,omitempty"` -} - -func (r saveResponse) Failed() error { return r.Err } - -func decodeSavePushCertificateRequest(ctx context.Context, r *http.Request) (interface{}, error) { - var req saveRequest - err := httputil.DecodeJSONRequest(r, &req) - return req, err -} - -func decodeSavePushCertificateResponse(_ context.Context, r *http.Response) (interface{}, error) { - var resp saveResponse - err := httputil.DecodeJSONResponse(r, &resp) - return resp, err -} - -func MakeSavePushCertificateEndpoint(svc Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (response interface{}, err error) { - req := request.(saveRequest) - err = svc.SavePushCertificate(ctx, req.Cert, req.Key) - return saveResponse{Err: err}, nil - } -} - -func (e Endpoints) SavePushCertificate(ctx context.Context, cert, key []byte) error { - request := saveRequest{ - Cert: cert, - Key: key, - } - - response, err := e.SavePushCertificateEndpoint(ctx, request) - if err != nil { - return err - } - - return response.(saveResponse).Err -} diff --git a/platform/config/server.go b/platform/config/server.go deleted file mode 100644 index 2b79320a..00000000 --- a/platform/config/server.go +++ /dev/null @@ -1,59 +0,0 @@ -package config - -import ( - "github.com/go-kit/kit/endpoint" - httptransport "github.com/go-kit/kit/transport/http" - "github.com/gorilla/mux" - "github.com/micromdm/micromdm/pkg/httputil" -) - -type Endpoints struct { - SavePushCertificateEndpoint endpoint.Endpoint - GetPushCertificateEndpoint endpoint.Endpoint - ApplyDEPTokensEndpoint endpoint.Endpoint - GetDEPTokensEndpoint endpoint.Endpoint -} - -func MakeServerEndpoints(s Service, outer endpoint.Middleware, others ...endpoint.Middleware) Endpoints { - return Endpoints{ - SavePushCertificateEndpoint: endpoint.Chain(outer, others...)(MakeSavePushCertificateEndpoint(s)), - GetPushCertificateEndpoint: endpoint.Chain(outer, others...)(MakeGetPushCertificateEndpoint(s)), - ApplyDEPTokensEndpoint: endpoint.Chain(outer, others...)(MakeApplyDEPTokensEndpoint(s)), - GetDEPTokensEndpoint: endpoint.Chain(outer, others...)(MakeGetDEPTokensEndpoint(s)), - } -} - -func RegisterHTTPHandlers(r *mux.Router, e Endpoints, options ...httptransport.ServerOption) { - // PUT /v1/config/certificate create or replace the MDM Push Certificate - // GET /v1/config/certificate retrieve the MDM Push Certificate - // PUT /v1/dep-tokens create or replace a DEP OAuth token - // GET /v1/dep-tokens get the OAuth Token used for the DEP client - - r.Methods("PUT").Path("/v1/config/certificate").Handler(httptransport.NewServer( - e.SavePushCertificateEndpoint, - decodeSavePushCertificateRequest, - httputil.EncodeJSONResponse, - options..., - )) - - r.Methods("GET").Path("/v1/config/certificate").Handler(httptransport.NewServer( - e.GetPushCertificateEndpoint, - decodeGetPushCertificateRequest, - httputil.EncodeJSONResponse, - options..., - )) - - r.Methods("PUT").Path("/v1/dep-tokens").Handler(httptransport.NewServer( - e.ApplyDEPTokensEndpoint, - decodeApplyDEPTokensRequest, - httputil.EncodeJSONResponse, - options..., - )) - - r.Methods("GET").Path("/v1/dep-tokens").Handler(httptransport.NewServer( - e.GetDEPTokensEndpoint, - decodeGetDEPTokensRequest, - httputil.EncodeJSONResponse, - options..., - )) -} diff --git a/platform/config/service.go b/platform/config/service.go deleted file mode 100644 index cb763988..00000000 --- a/platform/config/service.go +++ /dev/null @@ -1,33 +0,0 @@ -package config - -import ( - "context" - "crypto/rsa" - "crypto/tls" - "crypto/x509" -) - -type Service interface { - SavePushCertificate(ctx context.Context, cert, key []byte) error - GetPushCertificate(ctx context.Context) ([]byte, error) - ApplyDEPToken(ctx context.Context, P7MContent []byte) error - GetDEPTokens(ctx context.Context) ([]DEPToken, []byte, error) -} - -type Store interface { - SavePushCertificate(cert, key []byte) error - GetPushCertificate() ([]byte, error) - PushCertificate() (*tls.Certificate, error) - PushTopic() (string, error) - DEPKeypair() (key *rsa.PrivateKey, cert *x509.Certificate, err error) - AddToken(consumerKey string, json []byte) error - DEPTokens() ([]DEPToken, error) -} - -type ConfigService struct { - store Store -} - -func New(store Store) *ConfigService { - return &ConfigService{store: store} -} diff --git a/platform/dep/assign_profile.go b/platform/dep/assign_profile.go deleted file mode 100644 index 7e8d88af..00000000 --- a/platform/dep/assign_profile.go +++ /dev/null @@ -1,64 +0,0 @@ -package dep - -import ( - "context" - "errors" - "net/http" - - "github.com/go-kit/kit/endpoint" - - "github.com/micromdm/micromdm/dep" - "github.com/micromdm/micromdm/pkg/httputil" -) - -func (svc *DEPService) AssignProfile(ctx context.Context, id string, serials ...string) (*dep.ProfileResponse, error) { - if svc.client == nil { - return nil, errors.New("DEP not configured yet. add a DEP token to enable DEP") - } - return svc.client.AssignProfile(id, serials...) -} - -type assignProfileRequest struct { - ID string `json:"id"` - Serials []string `json:"serials"` -} - -type assignProfileResponse struct { - *dep.ProfileResponse - Err error `json:"err,omitempty"` -} - -func (r assignProfileResponse) Failed() error { return r.Err } - -func decodeAssignProfileRequest(ctx context.Context, r *http.Request) (interface{}, error) { - var req assignProfileRequest - err := httputil.DecodeJSONRequest(r, &req) - return req, err -} - -func decodeAssignProfileResponse(_ context.Context, r *http.Response) (interface{}, error) { - var resp assignProfileResponse - err := httputil.DecodeJSONResponse(r, &resp) - return resp, err -} - -func MakeAssignProfileEndpoint(svc Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (response interface{}, err error) { - req := request.(assignProfileRequest) - resp, err := svc.AssignProfile(ctx, req.ID, req.Serials...) - return &assignProfileResponse{ - ProfileResponse: resp, - Err: err, - }, nil - } -} - -func (e Endpoints) AssignProfile(ctx context.Context, id string, serials ...string) (*dep.ProfileResponse, error) { - request := assignProfileRequest{ID: id, Serials: serials} - resp, err := e.AssignProfileEndpoint(ctx, request) - if err != nil { - return nil, err - } - response := resp.(assignProfileResponse) - return response.ProfileResponse, response.Err -} diff --git a/platform/dep/client.go b/platform/dep/client.go deleted file mode 100644 index d45fdb71..00000000 --- a/platform/dep/client.go +++ /dev/null @@ -1,81 +0,0 @@ -package dep - -import ( - "net/url" - - "github.com/go-kit/kit/endpoint" - "github.com/go-kit/kit/log" - httptransport "github.com/go-kit/kit/transport/http" - - "github.com/micromdm/micromdm/pkg/httputil" -) - -func NewHTTPClient(instance, token string, logger log.Logger, opts ...httptransport.ClientOption) (Service, error) { - u, err := url.Parse(instance) - if err != nil { - return nil, err - } - - var defineProfileEndpoint endpoint.Endpoint - { - defineProfileEndpoint = httptransport.NewClient( - "PUT", - httputil.CopyURL(u, "/v1/dep/profiles"), - httputil.EncodeRequestWithToken(token, httptransport.EncodeJSONRequest), - decodeDefineProfileResponse, - opts..., - ).Endpoint() - } - - var assignProfileEndpoint endpoint.Endpoint - { - assignProfileEndpoint = httptransport.NewClient( - "POST", - httputil.CopyURL(u, "/v1/dep/assign"), - httputil.EncodeRequestWithToken(token, httptransport.EncodeJSONRequest), - decodeAssignProfileResponse, - opts..., - ).Endpoint() - } - - var fetchProfileEndpoint endpoint.Endpoint - { - fetchProfileEndpoint = httptransport.NewClient( - "POST", - httputil.CopyURL(u, "/v1/dep/profiles"), - httputil.EncodeRequestWithToken(token, httptransport.EncodeJSONRequest), - decodeFetchProfileResponse, - opts..., - ).Endpoint() - } - - var getAccountInfoEndpoint endpoint.Endpoint - { - getAccountInfoEndpoint = httptransport.NewClient( - "GET", - httputil.CopyURL(u, "/v1/dep/account"), - httputil.EncodeRequestWithToken(token, httptransport.EncodeJSONRequest), - decodeGetAccountInfoResponse, - opts..., - ).Endpoint() - } - - var getDeviceDetailsEndpoint endpoint.Endpoint - { - getDeviceDetailsEndpoint = httptransport.NewClient( - "POST", - httputil.CopyURL(u, "/v1/dep/devices"), - httputil.EncodeRequestWithToken(token, httptransport.EncodeJSONRequest), - decodeDeviceDetailsResponse, - opts..., - ).Endpoint() - } - - return Endpoints{ - DefineProfileEndpoint: defineProfileEndpoint, - AssignProfileEndpoint: assignProfileEndpoint, - FetchProfileEndpoint: fetchProfileEndpoint, - GetAccountInfoEndpoint: getAccountInfoEndpoint, - GetDeviceDetailsEndpoint: getDeviceDetailsEndpoint, - }, nil -} diff --git a/platform/dep/define_profile.go b/platform/dep/define_profile.go deleted file mode 100644 index 50d3cdc8..00000000 --- a/platform/dep/define_profile.go +++ /dev/null @@ -1,60 +0,0 @@ -package dep - -import ( - "context" - "errors" - "net/http" - - "github.com/go-kit/kit/endpoint" - - "github.com/micromdm/micromdm/dep" - "github.com/micromdm/micromdm/pkg/httputil" -) - -func (svc *DEPService) DefineProfile(ctx context.Context, p *dep.Profile) (*dep.ProfileResponse, error) { - if svc.client == nil { - return nil, errors.New("DEP not configured yet. add a DEP token to enable DEP") - } - return svc.client.DefineProfile(p) -} - -type defineProfileRequest struct{ *dep.Profile } -type defineProfileResponse struct { - *dep.ProfileResponse - Err error `json:"err,omitempty"` -} - -func (r defineProfileResponse) Failed() error { return r.Err } - -func decodeDefineProfileRequest(ctx context.Context, r *http.Request) (interface{}, error) { - var req defineProfileRequest - err := httputil.DecodeJSONRequest(r, &req) - return req, err -} - -func decodeDefineProfileResponse(_ context.Context, r *http.Response) (interface{}, error) { - var resp defineProfileResponse - err := httputil.DecodeJSONResponse(r, &resp) - return resp, err -} - -func MakeDefineProfileEndpoint(svc Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (response interface{}, err error) { - req := request.(defineProfileRequest) - resp, err := svc.DefineProfile(ctx, req.Profile) - return &defineProfileResponse{ - ProfileResponse: resp, - Err: err, - }, nil - } -} - -func (e Endpoints) DefineProfile(ctx context.Context, p *dep.Profile) (*dep.ProfileResponse, error) { - request := defineProfileRequest{Profile: p} - resp, err := e.DefineProfileEndpoint(ctx, request) - if err != nil { - return nil, err - } - response := resp.(defineProfileResponse) - return response.ProfileResponse, response.Err -} diff --git a/platform/dep/get_account_info.go b/platform/dep/get_account_info.go deleted file mode 100644 index a71477be..00000000 --- a/platform/dep/get_account_info.go +++ /dev/null @@ -1,53 +0,0 @@ -package dep - -import ( - "context" - "errors" - "net/http" - - "github.com/go-kit/kit/endpoint" - - "github.com/micromdm/micromdm/dep" - "github.com/micromdm/micromdm/pkg/httputil" -) - -func (svc *DEPService) GetAccountInfo(ctx context.Context) (*dep.Account, error) { - if svc.client == nil { - return nil, errors.New("DEP not configured yet. add a DEP token to enable DEP") - } - return svc.client.Account() -} - -type getAccountInfoRequest struct{} -type getAccountInfoResponse struct { - *dep.Account - Err error `json:"err,omitempty"` -} - -func (r getAccountInfoResponse) Failed() error { return r.Err } - -func decodeGetAccountInfoRequest(ctx context.Context, r *http.Request) (interface{}, error) { - return nil, nil -} - -func decodeGetAccountInfoResponse(_ context.Context, r *http.Response) (interface{}, error) { - var resp getAccountInfoResponse - err := httputil.DecodeJSONResponse(r, &resp) - return resp, err -} - -func MakeGetAccountInfoEndpoint(svc Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (response interface{}, err error) { - account, err := svc.GetAccountInfo(ctx) - return getAccountInfoResponse{Account: account, Err: err}, nil - } -} - -func (e Endpoints) GetAccountInfo(ctx context.Context) (*dep.Account, error) { - request := getAccountInfoRequest{} - response, err := e.GetAccountInfoEndpoint(ctx, request) - if err != nil { - return nil, err - } - return response.(getAccountInfoResponse).Account, response.(getAccountInfoResponse).Err -} diff --git a/platform/dep/get_dep_device.go b/platform/dep/get_dep_device.go deleted file mode 100644 index 0c67bb54..00000000 --- a/platform/dep/get_dep_device.go +++ /dev/null @@ -1,59 +0,0 @@ -package dep - -import ( - "context" - "errors" - "net/http" - - "github.com/go-kit/kit/endpoint" - - "github.com/micromdm/micromdm/dep" - "github.com/micromdm/micromdm/pkg/httputil" -) - -func (svc *DEPService) GetDeviceDetails(ctx context.Context, serials []string) (*dep.DeviceDetailsResponse, error) { - if svc.client == nil { - return nil, errors.New("DEP not configured yet. add a DEP token to enable DEP") - } - return svc.client.DeviceDetails(serials...) -} - -type deviceDetailsRequest struct { - Serials []string `json:"serials"` -} - -type deviceDetailsResponse struct { - *dep.DeviceDetailsResponse - Err error `json:"err,omitempty"` -} - -func (r deviceDetailsResponse) Failed() error { return r.Err } - -func decodeDeviceDetailsRequest(ctx context.Context, r *http.Request) (interface{}, error) { - var req deviceDetailsRequest - err := httputil.DecodeJSONRequest(r, &req) - return req, err -} - -func decodeDeviceDetailsResponse(_ context.Context, r *http.Response) (interface{}, error) { - var resp deviceDetailsResponse - err := httputil.DecodeJSONResponse(r, &resp) - return resp, err -} - -func MakeGetDeviceDetailsEndpoint(svc Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (response interface{}, err error) { - req := request.(deviceDetailsRequest) - details, err := svc.GetDeviceDetails(ctx, req.Serials) - return deviceDetailsResponse{DeviceDetailsResponse: details, Err: err}, nil - } -} - -func (e Endpoints) GetDeviceDetails(ctx context.Context, serials []string) (*dep.DeviceDetailsResponse, error) { - request := deviceDetailsRequest{Serials: serials} - response, err := e.GetDeviceDetailsEndpoint(ctx, request) - if err != nil { - return nil, err - } - return response.(deviceDetailsResponse).DeviceDetailsResponse, response.(deviceDetailsResponse).Err -} diff --git a/platform/dep/get_dep_profile.go b/platform/dep/get_dep_profile.go deleted file mode 100644 index b2c0c1dc..00000000 --- a/platform/dep/get_dep_profile.go +++ /dev/null @@ -1,59 +0,0 @@ -package dep - -import ( - "context" - "errors" - "net/http" - - "github.com/go-kit/kit/endpoint" - - "github.com/micromdm/micromdm/dep" - "github.com/micromdm/micromdm/pkg/httputil" -) - -func (svc *DEPService) FetchProfile(ctx context.Context, uuid string) (*dep.Profile, error) { - if svc.client == nil { - return nil, errors.New("DEP not configured yet. add a DEP token to enable DEP") - } - return svc.client.FetchProfile(uuid) -} - -type fetchProfileRequest struct { - UUID string `json:"uuid"` -} - -type fetchProfileResponse struct { - *dep.Profile - Err error `json:"err,omitempty"` -} - -func (r fetchProfileResponse) Failed() error { return r.Err } - -func decodeFetchProfileRequest(ctx context.Context, r *http.Request) (interface{}, error) { - var req fetchProfileRequest - err := httputil.DecodeJSONRequest(r, &req) - return req, err -} - -func decodeFetchProfileResponse(_ context.Context, r *http.Response) (interface{}, error) { - var resp fetchProfileResponse - err := httputil.DecodeJSONResponse(r, &resp) - return resp, err -} - -func MakeFetchProfileEndpoint(svc Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (response interface{}, err error) { - req := request.(fetchProfileRequest) - profile, err := svc.FetchProfile(ctx, req.UUID) - return fetchProfileResponse{Profile: profile, Err: err}, nil - } -} - -func (e Endpoints) FetchProfile(ctx context.Context, uuid string) (*dep.Profile, error) { - request := fetchProfileRequest{UUID: uuid} - response, err := e.FetchProfileEndpoint(ctx, request) - if err != nil { - return nil, err - } - return response.(fetchProfileResponse).Profile, response.(fetchProfileResponse).Err -} diff --git a/platform/dep/server.go b/platform/dep/server.go deleted file mode 100644 index 2976eb9c..00000000 --- a/platform/dep/server.go +++ /dev/null @@ -1,70 +0,0 @@ -package dep - -import ( - "github.com/go-kit/kit/endpoint" - httptransport "github.com/go-kit/kit/transport/http" - "github.com/gorilla/mux" - - "github.com/micromdm/micromdm/pkg/httputil" -) - -type Endpoints struct { - DefineProfileEndpoint endpoint.Endpoint - FetchProfileEndpoint endpoint.Endpoint - GetAccountInfoEndpoint endpoint.Endpoint - GetDeviceDetailsEndpoint endpoint.Endpoint - AssignProfileEndpoint endpoint.Endpoint -} - -func MakeServerEndpoints(s Service, outer endpoint.Middleware, others ...endpoint.Middleware) Endpoints { - return Endpoints{ - AssignProfileEndpoint: endpoint.Chain(outer, others...)(MakeAssignProfileEndpoint(s)), - DefineProfileEndpoint: endpoint.Chain(outer, others...)(MakeDefineProfileEndpoint(s)), - FetchProfileEndpoint: endpoint.Chain(outer, others...)(MakeFetchProfileEndpoint(s)), - GetAccountInfoEndpoint: endpoint.Chain(outer, others...)(MakeGetAccountInfoEndpoint(s)), - GetDeviceDetailsEndpoint: endpoint.Chain(outer, others...)(MakeGetDeviceDetailsEndpoint(s)), - } -} - -func RegisterHTTPHandlers(r *mux.Router, e Endpoints, options ...httptransport.ServerOption) { - // PUT /v1/dep/profiles define a DEP profile with mdmenrollment.apple.com - // POST /v1/dep/profiles get a DEP profile given a known profile UUID - // GET /v1/dep/account get information about the dep account - // POST /v1/dep/devices get device details given a list of serials - // POST /v1/dep/assign assign a specific profile ID to one or more serial - - r.Methods("PUT").Path("/v1/dep/profiles").Handler(httptransport.NewServer( - e.DefineProfileEndpoint, - decodeDefineProfileRequest, - httputil.EncodeJSONResponse, - options..., - )) - - r.Methods("POST").Path("/v1/dep/assign").Handler(httptransport.NewServer( - e.AssignProfileEndpoint, - decodeAssignProfileRequest, - httputil.EncodeJSONResponse, - options..., - )) - - r.Methods("POST").Path("/v1/dep/profiles").Handler(httptransport.NewServer( - e.FetchProfileEndpoint, - decodeFetchProfileRequest, - httputil.EncodeJSONResponse, - options..., - )) - - r.Methods("GET").Path("/v1/dep/account").Handler(httptransport.NewServer( - e.GetAccountInfoEndpoint, - decodeGetAccountInfoRequest, - httputil.EncodeJSONResponse, - options..., - )) - - r.Methods("POST").Path("/v1/dep/devices").Handler(httptransport.NewServer( - e.GetDeviceDetailsEndpoint, - decodeDeviceDetailsRequest, - httputil.EncodeJSONResponse, - options..., - )) -} diff --git a/platform/dep/service.go b/platform/dep/service.go deleted file mode 100644 index 2b0ee929..00000000 --- a/platform/dep/service.go +++ /dev/null @@ -1,39 +0,0 @@ -package dep - -import ( - "context" - "sync" - - "github.com/micromdm/micromdm/dep" - "github.com/micromdm/micromdm/platform/pubsub" -) - -type Service interface { - DefineProfile(ctx context.Context, p *dep.Profile) (*dep.ProfileResponse, error) - AssignProfile(ctx context.Context, uuid string, serials ...string) (*dep.ProfileResponse, error) - GetAccountInfo(ctx context.Context) (*dep.Account, error) - GetDeviceDetails(ctx context.Context, serials []string) (*dep.DeviceDetailsResponse, error) - FetchProfile(ctx context.Context, uuid string) (*dep.Profile, error) -} - -type DEPClient interface { - DefineProfile(*dep.Profile) (*dep.ProfileResponse, error) - AssignProfile(string, ...string) (*dep.ProfileResponse, error) - FetchProfile(string) (*dep.Profile, error) - Account() (*dep.Account, error) - DeviceDetails(...string) (*dep.DeviceDetailsResponse, error) -} - -type DEPService struct { - mtx sync.RWMutex - client DEPClient - subscriber pubsub.Subscriber -} - -func (svc *DEPService) Run() error { - return svc.watchTokenUpdates(svc.subscriber) -} - -func New(client DEPClient, subscriber pubsub.Subscriber) *DEPService { - return &DEPService{client: client, subscriber: subscriber} -} diff --git a/platform/dep/sync/apply_autoassigner.go b/platform/dep/sync/apply_autoassigner.go deleted file mode 100644 index fd017e44..00000000 --- a/platform/dep/sync/apply_autoassigner.go +++ /dev/null @@ -1,57 +0,0 @@ -package sync - -import ( - "context" - "net/http" - - "github.com/go-kit/kit/endpoint" - "github.com/pkg/errors" - - "github.com/micromdm/micromdm/pkg/httputil" -) - -func (s DEPSyncService) ApplyAutoAssigner(ctx context.Context, aa *AutoAssigner) error { - err := s.db.SaveAutoAssigner(aa) - return errors.Wrap(err, "saving AutoAssigner") -} - -type applyAutoAssignerRequest struct { - *AutoAssigner -} -type applyAutoAssignerResponse struct { - Err error `json:"err,omitempty"` -} - -func (r applyAutoAssignerResponse) Failed() error { return r.Err } - -func MakeApplyAutoAssignerEndpoint(s Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (interface{}, error) { - req := request.(applyAutoAssignerRequest) - err := s.ApplyAutoAssigner(ctx, req.AutoAssigner) - return &applyAutoAssignerResponse{ - Err: err, - }, nil - } -} - -func decodeApplyAutoAssignerResponse(ctx context.Context, r *http.Response) (interface{}, error) { - var req applyAutoAssignerResponse - err := httputil.DecodeJSONResponse(r, &req) - return req, err -} - -func decodeApplyAutoAssignerRequest(ctx context.Context, r *http.Request) (interface{}, error) { - var req applyAutoAssignerRequest - err := httputil.DecodeJSONRequest(r, &req) - return req, err -} - -func (e Endpoints) ApplyAutoAssigner(ctx context.Context, aa *AutoAssigner) error { - request := applyAutoAssignerRequest{AutoAssigner: aa} - resp, err := e.ApplyAutoAssignerEndpoint(ctx, request) - if err != nil { - return err - } - response := resp.(applyAutoAssignerResponse) - return response.Err -} diff --git a/platform/dep/sync/builtin/db.go b/platform/dep/sync/builtin/db.go deleted file mode 100644 index 10a0e0a7..00000000 --- a/platform/dep/sync/builtin/db.go +++ /dev/null @@ -1,116 +0,0 @@ -package builtin - -import ( - "encoding/json" - - "github.com/boltdb/bolt" - "github.com/pkg/errors" - - "github.com/micromdm/micromdm/platform/dep/sync" -) - -const ( - ConfigBucket = "mdm.DEPConfig" - AutoAssignBucket = "mdm.DEPAutoAssign" -) - -type DB struct { - *bolt.DB -} - -func NewDB(db *bolt.DB) (*DB, error) { - err := db.Update(func(tx *bolt.Tx) error { - _, err := tx.CreateBucketIfNotExists([]byte(ConfigBucket)) - if err != nil { - return err - } - _, err = tx.CreateBucketIfNotExists([]byte(AutoAssignBucket)) - return err - }) - if err != nil { - return nil, errors.Wrapf(err, "creating %s bucket", ConfigBucket) - } - datastore := &DB{DB: db} - return datastore, nil -} - -func (db *DB) LoadCursor() (*sync.Cursor, error) { - var cursor = struct { - Cursor sync.Cursor `json:"cursor"` - }{} - err := db.View(func(tx *bolt.Tx) error { - bkt := tx.Bucket([]byte(ConfigBucket)) - v := bkt.Get([]byte("configuration")) - if v == nil { - return nil // TODO add notfound - } - err := json.Unmarshal(v, &cursor) - return errors.Wrap(err, "unmarshal dep cursor") - }) - if err != nil { - return nil, errors.Wrap(err, "load cursor from bolt") - } - return &cursor.Cursor, nil -} - -func (db *DB) SaveCursor(c sync.Cursor) error { - err := db.Update(func(tx *bolt.Tx) error { - bkt, err := tx.CreateBucketIfNotExists([]byte(ConfigBucket)) - if err != nil { - return err - } - // use anonymous struct to preserve old structure. - var cursor = struct { - Cursor sync.Cursor `json:"cursor"` - }{Cursor: c} - v, err := json.Marshal(&cursor) - if err != nil { - return err - } - return bkt.Put([]byte("configuration"), v) - }) - return errors.Wrap(err, "saving dep sync cursor") -} - -func (db *DB) SaveAutoAssigner(a *sync.AutoAssigner) error { - if a.Filter != "*" { - return errors.New("only '*' filter auto-assigners supported") - } - err := db.Update(func(tx *bolt.Tx) error { - b, err := tx.CreateBucketIfNotExists([]byte(AutoAssignBucket)) - if err != nil { - return err - } - return b.Put([]byte(a.Filter), []byte(a.ProfileUUID)) - }) - return errors.Wrap(err, "saving auto-assigner") -} - -func (db *DB) DeleteAutoAssigner(filter string) error { - return db.Update(func(tx *bolt.Tx) error { - b := tx.Bucket([]byte(AutoAssignBucket)) - if b == nil { // bucket doesn't exist yet - return nil - } - return b.Delete([]byte(filter)) - }) -} - -func (db *DB) LoadAutoAssigners() ([]sync.AutoAssigner, error) { - var aa []sync.AutoAssigner - err := db.View(func(tx *bolt.Tx) error { - b := tx.Bucket([]byte(AutoAssignBucket)) - if b == nil { // bucket doesn't exist yet - return nil - } - - return b.ForEach(func(k, v []byte) error { - aa = append(aa, sync.AutoAssigner{ - Filter: string(k), - ProfileUUID: string(v), - }) - return nil - }) - }) - return aa, errors.Wrap(err, "loading auto-assigners") -} diff --git a/platform/dep/sync/client.go b/platform/dep/sync/client.go deleted file mode 100644 index e7a6e862..00000000 --- a/platform/dep/sync/client.go +++ /dev/null @@ -1,69 +0,0 @@ -package sync - -import ( - "net/url" - - "github.com/go-kit/kit/endpoint" - "github.com/go-kit/kit/log" - httptransport "github.com/go-kit/kit/transport/http" - - "github.com/micromdm/micromdm/pkg/httputil" -) - -func NewHTTPClient(instance, token string, logger log.Logger, opts ...httptransport.ClientOption) (Service, error) { - u, err := url.Parse(instance) - if err != nil { - return nil, err - } - - var syncNowEndpoint endpoint.Endpoint - { - syncNowEndpoint = httptransport.NewClient( - "PUT", - httputil.CopyURL(u, "/v1/dep/autoassign"), - httputil.EncodeRequestWithToken(token, httptransport.EncodeJSONRequest), - decodeEmptyResponse, - opts..., - ).Endpoint() - } - - var applyAutoAssignerEndpoint endpoint.Endpoint - { - applyAutoAssignerEndpoint = httptransport.NewClient( - "POST", - httputil.CopyURL(u, "/v1/dep/autoassigners"), - httputil.EncodeRequestWithToken(token, httptransport.EncodeJSONRequest), - decodeApplyAutoAssignerResponse, - opts..., - ).Endpoint() - } - - var getAutoAssignersEndpoint endpoint.Endpoint - { - getAutoAssignersEndpoint = httptransport.NewClient( - "GET", - httputil.CopyURL(u, "/v1/dep/autoassigners"), - httputil.EncodeRequestWithToken(token, httptransport.EncodeJSONRequest), - decodeGetAutoAssignersResponse, - opts..., - ).Endpoint() - } - - var removeAutoAssignerEndpoint endpoint.Endpoint - { - removeAutoAssignerEndpoint = httptransport.NewClient( - "DELETE", - httputil.CopyURL(u, "/v1/dep/autoassigners"), - httputil.EncodeRequestWithToken(token, httptransport.EncodeJSONRequest), - decodeRemoveAutoAssignerResponse, - opts..., - ).Endpoint() - } - - return Endpoints{ - SyncNowEndpoint: syncNowEndpoint, - ApplyAutoAssignerEndpoint: applyAutoAssignerEndpoint, - GetAutoAssignersEndpoint: getAutoAssignersEndpoint, - RemoveAutoAssignerEndpoint: removeAutoAssignerEndpoint, - }, nil -} diff --git a/platform/dep/sync/depsync.go b/platform/dep/sync/depsync.go deleted file mode 100644 index bdcdbf1a..00000000 --- a/platform/dep/sync/depsync.go +++ /dev/null @@ -1,352 +0,0 @@ -package sync - -import ( - "context" - "encoding/json" - "strings" - "sync" - "time" - - "github.com/go-kit/kit/log" - "github.com/go-kit/kit/log/level" - "github.com/pkg/errors" - - "github.com/micromdm/micromdm/dep" - conf "github.com/micromdm/micromdm/platform/config" - "github.com/micromdm/micromdm/platform/pubsub" -) - -const ( - SyncTopic = "mdm.DepSync" - - syncDuration = 30 * time.Minute - cursorValidDuration = 7 * 24 * time.Hour -) - -type Syncer interface{ SyncNow() } - -type WatcherDB interface { - LoadCursor() (*Cursor, error) - SaveCursor(c Cursor) error - LoadAutoAssigners() ([]AutoAssigner, error) -} - -type Watcher struct { - mtx sync.RWMutex - logger log.Logger - client Client - - publisher pubsub.Publisher - db WatcherDB - startSync chan bool - syncNow chan bool - - cursor Cursor -} - -func NewWatcher(db WatcherDB, pub pubsub.PublishSubscriber, opts ...Option) (*Watcher, error) { - w := Watcher{ - logger: log.NewNopLogger(), - db: db, - publisher: pub, - startSync: make(chan bool), - syncNow: make(chan bool), - } - for _, optFn := range opts { - optFn(&w) - } - - cursor, err := w.db.LoadCursor() - if err != nil { - return nil, err - } - if cursor.Valid() { - level.Debug(w.logger).Log("msg", "loaded DEP config", "cursor", cursor.Value) - w.cursor = *cursor - } - - if err := w.updateClient(pub); err != nil { - return nil, err - } - - saveCursor := func() { - if err := db.SaveCursor(w.cursor); err != nil { - level.Info(w.logger).Log("err", err, "msg", "saving cursor") - return - } - level.Info(w.logger).Log("msg", "saved DEP config", "cursor", w.cursor.Value) - } - - go func() { - defer saveCursor() - if w.client == nil { - // block until we have a DEP client to start sync process - level.Info(w.logger).Log("msg", "waiting for DEP token to be added before starting sync") - <-w.startSync - } - err := w.Run() - // the DEP sync should never end without an error, but log - // unconditionally anyway so we never silently stop watching - level.Info(w.logger).Log("err", err, "msg", "DEP watcher stopped") - }() - - return &w, nil -} - -type Client interface { - FetchDevices(...dep.DeviceRequestOption) (*dep.DeviceResponse, error) - SyncDevices(string, ...dep.DeviceRequestOption) (*dep.DeviceResponse, error) - AssignProfile(string, ...string) (*dep.ProfileResponse, error) -} - -type Option func(*Watcher) - -func WithClient(client Client) Option { - return func(w *Watcher) { - w.client = client - } -} - -func WithLogger(logger log.Logger) Option { - return func(w *Watcher) { - w.logger = logger - } -} - -func (w *Watcher) updateClient(pubsub pubsub.Subscriber) error { - tokenAdded, err := pubsub.Subscribe(context.TODO(), "token-events", conf.DEPTokenTopic) - if err != nil { - return err - } - - go func() { - for { - select { - case event := <-tokenAdded: - var token conf.DEPToken - if err := json.Unmarshal(event.Message, &token); err != nil { - level.Info(w.logger).Log("err", err, "msg", "unmarshalling tokenAdd to token") - continue - } - - client, err := token.Client() - if err != nil { - level.Info(w.logger).Log("err", err, "msg", "creating new DEP client") - continue - } - - w.mtx.Lock() - w.client = client - w.mtx.Unlock() - go func() { w.startSync <- true }() // unblock Run - } - } - }() - return nil -} - -func (w *Watcher) SyncNow() { - if w.client == nil { - level.Info(w.logger).Log("msg", "waiting for DEP token to be added before starting sync") - return - } - w.syncNow <- true -} - -// TODO this needs to be a proper error in the micromdm/dep package. -func isCursorExhausted(err error) bool { - return strings.Contains(err.Error(), "EXHAUSTED_CURSOR") -} - -func isCursorExpired(err error) bool { - return strings.Contains(err.Error(), "EXPIRED_CURSOR") -} - -func isCursorInvalid(err error) bool { - return strings.Contains(err.Error(), "INVALID_CURSOR") -} - -// Process DEP messages and pull out filter-matching serial numbers -// associated to profile UUIDs for auto-assignment. -func (w *Watcher) filteredAutoAssignments(devices []dep.Device) (map[string][]string, error) { - // load auto-assigners every run to make sure we get the latest set of - // auto-assigner profile UUIDs/filters. Note this makes every *watcher - // (i.e. every DEP sync instance) share the current DB set of auto- - // assigners. perhaps to refactor to be more separated. - assigners, err := w.db.LoadAutoAssigners() - if err != nil { - return nil, err - } - assigned := make(map[string][]string) - // skip looping over serials if we have no autoassigners - if len(assigners) < 1 { - return assigned, nil - } - for _, d := range devices { - // only process DEP "added" OpType messages - if d.OpType != "added" { - continue - } - // filter our devices by our assigner filters and get list of - // which devices are to be assigned to which profiles - for _, assigner := range assigners { - if assigner.Filter == "*" { // only supported filter type right now - if serials, ok := assigned[assigner.ProfileUUID]; ok { - assigned[assigner.ProfileUUID] = append(serials, d.SerialNumber) - } else { - assigned[assigner.ProfileUUID] = []string{d.SerialNumber} - } - } - } - - } - return assigned, nil -} - -func (w *Watcher) processAutoAssign(devices []dep.Device) error { - assignments, err := w.filteredAutoAssignments(devices) - if err != nil { - return err - } - - for profileUUID, serials := range assignments { - resp, err := w.client.AssignProfile(profileUUID, serials...) - if err != nil { - level.Info(w.logger).Log( - "err", err, - "msg", "auto-assign error assigning serials to profile", - "profile", profileUUID, - ) - continue - } - // count our results for logging - resultCounts := map[string]int{ - "SUCCESS": 0, - "NOT_ACCESSIBLE": 0, - "FAILED": 0, - } - for _, result := range resp.Devices { - if ct, ok := resultCounts[result]; ok { - // NOTE: we're logging _only_ the above pre-defined result types - resultCounts[result] = ct + 1 - } - } - // TODO: alternate strategy is to log all failed devices - // TODO: handle/requeue failed devices? - level.Info(w.logger).Log( - "msg", "DEP auto-assigned", - "profile", profileUUID, - "success", resultCounts["SUCCESS"], - "not_accessible", resultCounts["NOT_ACCESSIBLE"], - "failed", resultCounts["FAILED"], - ) - } - - return nil -} - -func (w *Watcher) publishAndProcessDevices(devices []dep.Device) error { - e := NewEvent(devices) - data, err := MarshalEvent(e) - if err != nil { - return err - } - err = w.publisher.Publish(context.TODO(), SyncTopic, data) - if err != nil { - return err - } - - // TODO: instead of directly kicking off the auto-assigner process - // consider placing a subscriber on the DEP pubsub topic. The same - // information gets marshalled but it allows us the future - // flexibility to separate out that component if we desired. - go func() { - err := w.processAutoAssign(devices) - if err != nil { - level.Info(w.logger).Log("err", err, "msg", "auto-assign error") - } - }() - return nil -} - -func (w *Watcher) Run() error { - var ( - err error - resp *dep.DeviceResponse - fetchNext = true - // for logging - fetchNextLabel = map[bool]string{ - true: "fetch", - false: "sync", - } - ) - - ticker := time.NewTicker(syncDuration).C - for { - if fetchNext { - resp, err = w.client.FetchDevices(dep.Limit(100), dep.Cursor(w.cursor.Value)) - if err != nil && isCursorExhausted(err) { - level.Info(w.logger).Log( - "msg", "DEP cursor returned all devices previously", - "phase", fetchNextLabel[fetchNext], - "cursor", w.cursor.Value, - ) - fetchNext = false - continue - } - } else { - resp, err = w.client.SyncDevices(w.cursor.Value) - } - - if err != nil && (isCursorExpired(err) || isCursorInvalid(err)) { - level.Info(w.logger).Log( - "msg", "DEP cursor error, retrying with empty cursor", - "phase", fetchNextLabel[fetchNext], - "cursor", w.cursor.Value, - "err", err, - ) - w.cursor.Value = "" - fetchNext = true - continue - } else if err != nil { - // log any other error, but do not return from the run loop. - // probably just a transient network issue. - level.Info(w.logger).Log( - "msg", "error syncing DEP devices", - "phase", fetchNextLabel[fetchNext], - "cursor", w.cursor.Value, - "err", err, - ) - } else { - level.Info(w.logger).Log( - "msg", "DEP sync", - "phase", fetchNextLabel[fetchNext], - "cursor", resp.Cursor, - "fetched", resp.FetchedUntil, - "devices", len(resp.Devices), - "more", resp.MoreToFollow, - ) - - w.cursor = Cursor{Value: resp.Cursor, CreatedAt: time.Now()} - if err := w.db.SaveCursor(w.cursor); err != nil { - return errors.Wrap(err, "saving cursor from fetch") - } - if err := w.publishAndProcessDevices(resp.Devices); err != nil { - return err - } - - if resp.MoreToFollow { - continue - } else if fetchNext { - fetchNext = false - continue - } - } - - select { - case <-ticker: - case <-w.syncNow: - level.Info(w.logger).Log("msg", "explicit DEP sync requested") - } - } -} diff --git a/platform/dep/sync/event.go b/platform/dep/sync/event.go deleted file mode 100644 index ae52526b..00000000 --- a/platform/dep/sync/event.go +++ /dev/null @@ -1,83 +0,0 @@ -package sync - -import ( - "time" - - "github.com/gogo/protobuf/proto" - "github.com/google/uuid" - - "github.com/micromdm/micromdm/dep" - "github.com/micromdm/micromdm/platform/dep/sync/internal/depsyncproto" -) - -type Event struct { - ID string - Time time.Time - Devices []dep.Device -} - -func NewEvent(devices []dep.Device) *Event { - event := Event{ - ID: uuid.New().String(), - Time: time.Now().UTC(), - Devices: devices, - } - return &event -} - -// MarshalEvent serializes an event to a protocol buffer wire format. -func MarshalEvent(e *Event) ([]byte, error) { - var devices []*depsyncproto.Device - for _, d := range e.Devices { - devices = append(devices, &depsyncproto.Device{ - SerialNumber: d.SerialNumber, - Model: d.Model, - Description: d.Description, - Color: d.Color, - AssetTag: d.AssetTag, - ProfileUuid: d.ProfileUUID, - ProfileAssignTime: d.ProfileAssignTime.UnixNano(), - ProfilePushTime: d.ProfilePushTime.UnixNano(), - DeviceAssignedDate: d.DeviceAssignedDate.UnixNano(), - DeviceAssignedBy: d.DeviceAssignedBy, - OpType: d.OpType, - OpDate: d.OpDate.UnixNano(), - }) - } - return proto.Marshal(&depsyncproto.Event{ - Id: e.ID, - Time: e.Time.UnixNano(), - Devices: devices, - }) -} - -// UnmarshalEvent parses a protocol buffer representation of data into -// the Event. -func UnmarshalEvent(data []byte, e *Event) error { - var pb depsyncproto.Event - if err := proto.Unmarshal(data, &pb); err != nil { - return err - } - e.ID = pb.GetId() - e.Time = time.Unix(0, pb.GetTime()).UTC() - protodev := pb.GetDevices() - var devices []dep.Device - for _, d := range protodev { - devices = append(devices, dep.Device{ - SerialNumber: d.GetSerialNumber(), - Model: d.GetModel(), - Description: d.GetDescription(), - Color: d.GetColor(), - AssetTag: d.GetAssetTag(), - ProfileUUID: d.GetProfileUuid(), - ProfileAssignTime: time.Unix(0, d.GetProfileAssignTime()).UTC(), - ProfilePushTime: time.Unix(0, d.GetProfilePushTime()).UTC(), - DeviceAssignedDate: time.Unix(0, d.GetDeviceAssignedDate()).UTC(), - DeviceAssignedBy: d.GetDeviceAssignedBy(), - OpType: d.GetOpType(), - OpDate: time.Unix(0, d.GetOpDate()).UTC(), - }) - } - e.Devices = devices - return nil -} diff --git a/platform/dep/sync/get_autoassigners.go b/platform/dep/sync/get_autoassigners.go deleted file mode 100644 index 63f7f7f5..00000000 --- a/platform/dep/sync/get_autoassigners.go +++ /dev/null @@ -1,48 +0,0 @@ -package sync - -import ( - "context" - "net/http" - - "github.com/go-kit/kit/endpoint" - "github.com/pkg/errors" - - "github.com/micromdm/micromdm/pkg/httputil" -) - -func (s DEPSyncService) GetAutoAssigners(ctx context.Context) ([]AutoAssigner, error) { - aa, err := s.db.LoadAutoAssigners() - return aa, errors.Wrap(err, "get AutoAssigners") -} - -type getAutoAssignersResponse struct { - AutoAssigners []AutoAssigner `json:"autoassigners"` - Err error `json:"err,omitempty"` -} - -func (r getAutoAssignersResponse) Failed() error { return r.Err } - -func MakeGetAutoAssignersEndpoint(s Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (interface{}, error) { - assigners, err := s.GetAutoAssigners(ctx) - return &getAutoAssignersResponse{ - AutoAssigners: assigners, - Err: err, - }, nil - } -} - -func decodeGetAutoAssignersResponse(ctx context.Context, r *http.Response) (interface{}, error) { - var req getAutoAssignersResponse - err := httputil.DecodeJSONResponse(r, &req) - return req, err -} - -func (e Endpoints) GetAutoAssigners(ctx context.Context) ([]AutoAssigner, error) { - resp, err := e.GetAutoAssignersEndpoint(ctx, nil) - if err != nil { - return nil, err - } - response := resp.(getAutoAssignersResponse) - return response.AutoAssigners, response.Err -} diff --git a/platform/dep/sync/internal/depsyncproto/depsync.go b/platform/dep/sync/internal/depsyncproto/depsync.go deleted file mode 100644 index e5cb3e86..00000000 --- a/platform/dep/sync/internal/depsyncproto/depsync.go +++ /dev/null @@ -1,3 +0,0 @@ -package depsyncproto - -//go:generate protoc --go_out=. depsync.proto diff --git a/platform/dep/sync/internal/depsyncproto/depsync.pb.go b/platform/dep/sync/internal/depsyncproto/depsync.pb.go deleted file mode 100644 index c0eb87ff..00000000 --- a/platform/dep/sync/internal/depsyncproto/depsync.pb.go +++ /dev/null @@ -1,208 +0,0 @@ -// Code generated by protoc-gen-go. -// source: depsync.proto -// DO NOT EDIT! - -/* -Package depsyncproto is a generated protocol buffer package. - -It is generated from these files: - depsync.proto - -It has these top-level messages: - Event - Device -*/ -package depsyncproto - -import proto "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package - -type Event struct { - Id string `protobuf:"bytes,1,opt,name=id" json:"id,omitempty"` - Time int64 `protobuf:"varint,2,opt,name=time" json:"time,omitempty"` - Devices []*Device `protobuf:"bytes,3,rep,name=devices" json:"devices,omitempty"` -} - -func (m *Event) Reset() { *m = Event{} } -func (m *Event) String() string { return proto.CompactTextString(m) } -func (*Event) ProtoMessage() {} -func (*Event) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } - -func (m *Event) GetId() string { - if m != nil { - return m.Id - } - return "" -} - -func (m *Event) GetTime() int64 { - if m != nil { - return m.Time - } - return 0 -} - -func (m *Event) GetDevices() []*Device { - if m != nil { - return m.Devices - } - return nil -} - -type Device struct { - SerialNumber string `protobuf:"bytes,1,opt,name=serial_number,json=serialNumber" json:"serial_number,omitempty"` - Model string `protobuf:"bytes,2,opt,name=model" json:"model,omitempty"` - Description string `protobuf:"bytes,3,opt,name=description" json:"description,omitempty"` - Color string `protobuf:"bytes,4,opt,name=color" json:"color,omitempty"` - AssetTag string `protobuf:"bytes,5,opt,name=asset_tag,json=assetTag" json:"asset_tag,omitempty"` - ProfileStatus string `protobuf:"bytes,6,opt,name=profile_status,json=profileStatus" json:"profile_status,omitempty"` - ProfileUuid string `protobuf:"bytes,7,opt,name=profile_uuid,json=profileUuid" json:"profile_uuid,omitempty"` - ProfileAssignTime int64 `protobuf:"varint,8,opt,name=profile_assign_time,json=profileAssignTime" json:"profile_assign_time,omitempty"` - ProfilePushTime int64 `protobuf:"varint,9,opt,name=profile_push_time,json=profilePushTime" json:"profile_push_time,omitempty"` - DeviceAssignedDate int64 `protobuf:"varint,10,opt,name=device_assigned_date,json=deviceAssignedDate" json:"device_assigned_date,omitempty"` - DeviceAssignedBy string `protobuf:"bytes,11,opt,name=device_assigned_by,json=deviceAssignedBy" json:"device_assigned_by,omitempty"` - OpType string `protobuf:"bytes,12,opt,name=op_type,json=opType" json:"op_type,omitempty"` - OpDate int64 `protobuf:"varint,13,opt,name=op_date,json=opDate" json:"op_date,omitempty"` -} - -func (m *Device) Reset() { *m = Device{} } -func (m *Device) String() string { return proto.CompactTextString(m) } -func (*Device) ProtoMessage() {} -func (*Device) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} } - -func (m *Device) GetSerialNumber() string { - if m != nil { - return m.SerialNumber - } - return "" -} - -func (m *Device) GetModel() string { - if m != nil { - return m.Model - } - return "" -} - -func (m *Device) GetDescription() string { - if m != nil { - return m.Description - } - return "" -} - -func (m *Device) GetColor() string { - if m != nil { - return m.Color - } - return "" -} - -func (m *Device) GetAssetTag() string { - if m != nil { - return m.AssetTag - } - return "" -} - -func (m *Device) GetProfileStatus() string { - if m != nil { - return m.ProfileStatus - } - return "" -} - -func (m *Device) GetProfileUuid() string { - if m != nil { - return m.ProfileUuid - } - return "" -} - -func (m *Device) GetProfileAssignTime() int64 { - if m != nil { - return m.ProfileAssignTime - } - return 0 -} - -func (m *Device) GetProfilePushTime() int64 { - if m != nil { - return m.ProfilePushTime - } - return 0 -} - -func (m *Device) GetDeviceAssignedDate() int64 { - if m != nil { - return m.DeviceAssignedDate - } - return 0 -} - -func (m *Device) GetDeviceAssignedBy() string { - if m != nil { - return m.DeviceAssignedBy - } - return "" -} - -func (m *Device) GetOpType() string { - if m != nil { - return m.OpType - } - return "" -} - -func (m *Device) GetOpDate() int64 { - if m != nil { - return m.OpDate - } - return 0 -} - -func init() { - proto.RegisterType((*Event)(nil), "depsyncproto.Event") - proto.RegisterType((*Device)(nil), "depsyncproto.Device") -} - -func init() { proto.RegisterFile("depsync.proto", fileDescriptor0) } - -var fileDescriptor0 = []byte{ - // 361 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x91, 0x51, 0x8b, 0xd3, 0x40, - 0x10, 0xc7, 0x69, 0x73, 0x4d, 0x2f, 0xd3, 0xe4, 0xd4, 0xb1, 0xe0, 0x82, 0x2f, 0xf1, 0x44, 0x28, - 0x22, 0x41, 0xf4, 0x13, 0x9c, 0x9c, 0xaf, 0x22, 0xb1, 0x3e, 0xf9, 0x10, 0xb6, 0xd9, 0xb1, 0xb7, - 0x90, 0x66, 0x97, 0xec, 0xa6, 0x90, 0x6f, 0xe9, 0x47, 0x92, 0xce, 0x6e, 0xa0, 0xfa, 0x96, 0xf9, - 0xff, 0x7e, 0x33, 0x13, 0x66, 0xa1, 0x50, 0x64, 0xdd, 0xd4, 0xb7, 0x95, 0x1d, 0x8c, 0x37, 0x98, - 0xc7, 0x92, 0xab, 0xfb, 0x5f, 0xb0, 0xfa, 0x7a, 0xa6, 0xde, 0xe3, 0x1d, 0x2c, 0xb5, 0x12, 0x8b, - 0x72, 0xb1, 0xcb, 0xea, 0xa5, 0x56, 0x88, 0x70, 0xe3, 0xf5, 0x89, 0xc4, 0xb2, 0x5c, 0xec, 0x92, - 0x9a, 0xbf, 0xb1, 0x82, 0xb5, 0xa2, 0xb3, 0x6e, 0xc9, 0x89, 0xa4, 0x4c, 0x76, 0x9b, 0x4f, 0xdb, - 0xea, 0x7a, 0x58, 0xf5, 0xc8, 0xb0, 0x9e, 0xa5, 0xfb, 0x3f, 0x09, 0xa4, 0x21, 0xc3, 0xb7, 0x50, - 0x38, 0x1a, 0xb4, 0xec, 0x9a, 0x7e, 0x3c, 0x1d, 0x68, 0x88, 0x9b, 0xf2, 0x10, 0x7e, 0xe3, 0x0c, - 0xb7, 0xb0, 0x3a, 0x19, 0x45, 0x1d, 0x2f, 0xcd, 0xea, 0x50, 0x60, 0x09, 0x1b, 0x45, 0xae, 0x1d, - 0xb4, 0xf5, 0xda, 0xf4, 0x22, 0x61, 0x76, 0x1d, 0x5d, 0xfa, 0x5a, 0xd3, 0x99, 0x41, 0xdc, 0x84, - 0x3e, 0x2e, 0xf0, 0x35, 0x64, 0xd2, 0x39, 0xf2, 0x8d, 0x97, 0x47, 0xb1, 0x62, 0x72, 0xcb, 0xc1, - 0x5e, 0x1e, 0xf1, 0x1d, 0xdc, 0xd9, 0xc1, 0xfc, 0xd6, 0x1d, 0x35, 0xce, 0x4b, 0x3f, 0x3a, 0x91, - 0xb2, 0x51, 0xc4, 0xf4, 0x07, 0x87, 0xf8, 0x06, 0xf2, 0x59, 0x1b, 0x47, 0xad, 0xc4, 0x3a, 0x2c, - 0x8f, 0xd9, 0xcf, 0x51, 0x2b, 0xac, 0xe0, 0xe5, 0xac, 0x48, 0xe7, 0xf4, 0xb1, 0x6f, 0xf8, 0x6e, - 0xb7, 0x7c, 0xb7, 0x17, 0x11, 0x3d, 0x30, 0xd9, 0x5f, 0x8e, 0xf8, 0x1e, 0xe6, 0xb0, 0xb1, 0xa3, - 0x7b, 0x0a, 0x76, 0xc6, 0xf6, 0xb3, 0x08, 0xbe, 0x8f, 0xee, 0x89, 0xdd, 0x8f, 0xb0, 0x0d, 0xb7, - 0x8c, 0xa3, 0x49, 0x35, 0x4a, 0x7a, 0x12, 0xc0, 0x3a, 0x06, 0xf6, 0x10, 0xd1, 0xa3, 0xf4, 0x84, - 0x1f, 0x00, 0xff, 0xef, 0x38, 0x4c, 0x62, 0xc3, 0xbf, 0xfd, 0xfc, 0x5f, 0xff, 0xcb, 0x84, 0xaf, - 0x60, 0x6d, 0x6c, 0xe3, 0x27, 0x4b, 0x22, 0x67, 0x25, 0x35, 0x76, 0x3f, 0x59, 0x8a, 0x80, 0x77, - 0x15, 0xbc, 0x2b, 0x35, 0xf6, 0x32, 0xff, 0x90, 0xf2, 0x4b, 0x7f, 0xfe, 0x1b, 0x00, 0x00, 0xff, - 0xff, 0x1d, 0x9a, 0x90, 0xb5, 0x55, 0x02, 0x00, 0x00, -} diff --git a/platform/dep/sync/internal/depsyncproto/depsync.proto b/platform/dep/sync/internal/depsyncproto/depsync.proto deleted file mode 100644 index dcb02bcf..00000000 --- a/platform/dep/sync/internal/depsyncproto/depsync.proto +++ /dev/null @@ -1,26 +0,0 @@ -syntax = "proto3"; - -package depsyncproto; - -message Event { - string id = 1; - int64 time = 2; - repeated Device devices = 3; -} - -message Device { - string serial_number = 1; - string model = 2; - string description = 3; - string color = 4; - string asset_tag = 5; - string profile_status = 6; - string profile_uuid = 7; - int64 profile_assign_time = 8; - int64 profile_push_time = 9; - int64 device_assigned_date = 10; - string device_assigned_by = 11; - - string op_type = 12; - int64 op_date = 13; -} diff --git a/platform/dep/sync/remove_autoassigners.go b/platform/dep/sync/remove_autoassigners.go deleted file mode 100644 index be132a89..00000000 --- a/platform/dep/sync/remove_autoassigners.go +++ /dev/null @@ -1,57 +0,0 @@ -package sync - -import ( - "context" - "net/http" - - "github.com/go-kit/kit/endpoint" - "github.com/micromdm/micromdm/pkg/httputil" - "github.com/pkg/errors" -) - -func (s DEPSyncService) RemoveAutoAssigner(ctx context.Context, filter string) error { - err := s.db.DeleteAutoAssigner(filter) - return errors.Wrap(err, "remove AutoAssigner") -} - -type removeAutoAssignerRequest struct { - Filter string `json:"filter"` -} - -type removeAutoAssignerResponse struct { - Err error `json:"err,omitempty"` -} - -func (r removeAutoAssignerResponse) Failed() error { return r.Err } - -func MakeRemoveAutoAssignerEndpoint(s Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (interface{}, error) { - req := request.(removeAutoAssignerRequest) - err := s.RemoveAutoAssigner(ctx, req.Filter) - return &removeAutoAssignerResponse{ - Err: err, - }, nil - } -} - -func decodeRemoveAutoAssignerResponse(ctx context.Context, r *http.Response) (interface{}, error) { - var req removeAutoAssignerResponse - err := httputil.DecodeJSONResponse(r, &req) - return req, err -} - -func decodeRemoveAutoAssignerRequest(ctx context.Context, r *http.Request) (interface{}, error) { - var req removeAutoAssignerRequest - err := httputil.DecodeJSONRequest(r, &req) - return req, err -} - -func (e Endpoints) RemoveAutoAssigner(ctx context.Context, filter string) error { - request := removeAutoAssignerRequest{Filter: filter} - resp, err := e.RemoveAutoAssignerEndpoint(ctx, request) - if err != nil { - return err - } - response := resp.(removeAutoAssignerResponse) - return response.Err -} diff --git a/platform/dep/sync/server.go b/platform/dep/sync/server.go deleted file mode 100644 index fd220f02..00000000 --- a/platform/dep/sync/server.go +++ /dev/null @@ -1,64 +0,0 @@ -package sync - -import ( - "github.com/go-kit/kit/endpoint" - httptransport "github.com/go-kit/kit/transport/http" - "github.com/gorilla/mux" - - "github.com/micromdm/micromdm/pkg/httputil" -) - -func NewService(syncer Syncer, db DB) *DEPSyncService { - return &DEPSyncService{syncer: syncer, db: db} -} - -type Endpoints struct { - SyncNowEndpoint endpoint.Endpoint - ApplyAutoAssignerEndpoint endpoint.Endpoint - GetAutoAssignersEndpoint endpoint.Endpoint - RemoveAutoAssignerEndpoint endpoint.Endpoint -} - -func MakeServerEndpoints(s Service, outer endpoint.Middleware, others ...endpoint.Middleware) Endpoints { - return Endpoints{ - SyncNowEndpoint: endpoint.Chain(outer, others...)(MakeSyncNowEndpoint(s)), - ApplyAutoAssignerEndpoint: endpoint.Chain(outer, others...)(MakeApplyAutoAssignerEndpoint(s)), - GetAutoAssignersEndpoint: endpoint.Chain(outer, others...)(MakeGetAutoAssignersEndpoint(s)), - RemoveAutoAssignerEndpoint: endpoint.Chain(outer, others...)(MakeRemoveAutoAssignerEndpoint(s)), - } -} - -func RegisterHTTPHandlers(r *mux.Router, e Endpoints, options ...httptransport.ServerOption) { - // POST /v1/dep/syncnow request a DEP sync operation to happen now - // POST /v1/dep/autoassigners set a DEP auto-assigner - // GET /v1/dep/autoassigners get list of DEP auto-assigners - // DELETE /v1/dep/autoassigners remove a DEP auto-assigner - - r.Methods("POST").Path("/v1/dep/syncnow").Handler(httptransport.NewServer( - e.SyncNowEndpoint, - decodeEmptyRequest, - encodeEmptyResponse, - options..., - )) - - r.Methods("POST").Path("/v1/dep/autoassigners").Handler(httptransport.NewServer( - e.ApplyAutoAssignerEndpoint, - decodeApplyAutoAssignerRequest, - httputil.EncodeJSONResponse, - options..., - )) - - r.Methods("GET").Path("/v1/dep/autoassigners").Handler(httptransport.NewServer( - e.GetAutoAssignersEndpoint, - decodeEmptyRequest, - httputil.EncodeJSONResponse, - options..., - )) - - r.Methods("DELETE").Path("/v1/dep/autoassigners").Handler(httptransport.NewServer( - e.RemoveAutoAssignerEndpoint, - decodeRemoveAutoAssignerRequest, - httputil.EncodeJSONResponse, - options..., - )) -} diff --git a/platform/dep/sync/service.go b/platform/dep/sync/service.go deleted file mode 100644 index 7ce3bdcb..00000000 --- a/platform/dep/sync/service.go +++ /dev/null @@ -1,40 +0,0 @@ -package sync - -import ( - "context" - "time" -) - -type Service interface { - SyncNow(context.Context) error - ApplyAutoAssigner(context.Context, *AutoAssigner) error - GetAutoAssigners(context.Context) ([]AutoAssigner, error) - RemoveAutoAssigner(context.Context, string) error -} - -type DB interface { - SaveAutoAssigner(a *AutoAssigner) error - LoadAutoAssigners() ([]AutoAssigner, error) - DeleteAutoAssigner(filter string) error -} - -type DEPSyncService struct { - db DB - syncer Syncer -} - -type Cursor struct { - Value string `json:"value"` - CreatedAt time.Time `json:"created_at"` -} - -// A cursor is valid for a week. -func (c Cursor) Valid() bool { - expiration := time.Now().Add(cursorValidDuration) - return c.CreatedAt.Before(expiration) -} - -type AutoAssigner struct { - Filter string `json:"filter"` - ProfileUUID string `json:"profile_uuid"` -} diff --git a/platform/dep/sync/syncnow.go b/platform/dep/sync/syncnow.go deleted file mode 100644 index 5a88a325..00000000 --- a/platform/dep/sync/syncnow.go +++ /dev/null @@ -1,40 +0,0 @@ -package sync - -import ( - "context" - "net/http" - - "github.com/go-kit/kit/endpoint" -) - -func (s *DEPSyncService) SyncNow(_ context.Context) error { - s.syncer.SyncNow() - return nil -} - -type syncNowResponse struct{} -type syncNowRequest struct{} - -func MakeSyncNowEndpoint(s Service) endpoint.Endpoint { - return func(ctx context.Context, _ interface{}) (interface{}, error) { - s.SyncNow(ctx) - return syncNowResponse{}, nil - } -} - -func decodeEmptyRequest(ctx context.Context, r *http.Request) (interface{}, error) { - return nil, nil -} - -func encodeEmptyResponse(ctx context.Context, w http.ResponseWriter, response interface{}) error { - return nil -} - -func decodeEmptyResponse(ctx context.Context, r *http.Response) (interface{}, error) { - return nil, nil -} - -func (e Endpoints) SyncNow(ctx context.Context) error { - _, err := e.SyncNowEndpoint(ctx, nil) - return err -} diff --git a/platform/dep/watch_tokenupdate.go b/platform/dep/watch_tokenupdate.go deleted file mode 100644 index c43dc362..00000000 --- a/platform/dep/watch_tokenupdate.go +++ /dev/null @@ -1,42 +0,0 @@ -package dep - -import ( - "context" - "encoding/json" - "log" - - "github.com/micromdm/micromdm/platform/config" - "github.com/micromdm/micromdm/platform/pubsub" -) - -func (svc *DEPService) watchTokenUpdates(pubsub pubsub.Subscriber) error { - tokenAdded, err := pubsub.Subscribe(context.TODO(), "list-token-events", config.DEPTokenTopic) - if err != nil { - return err - } - - go func() { - for { - select { - case event := <-tokenAdded: - var token config.DEPToken - if err := json.Unmarshal(event.Message, &token); err != nil { - log.Printf("unmarshalling tokenAdded to token: %s\n", err) - continue - } - - client, err := token.Client() - if err != nil { - log.Printf("creating new DEP client: %s\n", err) - continue - } - - svc.mtx.Lock() - svc.client = client - svc.mtx.Unlock() - } - } - }() - - return nil -} diff --git a/platform/device/builtin/db.go b/platform/device/builtin/db.go deleted file mode 100644 index 9710c065..00000000 --- a/platform/device/builtin/db.go +++ /dev/null @@ -1,219 +0,0 @@ -package builtin - -import ( - "context" - "fmt" - - "github.com/boltdb/bolt" - "github.com/pkg/errors" - - "github.com/micromdm/micromdm/platform/device" -) - -const ( - DeviceBucket = "mdm.Devices" - - // The deviceIndexBucket index bucket stores serial number and UDID references - // to the device uuid. - deviceIndexBucket = "mdm.DeviceIdx" - - // The udidCertAuthBucket stores a simple mapping from UDID to - // sha256 hash of the device identity certificate for future validation - udidCertAuthBucket = "mdm.UDIDCertAuth" -) - -type DB struct { - *bolt.DB -} - -func NewDB(db *bolt.DB) (*DB, error) { - err := db.Update(func(tx *bolt.Tx) error { - _, err := tx.CreateBucketIfNotExists([]byte(deviceIndexBucket)) - if err != nil { - return err - } - _, err = tx.CreateBucketIfNotExists([]byte(DeviceBucket)) - if err != nil { - return err - } - _, err = tx.CreateBucketIfNotExists([]byte(udidCertAuthBucket)) - return err - }) - if err != nil { - return nil, errors.Wrapf(err, "creating %s bucket", DeviceBucket) - } - datastore := &DB{DB: db} - return datastore, nil -} - -func (db *DB) List(ctx context.Context, opt device.ListDevicesOption) ([]device.Device, error) { - var devices []device.Device - err := db.View(func(tx *bolt.Tx) error { - b := tx.Bucket([]byte(DeviceBucket)) - // TODO optimize by implemting Seek() and bytes.HasPrefix() so we don't - // hit all keys in the database if we dont have to. - return b.ForEach(func(k, v []byte) error { - var dev device.Device - if err := device.UnmarshalDevice(v, &dev); err != nil { - return err - } - if len(opt.FilterSerial) == 0 { - devices = append(devices, dev) - return nil - } - for _, fs := range opt.FilterSerial { - if fs == dev.SerialNumber { - devices = append(devices, dev) - } - } - return nil - }) - }) - return devices, err -} - -func (db *DB) Save(ctx context.Context, dev *device.Device) error { - tx, err := db.DB.Begin(true) - if err != nil { - return errors.Wrap(err, "begin transaction") - } - bkt := tx.Bucket([]byte(DeviceBucket)) - if bkt == nil { - return fmt.Errorf("bucket %q not found!", DeviceBucket) - } - devproto, err := device.MarshalDevice(dev) - if err != nil { - return errors.Wrap(err, "marshalling device") - } - - // store an array of indices to reference the UUID, which will be the - // key used to store the actual device. - indexes := []string{dev.UDID, dev.SerialNumber} - idxBucket := tx.Bucket([]byte(deviceIndexBucket)) - if idxBucket == nil { - return fmt.Errorf("bucket %q not found!", deviceIndexBucket) - } - for _, idx := range indexes { - if idx == "" { - continue - } - key := []byte(idx) - if err := idxBucket.Put(key, []byte(dev.UUID)); err != nil { - return errors.Wrap(err, "put device to boltdb") - } - } - - key := []byte(dev.UUID) - if err := bkt.Put(key, devproto); err != nil { - return errors.Wrap(err, "put device to boltdb") - } - return tx.Commit() -} - -func (db *DB) DeleteByUDID(ctx context.Context, udid string) error { - return db.deleteByIndex(udid) -} - -func (db *DB) DeleteBySerial(ctx context.Context, serial string) error { - return db.deleteByIndex(serial) -} - -func (db *DB) deleteByIndex(key string) error { - device, err := db.deviceByIndex(key) - if err != nil { - return err - } - - tx, err := db.DB.Begin(true) - if err != nil { - return errors.Wrap(err, "begin transaction") - } - - bkt := tx.Bucket([]byte(DeviceBucket)) - if err := bkt.Delete([]byte(device.UUID)); err != nil { - return errors.Wrapf(err, "delete device for key %s", key) - } - - idxBucket := tx.Bucket([]byte(deviceIndexBucket)) - if err := idxBucket.Delete([]byte(device.UDID)); err != nil { - return errors.Wrapf(err, "delete device index for UDID %s", device.UDID) - } - if err := idxBucket.Delete([]byte(device.SerialNumber)); err != nil { - return errors.Wrapf(err, "delete device index for serial %s", device.SerialNumber) - } - - return tx.Commit() -} - -type notFound struct { - ResourceType string - Message string -} - -func (e *notFound) Error() string { - return fmt.Sprintf("not found: %s %s", e.ResourceType, e.Message) -} - -func (e *notFound) NotFound() bool { - return true -} - -func (db *DB) DeviceByUDID(ctx context.Context, udid string) (*device.Device, error) { - return db.deviceByIndex(udid) -} - -func (db *DB) DeviceBySerial(ctx context.Context, serial string) (*device.Device, error) { - return db.deviceByIndex(serial) -} - -func (db *DB) deviceByIndex(key string) (*device.Device, error) { - var dev device.Device - err := db.View(func(tx *bolt.Tx) error { - b := tx.Bucket([]byte(DeviceBucket)) - ib := tx.Bucket([]byte(deviceIndexBucket)) - idx := ib.Get([]byte(key)) - if idx == nil { - return ¬Found{"Device", fmt.Sprintf("key %s", key)} - } - v := b.Get(idx) - if idx == nil { - return ¬Found{"Device", fmt.Sprintf("uuid %s", string(idx))} - } - return device.UnmarshalDevice(v, &dev) - }) - if err != nil { - return nil, err - } - return &dev, nil -} - -func (db *DB) SaveUDIDCertHash(udid, certHash []byte) error { - tx, err := db.DB.Begin(true) - if err != nil { - return errors.Wrap(err, "begin transaction") - } - bkt := tx.Bucket([]byte(udidCertAuthBucket)) - if bkt == nil { - return fmt.Errorf("bucket %q not found!", udidCertAuthBucket) - } - if err := bkt.Put(udid, certHash); err != nil { - return errors.Wrap(err, "put udid cert to boltdb") - } - return tx.Commit() -} - -func (db *DB) GetUDIDCertHash(udid []byte) ([]byte, error) { - var certHash []byte - err := db.View(func(tx *bolt.Tx) error { - b := tx.Bucket([]byte(udidCertAuthBucket)) - if b == nil { - return fmt.Errorf("bucket %q not found!", udidCertAuthBucket) - } - certHash = b.Get(udid) - if certHash == nil { - return ¬Found{"UDID", fmt.Sprintf("udid %s", string(udid))} - } - return nil - }) - return certHash, err -} diff --git a/platform/device/builtin/db_test.go b/platform/device/builtin/db_test.go deleted file mode 100644 index 8b024580..00000000 --- a/platform/device/builtin/db_test.go +++ /dev/null @@ -1,132 +0,0 @@ -package builtin - -import ( - "context" - "io/ioutil" - "os" - "testing" - - "github.com/boltdb/bolt" - - "github.com/micromdm/micromdm/platform/device" -) - -func TestSave(t *testing.T) { - db := setupDB(t) - dev := &device.Device{ - UUID: "a-b-c-d", - UDID: "UDID-FOO-BAR-BAZ", - SerialNumber: "foobarbaz", - ProductName: "MacBook", - } - ctx := context.Background() - - if err := db.Save(ctx, dev); err != nil { - t.Fatalf("saving device in datastore: %s", err) - } - - byUDID, err := db.DeviceByUDID(ctx, dev.UDID) - if err != nil { - t.Fatalf("getting device by UDID: %s", err) - } - - bySerial, err := db.DeviceBySerial(ctx, dev.SerialNumber) - if err != nil { - t.Fatalf("getting device by UDID: %s", err) - } - - // test helper that verifies that the retrieved device is the same - tf := func(haveDev *device.Device) func(t *testing.T) { - return func(t *testing.T) { - if have, want := haveDev.UDID, dev.UDID; have != want { - t.Errorf("have %s, want %s", have, want) - } - - if have, want := haveDev.UUID, dev.UUID; have != want { - t.Errorf("have %s, want %s", have, want) - } - - if have, want := haveDev.SerialNumber, dev.SerialNumber; have != want { - t.Errorf("have %s, want %s", have, want) - } - - if have, want := haveDev.ProductName, dev.ProductName; have != want { - t.Errorf("have %s, want %s", have, want) - } - - if have, want := haveDev.LastSeen, dev.LastSeen; have != want { - t.Errorf("have %s, want %s", have, want) - } - - } - } - - t.Run("byUDID", tf(byUDID)) - t.Run("bySerial", tf(bySerial)) - -} - -func TestDeleteByUDID(t *testing.T) { - db := setupDB(t) - dev := &device.Device{ - UUID: "a-b-c-d", - UDID: "UDID-FOO-BAR-BAZ", - SerialNumber: "foobarbaz", - ProductName: "MacBook", - } - ctx := context.Background() - - if err := db.Save(ctx, dev); err != nil { - t.Fatalf("saving device in datastore: %s", err) - } - - if err := db.DeleteByUDID(ctx, dev.UDID); err != nil { - t.Fatalf("deleting device in datastore: %s", err) - } - - byUDID, _ := db.DeviceByUDID(ctx, dev.UDID) - if byUDID != nil { - t.Fatalf("expected device to be deleted") - } -} - -func TestDeleteBySerial(t *testing.T) { - db := setupDB(t) - dev := &device.Device{ - UUID: "a-b-c-d", - UDID: "UDID-FOO-BAR-BAZ", - SerialNumber: "foobarbaz", - ProductName: "MacBook", - } - - ctx := context.Background() - - if err := db.Save(ctx, dev); err != nil { - t.Fatalf("saving device in datastore: %s", err) - } - - if err := db.DeleteBySerial(ctx, dev.SerialNumber); err != nil { - t.Fatalf("deleting device in datastore: %s", err) - } - - byUDID, _ := db.DeviceBySerial(ctx, dev.SerialNumber) - if byUDID != nil { - t.Fatalf("expected device to be deleted") - } -} - -func setupDB(t *testing.T) *DB { - f, _ := ioutil.TempFile("", "bolt-") - f.Close() - os.Remove(f.Name()) - - db, err := bolt.Open(f.Name(), 0777, nil) - if err != nil { - t.Fatalf("couldn't open bolt, err %s\n", err) - } - devDB, err := NewDB(db) - if err != nil { - t.Fatalf("couldn't create device DB, err %s\n", err) - } - return devDB -} diff --git a/platform/device/client.go b/platform/device/client.go deleted file mode 100644 index cb0bbd86..00000000 --- a/platform/device/client.go +++ /dev/null @@ -1,46 +0,0 @@ -package device - -import ( - "net/url" - - "github.com/go-kit/kit/endpoint" - "github.com/go-kit/kit/log" - httptransport "github.com/go-kit/kit/transport/http" - - "github.com/micromdm/micromdm/pkg/httputil" -) - -func NewHTTPClient(instance, token string, logger log.Logger, opts ...httptransport.ClientOption) (Service, error) { - u, err := url.Parse(instance) - if err != nil { - return nil, err - } - - var listDevicesEndpoint endpoint.Endpoint - { - listDevicesEndpoint = httptransport.NewClient( - "POST", - httputil.CopyURL(u, "/v1/devices"), - httputil.EncodeRequestWithToken(token, httptransport.EncodeJSONRequest), - decodeListDevicesResponse, - opts..., - ).Endpoint() - } - - var removeDevicesEndpoint endpoint.Endpoint - { - removeDevicesEndpoint = httptransport.NewClient( - "DELETE", - httputil.CopyURL(u, "/v1/devices"), - httputil.EncodeRequestWithToken(token, httptransport.EncodeJSONRequest), - decodeRemoveDevicesResponse, - opts..., - ).Endpoint() - } - - return Endpoints{ - ListDevicesEndpoint: listDevicesEndpoint, - RemoveDevicesEndpoint: removeDevicesEndpoint, - }, nil - -} diff --git a/platform/device/device.go b/platform/device/device.go deleted file mode 100644 index 562413fc..00000000 --- a/platform/device/device.go +++ /dev/null @@ -1,133 +0,0 @@ -package device - -import ( - "time" - - "github.com/gogo/protobuf/proto" - "github.com/pkg/errors" - - "github.com/micromdm/micromdm/platform/device/internal/deviceproto" -) - -const DeviceEnrolledTopic = "mdm.DeviceEnrolled" - -type Device struct { - UUID string `db:"uuid"` - UDID string `db:"udid"` - SerialNumber string `db:"serial_number"` - OSVersion string `db:"os_version"` - BuildVersion string `db:"build_version"` - ProductName string `db:"product_name"` - IMEI string `db:"imei"` - MEID string `db:"meid"` - PushMagic string `db:"push_magic"` - AwaitingConfiguration bool `db:"awaiting_configuration"` - Token string `db:"token"` - UnlockToken string `db:"unlock_token"` - Enrolled bool `db:"enrolled"` - Description string `db:"description"` - Model string `db:"model"` - ModelName string `db:"model_name"` - DeviceName string `db:"device_name"` - Color string `db:"color"` - AssetTag string `db:"asset_tag"` - DEPProfileStatus DEPProfileStatus `db:"dep_profile_status"` - DEPProfileUUID string `db:"dep_profile_uuid"` - DEPProfileAssignTime time.Time `db:"dep_profile_assign_time"` - DEPProfilePushTime time.Time `db:"dep_profile_push_time"` - DEPProfileAssignedDate time.Time `db:"dep_profile_assigned_date"` - DEPProfileAssignedBy string `db:"dep_profile_assigned_by"` - LastSeen time.Time `db:"last_seen"` -} - -// DEPProfileStatus is the status of the DEP Profile -// can be either "empty", "assigned", "pushed", or "removed" -type DEPProfileStatus string - -// DEPProfileStatus values -const ( - EMPTY DEPProfileStatus = "empty" - ASSIGNED = "assigned" - PUSHED = "pushed" - REMOVED = "removed" -) - -func MarshalDevice(dev *Device) ([]byte, error) { - protodev := deviceproto.Device{ - Uuid: dev.UUID, - Udid: dev.UDID, - SerialNumber: dev.SerialNumber, - OsVersion: dev.OSVersion, - BuildVersion: dev.BuildVersion, - ProductName: dev.ProductName, - Imei: dev.IMEI, - Meid: dev.MEID, - Token: dev.Token, - PushMagic: dev.PushMagic, - UnlockToken: dev.UnlockToken, - Enrolled: dev.Enrolled, - AwaitingConfiguration: dev.AwaitingConfiguration, - DeviceName: dev.DeviceName, - Model: dev.Model, - ModelName: dev.ModelName, - Description: dev.Description, - Color: dev.Color, - AssetTag: dev.AssetTag, - DepProfileStatus: string(dev.DEPProfileStatus), - DepProfileUuid: dev.DEPProfileUUID, - DepProfileAssignTime: timeToNano(dev.DEPProfileAssignTime), - DepProfilePushTime: timeToNano(dev.DEPProfilePushTime), - DepProfileAssignedDate: timeToNano(dev.DEPProfileAssignedDate), - DepProfileAssignedBy: dev.DEPProfileAssignedBy, - LastSeen: timeToNano(dev.LastSeen), - } - return proto.Marshal(&protodev) -} - -func UnmarshalDevice(data []byte, dev *Device) error { - var pb deviceproto.Device - if err := proto.Unmarshal(data, &pb); err != nil { - return errors.Wrap(err, "unmarshal proto to device") - } - dev.UUID = pb.GetUuid() - dev.UDID = pb.GetUdid() - dev.SerialNumber = pb.GetSerialNumber() - dev.OSVersion = pb.GetOsVersion() - dev.BuildVersion = pb.GetBuildVersion() - dev.ProductName = pb.GetProductName() - dev.IMEI = pb.GetImei() - dev.MEID = pb.GetMeid() - dev.Token = pb.GetToken() - dev.PushMagic = pb.GetPushMagic() - dev.UnlockToken = pb.GetUnlockToken() - dev.Enrolled = pb.GetEnrolled() - dev.AwaitingConfiguration = pb.GetAwaitingConfiguration() - dev.DeviceName = pb.GetDeviceName() - dev.Model = pb.GetModel() - dev.ModelName = pb.GetModelName() - dev.Description = pb.GetDescription() - dev.Color = pb.GetColor() - dev.AssetTag = pb.GetAssetTag() - dev.DEPProfileStatus = DEPProfileStatus(pb.GetDepProfileStatus()) - dev.DEPProfileUUID = pb.GetDepProfileUuid() - dev.DEPProfileAssignTime = timeFromNano(pb.GetDepProfileAssignTime()) - dev.DEPProfilePushTime = timeFromNano(pb.GetDepProfilePushTime()) - dev.DEPProfileAssignedDate = timeFromNano(pb.GetDepProfileAssignedDate()) - dev.DEPProfileAssignedBy = pb.GetDepProfileAssignedBy() - dev.LastSeen = timeFromNano(pb.GetLastSeen()) - return nil -} - -func timeToNano(t time.Time) int64 { - if t.IsZero() { - return 0 - } - return t.UnixNano() -} - -func timeFromNano(nano int64) time.Time { - if nano == 0 { - return time.Time{} - } - return time.Unix(0, nano).UTC() -} diff --git a/platform/device/get_devices.go b/platform/device/get_devices.go deleted file mode 100644 index bb52b39e..00000000 --- a/platform/device/get_devices.go +++ /dev/null @@ -1,85 +0,0 @@ -package device - -import ( - "context" - "net/http" - "time" - - "github.com/go-kit/kit/endpoint" - - "github.com/micromdm/micromdm/pkg/httputil" -) - -type ListDevicesOption struct { - Page int `json:"page"` - PerPage int `json:"per_page"` - - FilterSerial []string `json:"filter_serial"` - FilterUDID []string `json:"filter_udid"` -} - -type DeviceDTO struct { - SerialNumber string `json:"serial_number"` - UDID string `json:"udid"` - EnrollmentStatus bool `json:"enrollment_status"` - LastSeen time.Time `json:"last_seen"` - DEPProfileStatus DEPProfileStatus `json:"dep_profile_status"` -} - -func (svc *DeviceService) ListDevices(ctx context.Context, opt ListDevicesOption) ([]DeviceDTO, error) { - devices, err := svc.store.List(ctx, opt) - var dto []DeviceDTO - for _, d := range devices { - dto = append(dto, DeviceDTO{ - SerialNumber: d.SerialNumber, - UDID: d.UDID, - EnrollmentStatus: d.Enrolled, - LastSeen: d.LastSeen, - DEPProfileStatus: d.DEPProfileStatus, - }) - } - return dto, err -} - -type getDevicesRequest struct{ Opts ListDevicesOption } -type getDevicesResponse struct { - Devices []DeviceDTO `json:"devices"` - Err error `json:"err,omitempty"` -} - -func (r getDevicesResponse) Failed() error { return r.Err } - -func decodeListDevicesRequest(ctx context.Context, r *http.Request) (interface{}, error) { - var opts ListDevicesOption - err := httputil.DecodeJSONRequest(r, &opts) - req := getDevicesRequest{ - Opts: opts, - } - return req, err -} - -func decodeListDevicesResponse(_ context.Context, r *http.Response) (interface{}, error) { - var resp getDevicesResponse - err := httputil.DecodeJSONResponse(r, &resp) - return resp, err -} - -func MakeListDevicesEndpoint(svc Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (response interface{}, err error) { - req := request.(getDevicesRequest) - dto, err := svc.ListDevices(ctx, req.Opts) - return getDevicesResponse{ - Devices: dto, - Err: err, - }, nil - } -} - -func (e Endpoints) ListDevices(ctx context.Context, opts ListDevicesOption) ([]DeviceDTO, error) { - request := getDevicesRequest{opts} - response, err := e.ListDevicesEndpoint(ctx, request.Opts) - if err != nil { - return nil, err - } - return response.(getDevicesResponse).Devices, response.(getDevicesResponse).Err -} diff --git a/platform/device/internal/deviceproto/device.go b/platform/device/internal/deviceproto/device.go deleted file mode 100644 index 19b9639c..00000000 --- a/platform/device/internal/deviceproto/device.go +++ /dev/null @@ -1,3 +0,0 @@ -package deviceproto - -//go:generate protoc --go_out=. device.proto diff --git a/platform/device/internal/deviceproto/device.pb.go b/platform/device/internal/deviceproto/device.pb.go deleted file mode 100644 index c710cb1e..00000000 --- a/platform/device/internal/deviceproto/device.pb.go +++ /dev/null @@ -1,314 +0,0 @@ -// Code generated by protoc-gen-go. -// source: device.proto -// DO NOT EDIT! - -/* -Package deviceproto is a generated protocol buffer package. - -It is generated from these files: - device.proto - -It has these top-level messages: - Device -*/ -package deviceproto - -import proto "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package - -type Device struct { - Uuid string `protobuf:"bytes,1,opt,name=uuid" json:"uuid,omitempty"` - Udid string `protobuf:"bytes,2,opt,name=udid" json:"udid,omitempty"` - SerialNumber string `protobuf:"bytes,3,opt,name=serial_number,json=serialNumber" json:"serial_number,omitempty"` - OsVersion string `protobuf:"bytes,4,opt,name=os_version,json=osVersion" json:"os_version,omitempty"` - BuildVersion string `protobuf:"bytes,5,opt,name=build_version,json=buildVersion" json:"build_version,omitempty"` - ProductName string `protobuf:"bytes,6,opt,name=product_name,json=productName" json:"product_name,omitempty"` - Imei string `protobuf:"bytes,7,opt,name=imei" json:"imei,omitempty"` - Meid string `protobuf:"bytes,8,opt,name=meid" json:"meid,omitempty"` - Token string `protobuf:"bytes,9,opt,name=token" json:"token,omitempty"` - PushMagic string `protobuf:"bytes,10,opt,name=push_magic,json=pushMagic" json:"push_magic,omitempty"` - MdmTopic string `protobuf:"bytes,11,opt,name=mdm_topic,json=mdmTopic" json:"mdm_topic,omitempty"` - UnlockToken string `protobuf:"bytes,12,opt,name=unlock_token,json=unlockToken" json:"unlock_token,omitempty"` - Enrolled bool `protobuf:"varint,13,opt,name=enrolled" json:"enrolled,omitempty"` - AwaitingConfiguration bool `protobuf:"varint,14,opt,name=awaiting_configuration,json=awaitingConfiguration" json:"awaiting_configuration,omitempty"` - DeviceName string `protobuf:"bytes,15,opt,name=device_name,json=deviceName" json:"device_name,omitempty"` - Model string `protobuf:"bytes,16,opt,name=model" json:"model,omitempty"` - ModelName string `protobuf:"bytes,17,opt,name=model_name,json=modelName" json:"model_name,omitempty"` - Description string `protobuf:"bytes,18,opt,name=description" json:"description,omitempty"` - Color string `protobuf:"bytes,19,opt,name=color" json:"color,omitempty"` - AssetTag string `protobuf:"bytes,20,opt,name=asset_tag,json=assetTag" json:"asset_tag,omitempty"` - DepDevice bool `protobuf:"varint,21,opt,name=dep_device,json=depDevice" json:"dep_device,omitempty"` - DepProfileStatus string `protobuf:"bytes,22,opt,name=dep_profile_status,json=depProfileStatus" json:"dep_profile_status,omitempty"` - DepProfileUuid string `protobuf:"bytes,23,opt,name=dep_profile_uuid,json=depProfileUuid" json:"dep_profile_uuid,omitempty"` - DepProfileAssignTime int64 `protobuf:"varint,24,opt,name=dep_profile_assign_time,json=depProfileAssignTime" json:"dep_profile_assign_time,omitempty"` - DepProfilePushTime int64 `protobuf:"varint,25,opt,name=dep_profile_push_time,json=depProfilePushTime" json:"dep_profile_push_time,omitempty"` - DepProfileAssignedDate int64 `protobuf:"varint,26,opt,name=dep_profile_assigned_date,json=depProfileAssignedDate" json:"dep_profile_assigned_date,omitempty"` - DepProfileAssignedBy string `protobuf:"bytes,27,opt,name=dep_profile_assigned_by,json=depProfileAssignedBy" json:"dep_profile_assigned_by,omitempty"` - LastSeen int64 `protobuf:"varint,28,opt,name=last_seen,json=lastSeen" json:"last_seen,omitempty"` - LastQueryResponse []byte `protobuf:"bytes,29,opt,name=last_query_response,json=lastQueryResponse,proto3" json:"last_query_response,omitempty"` -} - -func (m *Device) Reset() { *m = Device{} } -func (m *Device) String() string { return proto.CompactTextString(m) } -func (*Device) ProtoMessage() {} -func (*Device) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } - -func (m *Device) GetUuid() string { - if m != nil { - return m.Uuid - } - return "" -} - -func (m *Device) GetUdid() string { - if m != nil { - return m.Udid - } - return "" -} - -func (m *Device) GetSerialNumber() string { - if m != nil { - return m.SerialNumber - } - return "" -} - -func (m *Device) GetOsVersion() string { - if m != nil { - return m.OsVersion - } - return "" -} - -func (m *Device) GetBuildVersion() string { - if m != nil { - return m.BuildVersion - } - return "" -} - -func (m *Device) GetProductName() string { - if m != nil { - return m.ProductName - } - return "" -} - -func (m *Device) GetImei() string { - if m != nil { - return m.Imei - } - return "" -} - -func (m *Device) GetMeid() string { - if m != nil { - return m.Meid - } - return "" -} - -func (m *Device) GetToken() string { - if m != nil { - return m.Token - } - return "" -} - -func (m *Device) GetPushMagic() string { - if m != nil { - return m.PushMagic - } - return "" -} - -func (m *Device) GetMdmTopic() string { - if m != nil { - return m.MdmTopic - } - return "" -} - -func (m *Device) GetUnlockToken() string { - if m != nil { - return m.UnlockToken - } - return "" -} - -func (m *Device) GetEnrolled() bool { - if m != nil { - return m.Enrolled - } - return false -} - -func (m *Device) GetAwaitingConfiguration() bool { - if m != nil { - return m.AwaitingConfiguration - } - return false -} - -func (m *Device) GetDeviceName() string { - if m != nil { - return m.DeviceName - } - return "" -} - -func (m *Device) GetModel() string { - if m != nil { - return m.Model - } - return "" -} - -func (m *Device) GetModelName() string { - if m != nil { - return m.ModelName - } - return "" -} - -func (m *Device) GetDescription() string { - if m != nil { - return m.Description - } - return "" -} - -func (m *Device) GetColor() string { - if m != nil { - return m.Color - } - return "" -} - -func (m *Device) GetAssetTag() string { - if m != nil { - return m.AssetTag - } - return "" -} - -func (m *Device) GetDepDevice() bool { - if m != nil { - return m.DepDevice - } - return false -} - -func (m *Device) GetDepProfileStatus() string { - if m != nil { - return m.DepProfileStatus - } - return "" -} - -func (m *Device) GetDepProfileUuid() string { - if m != nil { - return m.DepProfileUuid - } - return "" -} - -func (m *Device) GetDepProfileAssignTime() int64 { - if m != nil { - return m.DepProfileAssignTime - } - return 0 -} - -func (m *Device) GetDepProfilePushTime() int64 { - if m != nil { - return m.DepProfilePushTime - } - return 0 -} - -func (m *Device) GetDepProfileAssignedDate() int64 { - if m != nil { - return m.DepProfileAssignedDate - } - return 0 -} - -func (m *Device) GetDepProfileAssignedBy() string { - if m != nil { - return m.DepProfileAssignedBy - } - return "" -} - -func (m *Device) GetLastSeen() int64 { - if m != nil { - return m.LastSeen - } - return 0 -} - -func (m *Device) GetLastQueryResponse() []byte { - if m != nil { - return m.LastQueryResponse - } - return nil -} - -func init() { - proto.RegisterType((*Device)(nil), "deviceproto.Device") -} - -func init() { proto.RegisterFile("device.proto", fileDescriptor0) } - -var fileDescriptor0 = []byte{ - // 557 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x94, 0x41, 0x4f, 0x1b, 0x31, - 0x10, 0x85, 0x95, 0x02, 0x21, 0x71, 0x02, 0x0d, 0x26, 0x09, 0x03, 0x14, 0x35, 0x6d, 0x2f, 0x39, - 0x54, 0x48, 0x55, 0xc5, 0xa1, 0xc7, 0xb6, 0x5c, 0x8b, 0x68, 0x48, 0x7b, 0xb5, 0x9c, 0xf5, 0xb0, - 0x58, 0xac, 0xed, 0xad, 0xed, 0xa5, 0xca, 0x2f, 0xef, 0xb5, 0xf2, 0x38, 0x90, 0xa8, 0xf4, 0xe6, - 0xf9, 0xde, 0xbc, 0xf1, 0xcc, 0xac, 0xb5, 0xac, 0xaf, 0xf0, 0x41, 0x17, 0x78, 0x5e, 0x7b, 0x17, - 0x1d, 0xef, 0xe5, 0x88, 0x82, 0xb7, 0x7f, 0x76, 0x59, 0xfb, 0x92, 0x62, 0xce, 0xd9, 0x76, 0xd3, - 0x68, 0x05, 0xad, 0x49, 0x6b, 0xda, 0x9d, 0xd1, 0x99, 0x98, 0xd2, 0x0a, 0x5e, 0xac, 0x98, 0xd2, - 0x8a, 0xbf, 0x63, 0x7b, 0x01, 0xbd, 0x96, 0x95, 0xb0, 0x8d, 0x59, 0xa0, 0x87, 0x2d, 0x12, 0xfb, - 0x19, 0x5e, 0x11, 0xe3, 0x67, 0x8c, 0xb9, 0x20, 0x1e, 0xd0, 0x07, 0xed, 0x2c, 0x6c, 0x53, 0x46, - 0xd7, 0x85, 0x9f, 0x19, 0xa4, 0x1a, 0x8b, 0x46, 0x57, 0xea, 0x29, 0x63, 0x27, 0xd7, 0x20, 0xf8, - 0x98, 0xf4, 0x86, 0xf5, 0x6b, 0xef, 0x54, 0x53, 0x44, 0x61, 0xa5, 0x41, 0x68, 0x53, 0x4e, 0x6f, - 0xc5, 0xae, 0xa4, 0xa1, 0x9e, 0xb5, 0x41, 0x0d, 0xbb, 0xb9, 0xbf, 0x74, 0x4e, 0xcc, 0xa0, 0x56, - 0xd0, 0xc9, 0x2c, 0x9d, 0xf9, 0x90, 0xed, 0x44, 0x77, 0x8f, 0x16, 0xba, 0x04, 0x73, 0x90, 0x9a, - 0xac, 0x9b, 0x70, 0x27, 0x8c, 0x2c, 0x75, 0x01, 0x2c, 0x37, 0x99, 0xc8, 0xb7, 0x04, 0xf8, 0x29, - 0xeb, 0x1a, 0x65, 0x44, 0x74, 0xb5, 0x2e, 0xa0, 0x47, 0x6a, 0xc7, 0x28, 0x33, 0x4f, 0x71, 0x6a, - 0xae, 0xb1, 0x95, 0x2b, 0xee, 0x45, 0x2e, 0xdc, 0xcf, 0xcd, 0x65, 0x36, 0xa7, 0xf2, 0x27, 0xac, - 0x83, 0xd6, 0xbb, 0xaa, 0x42, 0x05, 0x7b, 0x93, 0xd6, 0xb4, 0x33, 0x7b, 0x8a, 0xf9, 0x05, 0x1b, - 0xcb, 0xdf, 0x52, 0x47, 0x6d, 0x4b, 0x51, 0x38, 0x7b, 0xab, 0xcb, 0xc6, 0xcb, 0x98, 0x36, 0xb1, - 0x4f, 0x99, 0xa3, 0x47, 0xf5, 0xeb, 0xa6, 0xc8, 0x5f, 0xb3, 0xd5, 0xd7, 0xcb, 0x1b, 0x79, 0x49, - 0x97, 0xb2, 0x8c, 0x68, 0x21, 0x43, 0xb6, 0x63, 0x9c, 0xc2, 0x0a, 0x06, 0x79, 0x50, 0x0a, 0xd2, - 0xa0, 0x74, 0xc8, 0xae, 0x83, 0x3c, 0x28, 0x11, 0x32, 0x4d, 0x52, 0xd5, 0x50, 0x78, 0x5d, 0x53, - 0x07, 0x3c, 0x8f, 0xb2, 0x81, 0x52, 0xd9, 0xc2, 0x55, 0xce, 0xc3, 0x61, 0x2e, 0x4b, 0x41, 0x5a, - 0x90, 0x0c, 0x01, 0xa3, 0x88, 0xb2, 0x84, 0x61, 0x5e, 0x10, 0x81, 0xb9, 0x2c, 0xd3, 0x9d, 0x0a, - 0x6b, 0x91, 0x7b, 0x83, 0x11, 0x4d, 0xd5, 0x55, 0x58, 0xaf, 0x5e, 0xdb, 0x7b, 0xc6, 0x93, 0x5c, - 0x7b, 0x77, 0xab, 0x2b, 0x14, 0x21, 0xca, 0xd8, 0x04, 0x18, 0x53, 0x91, 0x81, 0xc2, 0xfa, 0x3a, - 0x0b, 0x37, 0xc4, 0xf9, 0x94, 0x0d, 0x36, 0xb3, 0xe9, 0x9d, 0x1e, 0x51, 0xee, 0xfe, 0x3a, 0xf7, - 0x47, 0x7a, 0xb1, 0x17, 0xec, 0x68, 0x33, 0x53, 0x86, 0xa0, 0x4b, 0x2b, 0xa2, 0x36, 0x08, 0x30, - 0x69, 0x4d, 0xb7, 0x66, 0xc3, 0xb5, 0xe1, 0x33, 0x89, 0x73, 0x6d, 0x90, 0x7f, 0x60, 0xa3, 0x4d, - 0x1b, 0x3d, 0x0b, 0x32, 0x1d, 0x93, 0x89, 0xaf, 0x4d, 0xd7, 0x4d, 0xb8, 0x23, 0xcb, 0x27, 0x76, - 0xfc, 0xfc, 0x26, 0x54, 0x42, 0xc9, 0x88, 0x70, 0x42, 0xb6, 0xf1, 0xbf, 0x77, 0xa1, 0xba, 0x94, - 0x11, 0xff, 0xdf, 0x24, 0x2a, 0xb1, 0x58, 0xc2, 0x29, 0x4d, 0x35, 0x7c, 0x6e, 0xfc, 0xb2, 0x4c, - 0xfb, 0xae, 0x64, 0x88, 0x22, 0x20, 0x5a, 0x78, 0x45, 0x37, 0x74, 0x12, 0xb8, 0x41, 0xb4, 0xfc, - 0x9c, 0x1d, 0x92, 0xf8, 0xab, 0x41, 0xbf, 0x14, 0x1e, 0x43, 0xed, 0x6c, 0x40, 0x38, 0x9b, 0xb4, - 0xa6, 0xfd, 0xd9, 0x41, 0x92, 0xbe, 0x27, 0x65, 0xb6, 0x12, 0x16, 0x6d, 0xfa, 0x01, 0x7c, 0xfc, - 0x1b, 0x00, 0x00, 0xff, 0xff, 0x9b, 0x06, 0xcd, 0x66, 0x1d, 0x04, 0x00, 0x00, -} diff --git a/platform/device/internal/deviceproto/device.proto b/platform/device/internal/deviceproto/device.proto deleted file mode 100644 index 27a3d0b6..00000000 --- a/platform/device/internal/deviceproto/device.proto +++ /dev/null @@ -1,37 +0,0 @@ -syntax = "proto3"; - -package deviceproto; - - -message Device { - string uuid = 1; - string udid = 2; - string serial_number = 3; - string os_version = 4; - string build_version = 5; - string product_name = 6; - string imei = 7; - string meid = 8; - string token = 9; - string push_magic = 10; - string mdm_topic = 11; - string unlock_token = 12; - bool enrolled = 13; - bool awaiting_configuration = 14; - string device_name = 15; - string model = 16; - string model_name =17; - string description =18; - string color =19; - string asset_tag =20; - bool dep_device =21; - string dep_profile_status =22; - string dep_profile_uuid =23; - int64 dep_profile_assign_time =24; - int64 dep_profile_push_time =25; - int64 dep_profile_assigned_date =26; - string dep_profile_assigned_by =27; - int64 last_seen =28; - bytes last_query_response =29; - -} diff --git a/platform/device/pg/pg.go b/platform/device/pg/pg.go deleted file mode 100644 index 016aa448..00000000 --- a/platform/device/pg/pg.go +++ /dev/null @@ -1,212 +0,0 @@ -package pg - -import ( - "context" - "database/sql" - "strings" - - "github.com/jmoiron/sqlx" - "github.com/pkg/errors" - sq "gopkg.in/Masterminds/squirrel.v1" - - "github.com/micromdm/micromdm/platform/device" -) - -type Postgres struct{ db *sqlx.DB } - -func New(db *sqlx.DB) *Postgres { - return &Postgres{db: db} -} - -func columns() []string { - return []string{ - "uuid", - "udid", - "serial_number", - "os_version", - "build_version", - "product_name", - "imei", - "meid", - "push_magic", - "awaiting_configuration", - "token", - "unlock_token", - "enrolled", - "description", - "model", - "model_name", - "device_name", - "color", - "asset_tag", - "dep_profile_status", - "dep_profile_uuid", - "dep_profile_assign_time", - "dep_profile_push_time", - "dep_profile_assigned_date", - "dep_profile_assigned_by", - "last_seen", - } -} - -const tableName = "devices" - -func (d *Postgres) Save(ctx context.Context, device *device.Device) error { - updateQuery, _, err := sq.StatementBuilder.PlaceholderFormat(sq.Dollar). - Update(tableName). - Prefix("ON CONFLICT (uuid) DO"). - Set("uuid", device.UUID). - Set("udid", device.UDID). - Set("serial_number", device.SerialNumber). - Set("os_version", device.OSVersion). - Set("build_version", device.BuildVersion). - Set("product_name", device.ProductName). - Set("imei", device.IMEI). - Set("meid", device.MEID). - Set("push_magic", device.PushMagic). - Set("awaiting_configuration", device.AwaitingConfiguration). - Set("token", device.Token). - Set("unlock_token", device.UnlockToken). - Set("enrolled", device.Enrolled). - Set("description", device.Description). - Set("model", device.Model). - Set("model_name", device.ModelName). - Set("device_name", device.DeviceName). - Set("color", device.Color). - Set("asset_tag", device.AssetTag). - Set("dep_profile_status", device.DEPProfileStatus). - Set("dep_profile_uuid", device.DEPProfileUUID). - Set("dep_profile_assign_time", device.DEPProfileAssignTime). - Set("dep_profile_push_time", device.DEPProfilePushTime). - Set("dep_profile_assigned_date", device.DEPProfileAssignedDate). - Set("dep_profile_assigned_by", device.DEPProfileAssignedBy). - Set("last_seen", device.LastSeen). - ToSql() - if err != nil { - return errors.Wrap(err, "building update query for device save") - } - updateQuery = strings.Replace(updateQuery, tableName, "", -1) - - query, args, err := sq.StatementBuilder.PlaceholderFormat(sq.Dollar). - Insert(tableName). - Columns(columns()...). - Values( - device.UUID, - device.UDID, - device.SerialNumber, - device.OSVersion, - device.BuildVersion, - device.ProductName, - device.IMEI, - device.MEID, - device.PushMagic, - device.AwaitingConfiguration, - device.Token, - device.UnlockToken, - device.Enrolled, - device.Description, - device.Model, - device.ModelName, - device.DeviceName, - device.Color, - device.AssetTag, - device.DEPProfileStatus, - device.DEPProfileUUID, - device.DEPProfileAssignTime, - device.DEPProfilePushTime, - device.DEPProfileAssignedDate, - device.DEPProfileAssignedBy, - device.LastSeen, - ). - Suffix(updateQuery). - ToSql() - if err != nil { - return errors.Wrap(err, "building device save query") - } - - _, err = d.db.ExecContext(ctx, query, args...) - return errors.Wrap(err, "exec device save in pg") -} - -func (d *Postgres) DeviceByUDID(ctx context.Context, udid string) (*device.Device, error) { - query, args, err := sq.StatementBuilder.PlaceholderFormat(sq.Dollar). - Select(columns()...). - From(tableName). - Where(sq.Eq{"udid": udid}). - ToSql() - if err != nil { - return nil, errors.Wrap(err, "building sql") - } - - var dev device.Device - err = d.db.QueryRowxContext(ctx, query, args...).StructScan(&dev) - if errors.Cause(err) == sql.ErrNoRows { - return nil, deviceNotFoundErr{} - } - return &dev, errors.Wrap(err, "finding device by udid") -} - -func (d *Postgres) DeviceBySerial(ctx context.Context, serial string) (*device.Device, error) { - query, args, err := sq.StatementBuilder.PlaceholderFormat(sq.Dollar). - Select(columns()...). - From(tableName). - Where(sq.Eq{"serial_number": serial}). - ToSql() - if err != nil { - return nil, errors.Wrap(err, "building sql") - } - - var dev device.Device - err = d.db.QueryRowxContext(ctx, query, args...).StructScan(&dev) - if errors.Cause(err) == sql.ErrNoRows { - return nil, deviceNotFoundErr{} - } - return &dev, errors.Wrap(err, "finding device by serial") -} - -func (d *Postgres) ListDevices(ctx context.Context, opt device.ListDevicesOption) ([]device.Device, error) { - query, args, err := sq.StatementBuilder.PlaceholderFormat(sq.Dollar). - Select(columns()...). - From(tableName). - ToSql() - if err != nil { - return nil, errors.Wrap(err, "building sql") - } - var list []device.Device - err = d.db.SelectContext(ctx, &list, query, args...) - return list, errors.Wrap(err, "list devices") -} - -func (d *Postgres) DeleteByUDID(ctx context.Context, udid string) error { - query, args, err := sq.StatementBuilder.PlaceholderFormat(sq.Dollar). - Delete(tableName). - Where(sq.Eq{"udid": udid}). - ToSql() - if err != nil { - return errors.Wrap(err, "building sql") - } - _, err = d.db.ExecContext(ctx, query, args...) - return errors.Wrap(err, "delete device by udid") -} - -func (d *Postgres) DeleteBySerial(ctx context.Context, serial string) error { - query, args, err := sq.StatementBuilder.PlaceholderFormat(sq.Dollar). - Delete(tableName). - Where(sq.Eq{"serial_number": serial}). - ToSql() - if err != nil { - return errors.Wrap(err, "building sql") - } - _, err = d.db.ExecContext(ctx, query, args...) - return errors.Wrap(err, "delete device by serial_number") -} - -type deviceNotFoundErr struct{} - -func (e deviceNotFoundErr) Error() string { - return "device not found" -} - -func (e deviceNotFoundErr) NotFound() bool { - return true -} diff --git a/platform/device/pg/pg_test.go b/platform/device/pg/pg_test.go deleted file mode 100644 index aa45f41b..00000000 --- a/platform/device/pg/pg_test.go +++ /dev/null @@ -1,73 +0,0 @@ -package pg - -import ( - "context" - "testing" - "time" - - "github.com/go-kit/kit/log" - "github.com/kolide/kit/dbutil" - _ "github.com/lib/pq" - "github.com/micromdm/micromdm/platform/device" -) - -func TestPGCrud(t *testing.T) { - db := setup(t) - ctx := context.Background() - - // create - dev := &device.Device{ - UUID: "foobar", - UDID: "foobar", - DEPProfileStatus: device.ASSIGNED, - LastSeen: time.Now().UTC(), - } - err := db.Save(ctx, dev) - if err != nil { - t.Fatal(err) - } - - // update - dev.DEPProfileStatus = device.PUSHED - err = db.Save(ctx, dev) - if err != nil { - t.Fatal(err) - } - - // find - found, err := db.DeviceByUDID(ctx, dev.UDID) - if err != nil { - t.Fatal(err) - } - - if have, want := found.DEPProfileStatus, dev.DEPProfileStatus; have != want { - t.Errorf("have %v, want %v", have, want) - } - - // list - devices, err := db.ListDevices(ctx, device.ListDevicesOption{}) - if err != nil { - t.Fatal(err) - } - - // delete - for _, dev := range devices { - if err := db.DeleteByUDID(ctx, dev.UDID); err != nil { - t.Fatal(err) - } - } -} - -func setup(t *testing.T) *Postgres { - db, err := dbutil.OpenDBX( - "postgres", - "host=localhost port=5432 user=micromdm dbname=micromdm_test password=micromdm sslmode=disable", - dbutil.WithLogger(log.NewNopLogger()), - dbutil.WithMaxAttempts(1), - ) - if err != nil { - t.Fatal(err) - } - - return New(db) -} diff --git a/platform/device/remove_devices.go b/platform/device/remove_devices.go deleted file mode 100644 index eb471ad0..00000000 --- a/platform/device/remove_devices.go +++ /dev/null @@ -1,66 +0,0 @@ -package device - -import ( - "context" - "net/http" - - "github.com/go-kit/kit/endpoint" - "github.com/micromdm/micromdm/pkg/httputil" -) - -func (svc *DeviceService) RemoveDevices(ctx context.Context, opt RemoveDevicesOptions) error { - for _, udid := range opt.UDIDs { - err := svc.store.DeleteByUDID(ctx, udid) - if err != nil { - return err - } - } - - for _, serial := range opt.Serials { - err := svc.store.DeleteBySerial(ctx, serial) - if err != nil { - return err - } - } - - return nil -} - -type removeDevicesRequest struct{ Opts RemoveDevicesOptions } - -type removeDevicesResponse struct { - Err error `json:"err,omitempty"` -} - -func (r removeDevicesResponse) Failed() error { return r.Err } - -func decodeRemoveDevicesRequest(ctx context.Context, r *http.Request) (interface{}, error) { - var req removeDevicesRequest - err := httputil.DecodeJSONRequest(r, &req) - return req, err -} - -func decodeRemoveDevicesResponse(_ context.Context, r *http.Response) (interface{}, error) { - var resp removeDevicesResponse - err := httputil.DecodeJSONResponse(r, &resp) - return resp, err -} - -func MakeRemoveDevicesEndpoint(svc Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (response interface{}, err error) { - req := request.(removeDevicesRequest) - err = svc.RemoveDevices(ctx, req.Opts) - return removeDevicesResponse{ - Err: err, - }, nil - } -} - -func (e Endpoints) RemoveDevices(ctx context.Context, Opts RemoveDevicesOptions) error { - request := removeDevicesRequest{Opts: Opts} - resp, err := e.RemoveDevicesEndpoint(ctx, request) - if err != nil { - return err - } - return resp.(removeDevicesResponse).Err -} diff --git a/platform/device/server.go b/platform/device/server.go deleted file mode 100644 index f6558c5e..00000000 --- a/platform/device/server.go +++ /dev/null @@ -1,40 +0,0 @@ -package device - -import ( - "github.com/go-kit/kit/endpoint" - httptransport "github.com/go-kit/kit/transport/http" - "github.com/gorilla/mux" - - "github.com/micromdm/micromdm/pkg/httputil" -) - -type Endpoints struct { - ListDevicesEndpoint endpoint.Endpoint - RemoveDevicesEndpoint endpoint.Endpoint -} - -func MakeServerEndpoints(s Service, outer endpoint.Middleware, others ...endpoint.Middleware) Endpoints { - return Endpoints{ - ListDevicesEndpoint: endpoint.Chain(outer, others...)(MakeListDevicesEndpoint(s)), - RemoveDevicesEndpoint: endpoint.Chain(outer, others...)(MakeRemoveDevicesEndpoint(s)), - } -} - -func RegisterHTTPHandlers(r *mux.Router, e Endpoints, options ...httptransport.ServerOption) { - // POST /v1/devices get a list of devices managed by the server - // DELETE /v1/devices remove one or more devices from the server - - r.Methods("POST").Path("/v1/devices").Handler(httptransport.NewServer( - e.ListDevicesEndpoint, - decodeListDevicesRequest, - httputil.EncodeJSONResponse, - options..., - )) - - r.Methods("DELETE").Path("/v1/devices").Handler(httptransport.NewServer( - e.RemoveDevicesEndpoint, - decodeRemoveDevicesRequest, - httputil.EncodeJSONResponse, - options..., - )) -} diff --git a/platform/device/service.go b/platform/device/service.go deleted file mode 100644 index d71cf724..00000000 --- a/platform/device/service.go +++ /dev/null @@ -1,29 +0,0 @@ -package device - -import ( - "context" -) - -type RemoveDevicesOptions struct { - UDIDs []string `json:"udids"` - Serials []string `json:"serials"` -} - -type Service interface { - ListDevices(ctx context.Context, opt ListDevicesOption) ([]DeviceDTO, error) - RemoveDevices(ctx context.Context, opt RemoveDevicesOptions) error -} - -type Store interface { - List(ctx context.Context, opt ListDevicesOption) ([]Device, error) - DeleteByUDID(ctx context.Context, udid string) error - DeleteBySerial(ctx context.Context, serial string) error -} - -type DeviceService struct { - store Store -} - -func New(store Store) *DeviceService { - return &DeviceService{store: store} -} diff --git a/platform/device/udidauth.go b/platform/device/udidauth.go deleted file mode 100644 index aa8295ff..00000000 --- a/platform/device/udidauth.go +++ /dev/null @@ -1,114 +0,0 @@ -package device - -import ( - "context" - "crypto/sha256" - "crypto/subtle" - - "github.com/go-kit/kit/log" - "github.com/go-kit/kit/log/level" - "github.com/pkg/errors" - - "github.com/micromdm/micromdm/mdm" -) - -type UDIDCertAuthStore interface { - SaveUDIDCertHash(udid, certHash []byte) error - GetUDIDCertHash(udid []byte) ([]byte, error) -} - -func UDIDCertAuthMiddleware(store UDIDCertAuthStore, logger log.Logger) mdm.Middleware { - return func(next mdm.Service) mdm.Service { - return &udidCertAuthMiddleware{ - store: store, - next: next, - logger: logger, - } - } -} - -type udidCertAuthMiddleware struct { - store UDIDCertAuthStore - next mdm.Service - logger log.Logger -} - -func hashCertRaw(c []byte) []byte { - retBytes := make([]byte, 32) - sum := sha256.Sum256(c) - copy(retBytes, sum[:]) - return retBytes -} - -func (mw *udidCertAuthMiddleware) validateUDIDCertAuth(udid, certHash []byte) (bool, error) { - dbCertHash, err := mw.store.GetUDIDCertHash(udid) - if err != nil && !isNotFound(err) { - return false, err - } else if err != nil && isNotFound(err) { - // TODO: we did not find any UDID at all. assume (but log) that - // this device already existed/was enrolled and we need to store - // its UDID-cert association. at some later late, when most/all - // micromdm instances have stored udid-cert associations - // this can be an outright failure. - level.Info(mw.logger).Log("msg", "device cert hash not found, saving anyway", "udid", string(udid)) - if err := mw.store.SaveUDIDCertHash(udid, certHash); err != nil { - return false, err - } - return true, nil - } - if 1 != subtle.ConstantTimeCompare(certHash, dbCertHash) { - level.Info(mw.logger).Log("msg", "device cert hash mismatch", "udid", string(udid)) - return false, nil - } - return true, nil -} - -func (mw *udidCertAuthMiddleware) Acknowledge(ctx context.Context, req mdm.AcknowledgeEvent) ([]byte, error) { - // only validate device enrollments, user enrollments should be separate. - if req.Response.EnrollmentID != nil { - return mw.next.Acknowledge(ctx, req) - } - - devcert, err := mdm.DeviceCertificateFromContext(ctx) - if err != nil { - return nil, errors.Wrap(err, "error retrieving device certificate") - } - matched, err := mw.validateUDIDCertAuth([]byte(req.Response.UDID), hashCertRaw(devcert.Raw)) - if err != nil { - return nil, err - } - if !matched { - return nil, errors.New("device certifcate UDID mismatch") - } - return mw.next.Acknowledge(ctx, req) -} - -func (mw *udidCertAuthMiddleware) Checkin(ctx context.Context, req mdm.CheckinEvent) error { - // only validate device enrollments, user enrollments should be separate. - if req.Command.EnrollmentID != "" { - return mw.next.Checkin(ctx, req) - } - devcert, err := mdm.DeviceCertificateFromContext(ctx) - if err != nil { - return errors.Wrap(err, "error retrieving device certificate") - } - switch req.Command.MessageType { - case "Authenticate": - // unconditionally save the cert hash on Authenticate message - if err := mw.store.SaveUDIDCertHash([]byte(req.Command.UDID), hashCertRaw(devcert.Raw)); err != nil { - return err - } - return mw.next.Checkin(ctx, req) - case "TokenUpdate", "CheckOut": - matched, err := mw.validateUDIDCertAuth([]byte(req.Command.UDID), hashCertRaw(devcert.Raw)) - if err != nil { - return err - } - if !matched { - return errors.New("device certifcate UDID mismatch") - } - return mw.next.Checkin(ctx, req) - default: - return errors.Errorf("unknown checkin message type %s", req.Command.MessageType) - } -} diff --git a/platform/device/worker.go b/platform/device/worker.go deleted file mode 100644 index 230664b0..00000000 --- a/platform/device/worker.go +++ /dev/null @@ -1,306 +0,0 @@ -package device - -import ( - "context" - "time" - - "github.com/go-kit/kit/log" - "github.com/go-kit/kit/log/level" - "github.com/google/uuid" - "github.com/pkg/errors" - - "github.com/micromdm/micromdm/mdm" - "github.com/micromdm/micromdm/platform/dep/sync" - "github.com/micromdm/micromdm/platform/pubsub" -) - -type DeviceWorkerStore interface { - Save(ctx context.Context, d *Device) error - DeviceByUDID(ctx context.Context, udid string) (*Device, error) - DeviceBySerial(ctx context.Context, serial string) (*Device, error) -} - -type Worker struct { - db DeviceWorkerStore - ps pubsub.PublishSubscriber - logger log.Logger -} - -func NewWorker(db DeviceWorkerStore, ps pubsub.PublishSubscriber, logger log.Logger) *Worker { - return &Worker{ - db: db, - ps: ps, - logger: logger, - } -} - -func (w *Worker) Run(ctx context.Context) error { - const subscription = "devices_worker" - authenticateEvents, err := w.ps.Subscribe(ctx, subscription, mdm.AuthenticateTopic) - if err != nil { - return errors.Wrapf(err, "subscribing %s to %s", subscription, mdm.AuthenticateTopic) - } - tokenUpdateEvents, err := w.ps.Subscribe(ctx, subscription, mdm.TokenUpdateTopic) - if err != nil { - return errors.Wrapf(err, "subscribing %s to %s", subscription, mdm.TokenUpdateTopic) - } - checkoutEvents, err := w.ps.Subscribe(ctx, subscription, mdm.CheckoutTopic) - if err != nil { - return errors.Wrapf(err, "subscribing %s to %s", subscription, mdm.CheckoutTopic) - } - depSyncEvents, err := w.ps.Subscribe(ctx, subscription, sync.SyncTopic) - if err != nil { - return errors.Wrapf(err, "subscribing %s to %s", subscription, sync.SyncTopic) - } - connectEvents, err := w.ps.Subscribe(ctx, subscription, mdm.ConnectTopic) - if err != nil { - return errors.Wrapf(err, "subscribing %s to %s", subscription, mdm.ConnectTopic) - } - - for { - var err error - select { - case <-ctx.Done(): - return ctx.Err() - case ev := <-authenticateEvents: - err = w.updateFromAuthenticate(ctx, ev.Message) - case ev := <-tokenUpdateEvents: - err = w.updateFromTokenUpdate(ctx, ev.Message) - case ev := <-checkoutEvents: - err = w.updateFromCheckout(ctx, ev.Message) - case ev := <-depSyncEvents: - err = w.updateFromDEPSync(ctx, ev.Message) - case ev := <-connectEvents: - err = w.updateFromAcknowledge(ctx, ev.Message) - } - if err != nil { - level.Info(w.logger).Log( - "msg", "update device from event", - "err", err, - ) - continue - } - } -} - -func (w *Worker) updateFromDEPSync(ctx context.Context, message []byte) error { - var ev sync.Event - if err := sync.UnmarshalEvent(message, &ev); err != nil { - return errors.Wrap(err, "unmarshal depsync event") - } - level.Debug(w.logger).Log( - "msg", "updating devices from DEP", - "device_count", len(ev.Devices), - ) - - for _, dd := range ev.Devices { - dev, err := getOrCreateDeviceBySerial(ctx, w.db, dd.SerialNumber) - if err != nil { - return errors.Wrap(err, "get device by serial") - } - - notSeenBefore := dev.UUID == "" - logEvent := dd.OpType == "deleted" || - (notSeenBefore && dd.OpType == "added") || - (!notSeenBefore && dd.OpType == "modified") - if logEvent { - level.Debug(w.logger).Log( - "msg", "updating devices from dep sync", - "op_type", dd.OpType, - "serial", dd.SerialNumber, - "previously_known", !notSeenBefore, - ) - } - - if dev.UUID == "" { - dev.UUID = uuid.New().String() - } - - dev.SerialNumber = dd.SerialNumber - dev.Model = dd.Model - dev.Description = dd.Description - dev.Color = dd.Color - dev.AssetTag = dd.AssetTag - dev.DEPProfileStatus = DEPProfileStatus(dd.ProfileStatus) - dev.DEPProfileUUID = dd.ProfileUUID - dev.DEPProfileAssignTime = dd.ProfileAssignTime - dev.DEPProfileAssignedDate = dd.DeviceAssignedDate - dev.DEPProfileAssignedBy = dd.DeviceAssignedBy - - if err := w.db.Save(ctx, dev); err != nil { - return errors.Wrap(err, "save device %s from DEP sync") - } - } - - return nil -} - -func (w *Worker) updateFromAcknowledge(ctx context.Context, message []byte) error { - var ev mdm.AcknowledgeEvent - if err := mdm.UnmarshalAcknowledgeEvent(message, &ev); err != nil { - return errors.Wrap(err, "unmarshal acknowledge event") - } - - if ev.Response.EnrollmentID != nil { - return nil - } - - dev, err := w.db.DeviceByUDID(ctx, ev.Response.UDID) - if err != nil { - return errors.Wrapf(err, "retrieve device with udid %s", ev.Response.UDID) - } - dev.LastSeen = time.Now() - - err = w.db.Save(ctx, dev) - return errors.Wrapf(err, "saving updated device for acknowledge event") - -} - -func (w *Worker) updateFromCheckout(ctx context.Context, message []byte) error { - var ev mdm.CheckinEvent - if err := mdm.UnmarshalCheckinEvent(message, &ev); err != nil { - return errors.Wrap(err, "unmarshal checkin event") - } - - if ev.Command.EnrollmentID != "" { - return nil - } - - dev, err := w.db.DeviceByUDID(ctx, ev.Command.UDID) - if err != nil { - return errors.Wrapf(err, "retrieve device with udid %s", ev.Command.UDID) - } - - dev.Enrolled = false - dev.LastSeen = time.Now() - - err = w.db.Save(ctx, dev) - return errors.Wrapf(err, "saving updated device for checkout event") - -} - -func (w *Worker) updateFromTokenUpdate(ctx context.Context, message []byte) error { - var ev mdm.CheckinEvent - if err := mdm.UnmarshalCheckinEvent(message, &ev); err != nil { - return errors.Wrap(err, "unmarshal checkin event") - } - - // do not process managed user, or user enrollment checkin events while updating device records. - if ev.Command.UserID != "" || ev.Command.EnrollmentID != "" { - return nil - } - - dev, err := w.db.DeviceByUDID(ctx, ev.Command.UDID) - if err != nil { - return errors.Wrapf(err, "retrieve device with udid %s", ev.Command.UDID) - } - dev.Token = ev.Command.Token.String() - dev.PushMagic = ev.Command.PushMagic - dev.UnlockToken = ev.Command.UnlockToken.String() - dev.AwaitingConfiguration = ev.Command.AwaitingConfiguration - dev.LastSeen = time.Now() - // first TokenUpdate event will have the enrollment status set to false. - newlyEnrolled := !dev.Enrolled - dev.Enrolled = true - if err := w.db.Save(ctx, dev); err != nil { - return errors.Wrapf(err, "saving updated device for Token event udid=%s", ev.Command.UDID) - } - - if newlyEnrolled { - // notify subscribers of a successful enrollment - // TODO: The enrollment topic needs a custom event. - err = w.ps.Publish(ctx, DeviceEnrolledTopic, message) - return errors.Wrap(err, "publishing new enrollment message") - } - return nil -} - -func (w *Worker) updateFromAuthenticate(ctx context.Context, message []byte) error { - var ev mdm.CheckinEvent - if err := mdm.UnmarshalCheckinEvent(message, &ev); err != nil { - return errors.Wrap(err, "unmarshal checkin event") - } - - if ev.Command.EnrollmentID != "" { - return nil - } - - device, reenrolling, err := getOrCreateDevice(ctx, w.db, ev.Command.SerialNumber, ev.Command.UDID) - if err != nil { - return errors.Wrap(err, "get device for authenticate event") - } - - if reenrolling { - level.Debug(w.logger).Log( - "msg", "re-enrolling device", - "serial", ev.Command.SerialNumber, - ) - } else { - level.Debug(w.logger).Log( - "msg", "enrolling new device", - "serial", ev.Command.SerialNumber, - ) - } - - if device.UUID == "" { - device.UUID = uuid.New().String() - } - device.UDID = ev.Command.UDID - device.OSVersion = ev.Command.OSVersion - device.BuildVersion = ev.Command.BuildVersion - device.ProductName = ev.Command.ProductName - device.SerialNumber = ev.Command.SerialNumber - device.IMEI = ev.Command.IMEI - device.MEID = ev.Command.MEID - device.DeviceName = ev.Command.DeviceName - device.Model = ev.Command.Model - device.ModelName = ev.Command.ModelName - device.LastSeen = time.Now() - err = w.db.Save(ctx, device) - return errors.Wrapf(err, "saving updated device for authenticate event") -} - -func getOrCreateDevice(ctx context.Context, db DeviceWorkerStore, serial, udid string) (dev *Device, reenrolling bool, err error) { - if udid != "" { - // first try to fetch a device by UDID. - // If the device was previously enrolled it will exist. - // In case the device is known, set the enrolled status to false before returning. - byUDID, err := db.DeviceByUDID(ctx, udid) - if err == nil { - byUDID.Enrolled = false - return byUDID, true, nil - } - if err != nil && !isNotFound(err) { - return nil, false, errors.Wrapf(err, "retrieve device with udid %s and serial %s", udid, serial) - } - } - - // next try to find the device by serial. If found, it's a DEP device, which contains only the - // serials but not a udid. - dev, err = getOrCreateDeviceBySerial(ctx, db, serial) - return dev, false, err -} - -func getOrCreateDeviceBySerial(ctx context.Context, db DeviceWorkerStore, serial string) (*Device, error) { - bySerial, err := db.DeviceBySerial(ctx, serial) - if err == nil && bySerial != nil { - return bySerial, nil - } - if err != nil && !isNotFound(err) { - return nil, errors.Wrapf(err, "retrieve device with serial number %s", serial) - } - - dev := new(Device) - return dev, nil -} - -func isNotFound(err error) bool { - err = errors.Cause(err) - type notFoundErr interface { - error - NotFound() bool - } - - e, ok := err.(notFoundErr) - return ok && e.NotFound() -} diff --git a/platform/profile/apply_profile.go b/platform/profile/apply_profile.go deleted file mode 100644 index aacb03ce..00000000 --- a/platform/profile/apply_profile.go +++ /dev/null @@ -1,54 +0,0 @@ -package profile - -import ( - "context" - "net/http" - - "github.com/go-kit/kit/endpoint" - "github.com/micromdm/micromdm/pkg/httputil" -) - -func (svc *ProfileService) ApplyProfile(ctx context.Context, p *Profile) error { - return svc.store.Save(p) -} - -type applyProfileRequest struct { - Profile *Profile `json:"profile"` -} - -type applyProfileResponse struct { - Err error `json:"err,omitempty"` -} - -func (r applyProfileResponse) Failed() error { return r.Err } - -func decodeApplyProfileRequest(ctx context.Context, r *http.Request) (interface{}, error) { - var req applyProfileRequest - err := httputil.DecodeJSONRequest(r, &req) - return req, err -} - -func decodeApplyProfileResponse(_ context.Context, r *http.Response) (interface{}, error) { - var resp applyProfileResponse - err := httputil.DecodeJSONResponse(r, &resp) - return resp, err -} - -func MakeApplyProfileEndpoint(svc Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (response interface{}, err error) { - req := request.(applyProfileRequest) - err = svc.ApplyProfile(ctx, req.Profile) - return applyProfileResponse{ - Err: err, - }, nil - } -} - -func (e Endpoints) ApplyProfile(ctx context.Context, p *Profile) error { - request := applyProfileRequest{Profile: p} - resp, err := e.ApplyProfileEndpoint(ctx, request) - if err != nil { - return err - } - return resp.(applyProfileResponse).Err -} diff --git a/platform/profile/builtin/db.go b/platform/profile/builtin/db.go deleted file mode 100644 index d8844b66..00000000 --- a/platform/profile/builtin/db.go +++ /dev/null @@ -1,111 +0,0 @@ -package builtin - -import ( - "context" - "fmt" - - "github.com/boltdb/bolt" - "github.com/micromdm/micromdm/platform/profile" - "github.com/pkg/errors" -) - -const ( - ProfileBucket = "mdm.Profile" -) - -type DB struct { - *bolt.DB -} - -func NewDB(db *bolt.DB) (*DB, error) { - err := db.Update(func(tx *bolt.Tx) error { - _, err := tx.CreateBucketIfNotExists([]byte(ProfileBucket)) - return err - }) - if err != nil { - return nil, errors.Wrapf(err, "creating %s bucket", ProfileBucket) - } - datastore := &DB{ - DB: db, - } - return datastore, nil -} - -func (db *DB) List() ([]profile.Profile, error) { - // TODO add filter/limit with ForEach - var list []profile.Profile - err := db.View(func(tx *bolt.Tx) error { - b := tx.Bucket([]byte(ProfileBucket)) - c := b.Cursor() - for k, v := c.First(); k != nil; k, v = c.Next() { - var p profile.Profile - if err := profile.UnmarshalProfile(v, &p); err != nil { - return err - } - list = append(list, p) - } - return nil - }) - return list, err -} - -func (db *DB) Save(p *profile.Profile) error { - err := p.Validate() - if err != nil { - return err - } - tx, err := db.DB.Begin(true) - if err != nil { - return errors.Wrap(err, "begin transaction") - } - bkt := tx.Bucket([]byte(ProfileBucket)) - if bkt == nil { - return fmt.Errorf("bucket %q not found!", ProfileBucket) - } - pproto, err := profile.MarshalProfile(p) - if err != nil { - return errors.Wrap(err, "marshalling profile") - } - if err := bkt.Put([]byte(p.Identifier), pproto); err != nil { - return errors.Wrap(err, "put profile to boltdb") - } - return tx.Commit() -} - -func (db *DB) ProfileById(ctx context.Context, id string) (*profile.Profile, error) { - var p profile.Profile - err := db.View(func(tx *bolt.Tx) error { - b := tx.Bucket([]byte(ProfileBucket)) - v := b.Get([]byte(id)) - if v == nil { - return ¬Found{"Profile", fmt.Sprintf("id %s", id)} - } - return profile.UnmarshalProfile(v, &p) - }) - return &p, err -} - -func (db *DB) Delete(id string) error { - err := db.Update(func(tx *bolt.Tx) error { - b := tx.Bucket([]byte(ProfileBucket)) - v := b.Get([]byte(id)) - if v == nil { - return ¬Found{"Profile", fmt.Sprintf("id %s", id)} - } - return b.Delete([]byte(id)) - }) - return err -} - -type notFound struct { - ResourceType string - Message string -} - -func (e *notFound) Error() string { - return fmt.Sprintf("not found: %s %s", e.ResourceType, e.Message) -} - -func (e *notFound) NotFound() bool { - return true -} diff --git a/platform/profile/client.go b/platform/profile/client.go deleted file mode 100644 index c26c78f3..00000000 --- a/platform/profile/client.go +++ /dev/null @@ -1,56 +0,0 @@ -package profile - -import ( - "net/url" - - "github.com/go-kit/kit/endpoint" - "github.com/go-kit/kit/log" - httptransport "github.com/go-kit/kit/transport/http" - "github.com/micromdm/micromdm/pkg/httputil" -) - -func NewHTTPClient(instance, token string, logger log.Logger, opts ...httptransport.ClientOption) (Service, error) { - u, err := url.Parse(instance) - if err != nil { - return nil, err - } - - var applyProfileEndpoint endpoint.Endpoint - { - applyProfileEndpoint = httptransport.NewClient( - "PUT", - httputil.CopyURL(u, "/v1/profiles"), - httputil.EncodeRequestWithToken(token, httptransport.EncodeJSONRequest), - decodeApplyProfileResponse, - opts..., - ).Endpoint() - } - - var getProfilesEndpoint endpoint.Endpoint - { - getProfilesEndpoint = httptransport.NewClient( - "POST", - httputil.CopyURL(u, "/v1/profiles"), - httputil.EncodeRequestWithToken(token, httptransport.EncodeJSONRequest), - decodeGetProfilesResponse, - opts..., - ).Endpoint() - } - - var removeProfilesEndpoint endpoint.Endpoint - { - removeProfilesEndpoint = httptransport.NewClient( - "DELETE", - httputil.CopyURL(u, "/v1/profiles"), - httputil.EncodeRequestWithToken(token, httptransport.EncodeJSONRequest), - decodeRemoveProfileResponse, - opts..., - ).Endpoint() - } - - return Endpoints{ - ApplyProfileEndpoint: applyProfileEndpoint, - GetProfilesEndpoint: getProfilesEndpoint, - RemoveProfilesEndpoint: removeProfilesEndpoint, - }, nil -} diff --git a/platform/profile/get_profiles.go b/platform/profile/get_profiles.go deleted file mode 100644 index 55e031bd..00000000 --- a/platform/profile/get_profiles.go +++ /dev/null @@ -1,68 +0,0 @@ -package profile - -import ( - "context" - "encoding/json" - "net/http" - - "github.com/go-kit/kit/endpoint" - "github.com/micromdm/micromdm/pkg/httputil" -) - -func (svc *ProfileService) GetProfiles(ctx context.Context, opt GetProfilesOption) ([]Profile, error) { - if opt.Identifier != "" { - foundProf, err := svc.store.ProfileById(ctx, opt.Identifier) - if err != nil { - return nil, err - } - return []Profile{*foundProf}, nil - } else { - return svc.store.List() - } -} - -type getProfilesRequest struct{ Opts GetProfilesOption } - -type getProfilesResponse struct { - Profiles []Profile `json:"profiles"` - Err error `json:"err,omitempty"` -} - -func (r getProfilesResponse) Failed() error { return r.Err } - -func decodeGetProfilesRequest(ctx context.Context, r *http.Request) (interface{}, error) { - var opts GetProfilesOption - if err := json.NewDecoder(r.Body).Decode(&opts); err != nil { - return nil, err - } - req := getProfilesRequest{ - Opts: opts, - } - return req, nil -} - -func decodeGetProfilesResponse(_ context.Context, r *http.Response) (interface{}, error) { - var resp getProfilesResponse - err := httputil.DecodeJSONResponse(r, &resp) - return resp, err -} - -func MakeGetProfilesEndpoint(svc Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (response interface{}, err error) { - req := request.(getProfilesRequest) - profiles, err := svc.GetProfiles(ctx, req.Opts) - return getProfilesResponse{ - Profiles: profiles, - Err: err, - }, nil - } -} - -func (e Endpoints) GetProfiles(ctx context.Context, opt GetProfilesOption) ([]Profile, error) { - request := getProfilesRequest{opt} - response, err := e.GetProfilesEndpoint(ctx, request.Opts) - if err != nil { - return nil, err - } - return response.(getProfilesResponse).Profiles, response.(getProfilesResponse).Err -} diff --git a/platform/profile/internal/profileproto/profile.go b/platform/profile/internal/profileproto/profile.go deleted file mode 100644 index 73977478..00000000 --- a/platform/profile/internal/profileproto/profile.go +++ /dev/null @@ -1,3 +0,0 @@ -package profileproto - -//go:generate protoc --go_out=. profile.proto diff --git a/platform/profile/internal/profileproto/profile.pb.go b/platform/profile/internal/profileproto/profile.pb.go deleted file mode 100644 index e212ff42..00000000 --- a/platform/profile/internal/profileproto/profile.pb.go +++ /dev/null @@ -1,70 +0,0 @@ -// Code generated by protoc-gen-go. -// source: profile.proto -// DO NOT EDIT! - -/* -Package profileproto is a generated protocol buffer package. - -It is generated from these files: - profile.proto - -It has these top-level messages: - Profile -*/ -package profileproto - -import proto "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package - -type Profile struct { - Id string `protobuf:"bytes,1,opt,name=id" json:"id,omitempty"` - Mobileconfig []byte `protobuf:"bytes,2,opt,name=mobileconfig,proto3" json:"mobileconfig,omitempty"` -} - -func (m *Profile) Reset() { *m = Profile{} } -func (m *Profile) String() string { return proto.CompactTextString(m) } -func (*Profile) ProtoMessage() {} -func (*Profile) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } - -func (m *Profile) GetId() string { - if m != nil { - return m.Id - } - return "" -} - -func (m *Profile) GetMobileconfig() []byte { - if m != nil { - return m.Mobileconfig - } - return nil -} - -func init() { - proto.RegisterType((*Profile)(nil), "profileproto.Profile") -} - -func init() { proto.RegisterFile("profile.proto", fileDescriptor0) } - -var fileDescriptor0 = []byte{ - // 97 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x2d, 0x28, 0xca, 0x4f, - 0xcb, 0xcc, 0x49, 0xd5, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x81, 0x72, 0xc1, 0x3c, 0x25, - 0x5b, 0x2e, 0xf6, 0x00, 0x08, 0x5f, 0x88, 0x8f, 0x8b, 0x29, 0x33, 0x45, 0x82, 0x51, 0x81, 0x51, - 0x83, 0x33, 0x88, 0x29, 0x33, 0x45, 0x48, 0x89, 0x8b, 0x27, 0x37, 0x3f, 0x29, 0x33, 0x27, 0x35, - 0x39, 0x3f, 0x2f, 0x2d, 0x33, 0x5d, 0x82, 0x49, 0x81, 0x51, 0x83, 0x27, 0x08, 0x45, 0x2c, 0x89, - 0x0d, 0x6c, 0x8a, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0xea, 0x33, 0x2f, 0xfa, 0x64, 0x00, 0x00, - 0x00, -} diff --git a/platform/profile/internal/profileproto/profile.proto b/platform/profile/internal/profileproto/profile.proto deleted file mode 100644 index f34c04df..00000000 --- a/platform/profile/internal/profileproto/profile.proto +++ /dev/null @@ -1,8 +0,0 @@ -syntax = "proto3"; - -package profileproto; - -message Profile { - string id = 1; - bytes mobileconfig = 2; -} diff --git a/platform/profile/profile.go b/platform/profile/profile.go deleted file mode 100644 index 1ebd1883..00000000 --- a/platform/profile/profile.go +++ /dev/null @@ -1,83 +0,0 @@ -package profile - -import ( - "github.com/pkg/errors" - - "github.com/fullsailor/pkcs7" - "github.com/gogo/protobuf/proto" - "github.com/groob/plist" - - "github.com/micromdm/micromdm/platform/profile/internal/profileproto" -) - -type Mobileconfig []byte - -// only used to parse plists to get the PayloadIdentifier -type payloadIdentifier struct { - PayloadIdentifier string -} - -func (mc *Mobileconfig) GetPayloadIdentifier() (string, error) { - mcBytes := *mc - if len(mcBytes) > 5 && string(mcBytes[0:5]) != "= 1 { - hasTokenConfig = true - conf.ConsumerSecret = tokens[0].ConsumerSecret - conf.ConsumerKey = tokens[0].ConsumerKey - conf.AccessSecret = tokens[0].AccessSecret - conf.AccessToken = tokens[0].AccessToken - // TODO: handle expiration - } - - // override with depsim keys if specified on CLI - if depsim != "" { - hasTokenConfig = true - conf = dep.OAuthParameters{ - ConsumerKey: "CK_48dd68d198350f51258e885ce9a5c37ab7f98543c4a697323d75682a6c10a32501cb247e3db08105db868f73f2c972bdb6ae77112aea803b9219eb52689d42e6", - ConsumerSecret: "CS_34c7b2b531a600d99a0e4edcf4a78ded79b86ef318118c2f5bcfee1b011108c32d5302df801adbe29d446eb78f02b13144e323eb9aad51c79f01e50cb45c3a68", - AccessToken: "AT_927696831c59ba510cfe4ec1a69e5267c19881257d4bca2906a99d0785b785a6f6fdeb09774954fdd5e2d0ad952e3af52c6d8d2f21c924ba0caf4a031c158b89", - AccessSecret: "AS_c31afd7a09691d83548489336e8ff1cb11b82b6bca13f793344496a556b1f4972eaff4dde6deb5ac9cf076fdfa97ec97699c34d515947b9cf9ed31c99dded6ba", - } - depsimurl, err := url.Parse(depsim) - if err != nil { - return err - } - opts = append(opts, dep.WithServerURL(depsimurl)) - } - - if !hasTokenConfig { - return nil - } - - c.DEPClient = dep.NewClient(conf, opts...) - return nil -} - -func (c *Server) CreateDEPSyncer(logger log.Logger) (sync.Syncer, error) { - client := c.DEPClient - opts := []sync.Option{ - sync.WithLogger(log.With(logger, "component", "depsync")), - } - if client != nil { - opts = append(opts, sync.WithClient(client)) - } - - syncdb, err := syncbuiltin.NewDB(c.DB) - if err != nil { - return nil, err - } - c.SyncDB = syncdb - - var syncer sync.Syncer - syncer, err = sync.NewWatcher(c.SyncDB, c.PubClient, opts...) - if err != nil { - return nil, err - } - return syncer, nil -} - -func (c *Server) setupSCEP(logger log.Logger) error { - depot, err := boltdepot.NewBoltDepot(c.DB) - if err != nil { - return err - } - - key, err := depot.CreateOrLoadKey(2048) - if err != nil { - return err - } - - _, err = depot.CreateOrLoadCA(key, 5, "MicroMDM", "US") - if err != nil { - return err - } - - opts := []scep.ServiceOption{ - scep.ClientValidity(c.SCEPClientValidity), - } - var scepChalOpt scep.ServiceOption - if c.UseDynSCEPChallenge { - c.SCEPChallengeDepot, err = challengestore.NewBoltDepot(c.DB) - if err != nil { - return err - } - scepChalOpt = scep.WithDynamicChallenges(c.SCEPChallengeDepot) - } else { - scepChalOpt = scep.ChallengePassword(c.SCEPChallenge) - } - opts = append(opts, scepChalOpt) - c.SCEPDepot = depot - c.SCEPService, err = scep.NewService(depot, opts...) - if err != nil { - return err - } - c.SCEPService = scep.NewLoggingService(logger, c.SCEPService) - - return nil -} diff --git a/server/testdata/ProviderPrivateKey.key b/server/testdata/ProviderPrivateKey.key deleted file mode 100644 index 647c64f8..00000000 --- a/server/testdata/ProviderPrivateKey.key +++ /dev/null @@ -1,30 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -Proc-Type: 4,ENCRYPTED -DEK-Info: DES-EDE3-CBC,22c0f4c89c7b1fcd - -KVnJeaMzHPrL5pHmkB6yAR9N8cvh2FKBfmJuRP61GiSR+PAI1UxsZ+627cnNZc/8 -Y2haoxAtW4k5Yl6gIQH8exf4el5yD+Ds4mEUacw7m3RV+WNL32I1+Z+jr55jetzP -nb3t9LQmsP07uigSe/oh0vumVhjxxSE31/iB2BISnEfJDsDYHFFc1XWAxNABG+JP -ttCnIHPXaFLb7jDdZnnsk2rBNsRkOPwJ27hna9b0RyHVmqMb3XZtQs2RtARTVqap -hCFSphMrS20wLqcHyJZ7v0p9MiCp71g58xs4Bl9Vh1FI86AA+AOaosA0Kl8lPa08 -ChuJf7ng3mhJ+nKRkPUK4eDtnCsNm3Xd0lQQHqRWcoUJ80Gdhla0CodJnt/BT35y -SP+j2SUJRuAvNpSeGyAcLv3wDwhMgkVTt1errZOL0tFa/ep5YwfFPMBDVNXx+lOd -AHDey8gnoGJFpwoQFdXp6TVZEJjP6kgN8njmAZmbwrFcqMdjg+eMZfAYXUAdy4aT -aMbMGwjyjUgP80iXX5OAgGchpQ+HO5otpbecAMKs6SAqAgTMbKMG2rLgZe+mlkbd -6xnwyrhkQpQHVN97gqWic2cIggyR3UL58mned/5eS3EcNTTxHJO8D7EwmIjkGVxY -fT+tdpJ6iKK6CfjIEZYFgtLafmKMxxDHaplLGnIK8VHiopwUIKxVcji9Pjp+0a1O -q9NSVZXAbt45mL2jV94hhEpt83YyBFdRYBFk5LT7AQg2ipVl51g7fO2SoTiHakzL -MrKfo+bSxDHOWefu9Z380Vmh1Mm0xDU44C8g9Jc4N7euCQtGfX5bnWuueuGwaaXL -lYrqKVuqKdc2y5d8N7KiHEHY0zsfyjFu4+zh/v2zYIBlbuM9ZGiuSlprHvy//wev -kPZDEtHNTeFXBn7qDeTGNlYK+aGQyTFOzasXcUbf3RywjpHOM/uL7rUpA11W+Ip/ -/b1h+mcADy90DMBv1xVX3vZVldwAdcqbQR0QTXxgCS1dzVdedG2N7noJVKUfbA4x -tI3NEAaBt7J7eLQm7TawRv6j5G+VB/ZS5B8WVCVbBjwwqbeccJcuzJKLBX0A7c+X -TouVuE7xpq9OK0zsaIwg7WMgKOY9ZMuMNzjKnXcSYcq5o9LHHsB1CHyOGdHkmj/J -AmME2xnyB+GCLWyN8B17hyC4MwkoNDWLnlUzL1Z3lf5jsorx+zORKho+rgg02Blw -hY02jVEcHoO8fup6GXkWtWpq2pljHD6DBg4thqwd2X3tpKBEDCcPYjMNRBmb+EZo -ZZrHMZX999BsgQip+9s6gpg4OxLbkn/wB94D+XoQYCF/rKb3ztlMHWygyjasKbWe -L5DnI4tDaO0CAYP79ixJWd8DnHy7lkDFCWA3ZdDV5brM81biJVr24b0SoV22/nT/ -wvTP0wgdRBmBmqFYZojlIWM+Gu09tVqXy8ui5oOGJThXgCyPWPrs9PSIfLyOjfDm -vUy/3yhOfCZmLEFG955P3A92ygojs/EvIrE2oWKVxf0X+T0mIVnBxeWpQ0OOVC1q -51gz/pyLNjbqxP2FUOkF5hLvRupAHhFpzbP4yZcDHUisNyUgjb4kHQ== ------END RSA PRIVATE KEY----- diff --git a/server/testdata/pushcert.p12 b/server/testdata/pushcert.p12 deleted file mode 100644 index c3cd1538..00000000 Binary files a/server/testdata/pushcert.p12 and /dev/null differ diff --git a/server/testdata/pushcert.pem b/server/testdata/pushcert.pem deleted file mode 100644 index 1328e203..00000000 --- a/server/testdata/pushcert.pem +++ /dev/null @@ -1,18 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIC9zCCAd+gAwIBAgIJAPQybPTtooGmMA0GCSqGSIb3DQEBCwUAMBIxEDAOBgNV -BAMMB21kbXB1c2gwHhcNMTcwMzIxMjMyNzEwWhcNNDQwODA2MjMyNzEwWjASMRAw -DgYDVQQDDAdtZG1wdXNoMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA -43VCT3Xw62hJ1t3HhLNsyJ/wTTaLJfyNu9zwNeNVY+yOxSaj6V5UVEpWiNIfyB+j -J7E+cUdWmEQewwXPaoNsCR4bKBElB1f45UApcrmkoqzruFI4O+yfmLJkN95fO5Sd -009VZPudFf96HdYjNpgg8ofIxAxo9dP+ReU+4QgxevIM2Hg+X+4zabDiLspfGX6Y -A5Iz/R6rFCx8rc+GEWFhkB4JE0cIV/TifP5xlOr0UFTCYQ1KUEM+30s928PFRXM4 -tsm/TcM5g0Mi2bNDiVHE0hvzxmJbiL2XjFE3VBK6Dphw9gF1GLe8D2TnZMeIAj3K -JW0sjnkmvBxRvTqTHA4LvwIDAQABo1AwTjAdBgNVHQ4EFgQUJmri9d+KEYhPyDu3 -dHsVm7eFWngwHwYDVR0jBBgwFoAUJmri9d+KEYhPyDu3dHsVm7eFWngwDAYDVR0T -BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAmRu4hFq4+WN7Vr9FucU+yHYcj0YV -kKfJMUSxDK/bab1DR02gxcYVR+bY/xtlcc/dA0zzzXUj97/BKLpkQCxu1+MtqMPx -bbVJnrSkGDXBXMmwn9C29WDdMjLQwS4WLrkDTEVc8W9kUqZsEBQalneKlV8u5kXi -A9tolc2Kaq2uJxKcsC2Yx1MLqpEm6bqKRlQSPM0G3uWupJBnvIQfXt0n3ErphQhf -m6BuVIs2iVvEo2W+VZ+LwfeN992Yd0DeMqvMAh6Rg/N/SGaxmMeD/Co+LHKCAzW4 -JVjDjF01dBDmWTBs+NC9euIoCBej+PjMwXUo229uA19DucZXMIed9Xyoqg== ------END CERTIFICATE----- diff --git a/tools/api/README.md b/tools/api/README.md deleted file mode 100644 index 0475b214..00000000 --- a/tools/api/README.md +++ /dev/null @@ -1,54 +0,0 @@ -A sample of the common API requests are available as `curl` scripts. To use them, install all the requirements and follow the steps as described. - -## Requirements - -- [jq](https://stedolan.github.io/jq/) - `brew install jq` - -## Setup -Create an `env` file and define environment variables you will need to talk to the server. -This env file will be sourced by the scripts. - -Contents of `env` file: -``` -# the value of the -api-key flag that MicroMDM was started with. -export API_TOKEN=supersecret -export SERVER_URL=https://mdm.acme.co -``` - -In your shell, set the environment variable `MICROMDM_ENV_PATH` to point to your env file. -Do this every time you open a new shell to work with the scripts in this folder. -``` -export MICROMDM_ENV_PATH="$(pwd)/env" -``` - -## Usage examples - -``` -# get all devices from micromdm. returns JSON. -./tools/api/get_devices - -# use jq to filter response. For example, to get the udid of the first device. -./tools/api/get_devices | jq .devices[0].udid -r - -# send a push notification to a device UDID -./tools/api/send_push_notification - -# combine sending a push notification with the get devices request. -$udid=(tools/api/get_devices |jq .devices[0].udid -r) -./tools/api/send_push_notification $udid -``` - -The `api` folder groups all MDM commands in the `commands` folder. Use these for scheduling commands against a remote device. All of these take the device udid as a first argument and might take additional arguments when necessary. - -``` -# install a configuration profile -./tools/api/commands/install_profile $udid /path/to/profile.mobileconfig - -# remove a configuration profile -./tools/api/commands/remove_profile $udid Your-Profile-PayloadIdentifier -``` - -All the scripts in this folder are tiny. Consider reading them to get an understanding of the API. -Also consider learning `jq`. -MicroMDM returns and accepts JSON for all of the API endpoints, and `jq` is a powerful tool for reading and manipulating JSON data. diff --git a/tools/api/commands/account_configuration_populate_user b/tools/api/commands/account_configuration_populate_user deleted file mode 100755 index 029a6471..00000000 --- a/tools/api/commands/account_configuration_populate_user +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash -# populate and lock the account info for the setup assistant. -# Example: -# ./tools/api/commands/account_configuration_populate_user $udid "Full Name" "username" -# -source $MICROMDM_ENV_PATH -endpoint="v1/commands" -jq -n \ - --arg request_type "AccountConfiguration" \ - --arg udid "$1" \ - --arg fullname "$2" \ - --arg username "$3" \ - '.udid = $udid - |.skip_primary_setup_account_creation = false - |.set_primary_setup_account_as_regular_user = false - |.set_primary_setup_account_as_regular_user = false - |.dont_auto_populate_primary_account_info = false - |.lock_primary_account_info = true - |.primary_account_full_name = $fullname - |.primary_account_user_name = $username - |.request_type = $request_type - '|\ - curl $CURL_OPTS -u "micromdm:$API_TOKEN" "$SERVER_URL/$endpoint" -d@- - diff --git a/tools/api/commands/activation_lock_bypass_code b/tools/api/commands/activation_lock_bypass_code deleted file mode 100755 index d1655060..00000000 --- a/tools/api/commands/activation_lock_bypass_code +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -source $MICROMDM_ENV_PATH -endpoint="v1/commands" -jq -n \ - --arg request_type "ActivationLockBypassCode" \ - --arg udid "$1" \ - '.udid = $udid - |.request_type = $request_type - '|\ - curl $CURL_OPTS -u "micromdm:$API_TOKEN" "$SERVER_URL/$endpoint" -d@- diff --git a/tools/api/commands/available_os_updates b/tools/api/commands/available_os_updates deleted file mode 100755 index 1d427ede..00000000 --- a/tools/api/commands/available_os_updates +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -source $MICROMDM_ENV_PATH -endpoint="v1/commands" -jq -n \ - --arg request_type "AvailableOSUpdates" \ - --arg udid "$1" \ - '.udid = $udid - |.request_type = $request_type - '|\ - curl $CURL_OPTS -u "micromdm:$API_TOKEN" "$SERVER_URL/$endpoint" -d@- diff --git a/tools/api/commands/certificate_list b/tools/api/commands/certificate_list deleted file mode 100755 index 2389808c..00000000 --- a/tools/api/commands/certificate_list +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -source $MICROMDM_ENV_PATH -endpoint="v1/commands" -jq -n \ - --arg request_type "CertificateList" \ - --arg udid "$1" \ - '.udid = $udid - |.request_type = $request_type - '|\ - curl $CURL_OPTS -u "micromdm:$API_TOKEN" "$SERVER_URL/$endpoint" -d@- diff --git a/tools/api/commands/device_configured b/tools/api/commands/device_configured deleted file mode 100755 index 3022207e..00000000 --- a/tools/api/commands/device_configured +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -source $MICROMDM_ENV_PATH -endpoint="v1/commands" -jq -n \ - --arg request_type "DeviceConfigured" \ - --arg udid "$1" \ - --arg query_strings "$2" \ - '.udid = $udid - |.request_type = $request_type - '|\ - curl $CURL_OPTS -u "micromdm:$API_TOKEN" "$SERVER_URL/$endpoint" -d@- diff --git a/tools/api/commands/device_information b/tools/api/commands/device_information deleted file mode 100755 index d9587df9..00000000 --- a/tools/api/commands/device_information +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -source $MICROMDM_ENV_PATH -endpoint="v1/commands" -jq -n \ - --arg request_type "DeviceInformation" \ - --arg udid "$1" \ - --arg query_strings "$2" \ - '.udid = $udid - |.request_type = $request_type - |.queries = ($query_strings | split(",")) - '|\ - curl $CURL_OPTS -u "micromdm:$API_TOKEN" "$SERVER_URL/$endpoint" -d@- diff --git a/tools/api/commands/device_lock b/tools/api/commands/device_lock deleted file mode 100755 index 1b24967f..00000000 --- a/tools/api/commands/device_lock +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -source $MICROMDM_ENV_PATH -endpoint="v1/commands" -jq -n \ - --arg request_type "DeviceLock" \ - --arg udid "$1" \ - --arg pin $2 \ - '.udid = $udid - |.pin = $pin - |.request_type = $request_type - '|\ - curl $CURL_OPTS -u "micromdm:$API_TOKEN" "$SERVER_URL/$endpoint" -d@- diff --git a/tools/api/commands/disable_remote_desktop b/tools/api/commands/disable_remote_desktop deleted file mode 100755 index bcccd39b..00000000 --- a/tools/api/commands/disable_remote_desktop +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -source $MICROMDM_ENV_PATH -endpoint="v1/commands" -jq -n \ - --arg request_type "DisableRemoteDesktop" \ - --arg udid "$1" \ - '.udid = $udid - |.request_type = $request_type - '|\ - curl $CURL_OPTS -u "micromdm:$API_TOKEN" "$SERVER_URL/$endpoint" -d@- diff --git a/tools/api/commands/enable_remote_desktop b/tools/api/commands/enable_remote_desktop deleted file mode 100755 index 8fca74d1..00000000 --- a/tools/api/commands/enable_remote_desktop +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -source $MICROMDM_ENV_PATH -endpoint="v1/commands" -jq -n \ - --arg request_type "EnableRemoteDesktop" \ - --arg udid "$1" \ - '.udid = $udid - |.request_type = $request_type - '|\ - curl $CURL_OPTS -u "micromdm:$API_TOKEN" "$SERVER_URL/$endpoint" -d@- diff --git a/tools/api/commands/erase_device b/tools/api/commands/erase_device deleted file mode 100755 index 433516c1..00000000 --- a/tools/api/commands/erase_device +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -source $MICROMDM_ENV_PATH -endpoint="v1/commands" -jq -n \ - --arg request_type "EraseDevice" \ - --arg udid "$1" \ - --arg pin $2 \ - '.udid = $udid - |.pin = $pin - |.request_type = $request_type - '|\ - curl $CURL_OPTS -u "micromdm:$API_TOKEN" "$SERVER_URL/$endpoint" -d@- diff --git a/tools/api/commands/install_application b/tools/api/commands/install_application deleted file mode 100755 index 942bf509..00000000 --- a/tools/api/commands/install_application +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -source $MICROMDM_ENV_PATH -endpoint="v1/commands" -jq -n \ - --arg request_type "InstallApplication" \ - --arg udid "$1" \ - --arg manifest_url "$2" \ - '.udid = $udid - |.request_type = $request_type - |.manifest_url = $manifest_url - '|\ - curl $CURL_OPTS \ - -H "Content-Type: application/json" \ - -u "micromdm:$API_TOKEN" "$SERVER_URL/$endpoint" -d@- diff --git a/tools/api/commands/install_appstore_application b/tools/api/commands/install_appstore_application deleted file mode 100755 index c18e5cab..00000000 --- a/tools/api/commands/install_appstore_application +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -source $MICROMDM_ENV_PATH -endpoint="v1/commands" -jq -n \ - --arg request_type "InstallApplication" \ - --arg udid "$1" \ - --arg identifier "$2" \ - '.udid = $udid - |.request_type = $request_type - |.identifier = $identifier - '|\ - curl $CURL_OPTS \ - -H "Content-Type: application/json" \ - -u "micromdm:$API_TOKEN" "$SERVER_URL/$endpoint" -d@- diff --git a/tools/api/commands/install_enterprise_application b/tools/api/commands/install_enterprise_application deleted file mode 100755 index dc86947d..00000000 --- a/tools/api/commands/install_enterprise_application +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -source $MICROMDM_ENV_PATH -endpoint="v1/commands" -jq -n \ - --arg request_type "InstallEnterpriseApplication" \ - --arg udid "$1" \ - --arg manifest_url "$2" \ - '.udid = $udid - |.request_type = $request_type - |.manifest_url = $manifest_url - '|\ - curl $CURL_OPTS \ - -H "Content-Type: application/json" \ - -u "micromdm:$API_TOKEN" "$SERVER_URL/$endpoint" -d@- diff --git a/tools/api/commands/install_profile b/tools/api/commands/install_profile deleted file mode 100755 index e15fd7c9..00000000 --- a/tools/api/commands/install_profile +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -source $MICROMDM_ENV_PATH -endpoint="v1/commands" -jq -n \ - --arg request_type "InstallProfile" \ - --arg udid "$1" \ - --arg payload "$(cat "$2"|openssl base64 -A)" \ - '.udid = $udid - |.payload = $payload - |.request_type = $request_type - '|\ - curl $CURL_OPTS -u "micromdm:$API_TOKEN" "$SERVER_URL/$endpoint" -d@- diff --git a/tools/api/commands/install_provisioning_profile b/tools/api/commands/install_provisioning_profile deleted file mode 100755 index 2eab4359..00000000 --- a/tools/api/commands/install_provisioning_profile +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -source $MICROMDM_ENV_PATH -endpoint="v1/commands" -jq -n \ - --arg request_type "InstallProvisioningProfile" \ - --arg udid "$1" \ - --arg provisioning_profile "$(cat "$2"|openssl base64 -A)" \ - '.udid = $udid - |.provisioning_profile = $provisioning_profile - |.request_type = $request_type - '|\ - curl $CURL_OPTS -u "micromdm:$API_TOKEN" "$SERVER_URL/$endpoint" -d@- diff --git a/tools/api/commands/installed_application_list b/tools/api/commands/installed_application_list deleted file mode 100755 index 0b6099c9..00000000 --- a/tools/api/commands/installed_application_list +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -source $MICROMDM_ENV_PATH -endpoint="v1/commands" -jq -n \ - --arg request_type "InstalledApplicationList" \ - --arg udid "$1" \ - '.udid = $udid - |.request_type = $request_type - '|\ - curl $CURL_OPTS -u "micromdm:$API_TOKEN" "$SERVER_URL/$endpoint" -d@- diff --git a/tools/api/commands/os_update_status b/tools/api/commands/os_update_status deleted file mode 100755 index e93031da..00000000 --- a/tools/api/commands/os_update_status +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -source $MICROMDM_ENV_PATH -endpoint="v1/commands" -jq -n \ - --arg request_type "OSUpdateStatus" \ - --arg udid "$1" \ - '.udid = $udid - |.request_type = $request_type - '|\ - curl $CURL_OPTS -u "micromdm:$API_TOKEN" "$SERVER_URL/$endpoint" -d@- diff --git a/tools/api/commands/profile_list b/tools/api/commands/profile_list deleted file mode 100755 index 25e744ef..00000000 --- a/tools/api/commands/profile_list +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -source $MICROMDM_ENV_PATH -endpoint="v1/commands" -jq -n \ - --arg request_type "ProfileList" \ - --arg udid "$1" \ - '.udid = $udid - |.request_type = $request_type - '|\ - curl $CURL_OPTS \ - -H "Content-Type: application/json" \ - -u "micromdm:$API_TOKEN" "$SERVER_URL/$endpoint" -d@- diff --git a/tools/api/commands/provisioning_profile_list b/tools/api/commands/provisioning_profile_list deleted file mode 100755 index e74cef94..00000000 --- a/tools/api/commands/provisioning_profile_list +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -source $MICROMDM_ENV_PATH -endpoint="v1/commands" -jq -n \ - --arg request_type "ProvisioningProfileList" \ - --arg udid "$1" \ - '.udid = $udid - |.request_type = $request_type - '|\ - curl $CURL_OPTS -u "micromdm:$API_TOKEN" "$SERVER_URL/$endpoint" -d@- diff --git a/tools/api/commands/remove_profile b/tools/api/commands/remove_profile deleted file mode 100755 index fd88c040..00000000 --- a/tools/api/commands/remove_profile +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -source $MICROMDM_ENV_PATH -endpoint="v1/commands" -jq -n \ - --arg request_type "RemoveProfile" \ - --arg udid "$1" \ - --arg identifier $2 \ - '.udid = $udid - |.identifier = $identifier - |.request_type = $request_type - '|\ - curl $CURL_OPTS -u "micromdm:$API_TOKEN" "$SERVER_URL/$endpoint" -d@- diff --git a/tools/api/commands/remove_provisioning_profile b/tools/api/commands/remove_provisioning_profile deleted file mode 100755 index b81f9aa1..00000000 --- a/tools/api/commands/remove_provisioning_profile +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -source $MICROMDM_ENV_PATH -endpoint="v1/commands" -jq -n \ - --arg request_type "RemoveProvisioningProfile" \ - --arg udid "$1" \ - --arg uuid $2 \ - '.udid = $udid - |.uuid = $uuid - |.request_type = $request_type - '|\ - curl $CURL_OPTS -u "micromdm:$API_TOKEN" "$SERVER_URL/$endpoint" -d@- diff --git a/tools/api/commands/restart_device b/tools/api/commands/restart_device deleted file mode 100755 index 8f5487e4..00000000 --- a/tools/api/commands/restart_device +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -source $MICROMDM_ENV_PATH -endpoint="v1/commands" -jq -n \ - --arg request_type "RestartDevice" \ - --arg udid "$1" \ - '.udid = $udid - |.request_type = $request_type - '|\ - curl $CURL_OPTS -u "micromdm:$API_TOKEN" "$SERVER_URL/$endpoint" -d@- diff --git a/tools/api/commands/schedule_os_update b/tools/api/commands/schedule_os_update deleted file mode 100755 index 42482046..00000000 --- a/tools/api/commands/schedule_os_update +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash -source $MICROMDM_ENV_PATH -endpoint="v1/commands" -jq -n \ - --arg request_type "ScheduleOSUpdate" \ - --arg udid "$1" \ - --arg product_key "$2" \ - --arg install_action "$3" \ - '.udid = $udid - |.request_type = $request_type - |.updates = [ - .product_key = $product_key - |.install_action = $install_action - ] - '|\ - curl $CURL_OPTS -u "micromdm:$API_TOKEN" "$SERVER_URL/$endpoint" -d@- diff --git a/tools/api/commands/schedule_os_update_scan b/tools/api/commands/schedule_os_update_scan deleted file mode 100755 index e68ea34f..00000000 --- a/tools/api/commands/schedule_os_update_scan +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -source $MICROMDM_ENV_PATH -endpoint="v1/commands" -jq -n \ - --arg request_type "ScheduleOSUpdateScan" \ - --arg udid "$1" \ - --argjson force "$2" \ - '.udid = $udid - |.request_type = $request_type - |.force = $force - '|\ - curl $CURL_OPTS -u "micromdm:$API_TOKEN" "$SERVER_URL/$endpoint" -d@- diff --git a/tools/api/commands/security_info b/tools/api/commands/security_info deleted file mode 100755 index ce0a52c6..00000000 --- a/tools/api/commands/security_info +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -source $MICROMDM_ENV_PATH -endpoint="v1/commands" -jq -n \ - --arg request_type "SecurityInfo" \ - --arg udid "$1" \ - '.udid = $udid - |.request_type = $request_type - '|\ - curl $CURL_OPTS -u "micromdm:$API_TOKEN" "$SERVER_URL/$endpoint" -d@- diff --git a/tools/api/commands/set_bootstrap_token b/tools/api/commands/set_bootstrap_token deleted file mode 100755 index 6dcd8d1e..00000000 --- a/tools/api/commands/set_bootstrap_token +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -source $MICROMDM_ENV_PATH -endpoint="v1/commands" -jq -n \ - --arg request_type "SetBootstrapToken" \ - --arg udid "$1" \ - --arg token "$2" \ - '.udid = $udid - |.request_type = $request_type - |.bootstrap_token = $token - '|\ - curl $CURL_OPTS -u "micromdm:$API_TOKEN" "$SERVER_URL/$endpoint" -d@- diff --git a/tools/api/commands/settings_application_configuration b/tools/api/commands/settings_application_configuration deleted file mode 100755 index 03f5ff82..00000000 --- a/tools/api/commands/settings_application_configuration +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash - -# Documentation: -# The configuration values must be provided to $3 must be a property list with the key/values for the configuration dictionary. -# Example: -# -# -# -# -# -# baz -# qux -# count -# 1 -# foo -# bar -# -# - -source $MICROMDM_ENV_PATH -endpoint="v1/commands" -jq -n \ - --arg request_type "Settings" \ - --arg udid "$1" \ - --arg identifier "$2" \ - --arg payload "$(cat $3|openssl base64 -A)" \ - '.udid = $udid - |.request_type = $request_type - |.settings[0].item = "ApplicationConfiguration" - |.settings[0].identifier = $identifier - |.settings[0].configuration = $payload - '|\ - curl $CURL_OPTS -u "micromdm:$API_TOKEN" "$SERVER_URL/$endpoint" -d@- diff --git a/tools/api/get_devices b/tools/api/get_devices deleted file mode 100755 index 4dcbf5a0..00000000 --- a/tools/api/get_devices +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -source $MICROMDM_ENV_PATH -endpoint="v1/devices" -curl $CURL_OPTS -X POST --data-binary {} -s -u "micromdm:$API_TOKEN" "$SERVER_URL/$endpoint" diff --git a/tools/api/send_push_notification b/tools/api/send_push_notification deleted file mode 100755 index 992f7036..00000000 --- a/tools/api/send_push_notification +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -source $MICROMDM_ENV_PATH -endpoint="push" -curl $CURL_OPTS -u "micromdm:$API_TOKEN" "$SERVER_URL/$endpoint/$1" diff --git a/tools/api/sync_dep_devices b/tools/api/sync_dep_devices deleted file mode 100755 index c9900274..00000000 --- a/tools/api/sync_dep_devices +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -source $MICROMDM_ENV_PATH -endpoint="v1/dep/syncnow" -curl $CURL_OPTS -u "micromdm:$API_TOKEN" -X POST "$SERVER_URL/$endpoint" diff --git a/tools/ngrok/README.md b/tools/ngrok/README.md deleted file mode 100644 index dbd6807c..00000000 --- a/tools/ngrok/README.md +++ /dev/null @@ -1,110 +0,0 @@ -# Local Development with ngrok - -When developing and testing MicroMDM you will likely want to enroll devices. Normally that means either generating or getting new TLS certificates and hosting micromdm on some publicly accessible server. -`ngrok` is a tool that makes it easy to expose the MicroMDM server as a public URL that your devices can enroll to. - -The scripts in this will help you get MicroMDM running for local development. -First, install the listed requirements. - -Next, make sure you've cloned the `micromdm` repo exactly as described in the [contributing guide](../../CONTRIBUTING.md). Follow the steps in the same document to downloads required dependencies and build `micromdm` and `mdmctl`. - -Finally, follow the described workflow for setting up your development server. - -## Requirements - -- [go](https://golang.org/) - `brew install go` - -- [jq](https://stedolan.github.io/jq/) - `brew install jq` - -- [ngrok](https://ngrok.com) - `brew cask install ngrok` - -## Workflow - -Follow the steps in order, and use separate terminal windows for running ngrok and micromdm. These are long running processes, and you will want to see the output. -Some of the steps are only required for first time setup. - -_Note:_ When the ngrok tunnel expires, you have to re-enroll the test device. The `configure_mdmctl` updates the DEP profile, so all you need to do is either reset the VM, or run `sudo /usr/bin/profiles -e -N` if testing with a real Mac. - -1. Run ngrok. A tunnel will be opened. If you're using the free version of `ngrok` this URL is only valid for 8 hours, but you can always start with a new URL. -``` -ngrok http 8080 -``` -Make sure to open a browser tab at `http://localhost:4040`. The ngrok web interface shows all the requests/responses between `micromdm` and its clients and can be invaluable for debugging. - -2. Create a env file and define environment variables you will need for micromdm. This is a first time setup only step. - -Contents of `env` file: -``` -export API_TOKEN=supersecret -export PUSH_CERTIFICATE_PRIVATE_KEY_PASSWORD=supersecret -export SERVER_URL="$(curl -s localhost:4040/api/tunnels | jq '.tunnels[]|.public_url' -r |grep https)" -``` - -3. Set the `MICROMDM_ENV_PATH` variable to be the path of your `env` file. This will be used to source the file in all the helper scripts. Do this once in every new terminal window you open while developing with micromdm. - -``` -export MICROMDM_ENV_PATH="$(pwd)/env" -``` - -4. Start `micromdm`. Do this every time you rebuild the binary and when your `ngrok` tunnel expires. - -``` -./tools/ngrok/start_server -``` - -The server will run on port `8080`. The default configuration is minimal, but you can pass any additional flags as arguments to the script. For example `./tools/ngrok/start_server -http-debug`. - -5. Configure the Push certificate and DEP tokens. This is a first time setup only step. -If you already have the `MDM CSR` option in your enterprise portal, [follow](https://github.com/micromdm/micromdm/blob/main/docs/user-guide/quickstart.md#configure-an-apns-certificate) the user guide steps. -If you don't have access to the enterprise portal, you can get an MDM certificate from [mdmcert.download](https://github.com/micromdm/micromdm/wiki/mdmcert.download) -You can also export the device management certificate from [Server.app](https://github.com/micromdm/micromdm/wiki/Export-the-Profile-Manager-Certificate). - -Configure `mdmdctl`: - -``` -source $MICROMDM_ENV_PATH -./build/darwin/mdmctl config set -name ngrok -api-token=$API_TOKEN -server-url=$SERVER_URL -./build/darwin/mdmctl config switch -name=ngrok -``` - -Upload push certificate: -``` -./build/darwin/mdmctl mdmcert upload \ - -cert "$path_to/mdm-certificates/push_certificate.pem" \ - -private-key "$path_to/mdm-certificates/PushCertificatePrivateKey.key" \ - -password $PUSH_CERTIFICATE_PRIVATE_KEY_PASSWORD -``` - -Get a DEP OAuth token at deploy.apple.com -``` -./build/darwin/mdmctl get dep-tokens -export-public-key /path/to/save/public.pem - -# after you upload the public key to your DEP portal, you'll get back a .p7m token file. -./build/darwin/mdmctl apply dep-tokens -import "$dev_path/dep/local_dep_smime.p7m" -``` - -6. Configure mdmctl and start using micromdm. Do this every time your ngrok tunnel expires. -``` -# substitute A_SERIAL_NUMBER for your test device. This serial number will be used to apply a DEP profile. -./tools/ngrok/configure_mdmctl A_SERIAL_NUMBER -``` - -`micromdm` and `mdmctl` should now be configured and you can begin testing. - -## Everyday workflow. - -``` -# In your first terminal window. Don't forget to open http://localhost:4040 -ngrok http 8080 - -# In a second terminal window -export MICROMDM_ENV_PATH="$(pwd)/env" -./tools/ngrok/start_server - -# In a third terminal window. -export MICROMDM_ENV_PATH="$(pwd)/env" -./tools/ngrok/configure_mdmctl -``` diff --git a/tools/ngrok/configure_mdmctl b/tools/ngrok/configure_mdmctl deleted file mode 100755 index 4a3b7f86..00000000 --- a/tools/ngrok/configure_mdmctl +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -source $MICROMDM_ENV_PATH -mdmctl="$(PWD)/build/$(uname |tr [:upper:] [:lower:])/mdmctl" -config_root="$(PWD)/tools/ngrok/config_root" - -$mdmctl config set -name ngrok -api-token=$API_TOKEN -server-url=$SERVER_URL -$mdmctl config switch -name=ngrok - -# DEP profile configuration. Comment out if not using DEP. -$mdmctl apply dep-profiles -template | jq \ - --arg server_url "$SERVER_URL/mdm/enroll" \ - --arg org_magic "$(uuidgen)" \ - --arg serial_number "$1" \ - --arg profile_name "$(whoami)-ngrok" \ - '.profile_name |= $profile_name - |.url |= $server_url - |.devices |= [$serial_number] - |.org_magic |= $org_magic - |.await_device_configured |= true' > $config_root/dep_profile.json -$mdmctl apply dep-profiles -f $config_root/dep_profile.json diff --git a/tools/ngrok/screen b/tools/ngrok/screen deleted file mode 100755 index 06cb5d9b..00000000 --- a/tools/ngrok/screen +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -NL=`echo -ne '\015'` -session="micromdm" -if ! screen -list | grep -q $session; then - screen -d -m -S $session - screen -S $session -p 0 -X stuff "ngrok http 8080$NL" - screen -S $session -X screen 1 - sleep 2 # wait for ngrok to start - screen -S $session -p 1 -X stuff "./tools/ngrok/start_server -filerepo /tmp/micromdm$NL" - sleep 1 -fi diff --git a/tools/ngrok/start_server b/tools/ngrok/start_server deleted file mode 100755 index fb2ce3fb..00000000 --- a/tools/ngrok/start_server +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -source $MICROMDM_ENV_PATH -micromdm="$(PWD)/build/$(uname |tr [:upper:] [:lower:])/micromdm" -config_root="$(PWD)/tools/ngrok/config_root" -mkdir -p $config_root - -$micromdm serve \ - -api-key $API_TOKEN \ - -server-url=$SERVER_URL \ - -config-path $config_root \ - -tls=false "$@" diff --git a/vpp/client.go b/vpp/client.go deleted file mode 100644 index dd5b20bd..00000000 --- a/vpp/client.go +++ /dev/null @@ -1,111 +0,0 @@ -package vpp - -import ( - "bytes" - "encoding/json" - "io/ioutil" - "net/http" - "net/url" - "path" - - "github.com/pkg/errors" -) - -const ( - serverURL = "https://your.server.com" // This needs to be modified to be imported from server - version = "" // This needs to be modified to be imported from server - - defaultBaseURL = "https://vpp.itunes.apple.com/WebObjects/MZFinance.woa/wa/VPPServiceConfigSrv" - mediaType = "application/json;charset=UTF8" - XServerProtocolVersionHeader = "X-Server-Protocol-Version" - XServerProtocolVersion = "3" -) - -type HTTPClient interface { - Do(req *http.Request) (*http.Response, error) -} - -// Contains the sToken string used to authenticate to the various VPP services -// Contains the return VPPServiceConfigSrv information -type Client struct { - SToken string - VPPServiceConfigSrv *VPPServiceConfigSrv - UserAgent string - Client HTTPClient - BaseURL *url.URL -} - -func NewClient(sToken string) (*Client, error) { - baseURL, _ := url.Parse(defaultBaseURL) - c := Client{ - SToken: sToken, - UserAgent: path.Join("micromdm", version), - Client: http.DefaultClient, - BaseURL: baseURL, - } - - // Get VPPServiceConfigSrv Data - VPPServiceConfigSrv, err := c.GetVPPServiceConfigSrv() - if err != nil { - return nil, errors.Wrap(err, "create VPPServiceConfigSrv request") - } - c.VPPServiceConfigSrv = VPPServiceConfigSrv - - // Set Client Context If Needed - context, err := c.GetClientContext() - if err != nil { - return nil, errors.Wrap(err, "GetClientContext request") - } - - if context.HostName != serverURL { - _, err := c.SetClientContext(serverURL) - if err != nil { - return nil, errors.Wrap(err, "SetClientContext request") - } - } - - return &c, nil -} - -func (c *Client) newRequest(method, URLStr string, body interface{}) (*http.Request, error) { - rel, err := url.Parse(URLStr) - if err != nil { - return nil, errors.Wrapf(err, "parse vpp request url %s", URLStr) - } - - u := c.BaseURL.ResolveReference(rel) - var buf bytes.Buffer - if body != nil { - if err := json.NewEncoder(&buf).Encode(body); err != nil { - return nil, errors.Wrap(err, "encode http body for VPP request") - } - } - - req, err := http.NewRequest(method, u.String(), &buf) - if err != nil { - return nil, errors.Wrapf(err, "creating %s request to vpp %s", method, u.String()) - } - - req.Header.Add("User-Agent", c.UserAgent) - req.Header.Add("Content-Type", mediaType) - req.Header.Add("Accept", mediaType) - req.Header.Add(XServerProtocolVersionHeader, XServerProtocolVersion) - return req, nil -} - -func (c *Client) do(req *http.Request, into interface{}) error { - resp, err := c.Client.Do(req) - if err != nil { - return errors.Wrap(err, "perform vpp request") - } - defer resp.Body.Close() - - if resp.StatusCode != http.StatusOK { - body, _ := ioutil.ReadAll(resp.Body) - return errors.Errorf("unexpected vpp response. status=%d VPP API Error: %s", resp.StatusCode, string(body)) - } - - err = json.NewDecoder(resp.Body).Decode(into) - - return errors.Wrap(err, "decode VPP response body") -} diff --git a/vpp/clientconfigsrv.go b/vpp/clientconfigsrv.go deleted file mode 100644 index eef7f921..00000000 --- a/vpp/clientconfigsrv.go +++ /dev/null @@ -1,153 +0,0 @@ -package vpp - -import ( - "encoding/json" - "strings" - - "github.com/google/uuid" - "github.com/pkg/errors" -) - -// Contains information that associates your particular mdm server to a VPP account token -type ClientContext struct { - HostName string `json:"hostname"` - GUID string `json:"guid"` -} - -// Contains location information associated with a VPP account token -type Location struct { - LocationName string `json:"locationName"` - LocationID int `json:"locationId"` -} - -// Contains org information associated with a VPP account token -type ClientConfigSrv struct { - ClientContext string `json:"clientContext"` - AppleID string `json:"appleId,omitempty"` - OrganizationIDHash string `json:"organizationIdHash"` - Status int `json:"status"` - OrganizationID int `json:"organizationId"` - UID string `json:"uId"` - CountryCode string `json:"countryCode"` - Location Location `json:"location"` - APNToken string `json:"apnToken"` - Email string `json:"email"` -} - -// These specify options for the ClientConfigSrv -type GetClientConfigSrvOptions func(*getClientConfigSrvOpts) error - -type getClientConfigSrvOpts struct { - SToken string `json:"sToken"` - Verbose bool `json:"verbose,omitempty"` - ClientContext string `json:"clientContext,omitempty"` -} - -// Verbose is an optional argument that can be added to GetClientConfigSrv -func VerboseOption(verbose bool) GetClientConfigSrvOptions { - return func(opts *getClientConfigSrvOpts) error { - opts.Verbose = verbose - return nil - } -} - -// ClientContext is an optional argument that can be added to GetClientConfigSrv -func ClientContextOption(context string) GetClientConfigSrvOptions { - return func(opts *getClientConfigSrvOpts) error { - opts.ClientContext = context - return nil - } -} - -// Gets ClientConfigSrv information -func (c *Client) GetClientConfigSrv(opts ...GetClientConfigSrvOptions) (*ClientConfigSrv, error) { - // Set required and optional arguments - request := &getClientConfigSrvOpts{SToken: c.SToken} - for _, option := range opts { - if err := option(request); err != nil { - return nil, err - } - } - - // Get the ClientConfigSrvURL - clientConfigSrvURL := c.VPPServiceConfigSrv.ClientConfigSrvURL - - // Create the ClientConfigSrvURL request - req, err := c.newRequest("POST", clientConfigSrvURL, request) - if err != nil { - return nil, errors.Wrap(err, "create ClientConfigSrv request") - } - - // Make the request - var response ClientConfigSrv - err = c.do(req, &response) - - return &response, errors.Wrap(err, "make ClientConfigSrv request") -} - -// Gets the appleID field along with the standard information -func (c *Client) GetClientConfigSrvVerbose() (*ClientConfigSrv, error) { - options := VerboseOption(true) - response, err := c.GetClientConfigSrv(options) - if err != nil { - return nil, errors.Wrap(err, "using verbose option") - } - - return response, nil -} - -// Gets the values that determine which mdm server is associated with a VPP account token -func (c *Client) GetClientContext() (*ClientContext, error) { - // Get the ClientConfigSrv info - clientConfigSrv, err := c.GetClientConfigSrv() - if err != nil { - return nil, errors.Wrap(err, "get ClientContext request") - } - - // Get the ClientContext string - var context = clientConfigSrv.ClientContext - - // Convert the string to a ClientContext type - var clientContext ClientContext - err = json.NewDecoder(strings.NewReader(context)).Decode(&clientContext) - if err != nil { - return nil, errors.Wrap(err, "decode ClientContext") - } - - return &clientContext, nil -} - -// Sets the values that determine which mdm server is associated with a VPP account token -func (c *Client) SetClientContext(serverURL string) (*ClientContext, error) { - // Generate a UUID that is tracked to ensure VPP licenses are up to date - uuid := uuid.New().String() - - // Generate a ClientContext string with the new UUID and the current serverURL - context := ClientContext{serverURL, uuid} - data, err := json.Marshal(context) - if err != nil { - return nil, errors.Wrap(err, "create new ClientContext") - } - newContext := string(data) - - // Enter the new ClientContext string into the ClientConfigSrv options - options := ClientContextOption(newContext) - - // Set the new ClientContext into the VPP account token - response, err := c.GetClientConfigSrv(options) - if err != nil { - return nil, errors.Wrap(err, "set ClientContext request") - } - - // Get the new ClientContext string - var contextString = response.ClientContext - - // Convert the string to a ClientContext type - var clientContext ClientContext - err = json.NewDecoder(strings.NewReader(contextString)).Decode(&clientContext) - if err != nil { - return nil, errors.Wrap(err, "decode new ClientContext") - } - - return &clientContext, nil -} diff --git a/vpp/getlicensessrv.go b/vpp/getlicensessrv.go deleted file mode 100644 index b9bf4597..00000000 --- a/vpp/getlicensessrv.go +++ /dev/null @@ -1,89 +0,0 @@ -package vpp - -import "github.com/pkg/errors" - -// Contains information about the VPP Licenses associated with a VPP account token -type LicensesSrv struct { - IfModifiedSinceMillisOrig string `json:"ifModifiedSinceMillisOrig"` - TotalCount int `json:"totalCount"` - Status int `json:"status"` - TotalBatchCount string `json:"totalBatchCount"` - Licenses []License `json:"licenses"` - BatchToken string `json:"batchToken"` - BatchCount int `json:"batchCount"` - ClientContext string `json:"clientContext"` - UID string `json:"uId"` - Location Location `json:"location"` -} - -// Contains information about VPP Licenses -type License struct { - LicenseID int `json:"licenseId"` - ProductTypeID int `json:"productTypeId"` - IsIrrevocable bool `json:"isIrrevocable"` - Status string `json:"status"` - PricingParam string `json:"pricingParam"` - AdamIDStr string `json:"adamIdStr"` - LicenseIDStr string `json:"licenseIdStr"` - ProductTypeName string `json:"productTypeName"` - AdamID int `json:"adamId"` - SerialNumber string `json:"serialNumber"` -} - -// Options for the LicensesSrv -type GetLicensesSrvOptions struct { - SToken string `json:"sToken"` - SerialNumber string `json:"serialNumber,omitempty"` -} - -// Gets the LicensesSrv information -func (c *Client) GetLicensesSrv(options GetLicensesSrvOptions) (*LicensesSrv, error) { - // Sends the sToken string - options.SToken = c.SToken - - // Get the LicensesSrvURL - licensesSrvURL := c.VPPServiceConfigSrv.GetLicensesSrvURL - - // Create the LicensesSrv request - req, err := c.newRequest("POST", licensesSrvURL, options) - if err != nil { - return nil, errors.Wrap(err, "create LicensesSrv request") - } - - // Make the request - var response LicensesSrv - err = c.do(req, &response) - - return &response, errors.Wrap(err, "make LicensesSrv request") -} - -// Gets licenses with specified serial associated -func (c *Client) GetLicensesForSerial(serial string) ([]License, error) { - options := GetLicensesSrvOptions{ - SerialNumber: serial, - } - - response, err := c.GetLicensesSrv(options) - if err != nil { - return nil, err - } - licenses := response.Licenses - return licenses, err -} - -// Checks if a particular serial is associated with an appID -func (c *Client) CheckAssignedLicense(serial string, appID string) (bool, error) { - // Get all licenses with serial associated - licenses, err := c.GetLicensesForSerial(serial) - if err != nil { - return false, err - } - - // Check for the particular appID - for _, lic := range licenses { - if lic.AdamIDStr == appID { - return true, nil - } - } - return false, nil -} diff --git a/vpp/getvppassetssrv.go b/vpp/getvppassetssrv.go deleted file mode 100644 index f8b7a6ca..00000000 --- a/vpp/getvppassetssrv.go +++ /dev/null @@ -1,74 +0,0 @@ -package vpp - -import "github.com/pkg/errors" - -// Contains information about the VPP Assets associated with a VPP account token -type VPPAssetsSrv struct { - TotalCount int `json:"totalCount"` - Status int `json:"status"` - Assets []Asset `json:"assets"` - ClientContext string `json:"clientContext"` - UID string `json:"uId"` - Location Location `json:"location"` -} - -// Contains information about VPP Assets -type Asset struct { - ProductTypeID int `json:"productTypeId"` - IsIrrevocable bool `json:"isIrrevocable"` - PricingParam string `json:"pricingParam"` - AdamIDStr string `json:"adamIdStr"` - ProductTypeName string `json:"productTypeName"` - DeviceAssignable bool `json:"deviceAssignable"` -} - -// Gets information about the VPP Assets associated with a VPP Account token -func (c *Client) GetVPPAssetsSrv() (*VPPAssetsSrv, error) { - // Send the sToken string - request := struct { - SToken string `json:"sToken"` - }{ - SToken: c.SToken, - } - - // Get the VPPAssetsSrvURL - VPPAssetsSrvURL := c.VPPServiceConfigSrv.GetVPPAssetsSrvURL - - // Create the VPPAssetsSrv request - req, err := c.newRequest("POST", VPPAssetsSrvURL, request) - if err != nil { - return nil, errors.Wrap(err, "create VPPAssetsSrv request") - } - - // Make the request - var response VPPAssetsSrv - err = c.do(req, &response) - - return &response, errors.Wrap(err, "get VPPAssetsSrv request") -} - -// Gets the pricing param for a particular VPP asset -func (c *Client) GetPricingParamForApp(appID string) (string, error) { - // Get a list of assets - response, err := c.GetVPPAssetsSrv() - if err != nil { - return "", err - } - var assets = response.Assets - - // Find the pricing param for the asset with matching appId - var pricing string - for _, asset := range assets { - if asset.AdamIDStr == appID { - pricing = asset.PricingParam - break - } - } - - // Check for err finding Pricing Param - if pricing == "" { - err := errors.New("Unable to find Pricing Param") - return pricing, err - } - return pricing, nil -} diff --git a/vpp/managevpplicensesbyadamidsrv.go b/vpp/managevpplicensesbyadamidsrv.go deleted file mode 100644 index cdd047b7..00000000 --- a/vpp/managevpplicensesbyadamidsrv.go +++ /dev/null @@ -1,86 +0,0 @@ -package vpp - -import "github.com/pkg/errors" - -// Contains information about a managed license -type ManageVPPLicensesByAdamIdSrv struct { - ProductTypeID int `json:"productTypeId,omitempty"` - ProductTypeName string `json:"productTypeName,omitempty"` - IsIrrevocable bool `json:"isIrrevocable,omitempty"` - PricingParam string `json:"pricingParam,omitempty"` - UID string `json:"uId,omitempty,omitempty"` - AdamIdStr string `json:"adamIdStr,omitempty"` - Status int `json:"status"` - ClientContext string `json:"clientContext,omitempty"` - Location *Location `json:"location,omitempty"` - Associations []Association `json:"associations,omitempty"` - ErrorMessage string `json:"errorMessage,omitempty"` - ErrorNumber int `json:"errorNumber,omitempty"` -} - -// Contains information about an app association -type Association struct { - SerialNumber string `json:"serialNumber"` - ErrorMessage string `json:"errorMessage,omitempty"` - ErrorCode int `json:"errorCode,omitempty"` - ErrorNumber int `json:"errorNumber,omitempty"` - LicenseIDStr string `json:"licenseIdStr,omitempty"` - LicenseAlreadyAssigned *License `json:"licenseAlreadyAssigned,omitempty"` -} - -// Contains options to pass to the ManageVPPLicensesByAdamIdSrv -type ManageVPPLicensesByAdamIdSrvOptions struct { - SToken string `json:"sToken"` - AdamIDStr string `json:"adamIdStr"` - PricingParam string `json:"pricingParam"` - AssociateSerialNumbers []string `json:"associateSerialNumbers,omitempty"` - DisassociateSerialNumbers []string `json:"disassociateSerialNumbers,omitempty"` -} - -// Associates a list of serials to a VPP app license -func (c *Client) AssociateSerialsToApp(appID string, serials []string) (*ManageVPPLicensesByAdamIdSrv, error) { - options := ManageVPPLicensesByAdamIdSrvOptions{ - AssociateSerialNumbers: serials, - } - - response, err := c.ManageVPPLicensesByAdamIdSrv(appID, options) - return &response, err -} - -// Disssociates a list of serials to a VPP app license -func (c *Client) DisassociateSerialsToApp(appID string, serials []string) (*ManageVPPLicensesByAdamIdSrv, error) { - options := ManageVPPLicensesByAdamIdSrvOptions{ - DisassociateSerialNumbers: serials, - } - - response, err := c.ManageVPPLicensesByAdamIdSrv(appID, options) - return &response, err -} - -// Interfaces with the ManageVPPLicensesByAdamIdSrv to managed VPP licenses -func (c *Client) ManageVPPLicensesByAdamIdSrv(appID string, options ManageVPPLicensesByAdamIdSrvOptions) (ManageVPPLicensesByAdamIdSrv, error) { - options.SToken = c.SToken - options.AdamIDStr = appID - - // Get the pricing param required to manage a vpp license - pricing, err := c.GetPricingParamForApp(appID) - if err != nil { - return ManageVPPLicensesByAdamIdSrv{}, errors.Wrap(err, "get PricingParam request") - } - options.PricingParam = pricing - - // Get the ManageVPPLicensesByAdamIdSrvURL - manageVPPLicensesByAdamIdSrvUrl := c.VPPServiceConfigSrv.ManageVPPLicensesByAdamIdSrvURL - - // Create the ManageVPPLicensesByAdamIdSrv request - req, err := c.newRequest("POST", manageVPPLicensesByAdamIdSrvUrl, options) - if err != nil { - return ManageVPPLicensesByAdamIdSrv{}, errors.Wrap(err, "create ManageVPPLicensesByAdamIdSrv request") - } - - // Make the Request - var response ManageVPPLicensesByAdamIdSrv - err = c.do(req, &response) - - return response, errors.Wrap(err, "ManageVPPLicensesByAdamIdSrv request") -} diff --git a/vpp/vppserviceconfigsrv.go b/vpp/vppserviceconfigsrv.go deleted file mode 100644 index b913220a..00000000 --- a/vpp/vppserviceconfigsrv.go +++ /dev/null @@ -1,41 +0,0 @@ -package vpp - -import "github.com/pkg/errors" - -// Contains the most recent data from Apple for configuring vpp -type VPPServiceConfigSrv struct { - EditUserSrvURL string `json:"editUserSrvUrl"` - DisassociateLicenseSrvURL string `json:"disassociateLicenseSrvUrl"` - ContentMetadataLookupURL string `json:"contentMetadataLookupUrl"` - ClientConfigSrvURL string `json:"clientConfigSrvUrl"` - GetUserSrvURL string `json:"getUserSrvUrl"` - GetUsersSrvURL string `json:"getUsersSrvUrl"` - GetLicensesSrvURL string `json:"getLicensesSrvUrl"` - GetVPPAssetsSrvURL string `json:"getVPPAssetsSrvUrl"` - VppWebsiteURL string `json:"vppWebsiteUrl"` - InvitationEmailURL string `json:"invitationEmailUrl"` - RetireUserSrvURL string `json:"retireUserSrvUrl"` - AssociateLicenseSrvURL string `json:"associateLicenseSrvUrl"` - ManageVPPLicensesByAdamIdSrvURL string `json:"manageVPPLicensesByAdamIdSrvUrl"` - RegisterUserSrvURL string `json:"registerUserSrvUrl"` - MaxBatchAssociateLicenseCount int `json:"maxBatchAssociateLicenseCount"` - MaxBatchDisassociateLicenseCount int `json:"maxBatchDisassociateLicenseCount"` - Status int `json:"status"` - ErrorCodes []Error `json:"errorCodes"` -} - -type Error struct { - ErrorMessage string `json:"errorMessage"` - ErrorNumber int `json:"errorNumber"` -} - -func (c *Client) GetVPPServiceConfigSrv() (*VPPServiceConfigSrv, error) { - var response VPPServiceConfigSrv - req, err := c.newRequest("GET", c.BaseURL.String(), nil) - if err != nil { - return nil, errors.Wrap(err, "create VPPServiceConfigSrv request") - } - - err = c.do(req, &response) - return &response, errors.Wrap(err, "VPPServiceConfigSrv request") -} diff --git a/workflow/webhook/acknowledge.go b/workflow/webhook/acknowledge.go deleted file mode 100644 index b15753b0..00000000 --- a/workflow/webhook/acknowledge.go +++ /dev/null @@ -1,41 +0,0 @@ -package webhook - -import ( - "github.com/pkg/errors" - - "github.com/micromdm/micromdm/mdm" -) - -type AcknowledgeEvent struct { - UDID string `json:"udid,omitempty"` - EnrollmentID string `json:"enrollment_id,omitempty"` - Status string `json:"status"` - CommandUUID string `json:"command_uuid,omitempty"` - Params map[string]string `json:"url_params,omitempty"` - RawPayload []byte `json:"raw_payload"` -} - -func acknowledgeEvent(topic string, data []byte) (*Event, error) { - var ev mdm.AcknowledgeEvent - if err := mdm.UnmarshalAcknowledgeEvent(data, &ev); err != nil { - return nil, errors.Wrap(err, "unmarshal acknowledge event for webhook") - } - webhookEvent := Event{ - Topic: topic, - EventID: ev.ID, - CreatedAt: ev.Time, - - AcknowledgeEvent: &AcknowledgeEvent{ - UDID: ev.Response.UDID, - Status: ev.Response.Status, - CommandUUID: ev.Response.CommandUUID, - Params: ev.Params, - RawPayload: ev.Raw, - }, - } - if ev.Response.EnrollmentID != nil { - webhookEvent.AcknowledgeEvent.EnrollmentID = *ev.Response.EnrollmentID - } - - return &webhookEvent, nil -} diff --git a/workflow/webhook/checkin.go b/workflow/webhook/checkin.go deleted file mode 100644 index b1713317..00000000 --- a/workflow/webhook/checkin.go +++ /dev/null @@ -1,36 +0,0 @@ -package webhook - -import ( - "github.com/pkg/errors" - - "github.com/micromdm/micromdm/mdm" -) - -type CheckinEvent struct { - UDID string `json:"udid,omitempty"` - EnrollmentID string `json:"enrollment_id,omitempty"` - Params map[string]string `json:"url_params"` - RawPayload []byte `json:"raw_payload"` -} - -func checkinEvent(topic string, data []byte) (*Event, error) { - var ev mdm.CheckinEvent - if err := mdm.UnmarshalCheckinEvent(data, &ev); err != nil { - return nil, errors.Wrap(err, "unmarshal checkin event for webhook") - } - - webhookEvent := Event{ - Topic: topic, - EventID: ev.ID, - CreatedAt: ev.Time, - - CheckinEvent: &CheckinEvent{ - UDID: ev.Command.UDID, - EnrollmentID: ev.Command.EnrollmentID, - Params: ev.Params, - RawPayload: ev.Raw, - }, - } - - return &webhookEvent, nil -} diff --git a/workflow/webhook/http_post.go b/workflow/webhook/http_post.go deleted file mode 100644 index e25a63b9..00000000 --- a/workflow/webhook/http_post.go +++ /dev/null @@ -1,43 +0,0 @@ -package webhook - -import ( - "bytes" - "context" - "encoding/json" - "net/http" - - "github.com/pkg/errors" -) - -type httpClient interface { - Do(*http.Request) (*http.Response, error) -} - -func postWebhookEvent( - ctx context.Context, - client httpClient, - url string, - event interface{}, -) error { - raw, err := json.MarshalIndent(event, "", " ") - if err != nil { - return errors.Wrap(err, "marshal webhook event") - } - - req, err := http.NewRequest(http.MethodPost, url, bytes.NewBuffer(raw)) - if err != nil { - return errors.Wrap(err, "create webhook http request") - } - req.Header.Set("Content-Type", "application/json; charset=utf-8") - - resp, err := client.Do(req.WithContext(ctx)) - if err != nil { - return errors.Wrap(err, "post webhook event to URL") - } - defer resp.Body.Close() - - if resp.StatusCode >= 400 { - return errors.Errorf("received unexpected HTTP status %d %s", resp.StatusCode, resp.Status) - } - return nil -} diff --git a/workflow/webhook/webhook.go b/workflow/webhook/webhook.go deleted file mode 100644 index 91338523..00000000 --- a/workflow/webhook/webhook.go +++ /dev/null @@ -1,119 +0,0 @@ -package webhook - -import ( - "context" - "net/http" - "time" - - "github.com/go-kit/kit/log" - "github.com/go-kit/kit/log/level" - "github.com/pkg/errors" - - "github.com/micromdm/micromdm/mdm" - "github.com/micromdm/micromdm/platform/pubsub" -) - -type Event struct { - Topic string `json:"topic"` - EventID string `json:"event_id"` - CreatedAt time.Time `json:"created_at"` - - AcknowledgeEvent *AcknowledgeEvent `json:"acknowledge_event,omitempty"` - CheckinEvent *CheckinEvent `json:"checkin_event,omitempty"` -} - -type Worker struct { - logger log.Logger - url string - client *http.Client - sub pubsub.Subscriber -} - -type Option func(*Worker) - -func WithLogger(logger log.Logger) Option { - return func(w *Worker) { - w.logger = logger - } -} - -func WithHTTPClient(client *http.Client) Option { - return func(w *Worker) { - w.client = client - } -} - -func New(url string, sub pubsub.Subscriber, opts ...Option) *Worker { - worker := &Worker{ - url: url, - sub: sub, - logger: log.NewNopLogger(), - client: http.DefaultClient, - } - - for _, optFn := range opts { - optFn(worker) - } - - return worker -} - -func (w *Worker) Run(ctx context.Context) error { - const subscription = "webhook_worker" - - ackEvents, err := w.sub.Subscribe(ctx, subscription, mdm.ConnectTopic) - if err != nil { - return errors.Wrapf(err, "subscribe %s to %s", subscription, mdm.ConnectTopic) - } - - authenticateEvents, err := w.sub.Subscribe(ctx, subscription, mdm.AuthenticateTopic) - if err != nil { - return errors.Wrapf(err, "subscribe %s to %s", subscription, mdm.AuthenticateTopic) - } - - tokenUpdateEvents, err := w.sub.Subscribe(ctx, subscription, mdm.TokenUpdateTopic) - if err != nil { - return errors.Wrapf(err, "subscribe %s to %s", subscription, mdm.TokenUpdateTopic) - } - - checkoutEvents, err := w.sub.Subscribe(ctx, subscription, mdm.CheckoutTopic) - if err != nil { - return errors.Wrapf(err, "subscribe %s to %s", subscription, mdm.CheckoutTopic) - } - - for { - var ( - event *Event - err error - ) - select { - case <-ctx.Done(): - return ctx.Err() - case ev := <-ackEvents: - event, err = acknowledgeEvent(ev.Topic, ev.Message) - case ev := <-authenticateEvents: - event, err = checkinEvent(ev.Topic, ev.Message) - case ev := <-tokenUpdateEvents: - event, err = checkinEvent(ev.Topic, ev.Message) - case ev := <-checkoutEvents: - event, err = checkinEvent(ev.Topic, ev.Message) - } - - if err != nil { - level.Info(w.logger).Log( - "msg", "create webhook event", - "err", err, - ) - continue - } - - if err := postWebhookEvent(ctx, w.client, w.url, event); err != nil { - level.Info(w.logger).Log( - "msg", "post webhook event", - "err", err, - ) - continue - } - - } -}