Class FinUtil

Namespace
Subsembly.FinTS
Assembly
Subsembly.FinTS.Core.dll

a collection of static utility methods that did not fit into any other class.

public static class FinUtil
Inheritance
FinUtil
Inherited Members

Properties

ApiVersion

Privides the version of the Subsembly FinTS API

public static Version ApiVersion { get; }

Property Value

Version

GermanEncoding

public static Encoding GermanEncoding { get; }

Property Value

Encoding

IsGermanTimeZone

Indicates whether the local time zone of this computer equals the German time zone.

public static bool IsGermanTimeZone { get; }

Property Value

bool

Now

Returns the current German Date and Time, regardless of the local timezone of this computer.

public static DateTime Now { get; }

Property Value

DateTime

Remarks

If the local timezone of this computer is the German time zone, then the DateTime.Kind property will be DateTimeKind.Local. If the local timezone of this computer is any other time zone, then the DateTime.Kind property will be DateTimeKind.Unspecified.

In FinTS date stamps there is no timezone indicator and the FinTS specification does not specify which time zone should be used for date stamps. Hence, we can only presume, that all date stamps are expected to use the current German time zone. To ensure appropriate date stamps, the date/time properties and methods of the FinUtil helper class should be used instead of the DateTime class.

Today

Returns the current German Date, regardless of the local timezone of this computer.

public static DateTime Today { get; }

Property Value

DateTime

Remarks

If the local timezone of this computer is the German time zone, then the DateTime.Kind property will be DateTimeKind.Local. If the local timezone of this computer is any other time zone, then the DateTime.Kind property will be DateTimeKind.Unspecified.

In FinTS date stamps there is no timezone indicator and the FinTS specification does not specify which time zone should be used for date stamps. Hence, we can only presume, that all date stamps are expected to use the current German time zone. To ensure appropriate date stamps, the date/time properties and methods of the FinUtil helper class should be used instead of the DateTime class.

Methods

CompareAcctNo(string, string)

Compares two account numbers.

public static int CompareAcctNo(string sAcctNo1, string sAcctNo2)

Parameters

sAcctNo1 string

First account number to compare.

sAcctNo2 string

Second account number to compare.

Returns

int

If both account numbers are logically equal, then zero is returned. The result is less than zero if the first account number preceedes the second account number, and greater than zero is the second account number preceedes the first.

Remarks

When comparing the account numbers any leading zeroes are ignores. The case of any characters in the account number is ignored.

CompareBytes(byte[], byte[])

Compares to byte arrays for equality.

public static bool CompareBytes(byte[] vb1, byte[] vb2)

Parameters

vb1 byte[]

First byte array or null.

vb2 byte[]

Second byte array or null.

Returns

bool

Returns true only if both array references are null, or both refences are the same, or both arrays have the same length and contain the same bytes.

ConvertToGermanTime(DateTime)

Attempts to convert a given DateTime to the same point in time at the German time zone.

public static DateTime ConvertToGermanTime(DateTime tDateTime)

Parameters

tDateTime DateTime

The DateTime value to be converted. If this DateTime is DateTime.MinValue or is of DateTimeKind Unspecified, then this method does nothing and just returns the given parameter. If the given DateTimeKind is Local and the TimeZoneInfo.Local is already the German time zone, then is also does nothing and just returns the parameter. In any other case a conversion is attempted.

Returns

DateTime

If the local time zone is the German time zone, then the returned DateTimeKind is Local. If the local time zone is different, then the returned DateTimeKind is Unspecified.

ConvertToUtc(DateTime)

Attempts to convert a given DateTime, which may be a time at the German time zone, into a UTC date time specification.

public static DateTime ConvertToUtc(DateTime tDateTime)

Parameters

tDateTime DateTime

The DateTime value to be converted. If this DateTime is DateTime.MinValue, then this method does nothing and just returns the given parameter. If the DateTime.Kind of this parameter is DateTimeKind.Unspecified, then it is assumed to be a German date time specification and is converted accordingly. If the DateTime.Kind of this parameter is DateTimeKind.Local, then it is converted from whatever local time zone this computer is in.

Returns

DateTime

CopyBytes(byte[], int, int)

Extracts a range of bytes from a byte array.

public static byte[] CopyBytes(byte[] vb, int nOffset, int nLength)

Parameters

vb byte[]

Source byte array from which to extract the byte range.

nOffset int

Offset where the byte range starts. This must not be negative, but may indicate an offset beyond the end of the source array.

