mirror of https://github.com/Rekoe/rk_svnadmin
dev
parent
148b07ee11
commit
ee60d2892d
|
@ -102,7 +102,7 @@ public class AdminSvnUserAct extends BaseAction {
|
|||
boolean isEmail = Strings.isEmail(user.getEmail());
|
||||
if (isOk && isEmail) {
|
||||
user.setPsw(EncryptUtil.encrypt(R.UU64().substring(0, 10)));
|
||||
user.setPsw("123456");
|
||||
user.setPsw(EncryptUtil.encrypt("123456"));
|
||||
SVNRoleType role = user.getRole();
|
||||
switch (role) {
|
||||
case admin: {
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
package com.rekoe.service;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
|
@ -15,6 +11,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Files;
|
||||
import org.nutz.log.Log;
|
||||
import org.nutz.log.Logs;
|
||||
|
||||
|
@ -62,8 +59,7 @@ public class SvnService {
|
|||
/**
|
||||
* 导出到配置文件
|
||||
*
|
||||
* @param pj
|
||||
* 项目id
|
||||
* @param pj 项目id
|
||||
*/
|
||||
public synchronized void exportConfig(String pj) {
|
||||
this.exportConfig(projectService.fetch(Cnd.where("pj", "=", pj)));
|
||||
|
@ -72,8 +68,7 @@ public class SvnService {
|
|||
/**
|
||||
* 导出到配置文件
|
||||
*
|
||||
* @param pj
|
||||
* 项目
|
||||
* @param pj 项目
|
||||
*/
|
||||
public synchronized void exportConfig(Pj pj) {
|
||||
if (pj == null) {
|
||||
|
@ -100,8 +95,7 @@ public class SvnService {
|
|||
/**
|
||||
* 导出svn协议的配置信息
|
||||
*
|
||||
* @param pj
|
||||
* 项目
|
||||
* @param pj 项目
|
||||
*/
|
||||
private void exportSVN(Pj pj) {
|
||||
// 项目的用户
|
||||
|
@ -118,8 +112,7 @@ public class SvnService {
|
|||
/**
|
||||
* 导出http(单库)的配置信息
|
||||
*
|
||||
* @param pj
|
||||
* 项目
|
||||
* @param pj 项目
|
||||
*/
|
||||
private void exportHTTP(Pj pj) {
|
||||
// 项目的用户
|
||||
|
@ -136,8 +129,7 @@ public class SvnService {
|
|||
/**
|
||||
* 导出http(多库)的配置信息
|
||||
*
|
||||
* @param root
|
||||
* svn root
|
||||
* @param root svn root
|
||||
*/
|
||||
private void exportHTTPMutil(File root) {
|
||||
String svnRoot = StringUtils.replace(root.getAbsolutePath(), "\\", "/");
|
||||
|
@ -158,8 +150,7 @@ public class SvnService {
|
|||
/**
|
||||
* 获取有相同svn root的项目的权限列表
|
||||
*
|
||||
* @param rootPath
|
||||
* svn root
|
||||
* @param rootPath svn root
|
||||
* @return 有相同svn root的项目的权限列表
|
||||
*/
|
||||
private Map<String, List<PjAuth>> getPjAuthsByRootPath(String rootPath) {
|
||||
|
@ -180,8 +171,7 @@ public class SvnService {
|
|||
/**
|
||||
* 获取项目的权限列表
|
||||
*
|
||||
* @param pj
|
||||
* 项目
|
||||
* @param pj 项目
|
||||
* @return 项目的权限列表
|
||||
*/
|
||||
private Map<String, List<PjAuth>> getPjAuths(String pj) {
|
||||
|
@ -203,8 +193,7 @@ public class SvnService {
|
|||
/**
|
||||
* 获取项目的组列表
|
||||
*
|
||||
* @param pj
|
||||
* 项目
|
||||
* @param pj 项目
|
||||
* @return 项目的组列表
|
||||
*/
|
||||
private Map<String, List<PjGrUsr>> getPjGrUsrs(String pj) {
|
||||
|
@ -225,8 +214,7 @@ public class SvnService {
|
|||
/**
|
||||
* 获取有相同svn root的项目的权限列表
|
||||
*
|
||||
* @param rootPath
|
||||
* svn root
|
||||
* @param rootPath svn root
|
||||
* @return 有相同svn root的项目的权限列表
|
||||
*/
|
||||
private Map<String, List<PjGrUsr>> getPjGrUsrsByRootPath(String rootPath) {
|
||||
|
@ -250,17 +238,13 @@ public class SvnService {
|
|||
/**
|
||||
* 输出http多库方式的密码文件
|
||||
*
|
||||
* @param root
|
||||
* svn root
|
||||
* @param usrList
|
||||
* 所有用户列表
|
||||
* @param root svn root
|
||||
* @param usrList 所有用户列表
|
||||
*/
|
||||
private void exportPasswdHTTPMutil(File root, List<Usr> usrList) {
|
||||
File outFile = new File(root, "passwd.http");
|
||||
StringBuffer contents = new StringBuffer();
|
||||
for (Usr usr : usrList) {
|
||||
// 采用SHA加密
|
||||
// http://httpd.apache.org/docs/2.2/misc/password_encryptions.html
|
||||
String shaPsw = "{SHA}" + EncryptUtil.encriptSHA1(EncryptUtil.decrypt(usr.getPsw()));
|
||||
contents.append(usr.getUsr()).append(":").append(shaPsw).append(SEP);
|
||||
}
|
||||
|
@ -270,18 +254,14 @@ public class SvnService {
|
|||
/**
|
||||
* 输出http单库方式的密码文件
|
||||
*
|
||||
* @param pj
|
||||
* 项目
|
||||
* @param usrList
|
||||
* 项目用户列表
|
||||
* @param pj 项目
|
||||
* @param usrList 项目用户列表
|
||||
*/
|
||||
private void exportPasswdHTTP(Pj pj, List<Usr> usrList) {
|
||||
String path = projectConfigService.getRepoPath(pj);
|
||||
File outFile = new File(path, "/conf/passwd.http");
|
||||
StringBuffer contents = new StringBuffer();
|
||||
for (Usr usr : usrList) {
|
||||
// 采用SHA加密
|
||||
// http://httpd.apache.org/docs/2.2/misc/password_encryptions.html
|
||||
String shaPsw = "{SHA}" + EncryptUtil.encriptSHA1(EncryptUtil.decrypt(usr.getPsw()));
|
||||
contents.append(usr.getUsr()).append(":").append(shaPsw).append(SEP);
|
||||
}
|
||||
|
@ -292,13 +272,12 @@ public class SvnService {
|
|||
String shaPsw = "admin:{SHA}" + EncryptUtil.encriptSHA1(EncryptUtil.decrypt("123456"));
|
||||
System.out.println(shaPsw);
|
||||
}
|
||||
|
||||
/**
|
||||
* 输出svn方式的密码文件
|
||||
*
|
||||
* @param pj
|
||||
* 项目
|
||||
* @param usrList
|
||||
* 项目用户列表
|
||||
* @param pj 项目
|
||||
* @param usrList 项目用户列表
|
||||
*/
|
||||
private void exportPasswdSVN(Pj pj, List<Usr> usrList) {
|
||||
String path = projectConfigService.getRepoPath(pj);
|
||||
|
@ -314,12 +293,9 @@ public class SvnService {
|
|||
/**
|
||||
* 输出http多库方式的权限文件
|
||||
*
|
||||
* @param root
|
||||
* svn root
|
||||
* @param pjGrUsrMap
|
||||
* 所有的项目组用户列表
|
||||
* @param resMap
|
||||
* 所有的权限列表
|
||||
* @param root svn root
|
||||
* @param pjGrUsrMap 所有的项目组用户列表
|
||||
* @param resMap 所有的权限列表
|
||||
*/
|
||||
private void exportAuthzHTTPMutil(File root, Map<String, List<PjGrUsr>> pjGrUsrMap, Map<String, List<PjAuth>> resMap) {
|
||||
if (root == null) {
|
||||
|
@ -352,7 +328,6 @@ public class SvnService {
|
|||
contents.append(res).append(SEP);
|
||||
for (PjAuth pjAuth : resMap.get(res)) {
|
||||
if (StringUtils.isNotBlank(pjAuth.getGr())) {
|
||||
// 项目ID_组ID see: Issue 4
|
||||
contents.append("@").append(pjAuth.getPj() + "_" + pjAuth.getGr()).append("=").append(pjAuth.getRw()).append(SEP);
|
||||
} else if (StringUtils.isNotBlank(pjAuth.getUsr())) {
|
||||
contents.append(pjAuth.getUsr()).append("=").append(pjAuth.getRw()).append(SEP);
|
||||
|
@ -366,21 +341,14 @@ public class SvnService {
|
|||
/**
|
||||
* 输出权限配置文件
|
||||
*
|
||||
* @param pj
|
||||
* 项目
|
||||
* @param pjGrUsrMap
|
||||
* 项目的组列表
|
||||
* @param resMap
|
||||
* 项目的权限列表
|
||||
* @param pj 项目
|
||||
* @param pjGrUsrMap 项目的组列表
|
||||
* @param resMap 项目的权限列表
|
||||
*/
|
||||
private void exportAuthz(Pj pj, Map<String, List<PjGrUsr>> pjGrUsrMap, Map<String, List<PjAuth>> resMap) {
|
||||
if (pj == null || StringUtils.isBlank(pj.getPj())) {
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* if(pjGrList == null || pjGrList.size() == 0){ return; } if(pjAuthMap
|
||||
* == null || pjAuthMap.size() == 0){ return; }
|
||||
*/
|
||||
String path = projectConfigService.getRepoPath(pj);
|
||||
File outFile = new File(path, "/conf/authz");
|
||||
StringBuffer contents = new StringBuffer();
|
||||
|
@ -422,8 +390,7 @@ public class SvnService {
|
|||
/**
|
||||
* 输出svn方式的svnserve.conf
|
||||
*
|
||||
* @param pj
|
||||
* 项目
|
||||
* @param pj 项目
|
||||
*/
|
||||
private void exportSvnConf(Pj pj) {
|
||||
if (pj == null || StringUtils.isBlank(pj.getPj())) {
|
||||
|
@ -444,8 +411,7 @@ public class SvnService {
|
|||
/**
|
||||
* 输出http单库方式的httpd.conf文件
|
||||
*
|
||||
* @param pj
|
||||
* 项目
|
||||
* @param pj 项目
|
||||
*/
|
||||
private void exportSVNPathConf(Pj pj) {
|
||||
if (pj == null || StringUtils.isBlank(pj.getPj())) {
|
||||
|
@ -478,11 +444,10 @@ public class SvnService {
|
|||
/**
|
||||
* 输出http多库方式的httpd.conf文件
|
||||
*
|
||||
* @param root
|
||||
* svn root
|
||||
* @param root svn root
|
||||
*/
|
||||
private void exportSVNParentPathConf(File root) {
|
||||
String svnRoot = StringUtils.replace(root.getAbsolutePath(), "\\", "/");
|
||||
String svnRoot = "/home/svn";//StringUtils.replace(root.getAbsolutePath(), "\\", "/");
|
||||
File outFile = new File(root, "httpd.conf");
|
||||
StringBuffer contents = new StringBuffer();
|
||||
contents.append("#Include ").append(svnRoot).append("/httpd.conf").append(SEP);
|
||||
|
@ -501,42 +466,7 @@ public class SvnService {
|
|||
this.write(outFile, contents.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* 写文件流
|
||||
*
|
||||
* @param outFile
|
||||
* 输出文件
|
||||
* @param contents
|
||||
* 内容
|
||||
*/
|
||||
private void write(File outFile, String contents) {
|
||||
BufferedWriter writer = null;
|
||||
try {
|
||||
if (contents == null) {
|
||||
contents = "";
|
||||
}
|
||||
if (!outFile.getParentFile().exists()) {
|
||||
outFile.getParentFile().mkdirs();
|
||||
}
|
||||
writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outFile), "UTF-8"));// UTF-8
|
||||
writer.write(contents);
|
||||
LOG.debug(outFile);
|
||||
} catch (Exception e) {
|
||||
LOG.error(e);
|
||||
throw new RuntimeException(e.getMessage());
|
||||
} finally {
|
||||
if (writer != null) {
|
||||
try {
|
||||
writer.flush();
|
||||
} catch (IOException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
try {
|
||||
writer.close();
|
||||
} catch (IOException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Files.write(outFile, contents);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,7 +64,6 @@ public class DoCommit {
|
|||
}
|
||||
}
|
||||
svnPassword = EncryptUtil.decrypt(svnPassword);// 解密
|
||||
svnPassword = "123456";
|
||||
SVNURL[] urlAr = new SVNURL[dirs.length];
|
||||
int i = 0;
|
||||
for (String url : dirs) {
|
||||
|
|
Loading…
Reference in New Issue