-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Certificate Enhancements #300
base: rc-1.6.0
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export class RegenerateExistingCertificate { | ||
installedCertificateId!: number; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { GetCertificateIdUseEnumType } from '@citrineos/base'; | ||
|
||
export class UploadExistingCertificate { | ||
certificate!: string; | ||
certificateType!: GetCertificateIdUseEnumType; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,6 +63,9 @@ export class Certificate extends Model { | |
@Column(DataType.STRING) | ||
declare certificateFileId?: string | null; | ||
|
||
@Column(DataType.STRING) | ||
declare certificateFileHash?: string | null; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be unique? |
||
|
||
@Column(DataType.STRING) | ||
declare privateKeyFileId?: string | null; | ||
|
||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,39 @@ | ||||||
import { DeleteCertificateStatusEnumType, HashAlgorithmEnumType, Namespace } from '@citrineos/base'; | ||||||
import { BelongsTo, Column, DataType, ForeignKey, Model, Table } from 'sequelize-typescript'; | ||||||
import { ChargingStation } from '../Location'; | ||||||
|
||||||
@Table | ||||||
export class DeleteCertificateAttempt extends Model { | ||||||
static readonly MODEL_NAME: string = Namespace.DeleteCertificateAttempt; | ||||||
|
||||||
@ForeignKey(() => ChargingStation) | ||||||
@Column({ | ||||||
type: DataType.STRING(36), | ||||||
allowNull: false, | ||||||
}) | ||||||
declare stationId: string; | ||||||
|
||||||
@BelongsTo(() => ChargingStation) | ||||||
station?: ChargingStation; | ||||||
|
||||||
@Column({ | ||||||
type: DataType.ENUM('SHA256', 'SHA384', 'SHA512'), | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about just using values from the enum? The same idea for enum columns in
Suggested change
|
||||||
allowNull: false, | ||||||
}) | ||||||
declare hashAlgorithm: HashAlgorithmEnumType; | ||||||
|
||||||
@Column(DataType.STRING) | ||||||
declare issuerNameHash: string; | ||||||
|
||||||
@Column(DataType.STRING) | ||||||
declare issuerKeyHash: string; | ||||||
|
||||||
@Column(DataType.STRING) | ||||||
declare serialNumber: string; | ||||||
|
||||||
@Column({ | ||||||
type: DataType.ENUM('Accepted', 'Failed', 'NotFound'), | ||||||
allowNull: true, | ||||||
}) | ||||||
declare status?: DeleteCertificateStatusEnumType | null; | ||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { type CustomDataType, GetCertificateIdUseEnumType, InstallCertificateStatusEnumType, Namespace } from '@citrineos/base'; | ||
import { BelongsTo, Column, DataType, ForeignKey, Model, Table } from 'sequelize-typescript'; | ||
import { ChargingStation } from '../Location'; | ||
import { Certificate } from './Certificate'; | ||
|
||
@Table | ||
export class InstallCertificateAttempt extends Model { | ||
static readonly MODEL_NAME: string = Namespace.InstallCertificateAttempt; | ||
|
||
@ForeignKey(() => ChargingStation) | ||
@Column({ | ||
type: DataType.STRING(36), | ||
allowNull: false, | ||
}) | ||
declare stationId: string; | ||
|
||
@BelongsTo(() => ChargingStation) | ||
station?: ChargingStation; | ||
|
||
@Column({ | ||
type: DataType.ENUM('V2GRootCertificate', 'MORootCertificate', 'CSMSRootCertificate', 'V2GCertificateChain', 'ManufacturerRootCertificate'), | ||
allowNull: false, | ||
}) | ||
declare certificateType: GetCertificateIdUseEnumType; | ||
|
||
@ForeignKey(() => Certificate) | ||
@Column(DataType.INTEGER) | ||
declare certificateId: number; | ||
|
||
@BelongsTo(() => Certificate) | ||
certificate?: Certificate; | ||
|
||
@Column({ | ||
type: DataType.ENUM('Accepted', 'Rejected', 'Failed'), | ||
allowNull: true, | ||
}) | ||
declare status?: InstallCertificateStatusEnumType | null; | ||
|
||
declare customData?: CustomDataType | null; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might be missed to remove? |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
import { CertificateHashDataType, GetCertificateIdUseEnumType, HashAlgorithmEnumType, Namespace } from '@citrineos/base'; | ||
import { Column, DataType, ForeignKey, Model, Table } from 'sequelize-typescript'; | ||
import { GetCertificateIdUseEnumType, HashAlgorithmEnumType, Namespace } from '@citrineos/base'; | ||
import { BelongsTo, Column, DataType, ForeignKey, Model, Table } from 'sequelize-typescript'; | ||
import { ChargingStation } from '../Location'; | ||
import { Certificate } from './Certificate'; | ||
|
||
@Table | ||
export class InstalledCertificate extends Model implements CertificateHashDataType { | ||
export class InstalledCertificate extends Model { | ||
static readonly MODEL_NAME: string = Namespace.InstalledCertificate; | ||
|
||
@ForeignKey(() => ChargingStation) | ||
|
@@ -15,31 +16,38 @@ export class InstalledCertificate extends Model implements CertificateHashDataTy | |
|
||
@Column({ | ||
type: DataType.STRING, | ||
allowNull: false, | ||
allowNull: true, | ||
}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why does these column changes from required to optional? |
||
declare hashAlgorithm: HashAlgorithmEnumType; | ||
declare hashAlgorithm?: HashAlgorithmEnumType | undefined; | ||
|
||
@Column({ | ||
type: DataType.STRING, | ||
allowNull: false, | ||
allowNull: true, | ||
}) | ||
declare issuerNameHash: string; | ||
declare issuerNameHash?: string | undefined; | ||
|
||
@Column({ | ||
type: DataType.STRING, | ||
allowNull: false, | ||
allowNull: true, | ||
}) | ||
declare issuerKeyHash: string; | ||
declare issuerKeyHash?: string | undefined; | ||
|
||
@Column({ | ||
type: DataType.STRING, | ||
allowNull: false, | ||
allowNull: true, | ||
}) | ||
declare serialNumber: string; | ||
declare serialNumber?: string | undefined; | ||
|
||
@Column({ | ||
type: DataType.ENUM('V2GRootCertificate', 'MORootCertificate', 'CSMSRootCertificate', 'V2GCertificateChain', 'ManufacturerRootCertificate'), | ||
allowNull: false, | ||
}) | ||
declare certificateType: GetCertificateIdUseEnumType; | ||
|
||
@ForeignKey(() => Certificate) | ||
@Column(DataType.INTEGER) | ||
declare certificateId?: number | null; | ||
|
||
@BelongsTo(() => Certificate) | ||
certificate!: Certificate; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright Contributors to the CitrineOS Project | ||
// | ||
// SPDX-License-Identifier: Apache 2.0 | ||
|
||
import { SequelizeRepository } from './Base'; | ||
import { SystemConfig } from '@citrineos/base'; | ||
import { Sequelize } from 'sequelize-typescript'; | ||
import { ILogObj, Logger } from 'tslog'; | ||
import { DeleteCertificateAttempt } from '../model/Certificate'; | ||
import { IDeleteCertificateAttemptRepository } from '../../../interfaces'; | ||
|
||
export class SequelizeDeleteCertificateAttemptRepository extends SequelizeRepository<DeleteCertificateAttempt> implements IDeleteCertificateAttemptRepository { | ||
constructor(config: SystemConfig, logger?: Logger<ILogObj>, sequelizeInstance?: Sequelize) { | ||
super(config, DeleteCertificateAttempt.MODEL_NAME, logger, sequelizeInstance); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright Contributors to the CitrineOS Project | ||
// | ||
// SPDX-License-Identifier: Apache 2.0 | ||
|
||
import { SequelizeRepository } from './Base'; | ||
import { IInstallCertificateAttemptRepository } from '../../../interfaces'; | ||
import { SystemConfig } from '@citrineos/base'; | ||
import { Sequelize } from 'sequelize-typescript'; | ||
import { ILogObj, Logger } from 'tslog'; | ||
import { InstallCertificateAttempt } from '../model/Certificate/InstallCertificateAttempt'; | ||
|
||
export class SequelizeInstallCertificateAttemptRepository extends SequelizeRepository<InstallCertificateAttempt> implements IInstallCertificateAttemptRepository { | ||
constructor(config: SystemConfig, logger?: Logger<ILogObj>, sequelizeInstance?: Sequelize) { | ||
super(config, InstallCertificateAttempt.MODEL_NAME, logger, sequelizeInstance); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super minor:
InstallCertificateAttempt
can be put together withDeleteCertificateAttempt
at line 55.