init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
162
Kreta.EESZTInterface/eFT/CreateSoap.cs
Normal file
162
Kreta.EESZTInterface/eFT/CreateSoap.cs
Normal file
|
@ -0,0 +1,162 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using System.Xml.Serialization;
|
||||
using Kreta.EESZTInterface.eFT.Model;
|
||||
using Kreta.EESZTInterface.eFT.Model.AllomanyResz.Request;
|
||||
using Kreta.EESZTInterface.eFT.Model.IntezmenyiAllomanyLista.Request;
|
||||
using Kreta.EESZTInterface.eFT.Model.SikeresCimzettAllomanyLetoltes.Request;
|
||||
using Kreta.EESZTInterface.STS;
|
||||
|
||||
namespace Kreta.EESZTInterface.eFT
|
||||
{
|
||||
public class CreateSoap
|
||||
{
|
||||
private static string CreateSoapRequest<T>(string samlContent, T bo)
|
||||
{
|
||||
string idTs = "TS-" + Guid.NewGuid().ToString().Replace("-", "");
|
||||
|
||||
var xDoc = new XmlDocument();
|
||||
|
||||
XmlElement root = xDoc.CreateElement("soap", "Envelope", Namespaces.soap11Ns);
|
||||
root.SetAttribute("xmlns:v1", Namespaces.allomanyPublikaloServiceV1Ns);
|
||||
xDoc.AppendChild(root);
|
||||
|
||||
XmlElement head = xDoc.CreateElement("soap", "Header", Namespaces.soap11Ns);
|
||||
root.AppendChild(head);
|
||||
|
||||
XmlElement sec = xDoc.CreateElement("wsse", "Security", Namespaces.wsseNs);
|
||||
sec.SetAttribute("xmlns:wsu", Namespaces.wsuNs);
|
||||
sec.SetAttribute("soap:mustUnderstand", "1");
|
||||
head.AppendChild(sec);
|
||||
|
||||
XmlElement timestamp = xDoc.CreateElement("wsu", "Timestamp", Namespaces.wsuNs);
|
||||
timestamp.SetAttribute("Id", Namespaces.wsuNs, idTs);
|
||||
sec.AppendChild(timestamp);
|
||||
|
||||
XmlElement created = xDoc.CreateElement("wsu", "Created", Namespaces.wsuNs);
|
||||
var now = DateTime.Now;
|
||||
created.InnerText = now.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ");
|
||||
timestamp.AppendChild(created);
|
||||
XmlElement expires = xDoc.CreateElement("wsu", "Expires", Namespaces.wsuNs);
|
||||
expires.InnerText = now.ToUniversalTime().AddMinutes(5).ToString("yyyy-MM-ddTHH:mm:ssZ");
|
||||
timestamp.AppendChild(expires);
|
||||
|
||||
sec.InnerXml += "{saml}";
|
||||
|
||||
XmlElement body = xDoc.CreateElement("soap", "Body", Namespaces.soap11Ns);
|
||||
|
||||
var ns = new XmlSerializerNamespaces();
|
||||
ns.Add("v1", Namespaces.allomanyPublikaloServiceV1Ns);
|
||||
var serializer = new XmlSerializer(typeof(T));
|
||||
var sb = new StringBuilder();
|
||||
var writer = new StringWriter(sb);
|
||||
serializer.Serialize(writer, bo, ns);
|
||||
writer.Close();
|
||||
|
||||
XmlDocument b = new XmlDocument();
|
||||
b.LoadXml(sb.Replace(typeof(T).Name, $"v1:{typeof(T).Name}").ToString());
|
||||
|
||||
XmlElement boXml = (XmlElement)xDoc.ImportNode(b.DocumentElement, true);
|
||||
boXml.Attributes.RemoveNamedItem("xmlns:v1");
|
||||
body.AppendChild(boXml);
|
||||
|
||||
xDoc.DocumentElement.AppendChild(body);
|
||||
|
||||
return xDoc.DocumentElement.OuterXml.Replace("{saml}", samlContent);
|
||||
}
|
||||
|
||||
public static string CreateGetIntezmenyiAllomanyLista(string samlContent, GetIntezmenyiAllomanyLista bo)
|
||||
{
|
||||
return CreateSoapRequest(samlContent, bo);
|
||||
}
|
||||
|
||||
public static string CreateGetAllomanyresz(string samlContent, GetAllomanyResz bo)
|
||||
{
|
||||
return CreateSoapRequest(samlContent, bo);
|
||||
}
|
||||
|
||||
public static string CreateSikeresLetoltes(string samlContent, SikeresCimzettAllomanyLetoltes bo)
|
||||
{
|
||||
return CreateSoapRequest(samlContent, bo);
|
||||
}
|
||||
|
||||
private static BusinessMessageHeader GetBusinessMessageHeader(SamlAssertion samlAssertion, string clientUserId, string organizationId)
|
||||
{
|
||||
var applicationVersion = "1.0";
|
||||
var applicationName = "eKreta";
|
||||
return new BusinessMessageHeader
|
||||
{
|
||||
Initiator = new Initiator
|
||||
{
|
||||
UserId = samlAssertion.UserId,
|
||||
UserName = samlAssertion.UserName,
|
||||
ClientUserId = clientUserId,
|
||||
ApplicationName = applicationName,
|
||||
ApplicationId = $"{applicationName}:{applicationVersion}",
|
||||
ApplicationFunction = "teszt",
|
||||
OrganizationId = organizationId,
|
||||
},
|
||||
RepresentedUser = new RepresentedUser
|
||||
{
|
||||
ClientUserId = clientUserId,
|
||||
UserId = samlAssertion.UserId,
|
||||
UserName = samlAssertion.UserName,
|
||||
},
|
||||
Logging = new Logging
|
||||
{
|
||||
SubmittedAt = DateTime.Now,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static GetIntezmenyiAllomanyLista GetIntezmenyiAllomanyListaBusinessObject(SamlAssertion samlAssertion, string clientUserId, string organizationId)
|
||||
{
|
||||
return new GetIntezmenyiAllomanyLista
|
||||
{
|
||||
IntezmenyiAllomanyListaRequest = new IntezmenyiAllomanyListaRequest
|
||||
{
|
||||
BusinessMessageHeader = GetBusinessMessageHeader(samlAssertion, clientUserId, organizationId),
|
||||
IntezmenyiAllomanyListaRequestBusinessContent = new IntezmenyiAllomanyListaRequestBusinessContent
|
||||
{
|
||||
CimzettId = organizationId,
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static GetAllomanyResz GetAllomanyReszBusinessObject(SamlAssertion samlAssertion, string clientUserId, string organizationId, Guid publikusId, int sorszam)
|
||||
{
|
||||
return new GetAllomanyResz
|
||||
{
|
||||
AllomanyReszRequest = new AllomanyReszRequest
|
||||
{
|
||||
BusinessMessageHeader = GetBusinessMessageHeader(samlAssertion, clientUserId, organizationId),
|
||||
AllomanyReszRequestBusinessContent = new AllomanyReszRequestBusinessContent
|
||||
{
|
||||
AllomanyPublikusId = publikusId,
|
||||
AllomanyReszSorszam = sorszam,
|
||||
CimzettId = organizationId,
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static SikeresCimzettAllomanyLetoltes GetSikeresCimzettAllomanyLetoltesBO(SamlAssertion samlAssertion, string clientUserId, string organizationId, Guid publikusId)
|
||||
{
|
||||
return new SikeresCimzettAllomanyLetoltes
|
||||
{
|
||||
SikeresAllomanyLetoltesRequest = new SikeresAllomanyLetoltesRequest
|
||||
{
|
||||
BusinessMessageHeader = GetBusinessMessageHeader(samlAssertion, clientUserId, organizationId),
|
||||
SikeresAllomanyLetoltesRequestBusinessContent = new SikeresAllomanyLetoltesRequestBusinessContent
|
||||
{
|
||||
AllomanyPublikusId = publikusId,
|
||||
CimzettId = organizationId,
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue