/// <summary> /// Given a Federated Authentication ticket, returns the Session Key from the authentication service /// </summary> public static IFederatedAuthenticationTicket DecryptTicket(TDSFedAuthLibraryType ticketType, byte[] encryptedTicket) { if (encryptedTicket == null) { throw new NullReferenceException("encryptedTicket is null. Unable to decrypt."); } switch (ticketType) { case TDSFedAuthLibraryType.IDCRL: return(RpsTicket.DecryptTicket(encryptedTicket)); case TDSFedAuthLibraryType.SECURITY_TOKEN: return(JwtTicket.DecryptTicket(encryptedTicket)); case TDSFedAuthLibraryType.MSAL: // For now, fake fed auth tokens are sent for ADAL, so just return null return(null); default: throw new ArgumentOutOfRangeException("Unexpected Federated Authentication ticket type."); } }
/// <summary> /// Given a Federated Authentication ticket, returns the Session Key from the authentication service /// </summary> public static IFederatedAuthenticationTicket DecryptTicket(TDSFedAuthLibraryType ticketType, byte[] encryptedTicket) { if (encryptedTicket == null) { throw new NullReferenceException("encryptedTicket is null. Unable to decrypt."); } switch (ticketType) { case TDSFedAuthLibraryType.IDCRL: return RpsTicket.DecryptTicket(encryptedTicket); case TDSFedAuthLibraryType.SECURITY_TOKEN: return JwtTicket.DecryptTicket(encryptedTicket); case TDSFedAuthLibraryType.ADAL: // For now, fake fed auth tokens are sent for ADAL, so just return null return null; default: throw new ArgumentOutOfRangeException("Unexpected Federated Authentication ticket type."); } }
/// <summary> /// Initialization Constructor. /// </summary> public TDSLogin7FedAuthOptionToken(TdsPreLoginFedAuthRequiredOption echo, TDSFedAuthLibraryType libraryType, byte[] token, byte[] nonce, byte[] channelBindingToken, bool fIncludeSignature, bool fRequestingFurtherInfo, TDSFedAuthMSALWorkflow workflow = TDSFedAuthMSALWorkflow.USERNAME_PASSWORD) : this() { Echo = echo; Library = libraryType; Token = token; Nonce = nonce; ChannelBingingToken = channelBindingToken; IsRequestingAuthenticationInfo = fRequestingFurtherInfo; Workflow = workflow; if (libraryType != TDSFedAuthLibraryType.SECURITY_TOKEN && fIncludeSignature) { Signature = new byte[s_signatureDataLength]; Signature = _GenerateRandomBytes(32); } }
/// <summary> /// Initialization Constructor. /// </summary> public TDSLogin7FedAuthOptionToken(TdsPreLoginFedAuthRequiredOption echo, TDSFedAuthLibraryType libraryType, byte[] token, byte[] nonce, byte[] channelBindingToken, bool fIncludeSignature, bool fRequestingFurtherInfo, TDSFedAuthADALWorkflow workflow = TDSFedAuthADALWorkflow.USERNAME_PASSWORD) : this() { Echo = echo; Library = libraryType; Token = token; Nonce = nonce; ChannelBingingToken = channelBindingToken; IsRequestingAuthenticationInfo = fRequestingFurtherInfo; Workflow = workflow; if (libraryType != TDSFedAuthLibraryType.SECURITY_TOKEN && fIncludeSignature) { Signature = new byte[s_signatureDataLength]; Signature = _GenerateRandomBytes(32); } }