├── Dockerfile ├── ci ├── integration │ └── docker-compose.yml ├── tasks │ ├── build-candidate.sh │ ├── unit.sh │ ├── util.sh │ ├── integration.sh │ ├── run-integration.sh │ └── secret-service-release.sh └── pipeline.yml ├── models ├── models_suite_test.go ├── handler.go └── handler_test.go ├── glide.yaml ├── .gitignore ├── README.md ├── Makefile ├── glide.lock ├── main.go └── LICENSE /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:16.04 2 | 3 | ADD bin/voyager-secret-service voyager-secret-service 4 | 5 | CMD ./voyager-secret-service 6 | -------------------------------------------------------------------------------- /ci/integration/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '2' 2 | services: 3 | rabbitmq: 4 | image: rabbitmq:3-management 5 | ports: 6 | - "5672:5672" 7 | container_name: "rabbitmq" 8 | hostname: "rabbitmq" 9 | -------------------------------------------------------------------------------- /models/models_suite_test.go: -------------------------------------------------------------------------------- 1 | package models_test 2 | 3 | import ( 4 | . "github.com/onsi/ginkgo" 5 | . "github.com/onsi/gomega" 6 | 7 | "testing" 8 | ) 9 | 10 | func TestModels(t *testing.T) { 11 | RegisterFailHandler(Fail) 12 | RunSpecs(t, "Models Suite") 13 | } 14 | -------------------------------------------------------------------------------- /glide.yaml: -------------------------------------------------------------------------------- 1 | package: github.com/RackHD/voyager-secret-service 2 | import: 3 | - package: github.com/RackHD/voyager-utilities 4 | subpackages: 5 | - amqp 6 | - models 7 | - package: github.com/streadway/amqp 8 | testImport: 9 | - package: github.com/onsi/ginkgo 10 | version: ~1.2.0 11 | - package: github.com/onsi/gomega 12 | version: ~1.0.0 13 | -------------------------------------------------------------------------------- /ci/tasks/build-candidate.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e -x 4 | source voyager-secret-service/ci/tasks/util.sh 5 | 6 | check_param GITHUB_EMAIL 7 | check_param GITHUB_USER 8 | check_param GITHUB_PASSWORD 9 | 10 | echo -e "machine github.com\n login $GITHUB_USER\n password $GITHUB_PASSWORD" >> ~/.netrc 11 | 12 | set_env 13 | build_binary "voyager-secret-service" 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | *.test 24 | *.prof 25 | 26 | bin 27 | *.coverprofile 28 | vendor 29 | -------------------------------------------------------------------------------- /ci/tasks/unit.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e -x 4 | source voyager-secret-service/ci/tasks/util.sh 5 | 6 | check_param GITHUB_USER 7 | check_param GITHUB_PASSWORD 8 | 9 | echo -e "machine github.com\n login $GITHUB_USER\n password $GITHUB_PASSWORD" >> ~/.netrc 10 | 11 | export GOPATH=$PWD 12 | export PATH=$PATH:$GOPATH/bin 13 | mkdir -p $GOPATH/src/github.com/RackHD/ 14 | cp -r voyager-secret-service $GOPATH/src/github.com/RackHD/voyager-secret-service 15 | 16 | pushd $GOPATH/src/github.com/RackHD/voyager-secret-service 17 | make deps 18 | make build 19 | make unit-test 20 | echo "Unit test complete." 21 | popd 22 | -------------------------------------------------------------------------------- /ci/tasks/util.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e -x 3 | 4 | check_param() { 5 | local name=$1 6 | local value=$(eval echo '$'$name) 7 | if [ "$value" == 'replace-me' ]; then 8 | echo "environment variable $name must be set" 9 | exit 1 10 | fi 11 | } 12 | 13 | set_env() { 14 | WORK_DIR=${PWD} 15 | export GOPATH=${PWD} 16 | SOURCE_DIR=${GOPATH}/src/github.com/RackHD 17 | mkdir -p ${SOURCE_DIR} 18 | } 19 | 20 | build_binary() { 21 | cp -r $1 ${SOURCE_DIR}/$1 22 | pushd ${SOURCE_DIR}/$1 23 | make deps 24 | make build 25 | cp -r bin ${WORK_DIR}/build 26 | cp Dockerfile ${WORK_DIR}/build 27 | popd 28 | } 29 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # voyager-secret-service 2 | 3 | Copyright © 2017 Dell Inc. or its subsidiaries. All Rights Reserved. 4 | 5 | ## Licensing 6 | 7 | Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 10 | 11 | RackHD is a Trademark of Dell EMC 12 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | ORGANIZATION = RackHD 2 | PROJECT = voyager-secret-service 3 | BINARYNAME = voyager-secret-service 4 | GOOUT = ./bin 5 | export RABBITMQ_URL = amqp://guest:guest@localhost:5672 6 | 7 | default: deps build test 8 | 9 | deps: 10 | go get github.com/onsi/ginkgo/ginkgo 11 | go get github.com/onsi/gomega 12 | go get github.com/satori/go.uuid 13 | go get ./... 14 | 15 | integration-test: 16 | ginkgo -r -race -trace -cover -randomizeAllSpecs --slowSpecThreshold=30 --focus="\bINTEGRATION\b" 17 | 18 | unit-test: 19 | ginkgo -r -race -trace -cover -randomizeAllSpecs --slowSpecThreshold=30 --focus="\bUNIT\b" 20 | 21 | cover-cmd: test 22 | go tool cover -html=cmd/cmd.coverprofile 23 | 24 | build: 25 | go build -o $(GOOUT)/$(BINARYNAME) 26 | -------------------------------------------------------------------------------- /ci/tasks/integration.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e -x 4 | source voyager-secret-service/ci/tasks/util.sh 5 | 6 | # Get the env ip from locks input 7 | export INTEGRATION_VM_IP=$(cat $PWD/it-env/metadata) 8 | 9 | check_param INTEGRATION_VM_IP 10 | check_param INTEGRATION_VM_SSH_KEY 11 | check_param INTEGRATION_VM_USER 12 | 13 | echo "$INTEGRATION_VM_SSH_KEY" > ssh.key 14 | chmod 400 ssh.key 15 | 16 | project_path=/home/emc/.gvm/pkgsets/go1.7/global/src/github.com/RackHD 17 | ssh -i ssh.key -o "StrictHostKeyChecking no" ${INTEGRATION_VM_USER}@${INTEGRATION_VM_IP} "rm -rf $project_path && mkdir -p $project_path" 18 | scp -i ssh.key -o "StrictHostKeyChecking no" -r voyager-secret-service ${INTEGRATION_VM_USER}@${INTEGRATION_VM_IP}:$project_path 19 | 20 | integration_file=$PWD/voyager-secret-service/ci/tasks/run-integration.sh 21 | ssh -i ssh.key -o "StrictHostKeyChecking no" ${INTEGRATION_VM_USER}@${INTEGRATION_VM_IP} 'bash -s' < $integration_file 22 | -------------------------------------------------------------------------------- /ci/tasks/run-integration.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e -x 4 | 5 | [[ -s "/home/emc/.gvm/scripts/gvm" ]] >/dev/null 2>/dev/null 6 | source "/home/emc/.gvm/scripts/gvm" >/dev/null 2>/dev/null 7 | 8 | PROJECT_PATH=$GOPATH/src/github.com/RackHD 9 | COMPOSE_PATH=ci/integration/docker-compose.yml 10 | 11 | cleanUp() 12 | { 13 | # Don't exit on error here. All commands in this cleanUp must run, 14 | # even if some of them fail 15 | set +e 16 | 17 | # Delete all containers 18 | docker rm -f $(docker ps -a -q) 19 | 20 | # Delete all images 21 | docker rmi -f $(docker images -q) 22 | 23 | # Delete any dangling volumes 24 | docker volume rm $(docker volume ls -qf dangling=true) 25 | 26 | # Clean up all cloned repos 27 | cd $GOPATH 28 | rm -rf $GOPATH/src 29 | } 30 | 31 | trap cleanUp EXIT 32 | 33 | pushd $PROJECT_PATH/voyager-secret-service 34 | echo "Testing Secret Service" 35 | 36 | docker-compose -f ${COMPOSE_PATH} create 37 | docker-compose -f ${COMPOSE_PATH} start 38 | 39 | make deps 40 | make integration-test 41 | 42 | docker-compose -f ${COMPOSE_PATH} kill 43 | # Delete all containers 44 | docker rm -f $(docker ps -a -q) 45 | 46 | echo "Secret Service PASS\n\n" 47 | popd 48 | 49 | exit 50 | -------------------------------------------------------------------------------- /ci/tasks/secret-service-release.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e -x 4 | source voyager-secret-service/ci/tasks/util.sh 5 | 6 | check_param GITHUB_EMAIL 7 | check_param GITHUB_USER 8 | check_param GITHUB_PASSWORD 9 | 10 | echo -e "machine github.com\n login $GITHUB_USER\n password $GITHUB_PASSWORD" >> ~/.netrc 11 | git config --global user.email ${GITHUB_EMAIL} 12 | git config --global user.name ${GITHUB_USER} 13 | git config --global push.default current 14 | 15 | export GOPATH=$PWD 16 | export PATH=$PATH:$GOPATH/bin 17 | mkdir -p $GOPATH/src/github.com/RackHD/ 18 | cp -r voyager-secret-service $GOPATH/src/github.com/RackHD/voyager-secret-service 19 | 20 | pushd $GOPATH/src/github.com/RackHD/voyager-secret-service 21 | make deps 22 | make build 23 | 24 | release_version=`cat version | tr -d '\n'` 25 | release_version=$((release_version+1)) 26 | printf ${release_version} > version 27 | 28 | git add version 29 | git commit -m ":airplane: New release v${release_version}" -m "[ci skip]" 30 | 31 | printf "voyager-secret-service Release v${release_version}" > name 32 | printf "v${release_version}" > tag 33 | tar -czvf voyager-secret-service-v${release_version}.tar.gz ./bin/* 34 | echo "New version released." 35 | popd 36 | 37 | cp -r $GOPATH/src/github.com/RackHD/voyager-secret-service release 38 | -------------------------------------------------------------------------------- /glide.lock: -------------------------------------------------------------------------------- 1 | hash: 23ccadd00c784a9685a3d90042ee9ec87bf5323b12e3f16ba2118e4c7d3b7b3f 2 | updated: 2017-01-05T14:34:37.50418889-05:00 3 | imports: 4 | - name: github.com/RackHD/voyager-utilities 5 | version: 3d475365f014ecf9e2b75e80220ebc0ab61d05b3 6 | subpackages: 7 | - amqp 8 | - models 9 | - name: github.com/sirupsen/logrus 10 | version: d26492970760ca5d33129d2d799e34be5c4782eb 11 | - name: github.com/streadway/amqp 12 | version: 63795daa9a446c920826655f26ba31c81c860fd6 13 | - name: golang.org/x/sys 14 | version: d75a52659825e75fff6158388dddc6a5b04f9ba5 15 | subpackages: 16 | - unix 17 | testImports: 18 | - name: github.com/onsi/ginkgo 19 | version: 462326b1628e124b23f42e87a8f2750e3c4e2d24 20 | subpackages: 21 | - config 22 | - internal/codelocation 23 | - internal/containernode 24 | - internal/failer 25 | - internal/leafnodes 26 | - internal/remote 27 | - internal/spec 28 | - internal/specrunner 29 | - internal/suite 30 | - internal/testingtproxy 31 | - internal/writer 32 | - reporters 33 | - reporters/stenographer 34 | - types 35 | - name: github.com/onsi/gomega 36 | version: a78ae492d53aad5a7a232d0d0462c14c400e3ee7 37 | subpackages: 38 | - format 39 | - internal/assertion 40 | - internal/asyncassertion 41 | - internal/testingtsupport 42 | - matchers 43 | - matchers/support/goraph/bipartitegraph 44 | - matchers/support/goraph/edge 45 | - matchers/support/goraph/node 46 | - matchers/support/goraph/util 47 | - types 48 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "flag" 5 | "log" 6 | 7 | "github.com/RackHD/voyager-secret-service/models" 8 | "github.com/RackHD/voyager-utilities/random" 9 | ) 10 | 11 | var ( 12 | uri = flag.String("uri", "amqp://guest:guest@rabbitmq:5672/", "AMQP URI") 13 | exchange = flag.String("exchange", "voyager-secret-service", "Durable, non-auto-deleted AMQP exchange name") 14 | exchangeType = flag.String("exchange-type", "topic", "Exchange type - direct|fanout|topic|x-custom") 15 | queue = flag.String("queue", "voyager-secret-service-queue", "Ephemeral AMQP queue name") 16 | bindingKey = flag.String("key", "requests", "AMQP binding key") 17 | consumerTag = flag.String("consumer-tag", "simple-consumer", "AMQP consumer tag (should not be blank)") 18 | ) 19 | 20 | func init() { 21 | flag.Parse() 22 | } 23 | 24 | func main() { 25 | 26 | handler := models.NewHandler(*uri) 27 | if handler.MQ == nil { 28 | log.Fatalf("Could not connect to RabbitMQ server\n") 29 | } 30 | defer handler.MQ.Close() 31 | 32 | secretServiceQueueName := random.RandQueue() 33 | _, secretServiceMessages, err := handler.MQ.Listen(*exchange, *exchangeType, secretServiceQueueName, *bindingKey, *consumerTag) 34 | if err != nil { 35 | log.Fatalf("Error Listening to RabbitMQ: %s\n", err) 36 | } 37 | 38 | go func() { 39 | // Listen for messages in the background in infinite loop 40 | for m := range secretServiceMessages { 41 | log.Printf( 42 | "got %dB delivery on exchange %s: [%v] %s", 43 | len(m.Body), 44 | m.Exchange, 45 | m.DeliveryTag, 46 | m.Body, 47 | ) 48 | m.Ack(true) 49 | go handler.ProcessMessage(&m) 50 | } 51 | }() 52 | 53 | select {} 54 | 55 | } 56 | -------------------------------------------------------------------------------- /models/handler.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "log" 7 | 8 | "github.com/RackHD/voyager-utilities/amqp" 9 | "github.com/RackHD/voyager-utilities/models" 10 | 11 | samqp "github.com/streadway/amqp" 12 | ) 13 | 14 | type Handler struct { 15 | MQ *amqp.Client 16 | } 17 | 18 | // NewHandler creates new amqp handler 19 | func NewHandler(amqpHandler string) *Handler { 20 | handler := Handler{} 21 | handler.MQ = amqp.NewClient(amqpHandler) 22 | if handler.MQ == nil { 23 | log.Fatalf("Could not connect to RabbitMQ handler: %s\n", amqpHandler) 24 | } 25 | 26 | return &handler 27 | } 28 | 29 | // ProcessMessage processes a message 30 | func (h *Handler) ProcessMessage(m *samqp.Delivery) error { 31 | switch m.Exchange { 32 | 33 | case "voyager-secret-service": 34 | return h.processSecretService(m) 35 | 36 | default: 37 | err := fmt.Errorf("Unknown exchange name: %s\n", m.Exchange) 38 | log.Printf("Error: %s", err) 39 | return err 40 | 41 | } 42 | } 43 | 44 | // processSecretService processes a message from the voyager-secret-service exchange 45 | func (h *Handler) processSecretService(d *samqp.Delivery) error { 46 | 47 | log.Printf("Received message on Secret-Service Exchange: %s\n", d.Body) 48 | switch string(d.Body) { 49 | case "generatePassword": 50 | credentials := models.Credentials{ 51 | Username: "admin", 52 | Password: "V0yag3r!", 53 | } 54 | 55 | credetialMessage, err := json.Marshal(credentials) 56 | if err != nil { 57 | log.Fatalf("Error marshalling credentials %s\n", err) 58 | } 59 | err = h.MQ.Send(d.Exchange, "topic", d.ReplyTo, string(credetialMessage), d.CorrelationId, d.RoutingKey) 60 | if err != nil { 61 | log.Fatalf("Error sending to RabbitMQ: %s\n", err) 62 | } 63 | } 64 | return nil 65 | } 66 | -------------------------------------------------------------------------------- /models/handler_test.go: -------------------------------------------------------------------------------- 1 | package models_test 2 | 3 | import ( 4 | "os" 5 | 6 | "github.com/RackHD/voyager-secret-service/models" 7 | "github.com/RackHD/voyager-utilities/random" 8 | samqp "github.com/streadway/amqp" 9 | 10 | . "github.com/onsi/ginkgo" 11 | . "github.com/onsi/gomega" 12 | ) 13 | 14 | var _ = Describe("Handler", func() { 15 | 16 | Describe("AMQP Message Handling", func() { 17 | var rabbitMQURL string 18 | var handler *models.Handler 19 | var testExchange string 20 | var testExchangeType string 21 | var testQueueName string 22 | var testBindingKey string 23 | var testConsumerTag string 24 | var testMessage string 25 | var testReplyTo string 26 | var testCorID string 27 | 28 | BeforeEach(func() { 29 | rabbitMQURL = os.Getenv("RABBITMQ_URL") 30 | handler = models.NewHandler(rabbitMQURL) 31 | testExchange = "voyager-secret-service" 32 | testExchangeType = "topic" 33 | testQueueName = random.RandQueue() 34 | testBindingKey = "requests" 35 | testConsumerTag = "testTag" 36 | testCorID = "TEST-CORRELATION-ID" 37 | testReplyTo = testBindingKey 38 | 39 | Expect(handler.MQ).ToNot(Equal(nil)) 40 | 41 | }) 42 | AfterEach(func() { 43 | handler.MQ.Close() 44 | }) 45 | 46 | Context("When a message comes in to voyager-secret-service", func() { 47 | 48 | var deliveries <-chan samqp.Delivery 49 | var err error 50 | 51 | It("INTEGRATION should handle a password request on the 'voyager-secret-service' exchange", func() { 52 | _, deliveries, err = handler.MQ.Listen(testExchange, testExchangeType, testQueueName, testBindingKey, testConsumerTag) 53 | Expect(err).ToNot(HaveOccurred()) 54 | 55 | testMessage = `generatePassword` 56 | err = handler.MQ.Send(testExchange, testExchangeType, testBindingKey, testMessage, testCorID, testReplyTo) 57 | Expect(err).ToNot(HaveOccurred()) 58 | 59 | d := <-deliveries 60 | d.Ack(false) 61 | Expect(d.CorrelationId).To(Equal(testCorID)) 62 | 63 | err = handler.ProcessMessage(&d) 64 | Expect(err).ToNot(HaveOccurred()) 65 | 66 | d = <-deliveries 67 | d.Ack(false) 68 | Expect(string(d.Body)).To(Equal(`{"username":"admin","password":"V0yag3r!"}`)) 69 | 70 | }) 71 | 72 | }) 73 | 74 | }) 75 | 76 | }) 77 | -------------------------------------------------------------------------------- /ci/pipeline.yml: -------------------------------------------------------------------------------- 1 | jobs: 2 | - name: unit 3 | plan: 4 | - aggregate: 5 | - get: voyager-secret-service 6 | trigger: true 7 | - get: concourse-whale 8 | - task: unit 9 | image: concourse-whale 10 | config: 11 | platform: linux 12 | inputs: 13 | - name: voyager-secret-service 14 | params: 15 | GITHUB_USER: {{github_username}} 16 | GITHUB_PASSWORD: {{github_password}} 17 | run: 18 | path: voyager-secret-service/ci/tasks/unit.sh 19 | 20 | - name: integration 21 | plan: 22 | - aggregate: 23 | - put: it-env 24 | params: {acquire: true} 25 | - get: voyager-secret-service 26 | trigger: true 27 | passed: [unit] 28 | - get: concourse-whale 29 | - task: integration 30 | image: concourse-whale 31 | config: 32 | platform: linux 33 | inputs: 34 | - name: voyager-secret-service 35 | - name: it-env 36 | params: 37 | GITHUB_USER: {{github_username}} 38 | GITHUB_PASSWORD: {{github_password}} 39 | INTEGRATION_VM_USER: {{integration_vm_user}} 40 | INTEGRATION_VM_SSH_KEY: {{integration_vm_ssh_key}} 41 | run: 42 | path: voyager-secret-service/ci/tasks/integration.sh 43 | ensure: 44 | put: it-env 45 | params: {release: it-env} 46 | 47 | - name: build-docker 48 | serial: true 49 | plan: 50 | - aggregate: 51 | - get: version 52 | params: {bump: patch} 53 | - get: concourse-whale 54 | - get: voyager-secret-service 55 | trigger: true 56 | passed: [integration] 57 | - task: build 58 | image: concourse-whale 59 | config: 60 | platform: linux 61 | inputs: 62 | - name: voyager-secret-service 63 | - name: version 64 | outputs: 65 | - name: build 66 | params: 67 | GITHUB_USER: {{github_username}} 68 | GITHUB_PASSWORD: {{github_password}} 69 | run: 70 | path: voyager-secret-service/ci/tasks/build-candidate.sh 71 | - put: docker-voyager-secret-service 72 | params: 73 | build: build 74 | tag: version/version 75 | - put: version 76 | params: {file: version/version} 77 | 78 | resources: 79 | - name: voyager-secret-service 80 | type: git 81 | default-github: &github-secrets 82 | username: {{github_username}} 83 | password: {{github_password}} 84 | skip_ssl_verification: true 85 | source: 86 | uri: https://github.com/RackHD/voyager-secret-service.git 87 | branch: master 88 | <<: *github-secrets 89 | 90 | - name: version 91 | type: semver 92 | source: 93 | driver: git 94 | uri: https://github.com/RackHD/voyager-secret-service.git 95 | branch: version 96 | file: version 97 | <<: *github-secrets 98 | 99 | - name: it-env 100 | type: pool 101 | source: 102 | uri: https://github.com/RackHD/voyager-release.git 103 | branch: locks 104 | pool: integration 105 | <<: *github-secrets 106 | 107 | - name: concourse-whale 108 | type: docker-image 109 | source: 110 | repository: {{concourse_whale_repository}} 111 | insecure_registries: [{{docker_insecure_registries}}] 112 | 113 | - name: docker-voyager-secret-service 114 | type: docker-image 115 | source: 116 | repository: {{docker_secret_service_private_repository}} 117 | insecure_registries: [{{docker_insecure_registries}}] 118 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | --------------------------------------------------------------------------------