public String getUserId() { if (user != null) { return user.getId(); } else { return null; } }
public String getUserId() { if (user != null) { return user.getId(); } else { return null; } }
public String getUserId(){ return user.getId(); }
public String getUserId(){ return user.getId(); }
/** * @return true if the passed-in user is currently authenticated */ protected boolean isAuthenticatedUser(UserEntity user) { if(user.getId() == null) { return false; } return user.getId().equalsIgnoreCase(org.camunda.bpm.engine.impl.context.Context.getCommandContext().getAuthenticatedUserId()); }
protected Void executeCmd(CommandContext commandContext) { ensureNotNull("user", user); ensureWhitelistedResourceId(commandContext, "User", user.getId()); commandContext .getWritableIdentityProvider() .saveUser(user); return null; } }
protected Void executeCmd(CommandContext commandContext) { ensureNotNull("user", user); ensureWhitelistedResourceId(commandContext, "User", user.getId()); commandContext .getWritableIdentityProvider() .saveUser(user); return null; } }
UserEntity userEntity = em.find(UserEntity.class, id); UserDTO userDTO = new UserDTO(); userDTO.setId(userEntity.getId()); userDTO.setName(userEntity.getName()); // ... return userDTO;
protected boolean isUserLocked(UserEntity user) { ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration(); int maxAttempts = processEngineConfiguration.getLoginMaxAttempts(); int attempts = user.getAttempts(); if (attempts >= maxAttempts) { throw new AuthenticationException(user.getId()); } Date lockExpirationTime = user.getLockExpirationTime(); Date currentTime = ClockUtil.getCurrentTime(); return lockExpirationTime != null && lockExpirationTime.after(currentTime); }
protected boolean isUserLocked(UserEntity user) { ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration(); int maxAttempts = processEngineConfiguration.getLoginMaxAttempts(); int attempts = user.getAttempts(); if (attempts >= maxAttempts) { throw new AuthenticationException(user.getId()); } Date lockExpirationTime = user.getLockExpirationTime(); Date currentTime = ClockUtil.getCurrentTime(); return lockExpirationTime != null && lockExpirationTime.after(currentTime); }
String userId = user.getId();
public String getUserId() { if (user != null) { return user.getId(); } else { return null; } }
public String getUserId(){ return user.getId(); }
/** * @return true if the passed-in user is currently authenticated */ protected boolean isAuthenticatedUser(UserEntity user) { if(user.getId() == null) { return false; } return user.getId().equalsIgnoreCase(org.camunda.bpm.engine.impl.context.Context.getCommandContext().getAuthenticatedUserId()); }
@Override public UserEntity mapToEntity(ODocument doc, UserEntity entity, OPersistenceSession session) { UserEntity ret = super.mapToEntity(doc, entity, session); ret.setFirstName(ret.getId()); //TODO: Extend OUser return ret; }
@Service @Transactional public class UserLoginService implements UserDetailsService { @Autowired private UserService userService; @Override public UserDetails loadUserByUsername(String userId) throws UsernameNotFoundException { UserEntity userEntity = this.userService.getUserByUserId(userId); if (userEntity == null) { throw new UsernameNotFoundException("User not found"); } UserLoginBean bean = new UserLoginBean(userEntity.getId(), userEntity.getUserId(), userEntity.getPassword(), userEntity.getEnabled()); bean.setFullname(userEntity.getFullname()); bean.setUserEntity(userEntity); Set<GrantedAuthority> roles = new HashSet<GrantedAuthority>(); roles.add( new SimpleGrantedAuthority( userEntity.getRole() ) ); bean.setAuthorities(roles); return bean; } }
protected Void executeCmd(CommandContext commandContext) { ensureNotNull("user", user); ensureWhitelistedResourceId(commandContext, "User", user.getId()); commandContext .getWritableIdentityProvider() .saveUser(user); return null; } }
protected boolean isUserLocked(UserEntity user) { ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration(); int maxAttempts = processEngineConfiguration.getLoginMaxAttempts(); int attempts = user.getAttempts(); if (attempts >= maxAttempts) { throw new AuthenticationException(user.getId()); } Date lockExpirationTime = user.getLockExpirationTime(); Date currentTime = ClockUtil.getCurrentTime(); return lockExpirationTime != null && lockExpirationTime.after(currentTime); }
identityService.unlockUser(lockedUser.getId()); fail("expected exception"); } catch (AuthorizationException e) {
public void testUserUnlock() throws ParseException { // crate user while still in god-mode: String userId = "jonny"; User jonny = identityService.newUser(userId); jonny.setPassword("xxx"); identityService.saveUser(jonny); lockUser(userId, "invalid pwd"); // assume int maxNumOfAttempts = 10; UserEntity lockedUser = (UserEntity) identityService.createUserQuery().userId(jonny.getId()).singleResult(); assertNotNull(lockedUser); assertNotNull(lockedUser.getLockExpirationTime()); assertEquals(maxNumOfAttempts, lockedUser.getAttempts()); // create global auth Authorization basePerms = authorizationService.createNewAuthorization(AUTH_TYPE_GLOBAL); basePerms.setResource(USER); basePerms.setResourceId(ANY); basePerms.addPermission(ALL); authorizationService.saveAuthorization(basePerms); // set auth processEngineConfiguration.setAuthorizationEnabled(true); identityService.setAuthentication("admin", Collections.singletonList(Groups.CAMUNDA_ADMIN), null); // when identityService.unlockUser(lockedUser.getId()); // then lockedUser = (UserEntity) identityService.createUserQuery().userId(jonny.getId()).singleResult(); assertNotNull(lockedUser); assertNull(lockedUser.getLockExpirationTime()); assertEquals(0, lockedUser.getAttempts()); }