use of org.mifos.security.MifosUser in project head by mifos.
the class RolesPermissionServiceFacadeWebTier method hasUserAccessForActivity.
@Override
public boolean hasUserAccessForActivity(Short activityID) throws Exception {
boolean result = false;
MifosUser mifosUser = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
try {
for (Short roleId : mifosUser.getRoleIds()) {
RoleBO role = legacyRolesPermissionsDao.getRole(roleId);
if (role.getActivityIds().contains(activityID) || null == activityID) {
result = true;
break;
}
}
} catch (PersistenceException e) {
throw new RolesPermissionException(e);
}
return result;
}
use of org.mifos.security.MifosUser in project head by mifos.
the class MifosDaoAuthenticationProvider method additionalAuthenticationChecks.
@Override
protected void additionalAuthenticationChecks(UserDetails userDetails, UsernamePasswordAuthenticationToken authentication) throws AuthenticationException {
MifosUser user = (MifosUser) userDetails;
if (authentication.getCredentials() == null) {
throw new BadCredentialsException(messages.getMessage("AbstractUserDetailsAuthenticationProvider.badCredentials", "Bad credentials"));
}
String presentedPassword = authentication.getCredentials().toString();
boolean isPasswordValid = passwordHashing.verifyPassword(presentedPassword, user.getPasswordAsBytes());
if (!isPasswordValid) {
throw new BadCredentialsException(messages.getMessage("AbstractUserDetailsAuthenticationProvider.badCredentials", "Bad credentials"));
}
}
use of org.mifos.security.MifosUser in project head by mifos.
the class RepayLoanActionStrutsTest 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.mifos.security.MifosUser in project head by mifos.
the class ApplyAdjustmentActionStrutsTest method setUpSecurityContext.
private void setUpSecurityContext() {
SecurityContext securityContext = new SecurityContextImpl();
MifosUser mifosUser = new MifosUserBuilder().nonLoanOfficer().withAdminRole().build();
Authentication authentication = new TestingAuthenticationToken(mifosUser, mifosUser);
securityContext.setAuthentication(authentication);
SecurityContextHolder.setContext(securityContext);
}
use of org.mifos.security.MifosUser in project head by mifos.
the class ApplyChargeActionStrutsTest method testUpdateSuccess.
@Test
public void testUpdateSuccess() {
SecurityContext securityContext = new SecurityContextImpl();
MifosUser principal = new MifosUserBuilder().nonLoanOfficer().withAdminRole().build();
Authentication authentication = new TestingAuthenticationToken(principal, principal);
securityContext.setAuthentication(authentication);
SecurityContextHolder.setContext(securityContext);
request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
createInitialObjects();
accountBO = getLoanAccount(client, meeting);
setRequestPathInfo("/applyChargeAction.do");
addRequestParameter("method", "update");
addRequestParameter("chargeType", IS_PENALTY_TYPE + ":" + FEE_ID + ":" + IS_NOT_RATE_TYPE);
addRequestParameter("charge", "18");
addRequestParameter("accountId", accountBO.getAccountId().toString());
addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
actionPerform();
// verifyForward("loanDetails_success");
verifyNoActionErrors();
verifyNoActionMessages();
}
Aggregations