public void TestMethod1() { MockHttp.FakeHttpContext(""); Credentials credentials = new NCAS.jasig.authentication.principal.UsernamePasswordCredentials { }; ((UsernamePasswordCredentials)credentials).setPassword("test"); ((UsernamePasswordCredentials)credentials).setUsername("test"); _authenticationViaFormAction.submit(HttpContext.Current, credentials, null); }
protected override bool authenticateUsernamePasswordInternal(UsernamePasswordCredentials credentials) { string username = credentials.getUsername(); string password = credentials.getPassword(); if (StringUtils.hasText(username) && StringUtils.hasText(password) && username.Equals(this.getPasswordEncoder().encode(password))) { //log // .debug("User [" + username // + "] was successfully authenticated."); return true; } //log.debug("User [" + username + "] failed authentication"); return false; }
public void MyTestMethodWithService() { MockHttp.FakeHttpContext("Service=http://www.google.com"); Credentials credentials = new NCAS.jasig.authentication.principal.UsernamePasswordCredentials { }; ((UsernamePasswordCredentials)credentials).setPassword("test"); ((UsernamePasswordCredentials)credentials).setUsername("test"); if ("success" == _authenticationViaFormAction.submit(HttpContext.Current, credentials, null)) { //这里还有些问题,还差一个 init var service = WebUtils.getService(HttpContext.Current).getResponse("").getUrl(); Console.WriteLine(service); } }
//@Override public bool equals(Object o) { if (this == o) { return(true); } if (o == null || this.GetType() != o.GetType()) { return(false); } UsernamePasswordCredentials that = (UsernamePasswordCredentials)o; if (this.password != null ? !this.password.Equals(that.password) : that.password != null) { return(false); } if (this.username != null ? !this.username.Equals(that.username) : that.username != null) { return(false); } return(true); }