services

package
v0.0.0-...-4086bda Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 27, 2024 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Overview

Package services defines pluggable services that are used to customize the processing of OCPP messages by the core handlers.

Index

Constants

View Source
const XsdMsgDefinition = "urn:iso:15118:2:2013:MsgDef"

Variables

View Source
var HubjectTestTokenRegexp = regexp.MustCompile(`Bearer (.+)\n`)

Functions

func ParseCertificates

func ParseCertificates(pemData []byte) ([]*x509.Certificate, error)

Types

type BasicKwhTariffService

type BasicKwhTariffService struct{}

func (BasicKwhTariffService) CalculateCost

func (BasicKwhTariffService) CalculateCost(transaction *store.Transaction) (float64, error)

type CachingHttpTokenService

type CachingHttpTokenService struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewCachingHttpTokenService

func NewCachingHttpTokenService(tokenService HttpTokenService, ttl time.Duration, clock clock.PassiveClock) *CachingHttpTokenService

func (*CachingHttpTokenService) GetToken

func (h *CachingHttpTokenService) GetToken(ctx context.Context, refresh bool) (string, error)

type CachingRootCertificateProviderService

type CachingRootCertificateProviderService struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*CachingRootCertificateProviderService) ProvideCertificates

func (c *CachingRootCertificateProviderService) ProvideCertificates(ctx context.Context) ([]*x509.Certificate, error)

type CcpResponse

type CcpResponse struct {
	EmaidContent []struct {
		MessageDef struct {
			CertificateInstallationRes string `json:"certificateInstallationRes"`
			Emaid                      string `json:"emaid"`
		} `json:"messageDef"`
	} `json:"emaidContent"`
}

type CertificateType

type CertificateType int
const (
	CertificateTypeV2G CertificateType = iota
	CertificateTypeCSO
)

type CertificateValidationService

type CertificateValidationService interface {
	ValidatePEMCertificateChain(ctx context.Context, pemChain []byte, eMAID string) (*string, error)
	ValidateHashedCertificateChain(ctx context.Context, ocspRequestData []ocpp201.OCSPRequestDataType) (*string, error)
}

type ChargeStationCertificateProvider

type ChargeStationCertificateProvider interface {
	ProvideCertificate(ctx context.Context, typ CertificateType, pemEncodedCSR string, csId string) (pemEncodedCertificateChain string, err error)
}

type CompositeRootCertificateProviderService

type CompositeRootCertificateProviderService struct {
	Providers []RootCertificateProviderService
}

func (CompositeRootCertificateProviderService) ProvideCertificates

type ContractCertificateProvider

type ContractCertificateProvider interface {
	ProvideCertificate(ctx context.Context, exiRequest string) (EvCertificate15118Response, error)
}

type DefaultChargeStationCertificateProvider

type DefaultChargeStationCertificateProvider struct{}

func (DefaultChargeStationCertificateProvider) ProvideCertificate

func (n DefaultChargeStationCertificateProvider) ProvideCertificate(context.Context, CertificateType, string, string) (pemEncodedCertificateChain string, err error)

type DefaultContractCertificateProvider

type DefaultContractCertificateProvider struct{}

func (DefaultContractCertificateProvider) ProvideCertificate

type DelegatingChargeStationCertificateProvider

type DelegatingChargeStationCertificateProvider struct {
	V2GChargeStationCertificateProvider ChargeStationCertificateProvider
	CSOChargeStationCertificateProvider ChargeStationCertificateProvider
}

func (*DelegatingChargeStationCertificateProvider) ProvideCertificate

func (d *DelegatingChargeStationCertificateProvider) ProvideCertificate(ctx context.Context, typ CertificateType, pemEncodedCSR string, csId string) (pemEncodedCertificateChain string, err error)

type EvCertificate15118Response

type EvCertificate15118Response struct {
	Status                     ocpp201.Iso15118EVCertificateStatusEnumType
	CertificateInstallationRes string
}

type FileRootCertificateProviderService

type FileRootCertificateProviderService struct {
	FilePaths []string
}

func (FileRootCertificateProviderService) ProvideCertificates

func (s FileRootCertificateProviderService) ProvideCertificates(context.Context) (certs []*x509.Certificate, err error)

type FileSource

