Created
May 31, 2019 11:00
-
-
Save ronaldhoek/ff7611a0b4bd03c01f72c3dd5a4f0a5c to your computer and use it in GitHub Desktop.
Delphi WS-Security headers - 2 versions: 2003.06 and 2004.01
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unit WSSecurity200306; | |
interface | |
uses | |
System.SysUtils, System.Types, | |
Soap.InvokeRegistry, Soap.SOAPHTTPClient, Soap.XSBuiltIns; | |
const | |
IS_OPTN = $0001; | |
IS_ATTR = $0010; | |
IS_TEXT = $0020; | |
IS_REF = $0080; | |
IS_QUAL = $0100; | |
type | |
AttributedString = class(TRemotable) | |
private | |
FText: WideString; | |
FId: WideString; | |
FId_Specified: boolean; | |
procedure SetId(Index: Integer; const AId: WideString); | |
function Id_Specified(Index: Integer): boolean; | |
published | |
property Text: WideString Index(IS_TEXT)read FText write FText; | |
property Id: WideString Index(IS_ATTR or IS_OPTN)read FId write SetId | |
stored Id_Specified; | |
end; | |
UsernameString = class(AttributedString) | |
private | |
FType_: WideString; | |
FType__Specified: boolean; | |
procedure SetType_(Index: Integer; const AWideString: WideString); | |
function Type__Specified(Index: Integer): boolean; | |
published | |
property Type_: WideString Index(IS_ATTR or IS_OPTN)read FType_ | |
write SetType_ stored Type__Specified; | |
end; | |
PasswordString = class(AttributedString) | |
private | |
FType_: WideString; | |
FType__Specified: boolean; | |
procedure SetType_(Index: Integer; const AWideString: WideString); | |
function Type__Specified(Index: Integer): boolean; | |
published | |
property Type_: WideString Index(IS_ATTR or IS_OPTN)read FType_ | |
write SetType_ stored Type__Specified; | |
end; | |
// ************************************************************************ // | |
// XML : UsernameTokenType, global, <complexType> | |
// Namespace : http://schemas.xmlsoap.org/ws/2002/07/secext | |
// ************************************************************************ // | |
UsernameTokenType = class(TRemotable) | |
private | |
FId: WideString; | |
FId_Specified: boolean; | |
FUsername: UsernameString; | |
FPassword: PasswordString; | |
FCreated: TXSDateTime; | |
procedure SetId(Index: Integer; const AId: WideString); | |
function Id_Specified(Index: Integer): boolean; | |
public | |
destructor Destroy; override; | |
published | |
property Id: WideString Index(IS_ATTR or IS_OPTN)read FId write SetId | |
stored Id_Specified; | |
property Username: UsernameString read FUsername write FUsername; | |
property Password: PasswordString read FPassword write FPassword; | |
property Created: TXSDateTime read FCreated write FCreated; | |
end; | |
// ************************************************************************ // | |
// XML : UsernameToken, global, <element> | |
// Namespace : http://schemas.xmlsoap.org/ws/2002/07/secext | |
// ************************************************************************ // | |
UsernameToken = class(UsernameTokenType) | |
private | |
published | |
end; | |
Security = class(TSOAPHeader) | |
private | |
FUserNameToken: UsernameToken; | |
public | |
destructor Destroy; override; | |
published | |
property UsernameToken: UsernameToken index(IS_REF)read FUserNameToken | |
write FUserNameToken; | |
end; | |
implementation | |
procedure AttributedString.SetId(Index: Integer; const AId: WideString); | |
begin | |
FId := AId; | |
FId_Specified := True; | |
end; | |
function AttributedString.Id_Specified(Index: Integer): boolean; | |
begin | |
Result := FId_Specified; | |
end; | |
procedure PasswordString.SetType_(Index: Integer; | |
const AWideString: WideString); | |
begin | |
FType_ := AWideString; | |
FType__Specified := True; | |
end; | |
function PasswordString.Type__Specified(Index: Integer): boolean; | |
begin | |
Result := FType__Specified; | |
end; | |
destructor Security.Destroy; | |
begin | |
FreeAndNIL(FUserNameToken); | |
inherited Destroy; | |
end; | |
const | |
NS_SECEXT = | |
'http://schemas.xmlsoap.org/ws/2003/06/secext'; | |
NS_UTILITY = | |
'http://schemas.xmlsoap.org/ws/2003/06/utility'; | |
{ UsernameTokenType } | |
destructor UsernameTokenType.Destroy; | |
begin | |
FreeAndNIL(FUsername); | |
FreeAndNIL(FPassword); | |
FreeAndNIL(FCreated); | |
inherited Destroy; | |
end; | |
procedure UsernameTokenType.SetId(Index: Integer; const AId: WideString); | |
begin | |
FId := AId; | |
FId_Specified := True; | |
end; | |
function UsernameTokenType.Id_Specified(Index: Integer): boolean; | |
begin | |
Result := FId_Specified; | |
end; | |
procedure UsernameString.SetType_(Index: Integer; | |
const AWideString: WideString); | |
begin | |
FType_ := AWideString; | |
FType__Specified := True; | |
end; | |
function UsernameString.Type__Specified(Index: Integer): boolean; | |
begin | |
Result := FType__Specified; | |
end; | |
initialization | |
RemClassRegistry.RegisterXSClass(Security, NS_SECEXT, 'Security'); | |
RemClassRegistry.RegisterXSClass(UsernameToken, NS_SECEXT, 'UsernameToken'); | |
RemClassRegistry.RegisterXSClass(UsernameTokenType, NS_SECEXT, 'UsernameTokenType'); | |
RemClassRegistry.RegisterExternalPropName(TypeInfo(UsernameTokenType), 'Id', '[Namespace="' + NS_UTILITY + '"]'); | |
RemClassRegistry.RegisterExternalPropName(TypeInfo(UsernameTokenType), 'Created', '[Namespace="' + NS_UTILITY + '"]'); | |
RemClassRegistry.RegisterXSClass(UsernameString, NS_SECEXT, 'Username'); | |
RemClassRegistry.RegisterExternalPropName(TypeInfo(UsernameString), 'Type_', 'Type'); | |
RemClassRegistry.RegisterXSClass(PasswordString, NS_SECEXT, 'Password'); | |
RemClassRegistry.RegisterExternalPropName(TypeInfo(PasswordString), 'Type_', 'Type'); | |
RemClassRegistry.RegisterXSClass(AttributedString, NS_SECEXT, 'AttributedString'); | |
RemClassRegistry.RegisterExternalPropName(TypeInfo(AttributedString), 'Id', '[Namespace="' + NS_UTILITY + '"]'); | |
end. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unit WSSecurity200401; | |
interface | |
uses | |
System.SysUtils, System.Types, | |
Soap.InvokeRegistry, Soap.SOAPHTTPClient, Soap.XSBuiltIns; | |
const | |
IS_OPTN = $0001; | |
IS_ATTR = $0010; | |
IS_TEXT = $0020; | |
IS_REF = $0080; | |
IS_QUAL = $0100; | |
type | |
AttributedString = class(TRemotable) | |
private | |
FText: WideString; | |
FId: WideString; | |
FId_Specified: boolean; | |
procedure SetId(Index: Integer; const AId: WideString); | |
function Id_Specified(Index: Integer): boolean; | |
published | |
property Text: WideString Index(IS_TEXT)read FText write FText; | |
property Id: WideString Index(IS_ATTR or IS_OPTN)read FId write SetId | |
stored Id_Specified; | |
end; | |
UsernameString = class(AttributedString) | |
private | |
FType_: WideString; | |
FType__Specified: boolean; | |
procedure SetType_(Index: Integer; const AWideString: WideString); | |
function Type__Specified(Index: Integer): boolean; | |
published | |
property Type_: WideString Index(IS_ATTR or IS_OPTN)read FType_ | |
write SetType_ stored Type__Specified; | |
end; | |
PasswordString = class(AttributedString) | |
private | |
FType_: WideString; | |
FType__Specified: boolean; | |
procedure SetType_(Index: Integer; const AWideString: WideString); | |
function Type__Specified(Index: Integer): boolean; | |
published | |
property Type_: WideString Index(IS_ATTR or IS_OPTN)read FType_ | |
write SetType_ stored Type__Specified; | |
end; | |
// ************************************************************************ // | |
// XML : UsernameTokenType, global, <complexType> | |
// Namespace : http://schemas.xmlsoap.org/ws/2002/07/secext | |
// ************************************************************************ // | |
UsernameTokenType = class(TRemotable) | |
private | |
FId: WideString; | |
FId_Specified: boolean; | |
FUsername: UsernameString; | |
FPassword: PasswordString; | |
procedure SetId(Index: Integer; const AId: WideString); | |
function Id_Specified(Index: Integer): boolean; | |
public | |
destructor Destroy; override; | |
published | |
property Id: WideString Index(IS_ATTR or IS_OPTN)read FId write SetId | |
stored Id_Specified; | |
property Username: UsernameString read FUsername write FUsername; | |
property Password: PasswordString read FPassword write FPassword; | |
end; | |
// ************************************************************************ // | |
// XML : UsernameToken, global, <element> | |
// Namespace : http://schemas.xmlsoap.org/ws/2002/07/secext | |
// ************************************************************************ // | |
UsernameToken = class(UsernameTokenType) | |
private | |
published | |
end; | |
// ************************************************************************ // | |
// XML : Security, global, <header> | |
// Namespace : http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd | |
// ************************************************************************ // | |
Security = class(TSOAPHeader) | |
private | |
FUserNameToken: UsernameToken; | |
public | |
destructor Destroy; override; | |
published | |
property UsernameToken: UsernameToken index(IS_REF)read FUserNameToken | |
write FUserNameToken; | |
end; | |
{ SAML properties 'Security' header | |
(waarde van 'Assertion.@AssertionID' zelfde als 'SecurityTokenReference.KeyIdentifier[Text]' | |
Assertion(AssertionID=, IssueInstant=, Issuer=, MajorVersion=, MinorVersion) | |
SecurityTokenReference(wsu:Id= , ValueType=) | |
KeyIdentifier(wsu:Id=, ValueType=) | |
} | |
implementation | |
procedure AttributedString.SetId(Index: Integer; const AId: WideString); | |
begin | |
FId := AId; | |
FId_Specified := True; | |
end; | |
function AttributedString.Id_Specified(Index: Integer): boolean; | |
begin | |
Result := FId_Specified; | |
end; | |
procedure PasswordString.SetType_(Index: Integer; | |
const AWideString: WideString); | |
begin | |
FType_ := AWideString; | |
FType__Specified := True; | |
end; | |
function PasswordString.Type__Specified(Index: Integer): boolean; | |
begin | |
Result := FType__Specified; | |
end; | |
destructor Security.Destroy; | |
begin | |
FreeAndNIL(FUserNameToken); | |
inherited Destroy; | |
end; | |
const | |
NS_SECEXT = | |
'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'; | |
NS_UTILITY = | |
'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd'; | |
// SAML | |
NS_SECEXT11 = | |
'http://docs.oasis-open.org/wss/oasis-wss-wssecurity-secext-1.1.xsd'; | |
// SAML 1.1 | |
NS_SAML_11 = 'urn: oasis:names:tc:SAML:1.0:assertion'; | |
SAML_11_TokenType = 'http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1'; | |
SAML_11_ValueType = 'http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.0#SAMLAssertionID'; | |
// SAML 2.0 | |
NS_SAML_20 = 'urn: oasis:names:tc:SAML:2.0:assertion'; | |
SAML_20_TokenType = 'http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV2.0'; | |
SAML_20_ValueType = 'http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLID'; | |
{ UsernameTokenType } | |
destructor UsernameTokenType.Destroy; | |
begin | |
FreeAndNIL(FUsername); | |
FreeAndNIL(FPassword); | |
inherited Destroy; | |
end; | |
procedure UsernameTokenType.SetId(Index: Integer; const AId: WideString); | |
begin | |
FId := AId; | |
FId_Specified := True; | |
end; | |
function UsernameTokenType.Id_Specified(Index: Integer): boolean; | |
begin | |
Result := FId_Specified; | |
end; | |
procedure UsernameString.SetType_(Index: Integer; | |
const AWideString: WideString); | |
begin | |
FType_ := AWideString; | |
FType__Specified := True; | |
end; | |
function UsernameString.Type__Specified(Index: Integer): boolean; | |
begin | |
Result := FType__Specified; | |
end; | |
initialization | |
RemClassRegistry.RegisterXSClass(Security, NS_SECEXT, 'Security'); | |
RemClassRegistry.RegisterXSClass(UsernameToken, NS_SECEXT, 'UsernameToken'); | |
RemClassRegistry.RegisterXSClass(UsernameTokenType, NS_SECEXT, 'UsernameTokenType'); | |
RemClassRegistry.RegisterExternalPropName(TypeInfo(UsernameTokenType), 'Id', '[Namespace="' + NS_UTILITY + '"]'); | |
RemClassRegistry.RegisterXSClass(UsernameString, NS_SECEXT, 'Username'); | |
RemClassRegistry.RegisterExternalPropName(TypeInfo(UsernameString), 'Type_', 'Type'); | |
RemClassRegistry.RegisterXSClass(PasswordString, NS_SECEXT, 'Password'); | |
RemClassRegistry.RegisterExternalPropName(TypeInfo(PasswordString), 'Type_', 'Type'); | |
RemClassRegistry.RegisterXSClass(AttributedString, NS_SECEXT, 'AttributedString'); | |
RemClassRegistry.RegisterExternalPropName(TypeInfo(AttributedString), 'Id', '[Namespace="' + NS_UTILITY + '"]'); | |
end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment