Skip to content

Commit

Permalink
Feature/new cxml model (#611)
Browse files Browse the repository at this point in the history
* Added new Cxml model

* Added and updated models for OCI.

* Fixed deserialization errors.

* Fixed bug that cookie was immediately deleted after logging in with a session cookie. This was already fixed in the JCL the same way, but we never copied that fix to the GCL until now.

* Fixed attribute formatting.

* Removed unneeded empty line.

* Added namespace to all lang properties.

---------

Co-authored-by: Alex van den Berg <[email protected]>
  • Loading branch information
GilianJuice and alexxxx1992 authored Aug 7, 2024
1 parent d374602 commit 5e073df
Show file tree
Hide file tree
Showing 45 changed files with 670 additions and 4 deletions.
4 changes: 2 additions & 2 deletions GeeksCoreLibrary/Components/Account/Account.cs
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ public async Task<string> HandleLoginModeAsync()

if (Settings.EnableOciLogin && !String.IsNullOrWhiteSpace(ociHookUrl))
{
HttpContextHelpers.WriteCookie(httpContext, Constants.OciHookUrlCookieName, ociHookUrl);
HttpContextHelpers.WriteCookie(httpContext, Constants.OciHookUrlCookieName, ociHookUrl, isEssential: true);
}

if (Settings.EnableOciLogin && !String.IsNullOrWhiteSpace(ociUsername) && !String.IsNullOrWhiteSpace(ociPassword))
Expand Down Expand Up @@ -1909,7 +1909,7 @@ private async Task SaveGoogleClientIdAsync(ulong userIdForGoogleCid)
var googleClientId = String.Join(".", clientIdSplit.Skip(2));

var tablePrefix = await wiserItemsService.GetTablePrefixForEntityAsync(Settings.EntityType);

var detail = new WiserItemDetailModel()
{
Key = String.IsNullOrWhiteSpace(Settings.GoogleClientIdFieldName) ? Constants.DefaultGoogleCidFieldName : Settings.GoogleClientIdFieldName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public async Task<UserCookieDataModel> GetUserDataFromCookieAsync(string cookieN

databaseConnection.AddParameter("selector", cookieValueParts[0]);
databaseConnection.AddParameter("entityType", cookieValueParts[2]);

// Writing connection is used because sometimes the sync to a read database is not instant and then the cookie cannot be found immediately after creating it.
var result = await databaseConnection.GetAsync(query, true, useWritingConnectionIfAvailable: true);

Expand Down Expand Up @@ -264,7 +264,7 @@ public async Task<string> GenerateNewCookieTokenAsync(ulong userId, ulong mainUs
databaseConnection.AddParameter("main_user_entity_type", mainUserEntityType);
databaseConnection.AddParameter("ip_address", HttpContextHelpers.GetUserIpAddress(httpContextAccessor?.HttpContext));
databaseConnection.AddParameter("user_agent", HttpContextHelpers.GetHeaderValueAs<string>(httpContextAccessor?.HttpContext, HeaderNames.UserAgent));
databaseConnection.AddParameter("expires", DateTime.Now.AddDays(amountOfDaysToRememberCookie));
databaseConnection.AddParameter("expires", DateTime.Now.AddDays(amountOfDaysToRememberCookie <= 0 ? 1 : amountOfDaysToRememberCookie));
databaseConnection.AddParameter("login_date", DateTime.Now);
databaseConnection.AddParameter("role", role);
await databaseConnection.InsertOrUpdateRecordBasedOnParametersAsync(Constants.AuthenticationTokensTableName, 0UL);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System.Xml.Serialization;

namespace GeeksCoreLibrary.Modules.OpenCatalogInterface.Models;

[XmlRoot(ElementName = "Accounting")]
public class AccountingModel
{
[XmlElement(ElementName = "Segment")]
public SegmentModel Segment { get; set; }

[XmlAttribute(AttributeName = "name")]
public string Name { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System.Xml.Serialization;

namespace GeeksCoreLibrary.Modules.OpenCatalogInterface.Models;

[XmlRoot(ElementName = "Address")]
public class AddressModel
{
[XmlElement(ElementName = "Name")]
public NameModel Name { get; set; }

[XmlElement(ElementName = "PostalAddress")]
public PostalAddressModel PostalAddress { get; set; }

[XmlElement(ElementName = "Email")]
public string Email { get; set; }

[XmlElement(ElementName = "Phone")]
public PhoneModel Phone { get; set; }

[XmlAttribute(AttributeName = "isoCountryCode")]
public string IsoCountryCode { get; set; }

[XmlAttribute(AttributeName = "addressID")]
public string AddressId { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System.Xml.Serialization;

namespace GeeksCoreLibrary.Modules.OpenCatalogInterface.Models;

[XmlRoot(ElementName="BillTo")]
public class BillToModel
{
[XmlElement(ElementName="Address")]
public AddressModel Address { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System.Xml.Serialization;

namespace GeeksCoreLibrary.Modules.OpenCatalogInterface.Models;

[XmlRoot(ElementName="Charge")]
public class ChargeModel
{
[XmlElement(ElementName="Money")]
public MoneyModel Money { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System.Xml.Serialization;

namespace GeeksCoreLibrary.Modules.OpenCatalogInterface.Models;

[XmlRoot(ElementName = "Classification")]
public class ClassificationModel
{
[XmlAttribute(AttributeName = "domain")]
public string Domain { get; set; }
}
10 changes: 10 additions & 0 deletions GeeksCoreLibrary/Modules/OpenCatalogInterface/Models/Comments.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System.Xml.Serialization;

namespace GeeksCoreLibrary.Modules.OpenCatalogInterface.Models;

[XmlRoot(ElementName = "Comments")]
public class Comments
{
[XmlAttribute(AttributeName = "lang", Namespace = "http://www.w3.org/XML/1998/namespace")]
public string Lang { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.Xml.Serialization;

namespace GeeksCoreLibrary.Modules.OpenCatalogInterface.Models;

[XmlRoot(ElementName = "Contact")]
public class ContactModel
{
[XmlElement(ElementName = "Name")]
public NameModel Name { get; set; }

[XmlElement(ElementName = "Email")]
public string Email { get; set; }

[XmlElement(ElementName = "Phone")]
public PhoneModel Phone { get; set; }

[XmlAttribute(AttributeName = "role")]
public string Role { get; set; }

[XmlText]
public string Text { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System.Xml.Serialization;

namespace GeeksCoreLibrary.Modules.OpenCatalogInterface.Models;

[XmlRoot(ElementName = "CountryCode")]
public class CountryCodeModel
{
[XmlAttribute(AttributeName = "isoCountryCode")]
public string IsoCountryCode { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System.Xml.Serialization;

namespace GeeksCoreLibrary.Modules.OpenCatalogInterface.Models;

[XmlRoot(ElementName = "Country")]
public class CountryModel
{
[XmlAttribute(AttributeName = "isoCountryCode")]
public string IsoCountryCode { get; set; }

[XmlText]
public string Value { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System.Xml.Serialization;

namespace GeeksCoreLibrary.Modules.OpenCatalogInterface.Models;

[XmlRoot(ElementName = "Credential")]
public class CredentialModel
{
[XmlElement(ElementName = "Identity")]
public string Identity { get; set; }

[XmlAttribute(AttributeName = "domain")]
public string Domain { get; set; }

[XmlElement(ElementName = "SharedSecret")]
public string SharedSecret { get; set; }
}
25 changes: 25 additions & 0 deletions GeeksCoreLibrary/Modules/OpenCatalogInterface/Models/CxmlModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System.Xml.Serialization;

namespace GeeksCoreLibrary.Modules.OpenCatalogInterface.Models;

[XmlRoot(ElementName = "cXML")]
public class CxmlModel
{
[XmlAttribute(AttributeName = "version")]
public string Version { get; set; }

[XmlAttribute(AttributeName = "payloadID")]
public string PayloadId { get; set; }

[XmlAttribute(AttributeName = "timestamp")]
public string Timestamp { get; set; }

[XmlAttribute(AttributeName = "lang", Namespace = "http://www.w3.org/XML/1998/namespace")]
public string Lang { get; set; }

[XmlElement(ElementName = "Header")]
public HeaderModel Header { get; set; }

[XmlElement(ElementName = "Request")]
public RequestModel Request { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System.Xml.Serialization;

namespace GeeksCoreLibrary.Modules.OpenCatalogInterface.Models;

[XmlRoot(ElementName = "Response")]
public class CxmlPunchOutResponseModel
{
[XmlElement(ElementName = "Status")]
public CxmlPunchOutStatusModel Status { get; set; } = new();

[XmlElement(ElementName = "PunchOutSetupResponse")]
public PunchOutSetupResponseModel PunchOutSetupResponse { get; set; } = new();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.Xml.Serialization;

namespace GeeksCoreLibrary.Modules.OpenCatalogInterface.Models;

[XmlRoot(ElementName = "cXML")]
public class CxmlPunchOutSetupResponseModel
{
[XmlElement(ElementName = "Response")]
public CxmlPunchOutResponseModel Response { get; set; } = new();

[XmlAttribute(AttributeName = "version")]
public string Version { get; set; }

[XmlAttribute(AttributeName = "lang", Namespace = "http://www.w3.org/XML/1998/namespace")]
public string Lang { get; set; }

[XmlAttribute(AttributeName = "payloadID")]
public string PayloadId { get; set; }

[XmlAttribute(AttributeName = "timestamp")]
public string Timestamp { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System.Xml.Serialization;

namespace GeeksCoreLibrary.Modules.OpenCatalogInterface.Models;

[XmlRoot(ElementName = "StartPage")]
public class CxmlPunchOutStartPageModel
{
[XmlElement(ElementName = "URL")]
public string Url { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System.Xml.Serialization;

namespace GeeksCoreLibrary.Modules.OpenCatalogInterface.Models;

[XmlRoot(ElementName = "Status")]
public class CxmlPunchOutStatusModel
{
[XmlAttribute(AttributeName = "code")]
public string Code { get; set; }

[XmlAttribute(AttributeName = "text")]
public string Text { get; set; }

[XmlText]
public string InnerText { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System.Xml.Serialization;

namespace GeeksCoreLibrary.Modules.OpenCatalogInterface.Models;

[XmlRoot(ElementName = "Description")]
public class DescriptionModel
{
[XmlAttribute(AttributeName = "lang", Namespace = "http://www.w3.org/XML/1998/namespace")]
public string Lang { get; set; }

[XmlText]
public string Value { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System.Xml.Serialization;

namespace GeeksCoreLibrary.Modules.OpenCatalogInterface.Models;

[XmlRoot(ElementName="Distribution")]
public class DistributionModel
{
[XmlElement(ElementName="Accounting")]
public AccountingModel Accounting { get; set; }

[XmlElement(ElementName="Charge")]
public ChargeModel Charge { get; set; }
}
13 changes: 13 additions & 0 deletions GeeksCoreLibrary/Modules/OpenCatalogInterface/Models/EmailModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System.Xml.Serialization;

namespace GeeksCoreLibrary.Modules.OpenCatalogInterface.Models;

[XmlRoot(ElementName = "Email")]
public class EmailModel
{
[XmlAttribute(AttributeName = "name")]
public string Name { get; set; }

[XmlText]
public string Value { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System.Xml.Serialization;

namespace GeeksCoreLibrary.Modules.OpenCatalogInterface.Models;

[XmlRoot(ElementName = "Extrinsic")]
public class ExtrinsicModel
{
[XmlAttribute(AttributeName = "name")]
public string Name { get; set; }

[XmlText]
public string Value { get; set; }
}
10 changes: 10 additions & 0 deletions GeeksCoreLibrary/Modules/OpenCatalogInterface/Models/FromModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System.Xml.Serialization;

namespace GeeksCoreLibrary.Modules.OpenCatalogInterface.Models;

[XmlRoot(ElementName="From")]
public class FromModel
{
[XmlElement(ElementName="Credential")]
public CredentialModel Credential { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System.Xml.Serialization;

namespace GeeksCoreLibrary.Modules.OpenCatalogInterface.Models;

[XmlRoot(ElementName="Header")]
public class HeaderModel
{
[XmlElement(ElementName="From")]
public FromModel From { get; set; }

[XmlElement(ElementName="To")]
public ToModel To { get; set; }

[XmlElement(ElementName="Sender")]
public SenderModel Sender { get; set; }
}
Loading

0 comments on commit 5e073df

Please sign in to comment.