type FileSource struct {
	FileName string
}

func (FileSource) GetData

func (f FileSource) GetData(_ context.Context) (string, error)

type FixedHttpTokenService

type FixedHttpTokenService struct {
	// contains filtered or unexported fields
}

func NewEnvHttpTokenService

func NewEnvHttpTokenService(envVar string) (*FixedHttpTokenService, error)

func NewFixedHttpTokenService

func NewFixedHttpTokenService(token string) *FixedHttpTokenService

func (*FixedHttpTokenService) GetToken

func (f *FixedHttpTokenService) GetToken(_ context.Context, _ bool) (string, error)

type GoogleSecretSource

type GoogleSecretSource struct {
	SecretName string
}

func (GoogleSecretSource) GetData

func (g GoogleSecretSource) GetData(ctx context.Context) (string, error)

type HttpError

type HttpError int

func (HttpError) Error

func (h HttpError) Error() string

type HttpTokenService

type HttpTokenService interface {
	GetToken(ctx context.Context, refresh bool) (string, error)
}

type HubjectTestHttpTokenService

type HubjectTestHttpTokenService struct {
	// contains filtered or unexported fields
}

func NewHubjectTestHttpTokenService

func NewHubjectTestHttpTokenService(url string, httpClient *http.Client) *HubjectTestHttpTokenService

func (*HubjectTestHttpTokenService) GetToken

type HubjectTestTokenResponse

type HubjectTestTokenResponse struct {
	Title string `json:"title"`
	Data  string `json:"data"`
}

type ISOVersion

type ISOVersion string
const (
	ISO15118V2  ISOVersion = "ISO15118-2"
	ISO15118V20 ISOVersion = "ISO15118-20"
)

type LocalChargeStationCertificateProvider

type LocalChargeStationCertificateProvider struct {
	Store             store.CertificateStore
	CertificateReader LocalSource
	PrivateKeyReader  LocalSource
}

LocalChargeStationCertificateProvider issues CSO certificates using local data

func (*LocalChargeStationCertificateProvider) ProvideCertificate

func (l *LocalChargeStationCertificateProvider) ProvideCertificate(ctx context.Context, typ CertificateType, pemEncodedCSR string, csId string) (pemEncodedCertificateChain string, err error)

type LocalSource

type LocalSource interface {
	GetData(ctx context.Context) (string, error)
}

type OAuth2HttpTokenService

type OAuth2HttpTokenService struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewOAuth2HttpTokenService

func NewOAuth2HttpTokenService(url, clientId, clientSecret string, httpClient *http.Client, clk clock.PassiveClock) *OAuth2HttpTokenService

func (*OAuth2HttpTokenService) GetToken

func (o *OAuth2HttpTokenService) GetToken(ctx context.Context, refresh bool) (string, error)

type OAuth2TokenRequest

type OAuth2TokenRequest struct {
	GrantType    string `json:"grant_type"`
	ClientId     string `json:"client_id"`
	ClientSecret string `json:"client_secret"`
}

type OAuth2TokenResponse

type OAuth2TokenResponse struct {
	AccessToken string `json:"access_token"`
	ExpiresIn   int    `json:"expires_in"`
	TokenType   string `json:"token_type"`
}

type OCSPError

type OCSPError int

OCSPError is an error returned by the OCSP server in response to a check

func (OCSPError) Error

func (o OCSPError) Error() string

type OcppTokenAuthService

type OcppTokenAuthService struct {
	TokenStore store.TokenStore
	Clock      clock.PassiveClock
}

func (*OcppTokenAuthService) Authorize

type OnlineCertificateValidationService

type OnlineCertificateValidationService struct {
	RootCertificateProvider RootCertificateProviderService
	MaxOCSPAttempts         int
	HttpClient              *http.Client
}

func (*OnlineCertificateValidationService) ValidateHashedCertificateChain

func (o *OnlineCertificateValidationService) ValidateHashedCertificateChain(ctx context.Context, ocspRequestData []ocpp201.OCSPRequestDataType) (*string, error)

func (*OnlineCertificateValidationService) ValidatePEMCertificateChain

func (o *OnlineCertificateValidationService) ValidatePEMCertificateChain(ctx context.Context, pemChain []byte, eMAID string) (*string, error)

