Class EbicsUtil
Collection of static utility functions.
Inheritance
Inherited Members
Namespace: Subsembly.EBICS
Assembly: Subsembly.EBICS.Core.dll
Syntax
public static class EbicsUtil
Fields
DSigNamespaceURI
Declaration
public const string DSigNamespaceURI = "http://www.w3.org/2000/09/xmldsig#"
Field Value
Type | Description |
---|---|
System.String |
DSigSHA1URI
Declaration
public const string DSigSHA1URI = "http://www.w3.org/2000/09/xmldsig#sha1"
Field Value
Type | Description |
---|---|
System.String |
DSigSHA256URI
Declaration
public const string DSigSHA256URI = "http://www.w3.org/2001/04/xmlenc#sha256"
Field Value
Type | Description |
---|---|
System.String |
Properties
ApiVersion
Provides the version of the Subsembly EBICS API
Declaration
public static Version ApiVersion { get; }
Property Value
Type | Description |
---|---|
System.Version |
LatinEncoding
Declaration
public static Encoding LatinEncoding { get; }
Property Value
Type | Description |
---|---|
System.Text.Encoding |
UTF8Encoding
Declaration
public static Encoding UTF8Encoding { get; }
Property Value
Type | Description |
---|---|
System.Text.Encoding |
Methods
AppendElement(XmlElement, String, String, String)
Creates and appends a new child XML element.
Declaration
public static XmlElement AppendElement(XmlElement xmlParent, string sElementTag, string sElementNamespace, string sElementValue)
Parameters
Type | Name | Description |
---|---|---|
System.Xml.XmlElement | xmlParent | The parent XML element where a new child XML element shall be appended to. |
System.String | sElementTag | The local name of the new XML element to be created. |
System.String | sElementNamespace | The namespace name of the namespace that the local name of the XML element is defined in. |
System.String | sElementValue | The string value of the XML element to create. This will become the InnerText of
the new XML element. If this is |
Returns
Type | Description |
---|---|
System.Xml.XmlElement |
BuildReturnCodeMessage(EbicsReturnCode, EbicsReturnCode)
Builds a nice message from a technical and a business message.
Declaration
public static string BuildReturnCodeMessage(EbicsReturnCode aTechnicalReturnCode, EbicsReturnCode aBusinessReturnCode)
Parameters
Type | Name | Description |
---|---|---|
EbicsReturnCode | aTechnicalReturnCode | The technical return code to present in the message. May be |
EbicsReturnCode | aBusinessReturnCode | The business return code to present in the message. May be |
Returns
Type | Description |
---|---|
System.String | A nice message string suitable to be presented in a message box. Or |
Remarks
Builds a nice, human consumable message string from the given return codes. If
both parameters are null
, or hold an EBICS_OK return code, then no
message is generated and null
is returned instead.
BytesToXml(Byte[])
Declaration
public static XmlDocument BytesToXml(byte[] vb)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | vb |
Returns
Type | Description |
---|---|
System.Xml.XmlDocument |
CheckFingerprint(Boolean, EbicsPubKeyInfo, String)
Declaration
public static bool CheckFingerprint(bool fFromCertificate, EbicsPubKeyInfo aPubKey, string sFingerprint)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | fFromCertificate | |
EbicsPubKeyInfo | aPubKey | |
System.String | sFingerprint | String of hex digits and optional whitespace. Hex digits may be lower or upper case.
If this is an empty string, contained only whitespace, or is |
Returns
Type | Description |
---|---|
System.Boolean | If the given |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | The parameter |
DataToXml(EbicsDataBuffer)
Loads an XML document from a raw data buffer.
Declaration
public static XmlDocument DataToXml(EbicsDataBuffer d)
Parameters
Type | Name | Description |
---|---|---|
EbicsDataBuffer | d |
Returns
Type | Description |
---|---|
System.Xml.XmlDocument |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | The given parameter was |
System.Xml.XmlException | The raw data buffer does not contain a valid XML document. |
EvaluateOrderResult(EbicsOrder)
Evaluates order result and returns message text for it.
Declaration
public static string EvaluateOrderResult(EbicsOrder aOrder)
Parameters
Type | Name | Description |
---|---|---|
EbicsOrder | aOrder | The order that was executed. Must not be |
Returns
Type | Description |
---|---|
System.String | If the order failed, then an approrpiate, detailed error message text is returned.
If the order succeeded then |
FormatDate(DateTime)
Format the given date in ISO 8601 date representation.
Declaration
public static string FormatDate(DateTime tDate)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | tDate |
Returns
Type | Description |
---|---|
System.String | If the given date is DateTime.MinValue, then |
FormatFingerprint(EbicsContact, EbicsPubKeyInfo)
Creates a multi-line formatted fingerprint text for the printed Ini-Letter or UI.
Declaration
public static string FormatFingerprint(EbicsContact aContact, EbicsPubKeyInfo aPubKey)
Parameters
Type | Name | Description |
---|---|---|
EbicsContact | aContact | The EbicsContact for which to create the formatted fingerprint. |
EbicsPubKeyInfo | aPubKey |
Returns
Type | Description |
---|---|
System.String |
FormatFingerprint(EbicsContact, EbicsPubKeyInfo, EbicsFingerprintPart)
Creates a nicely formatted fingerprint for the printed Ini-Letter or UI.
Declaration
public static string FormatFingerprint(EbicsContact aContact, EbicsPubKeyInfo aPubKey, EbicsFingerprintPart nPart)
Parameters
Type | Name | Description |
---|---|---|
EbicsContact | aContact | The EbicsContact for which to create the formatted fingerprint. |
EbicsPubKeyInfo | aPubKey | |
EbicsFingerprintPart | nPart |
Returns
Type | Description |
---|---|
System.String |
FormatHex(Byte[], Int32)
Declaration
public static string FormatHex(byte[] vb, int nColumns)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | vb | |
System.Int32 | nColumns |
Returns
Type | Description |
---|---|
System.String |
FormatHex(Byte[], Int32, Int32, Int32)
Declaration
public static string FormatHex(byte[] vb, int nOffset, int nLength, int nColumns)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | vb | |
System.Int32 | nOffset | |
System.Int32 | nLength | |
System.Int32 | nColumns |
Returns
Type | Description |
---|---|
System.String |
FormatXml(XmlDocument)
Creates a nicely formatted string from the XML document.
Declaration
public static string FormatXml(XmlDocument xmlDocument)
Parameters
Type | Name | Description |
---|---|---|
System.Xml.XmlDocument | xmlDocument | The XML document to be formatted. This must not be null. |
Returns
Type | Description |
---|---|
System.String |
GetAllKnownHosts()
Returns an array of all known Host-IDs.
Declaration
public static string[] GetAllKnownHosts()
Returns
Type | Description |
---|---|
System.String[] |
GetAttribute(XmlElement, String)
Get an attribute from an XML element. This method does never return an empty
string, but will return null
if an attribute is not present.
Declaration
public static string GetAttribute(XmlElement xmlElement, string sAttributeName)
Parameters
Type | Name | Description |
---|---|---|
System.Xml.XmlElement | xmlElement | |
System.String | sAttributeName |
Returns
Type | Description |
---|---|
System.String |
GetElement(XmlElement, String, String, Boolean)
Gets the InnerText from a XML element.
Declaration
public static string GetElement(XmlElement xmlParent, string sElementTag, string sElementNamespace = null, bool fMandatory = false)
Parameters
Type | Name | Description |
---|---|---|
System.Xml.XmlElement | xmlParent | The parent XML element that contains the XML element to be retrieved. |
System.String | sElementTag | The local name of the XML element to be retrieved. |
System.String | sElementNamespace | The namespace name of the namespace that the local name of the XML element is defined in. |
System.Boolean | fMandatory |
Returns
Type | Description |
---|---|
System.String | If the requested XML element exists, then its InnerText is returned. If the
requested XML element does not exist, then |
GetKnownHostURL(String)
Looks up the URL for a given Host ID.
Declaration
public static string GetKnownHostURL(string sHostID)
Parameters
Type | Name | Description |
---|---|---|
System.String | sHostID | The Host ID for which to look up an URL. Must not be |
Returns
Type | Description |
---|---|
System.String | If the Host ID is known, then the URL of that host is returned. If the Host ID is
not known, then |
Remarks
This method is based on a very small hard coded list. Therefore, for most hosts it won't know the URL.
GetOrderTypeDescription(String)
Returns a descriptive text for a given EBICS order type.
Declaration
public static string GetOrderTypeDescription(string sOrderType)
Parameters
Type | Name | Description |
---|---|---|
System.String | sOrderType | The EBICS order type consists of three upper case letters. |
Returns
Type | Description |
---|---|
System.String | If the requested order type is known, then a short, descriptive text is returned.
If the order type is not known, then a replacement string including the
|
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | The parameter |
System.ArgumentException | The parameter |
IsAdminOrderType(String)
Returns true if the given order type is a known admistrative order type.
Declaration
public static bool IsAdminOrderType(string sOrderType)
Parameters
Type | Name | Description |
---|---|---|
System.String | sOrderType |
Returns
Type | Description |
---|---|
System.Boolean |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | The parameter |
System.ArgumentException | The given order type did not consist of exactly three upper case letters in the range from A-Z or digits. |
IsBIC(String)
Check whether a string is a syntactically valid BIC.
Declaration
public static bool IsBIC(string sBIC)
Parameters
Type | Name | Description |
---|---|---|
System.String | sBIC |
Returns
Type | Description |
---|---|
System.Boolean |
Remarks
This method does not do any semantic validation of the, it only performs some simple syntactical checks.
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 |
IsDigitsOrUpperAscii(String)
Checks whether a string solely consists of digits and upper ASCII characters.
Declaration
public static bool IsDigitsOrUpperAscii(string s)
Parameters
Type | Name | Description |
---|---|---|
System.String | s | The string to be checked. |
Returns
Type | Description |
---|---|
System.Boolean | If the given string was |
IsIBAN(String)
Check whether a string is a syntactically valid IBAN.
Declaration
public static bool IsIBAN(string sIBAN)
Parameters
Type | Name | Description |
---|---|---|
System.String | sIBAN |
Returns
Type | Description |
---|---|
System.Boolean |
Remarks
This method does not compute and check the check digits of the IBAN. It only performs some simple syntactical checks.
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 |
IsValidHostID(String)
Determines whether the given HostID is syntactically correct. It does not validate whether the HostID is a known HostID.
Declaration
public static bool IsValidHostID(string sHostID)
Parameters
Type | Name | Description |
---|---|---|
System.String | sHostID | A HostID or |
Returns
Type | Description |
---|---|
System.Boolean | If the HostID looks like a valid HostID, then |
IsValidHostURL(String)
Declaration
public static bool IsValidHostURL(string sHostURL)
Parameters
Type | Name | Description |
---|---|---|
System.String | sHostURL |
Returns
Type | Description |
---|---|
System.Boolean |
IsValidID(String)
Validates the ID of an EBICS party, i.e. a UserID, PartnerID or SystemID.
Declaration
public static bool IsValidID(string sID)
Parameters
Type | Name | Description |
---|---|---|
System.String | sID | The ID to validate. If this is |
Returns
Type | Description |
---|---|
System.Boolean | If the ID has a valid syntax, then |
Remarks
Older EBICS versions did only allow up to eight upper case characters and digits in IDs according to the pattern [A-Z0-9]{1,8}. Since EBICS 2.4 the allowed range was extended according to the pattern [a-zA-Z0-9,=]{1,35}. This method validates the ID according to the new pattern.
IsValidIDChar(Char)
A valid ID consists of up to 35 valid ID chars.
Declaration
public static bool IsValidIDChar(char ch)
Parameters
Type | Name | Description |
---|---|---|
System.Char | ch |
Returns
Type | Description |
---|---|
System.Boolean |
Remarks
Older EBICS versions did only allow up to eight upper case characters and digits in IDs according to the pattern [A-Z0-9]{1,8}. Since EBICS 2.4 the allowed range was extended according to the pattern [a-zA-Z0-9,=]{1,35}. This method validates the ID according to the new pattern.
IsValidOrderID(String)
Declaration
public static bool IsValidOrderID(string sOrderID)
Parameters
Type | Name | Description |
---|---|---|
System.String | sOrderID |
Returns
Type | Description |
---|---|
System.Boolean |
IsValidOrderType(String)
Declaration
public static bool IsValidOrderType(string sOrderType)
Parameters
Type | Name | Description |
---|---|---|
System.String | sOrderType |
Returns
Type | Description |
---|---|
System.Boolean | Returns |
NextSibling(XmlElement)
Get next XML sibling element with the same name.
Declaration
public static XmlElement NextSibling(XmlElement xmlElement)
Parameters
Type | Name | Description |
---|---|---|
System.Xml.XmlElement | xmlElement | The XML element from which to find the next sibling with the same name. This must
not be |
Returns
Type | Description |
---|---|
System.Xml.XmlElement | If another sibling XML element is found, then it is returned. If there is no
adjacent XML element sibling with the same name, then |
Remarks
This methods simplifies walking over a sequence of similar XML elements. While looking for the next XML element sibling it skips over all whitespace and comment nodes that may appear in between.
ParseDate(String)
Tries to parse a given ISO 8601 date representation.
Declaration
public static DateTime ParseDate(string sDate)
Parameters
Type | Name | Description |
---|---|---|
System.String | sDate | The date string to be parsed. Only the date portion of this string is parsed,
any time specification is ignored. If the parameter is |
Returns
Type | Description |
---|---|
System.DateTime |
SetAttribute(XmlElement, String, String)
Declaration
public static void SetAttribute(XmlElement xmlElement, string sAttributeName, string sAttributeValue)
Parameters
Type | Name | Description |
---|---|---|
System.Xml.XmlElement | xmlElement | |
System.String | sAttributeName | |
System.String | sAttributeValue |
Squeeze(String)
Removes all the whitespaces in the specified string and returns the cleaned string.
Declaration
public static string Squeeze(string s)
Parameters
Type | Name | Description |
---|---|---|
System.String | s |
Returns
Type | Description |
---|---|
System.String | If the parameter was |
StreamToXml(Stream)
Declaration
public static XmlDocument StreamToXml(Stream aStream)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | aStream | Stream to read XML document from. This stream will not be closed. |
Returns
Type | Description |
---|---|
System.Xml.XmlDocument |
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 |
See Also
Trim(String, Int32)
Trims whitespace from a string.
Declaration
public static string Trim(string s, int nMaxLength)
Parameters
Type | Name | Description |
---|---|---|
System.String | s | String to be trimmed. May be |
System.Int32 | nMaxLength | The max length of the trimmed string to be returned. If the string is longer than this max length, then it is truncated at the max length. |
Returns
Type | Description |
---|---|
System.String |
XmlToBytes(XmlDocument)
Declaration
public static byte[] XmlToBytes(XmlDocument xmlDocument)
Parameters
Type | Name | Description |
---|---|---|
System.Xml.XmlDocument | xmlDocument |
Returns
Type | Description |
---|---|
System.Byte[] |
XmlToData(XmlDocument)
Serializes an XML document into a raw data buffer.
Declaration
public static EbicsDataBuffer XmlToData(XmlDocument xmlDocument)
Parameters
Type | Name | Description |
---|---|---|
System.Xml.XmlDocument | xmlDocument |
Returns
Type | Description |
---|---|
EbicsDataBuffer |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | The given parameter was |
XmlToStream(XmlDocument, Stream)
Serializes an XML document into the given byte stream.
Declaration
public static void XmlToStream(XmlDocument xmlDocument, Stream aStream)
Parameters
Type | Name | Description |
---|---|---|
System.Xml.XmlDocument | xmlDocument | |
System.IO.Stream | aStream | The stream to write the XML document to. This stream will not be closed! |
Remarks
The document will be written using UTF-8 encoding and will not have a byte order mark.