Search in sources :

Example 11 with IncorrectCredentialsException

use of org.apache.shiro.authc.IncorrectCredentialsException in project shiro by apache.

the class JDBCRealmTest method testSaltColumnWrongPassword.

@Test
public void testSaltColumnWrongPassword() throws Exception {
    String testMethodName = name.getMethodName();
    JdbcRealm realm = realmMap.get(testMethodName);
    createSaltColumnSchema(testMethodName);
    realm.setSaltStyle(JdbcRealm.SaltStyle.COLUMN);
    Subject.Builder builder = new Subject.Builder(securityManager);
    Subject currentUser = builder.buildSubject();
    UsernamePasswordToken token = new UsernamePasswordToken(username, "passwrd");
    try {
        currentUser.login(token);
    } catch (IncorrectCredentialsException ex) {
    // Expected
    }
}
Also used : IncorrectCredentialsException(org.apache.shiro.authc.IncorrectCredentialsException) Subject(org.apache.shiro.subject.Subject) UsernamePasswordToken(org.apache.shiro.authc.UsernamePasswordToken)

Aggregations

IncorrectCredentialsException (org.apache.shiro.authc.IncorrectCredentialsException)11 UsernamePasswordToken (org.apache.shiro.authc.UsernamePasswordToken)9 UnknownAccountException (org.apache.shiro.authc.UnknownAccountException)7 Subject (org.apache.shiro.subject.Subject)7 AuthenticationException (org.apache.shiro.authc.AuthenticationException)5 LockedAccountException (org.apache.shiro.authc.LockedAccountException)5 DisabledAccountException (org.apache.shiro.authc.DisabledAccountException)2 ExcessiveAttemptsException (org.apache.shiro.authc.ExcessiveAttemptsException)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)2 JSONObject (com.alibaba.fastjson.JSONObject)1 AjaxJson (com.cdeledu.common.base.AjaxJson)1 Users (io.github.tesla.authz.domain.Users)1 AccountException (org.apache.shiro.authc.AccountException)1 ExpiredCredentialsException (org.apache.shiro.authc.ExpiredCredentialsException)1 SimpleAuthenticationInfo (org.apache.shiro.authc.SimpleAuthenticationInfo)1 UnsupportedTokenException (org.apache.shiro.authc.pam.UnsupportedTokenException)1 UnauthorizedException (org.apache.shiro.authz.UnauthorizedException)1 Md5Hash (org.apache.shiro.crypto.hash.Md5Hash)1 Session (org.apache.shiro.session.Session)1