@Test public void testCreateUser() throws Exception { NexusSecurityTestCaseSupport.copyFile(tempTestDir, "conf", "apache-passwd"); final RemoteUserTokenAuthPluginConfiguration tokenAuthPluginConfiguration = mock(RemoteUserTokenAuthPluginConfiguration.class); when(tokenAuthPluginConfiguration.getUserFile()).thenReturn(new File(tempTestDir, "conf/apache-passwd")); when(tokenAuthPluginConfiguration.getRefreshInterval()).thenReturn(60); ApachePasswdUserDao tokenAuthUserDao = new ApachePasswdUserDao(tokenAuthPluginConfiguration); tokenAuthUserDao.enableLogging(new Slf4jPlexusLogger(LoggerFactory.getLogger(getClass()))); tokenAuthUserDao.initialize(); assertFalse(tokenAuthUserDao.userExists("dalquista")); tokenAuthUserDao.createUser("dalquista"); assertTrue(tokenAuthUserDao.userExists("dalquista")); }
@Override public void createUser(String userId) { if (this.userExists(userId)) { this.getLogger().warn("Not creating user " + userId + " they already exist"); return; } final String passwordToken = MD5Crypt.createRandomSalt(16); final String encryptedPassword = MD5Crypt.apacheCrypt(passwordToken); final TokenAuthUser user = this.createTokenAuthUser(userId, encryptedPassword, passwordToken); this.userMap.put(userId, user); this.userSet.add(user); this.getLogger().info("Created user: " + userId); this.refreshConfiguration(); }
ApachePasswdUserDao extends AbstractRefreshingFileLoader<Set<TokenAuthUser>> implements UserDao, Initializable, Disposable { @Override public void createUser(String userId) { if (this.userExists(userId)) { this.getLogger().warn("Not creating user " + userId + " they already exist"); return; } final String passwordToken = MD5Crypt.createRandomSalt(16); final String encryptedPassword = MD5Crypt.apacheCrypt(passwordToken); final TokenAuthUser user = this.createTokenAuthUser(userId, encryptedPassword, passwordToken); this.userMap.put(userId, user); this.userSet.add(user); this.getLogger().info("Created user: " + userId); this.refreshConfiguration(); } }
ApachePasswdUserDao extends AbstractRefreshingFileLoader<Set<TokenAuthUser>> implements UserDao, Initializable, Disposable { @Override public void createUser(String userId) { if (this.userExists(userId)) { this.getLogger().warn("Not creating user " + userId + " they already exist"); return; } final String passwordToken = MD5Crypt.createRandomSalt(16); final String encryptedPassword = MD5Crypt.apacheCrypt(passwordToken); final TokenAuthUser user = this.createTokenAuthUser(userId, encryptedPassword, passwordToken); this.userMap.put(userId, user); this.userSet.add(user); this.getLogger().info("Created user: " + userId); this.refreshConfiguration(); } ApachePasswdUserDao();   ApachePasswdUserDao(RemoteUserTokenAuthPluginConfiguration tokenAuthPluginConfiguration); }
ApachePasswdUserDao extends AbstractRefreshingFileLoader<Set<TokenAuthUser>> implements UserDao, Initializable, Disposable { @Override public void createUser(String userId) { if (this.userExists(userId)) { this.getLogger().warn("Not creating user " + userId + " they already exist"); return; } final String passwordToken = MD5Crypt.createRandomSalt(16); final String encryptedPassword = MD5Crypt.apacheCrypt(passwordToken); final TokenAuthUser user = this.createTokenAuthUser(userId, encryptedPassword, passwordToken); this.userMap.put(userId, user); this.userSet.add(user); this.getLogger().info("Created user: " + userId); this.refreshConfiguration(); } ApachePasswdUserDao();   ApachePasswdUserDao(RemoteUserTokenAuthPluginConfiguration tokenAuthPluginConfiguration); @Override String getUserPasswordToken(String userId); @Override Set<String> listUserIds(); @Override Set<User> listUsers(); @Override User getUser(String userId); @Override void createUser(String userId); @Override boolean userExists(String userId); }
ApachePasswdUserDao extends AbstractRefreshingFileLoader<Set<TokenAuthUser>> implements UserDao, Initializable, Disposable { @Override public void createUser(String userId) { if (this.userExists(userId)) { this.getLogger().warn("Not creating user " + userId + " they already exist"); return; } final String passwordToken = MD5Crypt.createRandomSalt(16); final String encryptedPassword = MD5Crypt.apacheCrypt(passwordToken); final TokenAuthUser user = this.createTokenAuthUser(userId, encryptedPassword, passwordToken); this.userMap.put(userId, user); this.userSet.add(user); this.getLogger().info("Created user: " + userId); this.refreshConfiguration(); } ApachePasswdUserDao();   ApachePasswdUserDao(RemoteUserTokenAuthPluginConfiguration tokenAuthPluginConfiguration); @Override String getUserPasswordToken(String userId); @Override Set<String> listUserIds(); @Override Set<User> listUsers(); @Override User getUser(String userId); @Override void createUser(String userId); @Override boolean userExists(String userId); static final String ROLE_NAME; }