mirror of
https://github.com/esiur/esiur-dotnet.git
synced 2026-04-04 12:28:21 +00:00
Layout
This commit is contained in:
64
Libraries/Esiur/Security/Authority/Authentication.cs
Normal file
64
Libraries/Esiur/Security/Authority/Authentication.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
|
||||
Copyright (c) 2017 Ahmed Kh. Zamil
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Esiur.Security.Authority;
|
||||
|
||||
public class Authentication
|
||||
{
|
||||
AuthenticationMode type;
|
||||
|
||||
public AuthenticationMethod Method { get; set; }
|
||||
|
||||
public ulong TokenIndex { get; set; }
|
||||
|
||||
public string Username { get; set; }
|
||||
public Certificate Certificate { get; set; }
|
||||
public string Domain { get; set; }
|
||||
|
||||
public string FullName => Username + "@" + Domain;
|
||||
|
||||
public Source Source { get; } = new Source();
|
||||
|
||||
public AuthenticationState State
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public AuthenticationMode Type
|
||||
{
|
||||
get => type;
|
||||
}
|
||||
|
||||
public Authentication(AuthenticationMode type)
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
18
Libraries/Esiur/Security/Authority/AuthenticationMethod.cs
Normal file
18
Libraries/Esiur/Security/Authority/AuthenticationMethod.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Esiur.Security.Authority;
|
||||
|
||||
public enum AuthenticationMethod : byte
|
||||
{
|
||||
None,
|
||||
PpapCredentialsAnonymous,
|
||||
PpapCredentialsCredentials,
|
||||
PpapCredentialsHec,
|
||||
PpapHecAnonymous,
|
||||
PpapHecCredentials,
|
||||
PpapHecHec,
|
||||
HashAnonymous,
|
||||
|
||||
}
|
||||
39
Libraries/Esiur/Security/Authority/AuthenticationMode.cs
Normal file
39
Libraries/Esiur/Security/Authority/AuthenticationMode.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
|
||||
Copyright (c) 2017 Ahmed Kh. Zamil
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Esiur.Security.Authority;
|
||||
|
||||
public enum AuthenticationMode:byte
|
||||
{
|
||||
None = 0x0,
|
||||
InitializerIdentity = 0x1,
|
||||
ResponderIdentity = 0x2,
|
||||
DualIdentity = 0x3,
|
||||
}
|
||||
28
Libraries/Esiur/Security/Authority/AuthenticationResult.cs
Normal file
28
Libraries/Esiur/Security/Authority/AuthenticationResult.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using Esiur.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Esiur.Security.Authority
|
||||
{
|
||||
public class AuthenticationResult
|
||||
{
|
||||
public AuthenticationRuling Ruling { get; internal set; }
|
||||
public string Identity { get; internal set; }
|
||||
|
||||
public object HandshakePayload { get; internal set; }
|
||||
|
||||
public byte[] SessionKey { get; internal set; }
|
||||
|
||||
public ExceptionCode? ExceptionCode { get; internal set; }
|
||||
public string ExceptionMessage { get; internal set; }
|
||||
|
||||
public AuthenticationResult(AuthenticationRuling ruling, string identity, object handshakePayload, byte[] sessionKey)
|
||||
{
|
||||
Ruling = ruling;
|
||||
Identity = identity;
|
||||
HandshakePayload = handshakePayload;
|
||||
SessionKey = sessionKey;
|
||||
}
|
||||
}
|
||||
}
|
||||
13
Libraries/Esiur/Security/Authority/AuthenticationRuling.cs
Normal file
13
Libraries/Esiur/Security/Authority/AuthenticationRuling.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Esiur.Security.Authority
|
||||
{
|
||||
public enum AuthenticationRuling
|
||||
{
|
||||
Failed,
|
||||
InProgress,
|
||||
Succeeded,
|
||||
}
|
||||
}
|
||||
40
Libraries/Esiur/Security/Authority/AuthenticationState.cs
Normal file
40
Libraries/Esiur/Security/Authority/AuthenticationState.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
|
||||
Copyright (c) 2017 Ahmed Kh. Zamil
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Esiur.Security.Authority;
|
||||
public enum AuthenticationState : int
|
||||
{
|
||||
Denied = 0x1,
|
||||
Succeeded = 0x2,
|
||||
Blocked = 0x4,
|
||||
Rejected = 0x8,
|
||||
NeedsUpdate = 0x10,
|
||||
NotFound = 0x20
|
||||
}
|
||||
20
Libraries/Esiur/Security/Authority/IAuthenticationHandler.cs
Normal file
20
Libraries/Esiur/Security/Authority/IAuthenticationHandler.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using Esiur.Net.Packets;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Esiur.Security.Authority
|
||||
{
|
||||
public interface IAuthenticationHandler
|
||||
{
|
||||
|
||||
public AuthenticationMode Mode { get; }
|
||||
public AuthenticationResult Initialize(Session session, object authenticationData);
|
||||
|
||||
public AuthenticationResult Process(object authenticationData);
|
||||
|
||||
public void Terminate(Session session);
|
||||
|
||||
public void Update(Session session, object authData);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Esiur.Security.Authority
|
||||
{
|
||||
public interface IAuthenticationInitiator
|
||||
{
|
||||
public AuthenticationResult Initiate(Session session);
|
||||
|
||||
public AuthenticationResult Process(object handshakePayload);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Esiur.Security.Authority
|
||||
{
|
||||
public interface IAuthenticationResponder
|
||||
{
|
||||
public AuthenticationResult Process(Session session);
|
||||
|
||||
}
|
||||
}
|
||||
63
Libraries/Esiur/Security/Authority/Session.cs
Normal file
63
Libraries/Esiur/Security/Authority/Session.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
|
||||
Copyright (c) 2017 Ahmed Kh. Zamil
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
*/
|
||||
using Esiur.Data;
|
||||
using Esiur.Core;
|
||||
using Esiur.Net;
|
||||
using Esiur.Resource;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Esiur.Security.Cryptography;
|
||||
using Esiur.Net.Packets;
|
||||
|
||||
namespace Esiur.Security.Authority;
|
||||
public class Session
|
||||
{
|
||||
public byte[] Id { get; set; }
|
||||
public DateTime Creation { get; }
|
||||
public DateTime Modification { get; }
|
||||
public KeyList<string, object> Variables { get; } = new KeyList<string, object>();
|
||||
|
||||
|
||||
|
||||
//public IKeyExchanger KeyExchanger { get; set; } = null;
|
||||
public ISymetricCipher SymetricCipher { get; set; } = null;
|
||||
|
||||
|
||||
public Map<EpAuthPacketHeader, object> LocalHeaders { get; set; } = new Map<EpAuthPacketHeader, object>();
|
||||
public Map<EpAuthPacketHeader, object> RemoteHeaders { get; set; } = new Map<EpAuthPacketHeader, object>();
|
||||
|
||||
//public AuthenticationMethod AuthenticationMethod { get; set; }
|
||||
//public AuthenticationMethod RemoteMethod { get; set; }
|
||||
|
||||
public AuthenticationMode AuthenticationMode { get; set; }
|
||||
public EncryptionMode EncryptionMode { get; set; }
|
||||
|
||||
public IAuthenticationHandler AuthenticationHandler { get; set; }
|
||||
//public IAuthenticationHandler AuthenticationResponder { get; set; }
|
||||
|
||||
public string AuthorizedIdentity { get; set; }
|
||||
}
|
||||
58
Libraries/Esiur/Security/Authority/Source.cs
Normal file
58
Libraries/Esiur/Security/Authority/Source.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
|
||||
Copyright (c) 2017 Ahmed Kh. Zamil
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
using Esiur.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Esiur.Security.Authority;
|
||||
|
||||
public class Source
|
||||
{
|
||||
|
||||
//string id;
|
||||
KeyList<SourceAttributeType, object> attributes;
|
||||
|
||||
public string Id { get; set; }
|
||||
|
||||
public KeyList<SourceAttributeType, object> Attributes
|
||||
{
|
||||
get => attributes;
|
||||
}
|
||||
|
||||
public Source(string id, KeyList<SourceAttributeType, object> attributes)
|
||||
{
|
||||
Id = id;
|
||||
this.attributes = attributes;
|
||||
}
|
||||
|
||||
public Source()
|
||||
{
|
||||
attributes = new KeyList<SourceAttributeType, object>();
|
||||
}
|
||||
|
||||
}
|
||||
79
Libraries/Esiur/Security/Authority/SourceAttributeType.cs
Normal file
79
Libraries/Esiur/Security/Authority/SourceAttributeType.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
|
||||
Copyright (c) 2017 Ahmed Kh. Zamil
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
using Esiur.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Esiur.Security.Authority;
|
||||
|
||||
public enum SourceAttributeType
|
||||
{
|
||||
Mobility, // Stationary/Mobile
|
||||
CPU, // Arc, Speed, Cores
|
||||
IPv4, // IPv4, IPv6 Address
|
||||
IPv6, // IPv4, IPv6 Address
|
||||
Port, // TCP or UDP port
|
||||
Proxy, // Proxy
|
||||
Route, // Trace Root
|
||||
Location, // Lon, Lat, Alt, Accuracy
|
||||
OS, // OS name, version, distro, kernel
|
||||
Application, // lib version, app version
|
||||
Network, // Bandwidth, MAC, IP, Route
|
||||
Display, // Screen WxH
|
||||
Media, // AudioIn, AudioOut, VideoIn,
|
||||
Identity, // IMEI, IMSI, Manufacture
|
||||
}
|
||||
/*
|
||||
public class SourceAttribute
|
||||
{
|
||||
SourceAttributeType type;
|
||||
Structure value;
|
||||
|
||||
public SourceAttributeType Type
|
||||
{
|
||||
get
|
||||
{
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
public Structure Value
|
||||
{
|
||||
get
|
||||
{
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
public SourceAttribute(SourceAttributeType type, Structure value)
|
||||
{
|
||||
this.type = type;
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
*/
|
||||
Reference in New Issue
Block a user