[630][adas] 修改证书认证流程
This commit is contained in:
@@ -155,7 +155,7 @@ public class BusPresenter extends Presenter<BusFragment>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotSNRequest(@NonNull AdasConstants.CertificationStatus status) {
|
||||
public void onAutopilotSNRequest(@NonNull MessagePad.BasicInfoReq basicInfoReq) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -154,7 +154,7 @@ public class BusPresenter extends Presenter<ShuttleFragment>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotSNRequest(@NonNull AdasConstants.CertificationStatus status) {
|
||||
public void onAutopilotSNRequest(@NonNull MessagePad.BasicInfoReq basicInfoReq) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -545,7 +545,7 @@ public class BusPassengerModel {
|
||||
private boolean arriveAtEnd = false; //乘客app专用字段
|
||||
|
||||
@Override
|
||||
public void onAutopilotSNRequest(@NonNull AdasConstants.CertificationStatus status) {
|
||||
public void onAutopilotSNRequest(@NonNull MessagePad.BasicInfoReq basicInfoReq) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -702,7 +702,7 @@ public class SweeperCloudTaskModel implements IMoGoSweeperFutianCloudTaskListene
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotSNRequest(@NonNull AdasConstants.CertificationStatus status) {
|
||||
public void onAutopilotSNRequest(@NonNull MessagePad.BasicInfoReq basicInfoReq) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -245,7 +245,7 @@ public class SweeperOperatePresenter extends Presenter<SweeperOperateFragment>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotSNRequest(@NonNull AdasConstants.CertificationStatus status) {
|
||||
public void onAutopilotSNRequest(@NonNull MessagePad.BasicInfoReq basicInfoReq) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1292,7 +1292,7 @@ public class TaxiModel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotSNRequest(@NonNull AdasConstants.CertificationStatus status) {
|
||||
public void onAutopilotSNRequest(@NonNull MessagePad.BasicInfoReq basicInfoReq) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -360,15 +360,27 @@ class MoGoAdasListenerImpl : OnAdasListener {
|
||||
|
||||
/**
|
||||
* 自动驾驶设备基础信息请求
|
||||
* 连接时启用认证 后才会有认证结果
|
||||
* 如果启用认证后,在AdasOptions中未传递RootCrt需要在此回调中调用{@link AdasManager#certification(String, ByteString)}进行域控证书认证
|
||||
*
|
||||
* @param header 头
|
||||
* @param basicInfoReq 数据
|
||||
*/
|
||||
override fun onBasicInfoReq(header: MessagePad.Header?, basicInfoReq: MessagePad.BasicInfoReq) {
|
||||
invokeAutopilotSNRequest(basicInfoReq)
|
||||
}
|
||||
|
||||
/**
|
||||
* 域控证书认证状态
|
||||
* 启用认证需要配置 AdasOptions.setEnableCertification()
|
||||
* 连接时启用认证 后才会有证认结果
|
||||
* ROOT证书异常会影响校验域控证书
|
||||
* PAD证书异常会影响域控端校验的证书校验,域控端证书校验失败将会断开连接,且并不会给出断开原因,ADAS LIB会执行重连操作(如果配置启用重连)
|
||||
* 校验域控证书认证失败会主动断开连接,且不进行重连
|
||||
* 假如校验域控证书认证失败会主动断开连接,且不进行重连
|
||||
*
|
||||
* @param status 域控证书认证结果{@link AdasConstants.CertificationStatus}
|
||||
*/
|
||||
override fun onBasicInfoReq(status: AdasConstants.CertificationStatus) {
|
||||
invokeAutopilotSNRequest(status)
|
||||
override fun onCertification(status: AdasConstants.CertificationStatus) {
|
||||
|
||||
}
|
||||
|
||||
//工控机基础配置信息
|
||||
|
||||
@@ -33,6 +33,7 @@ import com.zhidao.support.adas.high.common.Constants.ENVIRONMENT.TEST
|
||||
import com.zhidao.support.adas.high.common.Constants.TERMINAL_ROLE.DRIVER
|
||||
import com.zhidao.support.adas.high.common.Constants.TERMINAL_ROLE.PASSENGER
|
||||
import com.zhjt.mogo.adas.data.AdasConstants
|
||||
import mogo.telematics.pad.MessagePad
|
||||
|
||||
/**
|
||||
* ADAS-SDK与工控机连接状态回调
|
||||
@@ -265,7 +266,7 @@ class MoGoAdasMsgConnectStatusListenerImpl :
|
||||
/**
|
||||
* 工控机获取SN
|
||||
*/
|
||||
override fun onAutopilotSNRequest(status: AdasConstants.CertificationStatus) {
|
||||
override fun onAutopilotSNRequest(basicInfoReq: MessagePad.BasicInfoReq) {
|
||||
syncBasicInfoToAutopilot()
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ interface IMoGoAutopilotStatusListener {
|
||||
/**
|
||||
* 工控机获取SN
|
||||
*/
|
||||
fun onAutopilotSNRequest(status: AdasConstants.CertificationStatus) {}
|
||||
fun onAutopilotSNRequest(basicInfoReq: MessagePad.BasicInfoReq) {}
|
||||
|
||||
/**
|
||||
* 工控机监控节点
|
||||
|
||||
@@ -187,10 +187,10 @@ object CallerAutoPilotStatusListenerManager : CallerBase<IMoGoAutopilotStatusLis
|
||||
* 工控机获取SN 回调
|
||||
*/
|
||||
@Synchronized
|
||||
fun invokeAutopilotSNRequest(status: AdasConstants.CertificationStatus) {
|
||||
fun invokeAutopilotSNRequest(basicInfoReq: MessagePad.BasicInfoReq) {
|
||||
M_LISTENERS.forEach {
|
||||
val listener = it.value
|
||||
listener.onAutopilotSNRequest(status)
|
||||
listener.onAutopilotSNRequest(basicInfoReq)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -551,25 +551,38 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec
|
||||
private final Runnable certificationTimeoutRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
certification(true, null);
|
||||
certification(true, "", com.google.protobuf.ByteString.EMPTY);
|
||||
}
|
||||
};
|
||||
|
||||
private void certification(boolean isTimeout, String ipcCrt) {
|
||||
/**
|
||||
* 域控证书校验
|
||||
*
|
||||
* @param rootCrt root证书
|
||||
* @param ipcCrt 域控证书
|
||||
* @return 调用是否成功 false:AdasOptions中如果传入了RootCrt将会自动进行认证,无需再次调用
|
||||
*/
|
||||
@Override
|
||||
public boolean certification(@NonNull String rootCrt, @NonNull com.google.protobuf.ByteString ipcCrt) {
|
||||
if (TextUtils.isEmpty(adasOptions.getRootCrt())) {
|
||||
certification(false, rootCrt, ipcCrt);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void certification(boolean isTimeout, @NonNull String rootCrt, @NonNull com.google.protobuf.ByteString ipcCertification) {
|
||||
AdasConstants.CertificationStatus result = AdasConstants.CertificationStatus.NOT_ENABLED;
|
||||
//检查是否开启验证
|
||||
if (adasOptions.isCertification()) {
|
||||
if (isTimeout) {
|
||||
result = AdasConstants.CertificationStatus.TIMEOUT;
|
||||
} else {
|
||||
if (defaultDispatchHandler != null) {
|
||||
defaultDispatchHandler.removeCallbacks(certificationTimeoutRunnable);
|
||||
}
|
||||
String rootCrt = adasOptions.getRootCrt();
|
||||
if (rootCrt == null || rootCrt.length() == 0) {
|
||||
//提示证书验证失败
|
||||
result = AdasConstants.CertificationStatus.ROOT_CRT_ERROR;
|
||||
} else {
|
||||
String ipcCrt = CertificateUtils.decode(ipcCertification);
|
||||
if (ipcCrt == null || ipcCrt.length() == 0) {
|
||||
//提示域控证书失败
|
||||
result = AdasConstants.CertificationStatus.IPC_CRT_ERROR;
|
||||
@@ -581,7 +594,7 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec
|
||||
}
|
||||
}
|
||||
if (mAdasListener != null) {
|
||||
mAdasListener.onBasicInfoReq(result);
|
||||
mAdasListener.onCertification(result);
|
||||
}
|
||||
CupidLogUtils.log(TAG, "证书验证状态=" + result);
|
||||
if (result == AdasConstants.CertificationStatus.CERTIFICATE_CHAIN_SUCCESS) {
|
||||
@@ -613,9 +626,18 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec
|
||||
receivedAckManager.receiveReceivedAck(time, ack);
|
||||
CupidLogUtils.log(TAG, "收到回执=" + ack);
|
||||
} else if (messageType == MessageType.TYPE_RECEIVE_BASIC_INFO_REQ.typeCode) {
|
||||
MessagePad.BasicInfoReq autopilotState = MessagePad.BasicInfoReq.parser().parseFrom(raw.originalData.toByteArray(), raw.getOffsetValue(), raw.getPackageLengthValue() - raw.getOffsetValue());
|
||||
String ipcCrt = CertificateUtils.decode(autopilotState.getCertification());
|
||||
certification(false, ipcCrt);
|
||||
//移除证书超时
|
||||
if (defaultDispatchHandler != null) {
|
||||
defaultDispatchHandler.removeCallbacks(certificationTimeoutRunnable);
|
||||
}
|
||||
MessagePad.BasicInfoReq basicInfoReq = MessagePad.BasicInfoReq.parser().parseFrom(raw.originalData.toByteArray(), raw.getOffsetValue(), raw.getPackageLengthValue() - raw.getOffsetValue());
|
||||
if (mAdasListener != null) {
|
||||
mAdasListener.onBasicInfoReq(header, basicInfoReq);
|
||||
}
|
||||
String rootCrt = adasOptions.getRootCrt();
|
||||
if (!TextUtils.isEmpty(rootCrt)) {
|
||||
certification(rootCrt, basicInfoReq.getCertification());
|
||||
}
|
||||
} else {
|
||||
IMsg iMsg = myMessageFactory.createMessage(messageType);
|
||||
if (iMsg == null) {
|
||||
@@ -1142,10 +1164,18 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec
|
||||
if (!TextUtils.isEmpty(version)) {
|
||||
builder.setVersion(version);
|
||||
}
|
||||
if (deviceCrt != null && deviceCrt.length() > 0) {
|
||||
com.google.protobuf.ByteString crt = CertificateUtils.encode(deviceCrt);
|
||||
if (crt != null) {
|
||||
builder.setCertification(crt);
|
||||
if (adasOptions.isCertification()) {
|
||||
if (TextUtils.isEmpty(deviceCrt)) {
|
||||
String tem = adasOptions.getDeviceCrt();
|
||||
if (!TextUtils.isEmpty(tem)) {
|
||||
deviceCrt = tem;
|
||||
}
|
||||
}
|
||||
if (deviceCrt != null && deviceCrt.length() > 0) {
|
||||
com.google.protobuf.ByteString crt = CertificateUtils.encode(deviceCrt);
|
||||
if (crt != null) {
|
||||
builder.setCertification(crt);
|
||||
}
|
||||
}
|
||||
}
|
||||
MessagePad.BasicInfoResp resp = builder.build();
|
||||
|
||||
@@ -5,6 +5,7 @@ import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import com.zhidao.support.adas.high.bean.VersionCompatibility;
|
||||
import com.zhidao.support.adas.high.common.Constants;
|
||||
import com.zhidao.support.adas.high.common.CupidLogUtils;
|
||||
@@ -1766,6 +1767,18 @@ public class AdasManager implements IAdasNetCommApi {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 域控证书校验
|
||||
*
|
||||
* @param rootCrt root证书
|
||||
* @param ipcCrt 域控证书
|
||||
* @return 调用是否成功 false:AdasOptions中如果传入了RootCrt将会自动进行认证,无需再次调用
|
||||
*/
|
||||
@Override
|
||||
public boolean certification(@NonNull String rootCrt, @NonNull ByteString ipcCrt) {
|
||||
return mChannel != null && mChannel.certification(rootCrt, ipcCrt);
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动连接
|
||||
* 不会存储 下次启动恢复默认
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.zhidao.support.adas.high;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import com.zhidao.support.adas.high.subscribe.SubscribeInterfaceOption;
|
||||
import com.zhjt.mogo.adas.data.AdasConstants;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
@@ -46,6 +48,7 @@ public class AdasOptions {
|
||||
private final int reconnectCount;
|
||||
private final boolean isCertification;
|
||||
private final String rootCrt;
|
||||
private final String deviceCrt;
|
||||
private final boolean isAutoConnect;
|
||||
private final Set<SubscribeInterfaceOption> subscribeInterfaceOptions;
|
||||
private final Set<Chassis.GearPosition> unableLaunchAutopilotGear;
|
||||
@@ -60,6 +63,7 @@ public class AdasOptions {
|
||||
this.reconnectCount = builder.reconnectCount;
|
||||
this.isCertification = builder.isCertification;
|
||||
this.rootCrt = builder.rootCrt;
|
||||
this.deviceCrt = builder.deviceCrt;
|
||||
this.isAutoConnect = builder.isAutoConnect;
|
||||
this.subscribeInterfaceOptions = builder.subscribeInterfaceOptions;
|
||||
this.unableLaunchAutopilotGear = builder.unableLaunchAutopilotGear;
|
||||
@@ -97,6 +101,10 @@ public class AdasOptions {
|
||||
return rootCrt;
|
||||
}
|
||||
|
||||
public String getDeviceCrt() {
|
||||
return deviceCrt;
|
||||
}
|
||||
|
||||
public boolean isAutoConnect() {
|
||||
return isAutoConnect;
|
||||
}
|
||||
@@ -130,6 +138,7 @@ public class AdasOptions {
|
||||
private int reconnectCount = DEFAULT.RECONNECT_COUNT;
|
||||
private boolean isCertification = DEFAULT.IS_CERTIFICATION;
|
||||
private String rootCrt;
|
||||
private String deviceCrt;
|
||||
private boolean isAutoConnect = DEFAULT.IS_AUTO_CONNECT;
|
||||
private Set<SubscribeInterfaceOption> subscribeInterfaceOptions;
|
||||
private Set<Chassis.GearPosition> unableLaunchAutopilotGear;
|
||||
@@ -147,6 +156,7 @@ public class AdasOptions {
|
||||
this.reconnectCount = options.reconnectCount;
|
||||
this.isCertification = options.isCertification;
|
||||
this.rootCrt = options.rootCrt;
|
||||
this.deviceCrt = options.deviceCrt;
|
||||
this.isAutoConnect = options.isAutoConnect;
|
||||
this.subscribeInterfaceOptions = options.subscribeInterfaceOptions;
|
||||
this.unableLaunchAutopilotGear = options.unableLaunchAutopilotGear;
|
||||
@@ -164,6 +174,7 @@ public class AdasOptions {
|
||||
* *reconnectCount
|
||||
* *isCertification
|
||||
* *rootCrt
|
||||
* *deviceCrt
|
||||
* *isAutoConnect
|
||||
* *subscribeInterfaceOptions
|
||||
* *unableLaunchAutopilotGear
|
||||
@@ -252,7 +263,7 @@ public class AdasOptions {
|
||||
|
||||
/**
|
||||
* ROOT证书
|
||||
* 启用认证必须传
|
||||
* 启用认证后如果不传递,认证域控证书可以主动调用{@link AdasManager#certification(String, ByteString)}
|
||||
*
|
||||
* @param rootCrt root证书
|
||||
* @return Builder
|
||||
@@ -262,6 +273,20 @@ public class AdasOptions {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设备证书
|
||||
* 启用认证后如果不传递,必须在调用以下方法时传递
|
||||
* {@link AdasManager#sendBasicInfoResp(String, AdasConstants.Environment, AdasConstants.TerminalRole, String)}
|
||||
* {@link AdasManager#sendBasicInfoResp(String, AdasConstants.Environment, AdasConstants.TerminalRole, int, String, String)}
|
||||
*
|
||||
* @param deviceCrt root证书
|
||||
* @return Builder
|
||||
*/
|
||||
public Builder setDeviceCrt(String deviceCrt) {
|
||||
this.deviceCrt = deviceCrt;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否自动连接
|
||||
* create之后是否自动连接域控
|
||||
|
||||
@@ -126,6 +126,15 @@ public interface IAdasNetCommApi {
|
||||
*/
|
||||
void setRootCrt(String rootCrt);
|
||||
|
||||
/**
|
||||
* 域控证书校验
|
||||
*
|
||||
* @param rootCrt root证书
|
||||
* @param ipcCrt 域控证书
|
||||
* @return 调用是否成功 false:AdasOptions中如果传入了RootCrt将会自动进行认证,无需再次调用
|
||||
*/
|
||||
boolean certification(@NonNull String rootCrt, @NonNull com.google.protobuf.ByteString ipcCrt);
|
||||
|
||||
/**
|
||||
* 自动连接
|
||||
* 不会存储 下次启动恢复默认
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.zhidao.support.adas.high;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.google.protobuf.ByteString;
|
||||
import com.mogo.support.obu.ObuScene;
|
||||
import com.zhidao.support.adas.high.common.ProtocolStatus;
|
||||
import com.zhjt.mogo.adas.common.MessageType;
|
||||
@@ -147,14 +148,24 @@ public interface OnAdasListener {
|
||||
|
||||
/**
|
||||
* 自动驾驶设备基础信息请求
|
||||
* 连接时启用认证 后才会有认证结果
|
||||
* 如果启用认证后,在AdasOptions中未传递RootCrt需要在此回调中调用{@link AdasManager#certification(String, ByteString)}进行域控证书认证
|
||||
*
|
||||
* @param header 头
|
||||
* @param basicInfoReq 数据
|
||||
*/
|
||||
void onBasicInfoReq(MessagePad.Header header, @NonNull MessagePad.BasicInfoReq basicInfoReq);
|
||||
|
||||
/**
|
||||
* 域控证书认证状态
|
||||
* 启用认证需要配置 AdasOptions.setEnableCertification()
|
||||
* 连接时启用认证 后才会有证认结果
|
||||
* ROOT证书异常会影响校验域控证书
|
||||
* PAD证书异常会影响域控端校验的证书校验,域控端证书校验失败将会断开连接,且并不会给出断开原因,ADAS LIB会执行重连操作(如果配置启用重连)
|
||||
* 校验域控证书认证失败会主动断开连接,且不进行重连
|
||||
* 假如校验域控证书认证失败会主动断开连接,且不进行重连
|
||||
*
|
||||
* @param status 域控证书认证结果{@link AdasConstants.CertificationStatus}
|
||||
*/
|
||||
void onBasicInfoReq(@NonNull AdasConstants.CertificationStatus status);
|
||||
void onCertification(@NonNull AdasConstants.CertificationStatus status);
|
||||
|
||||
/**
|
||||
* 车机基础信息应答
|
||||
|
||||
Reference in New Issue
Block a user