nLength int

The number of bytes to extract. This must not be negative, but may indicate a length that exceeds the end of the source array.

Returns

byte[]

A new byte array that contains the byte range from the source byte array. If the parameter vb was null, then the return value is null, too. If the indicated byte range exceeds the end of the array, then only the actually available bytes are returned, which may produce an empty byte array.

DigitCount(string)

Returns the number of digits in a given string.

public static int DigitCount(string s)

Parameters

s string

The string to count the digits of. May be null.

Returns

int

If the parameter s is null, then zero is returned. In any other case, the count of digits is returned.

Remarks

This strange utility function is required to determine the challenge class in the even more strange Smart-TAN security procedure.

GetAuthenticateResultMessage(FinAuthenticateResult, FinSecurityMediaType)

Provides a descriptive message for an authentication result for the purpose of presenting the message to the user.

public static string GetAuthenticateResultMessage(FinAuthenticateResult nAuthRes, FinSecurityMediaType nMediaType)

Parameters

nAuthRes FinAuthenticateResult

The authentication result code.

nMediaType FinSecurityMediaType

The type of security media for which to generate the message. This must be either KeyFile, SmartCard, or Void

Returns

string

A German descriptive string is returned. If the given nAuthRes value indicates Success, then null is returned.

Remarks

For the security media type SmartCard the term "PIN" is used. For the security media type KeyFile the term "Password" is used.

GetCommErrorMessage(FinCommServiceException)

Translates a communication exception to a human readable string.

public static string GetCommErrorMessage(FinCommServiceException xCommService)

Parameters

xCommService FinCommServiceException

Returns

string

GetSecurityErrorMessage(FinSecurityException)

public static string GetSecurityErrorMessage(FinSecurityException xSecurity)

Parameters

xSecurity FinSecurityException

Returns

string

IsDigit(char)

public static bool IsDigit(char c)

Parameters

c char

Returns

bool

IsDigits(string)

Checks whether a string solely consists of digits.

public static bool IsDigits(string s)

Parameters

s string

The string to be checked.

Returns

bool

If the given string was null, then false is returned. If the given string was empty, then true is returned. If the string contains only digits, then true is returned, otherwise false is returned.

IsUpperAscii(char)

public static bool IsUpperAscii(char c)

Parameters

c char

Returns

bool

IsUpperAscii(string)

Checks whether a string solely consists of upper ASCII characters.

public static bool IsUpperAscii(string s)

Parameters

s string

The string to be checked.

Returns

bool

If the given string was null, then false is returned. If the given string was empty, then true is returned. If the string contains only upper ASCII characters in the range 'A' through 'Z', then true is returned, otherwise false is returned.

IsUpperOrDigit(char)

public static bool IsUpperOrDigit(char c)

Parameters

c char

Returns

bool

IsUpperOrDigits(string)

public static bool IsUpperOrDigits(string s)

Parameters

s string

Returns

bool

IsValidBankCode(string)

Checks whether the given string is a syntactically correct bank code.

public static bool IsValidBankCode(string sBankCode)

Parameters

sBankCode string

Returns

bool

Remarks

This check allows pseudo bank codes starting with '9', but it does not allow bank codes starting with '0'.

Trim(string)

Trims whitespace from a string.

public static string Trim(string s)

Parameters

s string

String to be trimmed. May be null.

Returns

string

If the parameter s was null, then null is returned, otherwise the trimmed string is returned. If the given string consists solely of whitespace, then an empty string will be returned.

TrimBankCode(string)

Trims leading, trailing and any internal white-space.

public static string TrimBankCode(string sBankCode)

Parameters

sBankCode string

The bank code to be trimmed. May be null.

Returns

string

If the parameter sBankCode was null, then null is returned, otherwise the trimmed string is returned. If the given string consists solely of whitespace, then an empty string will be returned.

Remarks

For example, if the bank code is given as "701 500 00 ", then the returned string will be "70150000". This method should be used whenever a bank code entered by the used is processed.

TryParseInt32(string, int)

Parses an Int32 from a String without throwing any exceptions.

public static int TryParseInt32(string s, int nDefault)

Parameters

s string

The string to be parsed. This may be null or otherwise invalid.

nDefault int

The default value that will be returned when the given string was null or could not be parsed for some other reason.

Returns

int

If parsing was successful, then the parsed Int32 value from the given string is returned. If the string could not be parsed, then the value of nDefault is returned.