Table of Contents

Class UtilityValidator

Namespace
Geotab.Checkmate.ObjectModel
Assembly
Geotab.Checkmate.ObjectModel.dll

Stand alone validation routines.

public static class UtilityValidator
Inheritance
UtilityValidator
Inherited Members

Remarks

Documenting because I spent time trying to figure out why I was getting build errors and I don't want anyone else to have waste his/her time next time. The conditional compilation is required because in some configurations, objectModel.dll actually embeds files from this directory directly. Possibly so we can publish objectModel.dll without having to publish a matching utility.dll.

Fields

MaxDbNameLength

Value of 58 copied from WebMethods.GetValidatedDatabaseName for consistency. Postgres documentation says the limit is 63. Later consolidate all checks in one place. For now, just see what we need to do to pass security scanner validation.

public const int MaxDbNameLength = 58

Field Value

int

MaxServerNameLength

The length was arbitrarily chosen. If you modify it, then please document the reason for the new length.

public const int MaxServerNameLength = 200

Field Value

int

Methods

CreateDatabaseNameFromCompany(string)

Creates the database name from supplied company. Honours certain rules about naming databases *** almost the same as CreateSafeDatabaseName *** Some of the complex authentication code relies on certain exceptions being thrown. Throwing when the input is null or empty is the "wrong" exception. This function is here for legacy support, as the first changes are to support Veracode security scanning. Logic changes should be a different ticket.

public static string CreateDatabaseNameFromCompany(string original)

Parameters

original string

String used to create the database name. For example, it could be based on the name of the company.

Returns

string

Sanitized company name.

CreateSafeDatabaseName(string)

Creates a valid database name. Contiguous invalid characters sets are replaced with an underscore. Oddly, the tests that reference the database name are not in the same module. CheckmateServer.Tests/RegistrationTest.DatabaseNameFormattingTest CheckmateServer.Tests/MyFederationTest.CreateCompanyTest.

public static string CreateSafeDatabaseName(string original)

Parameters

original string

String used to create the database name. For example, it could be based on the name of the company.

Returns

string

Sanitized company name.

CreateSafeServerName(string)

Cleans the user supplied server name. A server name cannot: be null, empty or all blanks too long use any characters other than those white listed. A name can be entered with upper case characters, but we convert them to lower case.

public static string CreateSafeServerName(string original)

Parameters

original string

Name of the server to validate.

Returns

string

Cleaned database name.

IsAsciiString(string)

To check a string is ASCII or not.

public static bool IsAsciiString(string s)

Parameters

s string

String to check.

Returns

bool

A true or false

Remarks

Currently only used to check if the input serial number of Tachograph key is ASCII or not.