use of org.springframework.security.core.context.SecurityContext in project head by mifos.
the class ApplyChargeActionStrutsTest method setMifosUserFromContext.
private void setMifosUserFromContext() {
SecurityContext securityContext = new SecurityContextImpl();
MifosUser principal = new MifosUser(userContext.getId(), userContext.getBranchId(), userContext.getLevelId(), new ArrayList<Short>(userContext.getRoles()), userContext.getName(), "".getBytes(), true, true, true, true, new ArrayList<GrantedAuthority>(), userContext.getLocaleId());
Authentication authentication = new TestingAuthenticationToken(principal, principal);
securityContext.setAuthentication(authentication);
SecurityContextHolder.setContext(securityContext);
}
use of org.springframework.security.core.context.SecurityContext in project head by mifos.
the class SavingsServiceFacadeWebTierTest method setupAndInjectDependencies.
@Before
public void setupAndInjectDependencies() {
oldCurrency = Money.getDefaultCurrency();
Money.setDefaultCurrency(TestUtils.RUPEE);
savingsServiceFacade = new SavingsServiceFacadeWebTier(savingsDao, savingsProductDao, personnelDao, customerDao, holidayDao);
((SavingsServiceFacadeWebTier) savingsServiceFacade).setSavingsInterestScheduledEventFactory(savingsInterestScheduledEventFactory);
((SavingsServiceFacadeWebTier) savingsServiceFacade).setTransactionHelper(transactionHelper);
MifosUser principal = new MifosUserBuilder().build();
SecurityContext securityContext = SecurityContextHolder.getContext();
if (securityContext == null) {
securityContext = new SecurityContextImpl();
SecurityContextHolder.setContext(securityContext);
}
if (securityContext.getAuthentication() == null || !securityContext.getAuthentication().isAuthenticated()) {
Authentication authentication = new UsernamePasswordAuthenticationToken(principal, principal, principal.getAuthorities());
securityContext.setAuthentication(authentication);
}
}
use of org.springframework.security.core.context.SecurityContext in project head by mifos.
the class EditCustomerStatusActionStrutsTest method setUp.
@Before
public void setUp() throws Exception {
UserContext userContext = TestObjectFactory.getContext();
request.getSession().setAttribute(Constants.USER_CONTEXT_KEY, userContext);
addRequestParameter("recordLoanOfficerId", "1");
addRequestParameter("recordOfficeId", "1");
request.getSession(false).setAttribute("ActivityContext", TestObjectFactory.getActivityContext());
flowKey = createFlow(request, EditCustomerStatusAction.class);
addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
SecurityContext securityContext = new SecurityContextImpl();
MifosUser principal = new MifosUserBuilder().nonLoanOfficer().withAdminRole().build();
Authentication authentication = new TestingAuthenticationToken(principal, principal);
securityContext.setAuthentication(authentication);
SecurityContextHolder.setContext(securityContext);
}
use of org.springframework.security.core.context.SecurityContext in project head by mifos.
the class MifosMockStrutsTestCase method beforeStrutsTest.
@Before
public void beforeStrutsTest() throws Exception {
mockStruts.setUp();
if (!strutsConfigSet) {
setStrutsConfig();
strutsConfigSet = true;
}
getActionServlet().getServletContext().setAttribute(ShutdownManager.class.getName(), new ShutdownManager());
SecurityContext securityContext = new SecurityContextImpl();
MifosUser principal = new MifosUserBuilder().build();
Authentication authentication = new TestingAuthenticationToken(principal, principal);
securityContext.setAuthentication(authentication);
SecurityContextHolder.setContext(securityContext);
}
use of org.springframework.security.core.context.SecurityContext in project head by mifos.
the class PersonnelNoteActionStrutsTest method testSuccessCreatePersonnelNote.
@Test
public void testSuccessCreatePersonnelNote() throws Exception {
SecurityContext securityContext = new SecurityContextImpl();
MifosUser principal = new MifosUserBuilder().nonLoanOfficer().withAdminRole().build();
Authentication authentication = new TestingAuthenticationToken(principal, principal);
securityContext.setAuthentication(authentication);
SecurityContextHolder.setContext(securityContext);
createPersonnelAndSetInSession(getBranchOffice(), PersonnelLevel.LOAN_OFFICER);
setRequestPathInfo("/personnelNoteAction.do");
addRequestParameter("method", Methods.create.toString());
addRequestParameter("personnelId", personnel.getPersonnelId().toString());
addRequestParameter("comment", "Test");
addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
actionPerform();
verifyForward(ActionForwards.create_success.toString());
verifyNoActionErrors();
verifyNoActionMessages();
}
Aggregations