type OpcpChargeStationCertificateProvider

type OpcpChargeStationCertificateProvider struct {
	BaseURL          string
	HttpTokenService HttpTokenService
	ISOVersion       ISOVersion
	HttpClient       *http.Client
}

The OpcpChargeStationCertificateProvider issues certificates using the CPO CA

func (OpcpChargeStationCertificateProvider) ProvideCertificate

func (h OpcpChargeStationCertificateProvider) ProvideCertificate(ctx context.Context, typ CertificateType, pemEncodedCSR string, csId string) (string, error)

type OpcpContractCertificateProvider

type OpcpContractCertificateProvider struct {
	BaseURL          string
	HttpTokenService HttpTokenService
	HttpClient       *http.Client
}

func (OpcpContractCertificateProvider) ProvideCertificate

func (h OpcpContractCertificateProvider) ProvideCertificate(ctx context.Context, exiRequest string) (EvCertificate15118Response, error)

type OpcpRootCertificateCollectionType

type OpcpRootCertificateCollectionType struct {
	RootCertificates []OpcpRootCertificateType `json:"rootCertificates"`
}

type OpcpRootCertificateProviderService

type OpcpRootCertificateProviderService struct {
	BaseURL      string
	TokenService HttpTokenService
	HttpClient   *http.Client
}

func (OpcpRootCertificateProviderService) ProvideCertificates

func (s OpcpRootCertificateProviderService) ProvideCertificates(ctx context.Context) (certs []*x509.Certificate, err error)

type OpcpRootCertificateReturnType

type OpcpRootCertificateReturnType struct {
	RootCertificateCollection OpcpRootCertificateCollectionType `json:"RootCertificateCollection"`
}

type OpcpRootCertificateType

type OpcpRootCertificateType struct {
	RootCertificateId          string `json:"rootCertificateId"`
	DN                         string `json:"distinguishedName"`
	CACertificate              string `json:"caCertificate"`
	CommonName                 string `json:"commonName"`
	RootAuthorityKeyIdentifier string `json:"rootAuthorityKeyIdentifier"`
	RootIssuerSerialNumber     string `json:"rootIssuerSerialNumber"`
	ValidFrom                  string `json:"validFrom"`
	ValidTo                    string `json:"validTo"`
	OrganizationName           string `json:"organizationName"`
	CertificateRevocationList  string `json:"certificateRevocationList"`
	CrossCertificatePair       string `json:"crossCertificatePair"`
	LabeledURI                 string `json:"labeledUri"`
	RootType                   string `json:"rootType"`
	Fingerprint                string `json:"fingerprint"`
}

type RootCertificateProviderService

type RootCertificateProviderService interface {
	ProvideCertificates(ctx context.Context) ([]*x509.Certificate, error)
}

type SignedContractDataRequest

type SignedContractDataRequest struct {
	CertificateInstallationReq string `json:"certificateInstallationReq"`
	XsdMsgDefNamespace         string `json:"xsdMsgDefNamespace"`
}

type SignedContractDataResponse

type SignedContractDataResponse struct {
	CcpResponse        CcpResponse `json:"CCPResponse"`
	XsdMsgDefNamespace string      `json:"xsdMsgDefNamespace"`
}

type StringSource

type StringSource struct {
	Data string
}

func (StringSource) GetData

func (s StringSource) GetData(_ context.Context) (string, error)

type TariffService

type TariffService interface {
	CalculateCost(transaction *store.Transaction) (float64, error)
}

type TokenAuthService

type TokenAuthService interface {
	Authorize(ctx context.Context, token ocpp201.IdTokenType) ocpp201.IdTokenInfoType
}

type ValidationError

type ValidationError int
const (
	ValidationErrorCertChain ValidationError = iota
	ValidationErrorCertExpired
	ValidationErrorCertRevoked
	ValidationErrorWrongEmaid
)

func (ValidationError) Error

func (v ValidationError) Error() string

type X509RootCertificateProviderService

type X509RootCertificateProviderService struct {
	Certificates []*x509.Certificate
}

func (X509RootCertificateProviderService) ProvideCertificates

func (x X509RootCertificateProviderService) ProvideCertificates(ctx context.Context) ([]*x509.Certificate, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL