public byte[] handleChallenge(byte[] challenge, IConnectionFactory factory) { if (factory is ConnectionFactory val) { return(Encoding.UTF8.GetBytes("\0" + GetUserName(val) + "\0" + AliyunUtils.GetPassword(val.Password))); } throw new InvalidCastException("Need ConnectionFactory."); }
private string GetUserName(ConnectionFactory cf) { string text; try { text = cf.HostName.Split('.')[0]; } catch (Exception) { throw new InvalidProgramException("HostName invalid."); } return(AliyunUtils.GetUserName(cf.UserName, text)); }