/**
 *
 * <p class=proto-main> For vehicle authorization, commmonly referred to as Bootstrap, the vehicle will send an initial auth key consisting of hash of client generated challengekey and a nonce (a trust id to be identified in implementation)
 * and will recieve in return a server challenge key and nonce. These will be used to generate a temporary session key, which when passed to the server will return a valid sessionid. Once received, the valid sessionId should be used in the Uconnect Message.SessionID filed for all future Uconnect Messages
 * until it is refreshed.
 * <b> This is deprecated and not expected to be used by any current program</b>
 *
 *
 * <div class=proto-hier>
 *  	UconnectAny
 * 		|
 * 		|
 * 		|---- <a href="#com.fca.uconnect.global.FirstVehAuthRequest">FirstVehAuthRequest firstVehAuthRequest (1720)</a>
 *     	|
 *		|---- <a href="#com.fca.uconnect.global.FirstVehAuthResponse">FirstVehAuthResponse firstVehAuthResponse (1721)</a>
 * 		|
 * 		|---- <a href="#com.fca.uconnect.global.SecVehAuthRequest">SecVehAuthRequest secVehAuthRequest (1722)</a>
 *     	|
 *		|---- <a href="#com.fca.uconnect.global.SecVehAuthResponse">SecVehAuthResponse secVehAuthResponse (1723)</a>
 * 		|
 * 		|---- <a href="#com.fca.uconnect.global.CreateTokenRequest">CreateTokenRequest createTokenRequest (1724)</a>
 *     	|
 *		|---- <a href="#com.fca.uconnect.global.CreateTokenResponse">CreateTokenResponse createTokenResponse (1725)</a>
 * 		|
 * 		|---- <a href="#com.fca.uconnect.global.RefreshTokenRequest">RefreshTokenRequest refreshTokenRequest (1724)</a>
 *     	|
 *		|---- <a href="#com.fca.uconnect.global.RefreshTokenResponse">RefreshTokenResponse refreshTokenResponse (1725)</a>
 * </div>
 *
 *   <h3 class=change-log-hdr> Change Log</h3>
 *  <table id="change-log" class="change-log"><thead><tr>
 *	<th>Version</th><th>Date</th><th>Notes</th></tr></thead>
 *   <tbody>
 * 		<tr><td>1.0</td><td>2017-12-11</td><td>Moved From Auth</td></tr>
  *    	</tbody></table>
 *
 *  <h3 class=change-log-hdr>List of MQTT Topics</h3>
 *  <table class="change-log"><thead><tr>
 *	<th>Flow</th><th>Type</th><th>Topic Name</th></tr></thead>
 *    <tbody>
 *   <tr><td>Cloud send to Vehicle</td><td>Publish</td><td>fcasdp/${iot:ClientId}/</td></tr>
 *	 <tr><td>Cloud receive from Vehicle</td><td>Subscribe</td><td>fcasdp/Auth/#</td></tr>
 *	 <tr><td>Vehicle send to Cloud </td><td>Publish</td><td>fcasdp/Auth/${iot:ClientId}</td></tr>
 * <tr><td>Cloud receive from Vehicle</td><td>Subscribe</td><td>fcasdp/Auth/#</td></tr>
 *	 <tr><td>Vehicle send to Cloud </td><td>Publish</td><td>fcasdp/Auth/${iot:ClientId}</td></tr>
 *	 <tr><td>Vehicle receive from Cloud </td><td>Subscribe</td><td>fcasdp/${iot:ClientId}/#</td></tr>
 *	</tbody></table>
 *  <h3 class=change-log-hdr>Data Flow</h3>
 *
 * <p class=proto-main>The following sequence diagram shows the messages for implementing Bootstrap to support mutual authentication between the client and the SDP:
 * </p>
 *
 * <img class=img-border src=./images/bootstrap.png>
 *
 *<table class=sequence-table>
*<thead><tr>
*<td>Sequence</td><td>Title</td><td>Role</td><td>Message</td><td>Topic</td><td>Description</td></tr></thead>
*<tbody><tr>
*<td align="right">100</td>
*<td>Generate Public Key</td>
*<td>TU </td>
*<td> </td>
*<td> </td>
*<td> </td>
*</tr>
*<tr>
*<td align="right">110</td>
*<td>InitialCreate CSR</td>
*<td>TU</td>
*<td></td>
*<td></td>
*<td></td>
*</tr>
* <tr>
*<td align="right">120</td>
*<td>App CSR to TU Feed Data</td>
*<td>TU Manufacturer</td>
*<td> </td>
*<td> </td>
*<td>TU Manufacturer Sends TU Feed Data</td>
*</tr>
*<tr>
*<td align="right">130</td>
*<td>CMM Receives TU Feed Data</td>
*<td>CMM</td>
*<td> </td>
*<td> </td>
*<td>The TU Feed is received at FCA and Propagated to other systems as needed</td>
*</tr>
*<tr>
*<td align="right">140</td>
*<td>CSR and TU ID Sent to PKI</td>
*<td>CMM</td>
*<td></td>
*<td></td>
*<td>The PKI Certificate Generation Request is made</td>
*</tr>
*<tr>
*<td align="right">150</td>
*<td>X.509 Certificate Returned</td>
*<td>PKI</td>
*<td> </td>
*<td>PKI Returns a Valid Certificate</td>
*</tr>
*<tr>
* <tr>
*<td align="right">170/td>
*<td>Request Authorization</td>
*<td>TU</td>
*<td> </td>
*<td> </td>
*<td>The TU Requests Authorization for 1st time</td>
*</tr>
*<tr>
*<td align="right">180,190,200</td>
*<td>Download Certificate via HTTPS service</td>
*<td>TU</td>
*<td>certificateGet</td>
*<td></td>
*<td>Download the client certificate</td>
*</tr>
*<tr>
*<td align="right">210</td>
*<td>Store Certificate</td>
*<td>TU</td>
*<td> </td>
*<td> </td>
*<td>Stores the certificate for mutual authentication</td>
*</tr>
*<tr>
*<td align="right">220,230</td>
*<td>Alternate Path: Feeds not propogated TU not known to the SDP</td>
*<td>SDP</td>
*<td> </td>
*<td> </td>
*<td>Rejects connections, unable to identify the TU and VIN relationship\n system will retry until success</td>
*</tr>
*<tr>
*<td align="right">300</td>
*<td>Request MQTT Connection</td>
*<td>TU</td>
*<td></td>
*<td></td>
*<td>Open MQTT Connection and start TLS session.</td>
*</tr>
*<tr>
*<td align="right">310,320</td>
*<td>Validate TU and TU Validate SDP</td>
*<td>SDP</td>
*<td></td>
*<td></td>
*<td>Mutual Auth</td>
*</tr>
*<tr>
*<td align="right">330</td>
*<td>Connection Established</td>
*<td>TU </td>
*<td></td>
*<td></td>
*<td></td>
*</tr>
*
*</tbody></table>
 */
