Class FinUtil
a collection of static utility methods that did not fit into any other class.
Inheritance
Inherited Members
Namespace: Subsembly.FinTS
Assembly: Subsembly.FinTS.Core.dll
Syntax
public static class FinUtil
Properties
ApiVersion
Privides the version of the Subsembly FinTS API
Declaration
public static Version ApiVersion { get; }
Property Value
Type | Description |
---|---|
System.Version |
GermanEncoding
Declaration
public static Encoding GermanEncoding { get; }
Property Value
Type | Description |
---|---|
System.Text.Encoding |
Now
Returns the current German Date and Time, regardless of the local timezone of this computer.
Declaration
public static DateTime Now { get; }
Property Value
Type | Description |
---|---|
System.DateTime |
Remarks
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.
Declaration
public static DateTime Today { get; }
Property Value
Type | Description |
---|---|
System.DateTime |
Remarks
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.
Declaration
public static int CompareAcctNo(string sAcctNo1, string sAcctNo2)
Parameters
Type | Name | Description |
---|---|---|
System.String | sAcctNo1 | First account number to compare. |
System.String | sAcctNo2 | Second account number to compare. |
Returns
Type | Description |
---|---|
System.Int32 | 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.
Declaration
public static bool CompareBytes(byte[] vb1, byte[] vb2)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | vb1 | First byte array or |
System.Byte[] | vb2 | Second byte array or |
Returns
Type | Description |
---|---|
System.Boolean | Returns |
ConvertToGermanTime(DateTime)
Attempts to convert a given DateTime to the same point in time at the German time zone.
Declaration
public static DateTime ConvertToGermanTime(DateTime tDateTime)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | tDateTime | 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
Type | Description |
---|---|
System.DateTime |
CopyBytes(Byte[], Int32, Int32)
Extracts a range of bytes from a byte array.
Declaration
public static byte[] CopyBytes(byte[] vb, int nOffset, int nLength)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | vb | Source byte array from which to extract the byte range. |
System.Int32 | nOffset | Offset where the byte range starts. This must not be negative, but may indicate an offset beyond the end of the source array. |
System.Int32 | nLength | 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
Type | Description |
---|---|
System.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.
Declaration
public static int DigitCount(string s)
Parameters
Type | Name | Description |
---|---|---|
System.String | s | The string to count the digits of. May be |
Returns
Type | Description |
---|---|
System.Int32 | If the parameter s is |
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.
Declaration
public static string GetAuthenticateResultMessage(FinAuthenticateResult nAuthRes, FinSecurityMediaType nMediaType)
Parameters
Type | Name | Description |
---|---|---|
FinAuthenticateResult | nAuthRes | The authentication result code. |
FinSecurityMediaType | nMediaType | The type of security media for which to generate the message. This must be either KeyFile, SmartCard, or Void |
Returns
Type | Description |
---|---|
System.String | A German descriptive string is returned. If the given nAuthRes value indicates
Success, then |
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.
Declaration
public static string GetCommErrorMessage(FinCommServiceException xCommService)
Parameters
Type | Name | Description |
---|---|---|
FinCommServiceException | xCommService |
Returns
Type | Description |
---|---|
System.String |
GetSecurityErrorMessage(FinSecurityException)
Declaration
public static string GetSecurityErrorMessage(FinSecurityException xSecurity)
Parameters
Type | Name | Description |
---|---|---|
FinSecurityException | xSecurity |
Returns
Type | Description |
---|---|
System.String |
IsDigit(Char)
Declaration
public static bool IsDigit(char c)
Parameters
Type | Name | Description |
---|---|---|
System.Char | c |
Returns
Type | Description |
---|---|
System.Boolean |
IsDigits(String)
Checks whether a string solely consists of digits.
Declaration
public static bool IsDigits(string s)
Parameters
Type | Name | Description |
---|---|---|
System.String | s | The string to be checked. |
Returns
Type | Description |
---|---|
System.Boolean | If the given string was |
IsUpperAscii(Char)
Declaration
public static bool IsUpperAscii(char c)
Parameters
Type | Name | Description |
---|---|---|
System.Char | c |
Returns
Type | Description |
---|---|
System.Boolean |
IsUpperAscii(String)
Checks whether a string solely consists of upper ASCII characters.
Declaration
public static bool IsUpperAscii(string s)
Parameters
Type | Name | Description |
---|---|---|
System.String | s | The string to be checked. |
Returns
Type | Description |
---|---|
System.Boolean | If the given string was |
IsUpperOrDigit(Char)
Declaration
public static bool IsUpperOrDigit(char c)
Parameters
Type | Name | Description |
---|---|---|
System.Char | c |
Returns
Type | Description |
---|---|
System.Boolean |
IsUpperOrDigits(String)
Declaration
public static bool IsUpperOrDigits(string s)
Parameters
Type | Name | Description |
---|---|---|
System.String | s |
Returns
Type | Description |
---|---|
System.Boolean |
IsValidBankCode(String)
Checks whether the given string is a syntactically correct bank code.
Declaration
public static bool IsValidBankCode(string sBankCode)
Parameters
Type | Name | Description |
---|---|---|
System.String | sBankCode |
Returns
Type | Description |
---|---|
System.Boolean |
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.
Declaration
public static string Trim(string s)
Parameters
Type | Name | Description |
---|---|---|
System.String | s | String to be trimmed. May be |
Returns
Type | Description |
---|---|
System.String | If the parameter s was |
TrimBankCode(String)
Trims leading, trailing and any internal white-space.
Declaration
public static string TrimBankCode(string sBankCode)
Parameters
Type | Name | Description |
---|---|---|
System.String | sBankCode | The bank code to be trimmed. May be |
Returns
Type | Description |
---|---|
System.String | If the parameter sBankCode was |
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, Int32)
Parses an Int32 from a String without throwing any exceptions.
Declaration
public static int TryParseInt32(string s, int nDefault)
Parameters
Type | Name | Description |
---|---|---|
System.String | s | The string to be parsed. This may be |
System.Int32 | nDefault | The default value that will be returned when the given string was |
Returns
Type | Description |
---|---|
System.Int32 | 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. |