dev
rekoe 2020-01-12 21:04:21 +08:00
parent 148b07ee11
commit ee60d2892d
3 changed files with 29 additions and 100 deletions

View File

@ -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: {

View File

@ -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 {
/**
* svnsvnserve.conf
*
* @param pj
*
* @param pj
*/
private void exportSvnConf(Pj pj) {
if (pj == null || StringUtils.isBlank(pj.getPj())) {
@ -444,8 +411,7 @@ public class SvnService {
/**
* httphttpd.conf
*
* @param pj
*
* @param pj
*/
private void exportSVNPathConf(Pj pj) {
if (pj == null || StringUtils.isBlank(pj.getPj())) {
@ -478,11 +444,10 @@ public class SvnService {
/**
* httphttpd.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);
}
}

View File

@ -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) {