163164165166167168169170171172173
// Validate field values try { if (PdpScanner.projects.containsKey(name)) { throw new BadProjectNameException(name, "Project name already exists"); } else { Validator.validateProject(name, svnUrl, svnUser, svnPassword);
4344454647484950515253
} // Validate name if (name.contains(" ")) { throw new BadProjectNameException(name, "Project name contains spaces"); } // Validate repository auth if (svnUser.isEmpty() != svnPassword.isEmpty()) {
505152535455565758
} // Validate repository auth if (svnUser.isEmpty() != svnPassword.isEmpty()) { throw new BadReposAuthException(svnUser, svnPassword, "Empty repository user or password"); } }
123124125126127128129130131132133
try { SVNURL.parseURIDecoded(svnUrl); } catch (SVNException e) { throw new BadReposUrlException(svnUrl, "Invalid repository url format"); } try { checkProjectRepository(svnUrl, svnUser, svnPassword);
124125126127128129130131132133134
String s = rs.getString("username"); if (s.equals(username)) { throw new BadUsernameException(username, "Username already exists"); } } String passwordHash = BCrypt.hashpw(password, BCrypt.gensalt());
200201202203204205206207208209210
userId = Integer.parseInt((String) getThreadLocalRequest() .getSession().getAttribute("id")); } else { throw new InvalidSessionException(); } MySQLConnection conn = new MySQLConnection(); conn.connect();
244245246247248249250251252253254
196197198199200201202203
} return null; } else { throw new InvalidSessionException(); } }
189190191192193194195196197198199
+ UserRole.OWNER.code() + ")"); conn.disconnect(); } catch (SVNException e) { throw new RepositoryException(svnUrl, svnUser, svnPassword, "Project repository couldn't be reached (svn info)"); } return null; } else {
3738394041424344454647
public static void validateProject(String name, String svnUrl, String svnUser, String svnPassword) throws Exception { if (!validateEmptyFields(name, svnUrl)) { throw new RequiredFieldException(); } // Validate name if (name.contains(" ")) {