本文整理汇总了Java中org.springframework.security.core.userdetails.jdbc.JdbcDaoImpl类的典型用法代码示例。如果您正苦于以下问题:Java JdbcDaoImpl类的具体用法?Java JdbcDaoImpl怎么用?Java JdbcDaoImpl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JdbcDaoImpl类属于org.springframework.security.core.userdetails.jdbc包,在下文中一共展示了JdbcDaoImpl类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: setup
import org.springframework.security.core.userdetails.jdbc.JdbcDaoImpl; //导入依赖的package包/类
@Before
public void setup() {
userDetailService = appContext.getBean(JdbcDaoImpl.class);
UserDetails userDetails = userDetailService.loadUserByUsername("Admin");
Authentication authToken = new UsernamePasswordAuthenticationToken(
userDetails.getUsername(), userDetails.getPassword(),
userDetails.getAuthorities());
SecurityContextHolder.getContext().setAuthentication(authToken);
rCtx = new MockRequestContext();
MockExternalContext ec = new MockExternalContext();
ec.setCurrentUser("Admin");
((MockRequestContext) rCtx).setExternalContext(ec);
// Add a user first, it will add a "ROLE_USER" by default.
UserBean ub = new UserBean();
ub.setEmailId("[email protected]");
ub.setEnabled(true);
ub.setFirstName("Test");
ub.setLastName("User");
ub.setMiddleInit("1");
ub.setPassword("password");
ub.setUsername("testuser1");
userBean = userService.addUser(ub,rCtx);
}
开发者ID:arunkpatra,项目名称:expense-tracker,代码行数:24,代码来源:JpaAuthServiceTests.java
示例2: setup
import org.springframework.security.core.userdetails.jdbc.JdbcDaoImpl; //导入依赖的package包/类
@Before
public void setup() {
// Sanity check
Assert.assertTrue("Expected an WebApplicationContext",
appContext instanceof WebApplicationContext);
WebApplicationContext ctx = (WebApplicationContext) appContext;
context = ctx.getServletContext();
// Set current user
userDetailService = appContext.getBean(JdbcDaoImpl.class);
UserDetails userDetails = userDetailService.loadUserByUsername("Admin");
Authentication authToken = new UsernamePasswordAuthenticationToken(
userDetails.getUsername(), userDetails.getPassword(),
userDetails.getAuthorities());
SecurityContextHolder.getContext().setAuthentication(authToken);
rCtx = new MockRequestContext();
MockExternalContext ec = new MockExternalContext();
ec.setCurrentUser("Admin");
((MockRequestContext) rCtx).setExternalContext(ec);
// Create two users
// Add 1st user
UserBean ub1 = new UserBean();
ub1.setEmailId("[email protected]");
ub1.setEnabled(true);
ub1.setFirstName("Test1");
ub1.setLastName("User1");
ub1.setMiddleInit("1");
ub1.setPassword("password");
ub1.setUsername("reptusr1");
UserBean userBean1 = userService.addUser(ub1, rCtx);
Assert.assertNotNull("Failed to create user1.", userBean1);
//
// Add 2nd user
UserBean ub2 = new UserBean();
ub2.setEmailId("[email protected]");
ub2.setEnabled(true);
ub2.setFirstName("Test2");
ub2.setLastName("User2");
ub2.setMiddleInit("2");
ub2.setPassword("password");
ub2.setUsername("reptusr2");
UserBean userBean2 = userService.addUser(ub2, rCtx);
Assert.assertNotNull("Failed to create user2", userBean2);
// Setup an expense
ExpenseDetail ed = new ExpenseDetail();
ed.setAmount(20.0F);
ed.setCategory("Somecategory");
ed.setCreatedBy("Admin");
ed.setDate(new Date());
ed.setDescription("Some Expense");
ed.setPaidBy("reptusr1");
ed.setSettlementId(null);
// now set shares
UserShare us1 = new UserShare("reptusr1", 10.0F, 0.0F, true);
UserShare us2 = new UserShare("reptusr2", 10.0F, 0.0F, true);
ed.getUserShares().add(us1);
ed.getUserShares().add(us2);
//
expenseDetail = ed;
}
开发者ID:arunkpatra,项目名称:expense-tracker,代码行数:63,代码来源:JasperReportGenerationServiceTests.java
示例3: setup
import org.springframework.security.core.userdetails.jdbc.JdbcDaoImpl; //导入依赖的package包/类
@Before
public void setup() {
userDetailService = ctx.getBean(JdbcDaoImpl.class);
UserDetails userDetails = userDetailService.loadUserByUsername("Admin");
Authentication authToken = new UsernamePasswordAuthenticationToken(
userDetails.getUsername(), userDetails.getPassword(),
userDetails.getAuthorities());
SecurityContextHolder.getContext().setAuthentication(authToken);
rCtx = new MockRequestContext();
MockExternalContext ec = new MockExternalContext();
ec.setCurrentUser("Admin");
((MockRequestContext) rCtx).setExternalContext(ec);
// Add 1st user
UserBean ub1 = new UserBean();
ub1.setEmailId("[email protected]");
ub1.setEnabled(true);
ub1.setFirstName("Test1");
ub1.setLastName("User1");
ub1.setMiddleInit("1");
ub1.setPassword("password");
ub1.setUsername("testuser1");
UserBean userBean1 = userService.addUser(ub1,rCtx);
Assert.assertNotNull("Failed to create user1. Why", userBean1);
//
// Add 1st user
UserBean ub2 = new UserBean();
ub2.setEmailId("[email protected]");
ub2.setEnabled(true);
ub2.setFirstName("Test2");
ub2.setLastName("User2");
ub2.setMiddleInit("2");
ub2.setPassword("password");
ub2.setUsername("testuser2");
UserBean userBean2 = userService.addUser(ub2,rCtx);
Assert.assertNotNull("Failed to create user2", userBean2);
// Setup an expense
ExpenseDetail ed = new ExpenseDetail();
ed.setAmount(20.0F);
ed.setCategory("Somecategory");
ed.setCreatedBy("Admin");
ed.setDate(new Date());
ed.setDescription("Some Expense");
ed.setPaidBy("testuser1");
ed.setSettlementId(null);
// now set shares
UserShare us1 = new UserShare("testuser1", 10.0F, 0.0F, true);
UserShare us2 = new UserShare("testuser2", 10.0F, 0.0F, true);
ed.getUserShares().add(us1);
ed.getUserShares().add(us2);
//
expenseDetail = ed;
}
开发者ID:arunkpatra,项目名称:expense-tracker,代码行数:54,代码来源:JpaExpenseServiceTests.java
示例4: groupServiceTests
import org.springframework.security.core.userdetails.jdbc.JdbcDaoImpl; //导入依赖的package包/类
@Test
public void groupServiceTests() {
userDetailService = ctx.getBean(JdbcDaoImpl.class);
UserDetails userDetails = userDetailService.loadUserByUsername("Admin");
Authentication authToken = new UsernamePasswordAuthenticationToken(
userDetails.getUsername(), userDetails.getPassword(),
userDetails.getAuthorities());
SecurityContextHolder.getContext().setAuthentication(authToken);
rCtx = new MockRequestContext();
MockExternalContext ec = new MockExternalContext();
ec.setCurrentUser("Admin");
((MockRequestContext) rCtx).setExternalContext(ec);
// This test runs with two groups already setup in the embedded test db
// get all groups
Collection<GroupBean> groups = groupService.getGroups();
Assert.assertNotNull("Expected a non null group list", groups);
Assert.assertTrue("Expected exactly two groups", groups.size() == 2);
// Add a group
GroupBean gb = new GroupBean();
gb.setActive(true);
gb.setGroupDescription("Test Description");
gb.setGroupName("Test group name");
gb.setUsers(null);
GroupBean retGb = groupService.addGroup(gb);
Assert.assertNotNull("Failed to create group", retGb);
groups = groupService.getGroups();
Assert.assertTrue("Expected exactly three groups", groups.size() == 3);
//
validationService.checkGroupCreationResult(retGb, rCtx);
Message[] msgs = rCtx.getMessageContext().getAllMessages();
Assert.assertTrue("Expected one message", msgs.length == 1);
Message msg = msgs[0];
Assert.assertTrue("Expected a success message",
"Your group was created succesfuly.".equals(msg.getText()));
// clear this message
rCtx.getMessageContext().clearMessages();
// now try adding group again with same name
retGb = groupService.addGroup(gb);
Assert.assertNull("Should have failed to create group", retGb);
validationService.checkGroupCreationResult(retGb, rCtx);
msgs = rCtx.getMessageContext().getAllMessages();
Assert.assertTrue("Expected one message", msgs.length == 1);
msg = msgs[0];
Assert.assertTrue("Expected a failure message",
"Failed to create group.".equals(msg.getText()));
}
开发者ID:arunkpatra,项目名称:expense-tracker,代码行数:50,代码来源:GroupServiceImplTests.java
示例5: setup
import org.springframework.security.core.userdetails.jdbc.JdbcDaoImpl; //导入依赖的package包/类
@Before
public void setup()
{
userDetailService = wac.getBean(JdbcDaoImpl.class);
UserDetails userDetails = userDetailService.loadUserByUsername("Admin");
Authentication authToken = new UsernamePasswordAuthenticationToken(
userDetails.getUsername(), userDetails.getPassword(),
userDetails.getAuthorities());
SecurityContextHolder.getContext().setAuthentication(authToken);
rCtx = new MockRequestContext();
MockExternalContext ec = new MockExternalContext();
ec.setCurrentUser("Admin");
((MockRequestContext) rCtx).setExternalContext(ec);
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build();
//
// Add 1st user
UserBean ub1 = new UserBean();
ub1.setEmailId("[email protected]");
ub1.setEnabled(true);
ub1.setFirstName("Test1");
ub1.setLastName("User1");
ub1.setMiddleInit("1");
ub1.setPassword("password");
ub1.setUsername("testuserX");
UserBean userBean1 = userService.addUser(ub1,rCtx);
Assert.assertNotNull("Failed to create userX. Why Why", userBean1);
//
// Add 1st user
UserBean ub2 = new UserBean();
ub2.setEmailId("[email protected]");
ub2.setEnabled(true);
ub2.setFirstName("Test2");
ub2.setLastName("User2");
ub2.setMiddleInit("2");
ub2.setPassword("password");
ub2.setUsername("testuserY");
UserBean userBean2 = userService.addUser(ub2,rCtx);
Assert.assertNotNull("Failed to create userY", userBean2);
//
ExpenseDetail ed = new ExpenseDetail();
ed.setAmount(20.0F);
ed.setCategory("Somecategory");
ed.setCreatedBy("Admin");
ed.setDate(new Date());
ed.setDescription("Some Expense");
ed.setPaidBy("testuserX");
ed.setSettlementId(null);
// now set shares
UserShare us1 = new UserShare("testuserX", 10.0F, 0.0F, true);
UserShare us2 = new UserShare("testuserY", 10.0F, 0.0F, true);
ed.getUserShares().add(us1);
ed.getUserShares().add(us2);
Assert.assertNotNull("Expense detail is null", ed);
int result = expenseService.saveExpense(ed);
Assert.assertTrue("Failed to save expense.", result == 0);
}
开发者ID:arunkpatra,项目名称:expense-tracker,代码行数:59,代码来源:ReportControllerTests.java
示例6: setup
import org.springframework.security.core.userdetails.jdbc.JdbcDaoImpl; //导入依赖的package包/类
@Before
public void setup() {
userDetailService = ctx.getBean(JdbcDaoImpl.class);
UserDetails userDetails = userDetailService.loadUserByUsername("Admin");
Authentication authToken = new UsernamePasswordAuthenticationToken(
userDetails.getUsername(), userDetails.getPassword(),
userDetails.getAuthorities());
SecurityContextHolder.getContext().setAuthentication(authToken);
rCtx = new MockRequestContext();
MockExternalContext ec = new MockExternalContext();
ec.setCurrentUser("Admin");
((MockRequestContext) rCtx).setExternalContext(ec);
// Add 1st user
UserBean ub1 = new UserBean();
ub1.setEmailId("[email protected]");
ub1.setEnabled(true);
ub1.setFirstName("Test1");
ub1.setLastName("User1");
ub1.setMiddleInit("1");
ub1.setPassword("password");
ub1.setUsername("testuser3");
UserBean userBean1 = userService.addUser(ub1,rCtx);
Assert.assertNotNull("Failed to create user3. Why Why", userBean1);
//
// Add 1st user
UserBean ub2 = new UserBean();
ub2.setEmailId("[email protected]");
ub2.setEnabled(true);
ub2.setFirstName("Test2");
ub2.setLastName("User2");
ub2.setMiddleInit("2");
ub2.setPassword("password");
ub2.setUsername("testuser4");
UserBean userBean2 = userService.addUser(ub2,rCtx);
Assert.assertNotNull("Failed to create user4", userBean2);
//
ExpenseDetail ed = new ExpenseDetail();
ed.setAmount(20.0F);
ed.setCategory("Somecategory");
ed.setCreatedBy("Admin");
ed.setDate(new Date());
ed.setDescription("Some Expense");
ed.setPaidBy("testuser3");
ed.setSettlementId(null);
// now set shares
UserShare us1 = new UserShare("testuser3", 10.0F, 0.0F, true);
UserShare us2 = new UserShare("testuser4", 10.0F, 0.0F, true);
ed.getUserShares().add(us1);
ed.getUserShares().add(us2);
Assert.assertNotNull("Expense detail is null", ed);
int result = expenseService.saveExpense(ed);
Assert.assertTrue("Failed to save expense.", result == 0);
}
开发者ID:arunkpatra,项目名称:expense-tracker,代码行数:55,代码来源:JpaSettlementServiceTests.java
注:本文中的org.springframework.security.core.userdetails.jdbc.JdbcDaoImpl类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论