syntax="proto3";
package com.fca.uconnect.global;
import public "Global_Uconnect_Device.proto";


/**
 * This is for SecondVehicleAuthorizationRequest.
 *<div class=exmsg-main>
 *  <h4>FirstVehicleAuthorization Request Example Message:</h4>
 * <div class=ex-msg>
 *	<code>
 * 		timestamp: 1488868820053
 * 		messageId: 1
 * 		messages
 * 		{
 * 		 [com.fca.uconnect.global.FirstAuthorizationResponse]
 * 		 {
 * 			“vin”: “AEEUDHS4857382038”,
 * 			“tuProfile”: {
 * 				“nadimei”: “323232323232”,
 * 				“simMsisdn”: “12123123123”,
 * 				“simIccid”: “12123123123”,
 * 				“imsi”: “12123123123”,
 * 				“tbmSerial”: “JK1212ASD233”,
 * 				“tbmSoftwareVersion”: “17.03.03”
 * 				},
 * 			“tempAuthKey”: “12ABc345”,
 * 			“correlationId”: “12abCd1”
 * 			}
 * 		 }
 * 		}
 *	</code>
 *   </div></div>
 */
message VehAuthRequest {
	enum RequestTypeEnum {
		UNKNOWN = 0;///
		INITIAL = 1;/// Initial provisioning request for a temporary session.
		SECOND = 2;/// Secondary request to receive valid session token.
		}

	string vin =1; /// Vehicle Identification Number
	Device device = 2; /// requires the deviceType, IMIE, MSISDN,ICCID, IMSI, and TBM or HU Serial and Software Version
	bytes authToken = 3; /// Hash token of client challenge fields.  Temporary Session Key (concatenated string of Client and Server Challenge Keys)
	bytes nonce= 4; /// Nonce for protecting against replay
	RequestTypeEnum type = 5; /// Indicate the initial or second auth request.
}
message VehAuthResponse {
	enum TokenTypeEnum {
		UNKNOWN = 0;///
		TEMP = 1;/// Initial temporary session token.
		VALID = 2;/// Valid session token.
		}
	bytes sessionToken=1; /// Permanent Session Key provided by Server, should be used in MQTT Header for future operations
	bytes nonce= 2; /// CR or Correlation ID
	TokenTypeEnum type = 3;/// Indicate the type of session token returned to the client.
}

message CreateTokenRequest {
	string grant_type=1; /// Type of challenge response, use "password" for basic auth
	string deviceId=2; /// IMEI of TU Profile for the vehicle

	string permKey =3; /// In case of TU communication bootstrap, it will be Permanent Session Key returned by the server

	}
message CreateTokenResponse {
	string accessToken =1; /// Access Token
	string authorizationToken=2; ///Authorization Token / Null on TU's
	int32 expiresIn=3; /// The lifetime of the access token in seconds.
	string refreshToken=4; /// Refresh token to be used to retrieve new tokens when they are expired
	string token_type=5; /// use only bearer
	string accountDN=6; /// Account DNm unique account name

}

message RefreshTokenRequest {
	string grant_type=1; /// Type of challenge response, use "refresh token" for basic auth
	string deviceId=2; /// Correlation ID, unique to the TU
	string refreshToken =3; /// Value of refresh token that was issued previously.
	}
message RefreshTokenResponse {
	string accessToken =1; /// Access Token
	string authorizationToken=2; ///Authorization Token
	int32 expiresIn=3; /// time until the token(s) expire
	string refreshToken=4; /// refresh Authorization Token
	string token_type=5; /// use only bearer
	string accountDN=6; /// Account DN
	enum ResponseEnum {
		SUCCESS = 0;/// Response successful for provisioning.
		FAILURE = 1;/// Response failure for provisioning.
		}
 ResponseEnum responseEnum = 7; /// Success or Failure Response
	 bool isTransient = 8; /// Indicates a transient error and a retry can be attempted.
	 int32 failureReasonCode = 9; /// Specific error code. Error codes should include Invalid_Grant and Common Error Codes

}


