-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Juris Gekiss
authored and
Juris Gekiss
committed
Feb 16, 2024
1 parent
b48be65
commit 8802dd7
Showing
2 changed files
with
2 additions
and
59 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +0,0 @@ | ||
1. STS izsaukums | ||
|
||
var f = new ChannelFactory<IWSTrust13Contract>(b, e); | ||
f.Credentials.UserName.UserName = "user"; | ||
f.Credentials.UserName.Password = "pwd"; | ||
// VAI f.Credentials.Certificate.SetCertificate(...); | ||
|
||
var serviceProxy = f.CreateChannel(); | ||
|
||
var rst = new RequestSecurityToken() { | ||
RequestType = "http://docs.oasis-open.org/ws-sx/ws-trust/200512/Issue", | ||
AppliesTo = new EndpointReference("URN:VISSDEV:DIT:WS"), | ||
}; | ||
|
||
var request = Message.CreateMessage(MessageVersion.Soap12WSAddressing10, "http://docs.oasis-open.org/ws-sx/ws-trust/200512/RST/Issue", new WSTrustRequestBodyWriter(rst, new WSTrustRequestSerializer(), new WSTrustSerializationContext())); | ||
var result = serviceProxy.ProcessTrust13IssueAsync(request); | ||
var ser = new WSTrustResponseSerializer(); | ||
var rstr = ser.ReadXml(result.GetReaderAtBodyContents(), new WSTrustSerializationContext()); | ||
|
||
2. MyClientCredentials | ||
public override SecurityTokenManager CreateSecurityTokenManager() | ||
{ | ||
return new MyClientCredentialsSecurityTokenManager(Clone()); | ||
} | ||
|
||
|
||
MyClientCredentialsSecurityTokenManager | ||
public override SecurityTokenProvider CreateSecurityTokenProvider(SecurityTokenRequirement tokenRequirement) { | ||
if (tokenRequirement is InitiatorServiceModelSecurityTokenRequirement initiatorRequirement) { | ||
retuen new SimpleSecurityTokenProvider() : SecurityTokenProvider | ||
} | ||
} | ||
|
||
public class SimpleSecurityTokenProvider : SecurityTokenProvider { | ||
public SimpleSecurityTokenProvider(SecurityToken token, SecurityTokenRequirement tokenRequirement) | ||
{ | ||
if (token == null) | ||
{ | ||
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("token"); | ||
} | ||
GenericXmlSecurityToken genericXmlSecurityToken = token as GenericXmlSecurityToken; | ||
if (genericXmlSecurityToken != null) | ||
{ | ||
_securityToken = WrapWithAuthPolicy(genericXmlSecurityToken, tokenRequirement); | ||
} | ||
else | ||
{ | ||
_securityToken = token; | ||
} | ||
} | ||
|
||
protected override SecurityToken GetTokenCore(TimeSpan timeout) | ||
{ | ||
return _securityToken; | ||
} | ||
|
||
} | ||
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