Exemplo n.º 1
0
func GetBearerForMachine(w http.ResponseWriter, r *http.Request) {
	if r.Method == "GET" {
		bearerToken = oauth.GetBearerTokenForMachineAccount(cannedmachine)
		log.Printf("Bearer Token = %s\n", bearerToken)
	} else {
		w.WriteHeader(http.StatusMethodNotAllowed)
	}
}
Exemplo n.º 2
0
func connect(r *http.Request) {
	log.Printf("DMC-Agent Connected - currently connected =  %v\n", status.GetState())
	buf := make([]byte, 1500)
	n, _ := r.Body.Read(buf)
	var machine = MachineAccount{}
	json.Unmarshal(buf[0:n], &machine)
	bearerToken := oauth.GetBearerTokenForMachineAccount(machine)
	oauth.GetTokenForMachineAccount(bearerToken)
}
Exemplo n.º 3
0
func Token(w http.ResponseWriter, r *http.Request) {
	if r.Method == "GET" {
		key := []byte("12345678901234567890123456789012")
		r.ParseForm()
		token := r.FormValue("access_token")
		sId := r.FormValue("session_id")
		log.Printf("Token crypted - token      - %s\n", token)
		log.Printf("Token crypted - session_id - %s\n", sId)
		sId = oauth.DecryptAesCBC(key, sId)
		log.Printf("Decrypted Session = %s\n", sId)
		tempToken = oauth.DecryptAesCBC(key, token)
		log.Printf("Decrypted Token   = %s\n", tempToken)
		ma := getMachineAccount(tempToken, sId)
		machine = ma
		bearerToken = oauth.GetBearerTokenForMachineAccount(machine)
		token = oauth.GetTokenForMachineAccount(bearerToken)
		fmsRegisterDevice(token)
		//http.Redirect(w, r, "https://int-admin.wbx2.com/#/login", 302)

	} else {
		w.WriteHeader(http.StatusMethodNotAllowed)
	}
}