public NegotiateContextToken(GssApiToken gssToken) { // SPNego tokens optimistically include a token of the first MechType // so if mechType[0] == Ntlm process as ntlm, == kerb process as kerb, etc. token = NegotiationToken.Decode(gssToken.Token); }
internal static ContextToken Parse(GssApiToken token) { var mechType = token.ThisMech.Value; if (!KnownMessageTypes.TryGetValue(mechType, out Func <GssApiToken, ContextToken> tokenFunc)) { throw new UnknownMechTypeException(mechType); } return(tokenFunc(token)); }
public NegotiateContextToken(GssApiToken gssToken) { if (gssToken == null) { throw new ArgumentNullException(nameof(gssToken)); } // SPNego tokens optimistically include a token of the first MechType // so if mechType[0] == Ntlm process as ntlm, == kerb process as kerb, etc. this.Token = NegotiationToken.Decode(gssToken.Token); }
public KerberosContextToken(GssApiToken gssToken = null, ReadOnlyMemory <byte>?data = null) { var kerb = data ?? gssToken?.Token; if (KrbApReq.CanDecode(kerb.Value)) { KrbApReq = KrbApReq.DecodeApplication(kerb.Value); } else if (KrbApRep.CanDecode(kerb.Value)) { KrbApRep = KrbApRep.DecodeApplication(kerb.Value); } }
public ReadOnlyMemory <byte> EncodeGssApi() { var token = GssApiToken.Encode(Kerberos5Oid, this); var negoToken = new NegotiationToken { InitialToken = new NegTokenInit { MechTypes = new[] { Kerberos5Oid }, MechToken = token } }; return(GssApiToken.Encode(SPNegoOid, negoToken)); }
public static GssApiToken Decode(ReadOnlyMemory <byte> data) { var reader = new AsnReader(data, AsnEncodingRules.DER); var token = new GssApiToken(); var sequenceReader = reader.ReadSequence(ApplicationTag); token.ThisMech = sequenceReader.ReadObjectIdentifier(); // this is a frustrating format -- it starts off as an ASN.1 encoded-thing // but values after thisMech don't have to be ASN.1 encoded, which means // you can't rely on the decoder to detect a single blob of next data // // as such this is still probably an incorrect way to parse the message while (sequenceReader.HasData) { var read = sequenceReader.ReadEncodedValue(); if (sequenceReader.HasData) { switch (read.Span[0]) { case 0x01: token.MessageType = MessageType.KRB_AP_REQ; break; case 0x02: token.MessageType = MessageType.KRB_AP_REP; break; case 0x03: token.MessageType = MessageType.KRB_ERROR; break; } } else { token.Token = read; break; } } return(token); }
public KerberosUser2UserContextToken(GssApiToken _) { }
public KerberosContextToken(GssApiToken gssToken = null, ReadOnlyMemory <byte>?data = null) { var kerb = data ?? gssToken?.Token; this.KrbApReq = KrbApReq.DecodeApplication(kerb.Value); }