use of org.apache.shiro.authc.UsernamePasswordToken in project shiro by apache.
the class JDBCRealmTest method testUnSaltedWrongPassword.
@Test
public void testUnSaltedWrongPassword() throws Exception {
String testMethodName = name.getMethodName();
JdbcRealm realm = realmMap.get(testMethodName);
createDefaultSchema(testMethodName, false);
realm.setSaltStyle(JdbcRealm.SaltStyle.NO_SALT);
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
}
}
use of org.apache.shiro.authc.UsernamePasswordToken in project shiro by apache.
the class JDBCRealmTest method testUnSaltedMultipleRows.
@Test
public void testUnSaltedMultipleRows() throws Exception {
String testMethodName = name.getMethodName();
JdbcRealm realm = realmMap.get(testMethodName);
createDefaultSchema(testMethodName, false);
realm.setSaltStyle(JdbcRealm.SaltStyle.NO_SALT);
Connection conn = dsMap.get(testMethodName).getConnection();
Statement sql = conn.createStatement();
sql.executeUpdate("insert into users values ('" + username + "', 'dupe')");
Subject.Builder builder = new Subject.Builder(securityManager);
Subject currentUser = builder.buildSubject();
UsernamePasswordToken token = new UsernamePasswordToken(username, "passwrd");
try {
currentUser.login(token);
} catch (AuthenticationException ex) {
// Expected
}
}
use of org.apache.shiro.authc.UsernamePasswordToken in project shiro by apache.
the class JDBCRealmTest method testExternalWrongPassword.
@Test
public void testExternalWrongPassword() throws Exception {
String testMethodName = name.getMethodName();
JdbcRealm realm = realmMap.get(testMethodName);
createDefaultSchema(testMethodName, true);
realm.setSaltStyle(JdbcRealm.SaltStyle.EXTERNAL);
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
}
}
use of org.apache.shiro.authc.UsernamePasswordToken in project shiro by apache.
the class JDBCRealmTest method testUnSaltedSuccess.
@Test
public void testUnSaltedSuccess() throws Exception {
String testMethodName = name.getMethodName();
JdbcRealm realm = realmMap.get(testMethodName);
createDefaultSchema(testMethodName, false);
realm.setSaltStyle(JdbcRealm.SaltStyle.NO_SALT);
Subject.Builder builder = new Subject.Builder(securityManager);
Subject currentUser = builder.buildSubject();
UsernamePasswordToken token = new UsernamePasswordToken(username, plainTextPassword);
currentUser.login(token);
currentUser.logout();
}
use of org.apache.shiro.authc.UsernamePasswordToken in project shiro by apache.
the class JDBCRealmTest method testSaltColumnSuccess.
@Test
public void testSaltColumnSuccess() 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, plainTextPassword);
currentUser.login(token);
currentUser.logout();
}
Aggregations