• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java JdbcDaoImpl类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PacketPlayOutScoreboardTeam类代码示例发布时间:2022-05-22
下一篇:
Java BackPropagation类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap