dev
rekoe 2020-01-12 16:39:38 +08:00
parent f34f706643
commit 2ae411c8e4
15 changed files with 4465 additions and 246 deletions

View File

@ -1,5 +1,9 @@
#Sun Jan 12 10:00:36 CST 2020
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.source=1.8
org.eclipse.jdt.core.compiler.codegen.methodParameters=generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8

4370
nutz.log

File diff suppressed because it is too large Load Diff

View File

@ -12,7 +12,6 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<nutzboot.version>2.3.9-SNAPSHOT</nutzboot.version>
<nutz.version>1.r.68-SNAPSHOT</nutz.version>
<axe.version>1.5</axe.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencyManagement>
@ -45,7 +44,7 @@
<dependency>
<groupId>ch.ethz.ganymed</groupId>
<artifactId>ganymed-ssh2</artifactId>
<version>build210</version>
<version>262</version>
</dependency>
<dependency>
<groupId>org.nutz</groupId>

View File

@ -22,7 +22,6 @@ import org.nutz.lang.Each;
import org.nutz.lang.ExitLoop;
import org.nutz.lang.Lang;
import org.nutz.lang.LoopException;
import org.nutz.mvc.Mvcs;
import org.nutz.mvc.annotation.Encoding;
import org.nutz.mvc.annotation.Fail;
import org.nutz.mvc.annotation.IocBy;
@ -58,11 +57,11 @@ import com.rekoe.web.freemarker.TimeFormatDirective;
import freemarker.template.SimpleHash;
@IocBean(create = "init")
@IocBy(args = { "*slog" })
@Fail(">>:/admin/common/unauthorized.rk")
@Encoding(input = "UTF-8", output = "UTF-8")
@Localization(value = "msg/", defaultLocalizationKey = "zh-CN")
@IocBean(create = "init")
@IocBy(args = { "*slog" })
public class CloudLauncher {
@Inject

View File

@ -1,5 +1,7 @@
package com.rekoe.domain;
import java.io.Serializable;
import org.nutz.dao.entity.annotation.ColDefine;
import org.nutz.dao.entity.annotation.Comment;
import org.nutz.dao.entity.annotation.Index;
@ -10,8 +12,12 @@ import org.nutz.dao.entity.annotation.TableIndexes;
@Table("pj_gr_auth")
@PK({ "pj", "res", "gr" })
@TableIndexes({ @Index(name = "FK_Reference_6", fields = { "pj", "gr" }, unique = false) })
public class PjGrAuth {
public class PjGrAuth implements Serializable{
/**
*
*/
private static final long serialVersionUID = 5801319002448310527L;
@Comment
private String pj;
@Comment

View File

@ -1,5 +1,7 @@
package com.rekoe.domain;
import java.io.Serializable;
import org.nutz.dao.entity.annotation.ColDefine;
import org.nutz.dao.entity.annotation.Comment;
import org.nutz.dao.entity.annotation.Index;
@ -10,8 +12,9 @@ import org.nutz.dao.entity.annotation.TableIndexes;
@Table("pj_usr_auth")
@PK({ "pj", "res", "usr" })
@TableIndexes({ @Index(name = "FK_Reference_8", fields = { "usr" }, unique = false) })
public class PjUsrAuth {
public class PjUsrAuth implements Serializable{
private static final long serialVersionUID = 6040417861883996978L;
@Comment
private String pj;
@Comment

View File

@ -102,6 +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");
SVNRoleType role = user.getRole();
switch (role) {
case admin: {

View File

@ -3,15 +3,13 @@ package com.rekoe.service;
import java.io.File;
import java.util.Map;
import org.apache.commons.mail.HtmlEmail;
import org.apache.commons.mail.ImageHtmlEmail;
import org.nutz.boot.starter.freemarker.FreeMarkerConfigurer;
import org.nutz.ioc.Ioc;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.log.Log;
import org.nutz.log.Logs;
import freemarker.template.Configuration;
import freemarker.template.Template;
@IocBean(name = "emailService")
@ -19,20 +17,19 @@ public class EmailServiceImpl implements EmailService {
private static final Log log = Logs.get();
@Inject("refer:$ioc")
protected Ioc ioc;
@Inject
protected ImageHtmlEmail imageHtmlEmail;
@Inject
private FreeMarkerConfigurer freeMarkerConfigurer;
public boolean send(String to, String subject, String templateFile, Map<String, Object> root) {
try {
HtmlEmail email = ioc.get(HtmlEmail.class);
email.setCharset("UTF-8");
email.setSubject(subject);
email.setHtmlMsg(processTemplateIntoString(templateFile, root));
email.addTo(to);
String res = email.send();
imageHtmlEmail.setCharset("UTF-8");
imageHtmlEmail.setSubject(subject);
imageHtmlEmail.setHtmlMsg(processTemplateIntoString(templateFile, root));
imageHtmlEmail.addTo(to);
String res = imageHtmlEmail.send();
if (log.isDebugEnabled()) {
log.debug(res);
}

View File

@ -35,8 +35,9 @@ public class ProjectConfigService extends BaseService<ProjectConfig> {
dao().update(conf);
return true;
}
public int update(ProjectConfig conf) {
return dao().update(conf);
public boolean update(ProjectConfig conf) {
dao().update(conf);
return true;
}
public void init() {

View File

@ -124,6 +124,7 @@ public class RepositoryService {
}
}
svnPassword = EncryptUtil.decrypt(svnPassword);// 解密
System.out.println(svnPassword);
SVNRepository repository = SVNRepositoryFactory.create(SVNURL.parseURIDecoded(svnUrl));
ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(svnUserName, svnPassword);
repository.setAuthenticationManager(authManager);
@ -159,7 +160,7 @@ public class RepositoryService {
}
public boolean svnMkDirs(SVNURL[] urls) {
ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager("admin", "john");
ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager("admin", "123456".toCharArray());
SVNClientManager manager = SVNClientManager.newInstance();
manager.setAuthenticationManager(authManager);
SVNCommitClient commitClient = SVNClientManager.newInstance().getCommitClient();
@ -181,7 +182,7 @@ public class RepositoryService {
}
public static void main(String[] args) throws SVNException {
ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager("admin", "123456");
ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager("admin", "123456".toCharArray());
SVNClientManager manager = SVNClientManager.newInstance(SVNWCUtil.createDefaultOptions(true), authManager);
SVNCommitClient commitClient = manager.getCommitClient();
commitClient.getDebugLog();

View File

@ -17,7 +17,6 @@ import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.log.Log;
import org.nutz.log.Logs;
import org.nutz.repo.Base64;
import com.rekoe.domain.Pj;
import com.rekoe.domain.PjAuth;
@ -26,9 +25,6 @@ import com.rekoe.domain.Usr;
import com.rekoe.utils.Constants;
import com.rekoe.utils.EncryptUtil;
import cn.hutool.crypto.digest.DigestAlgorithm;
import cn.hutool.crypto.digest.DigestUtil;
/**
* svn
*
@ -66,7 +62,8 @@ public class SvnService {
/**
*
*
* @param pj id
* @param pj
* id
*/
public synchronized void exportConfig(String pj) {
this.exportConfig(projectService.fetch(Cnd.where("pj", "=", pj)));
@ -75,7 +72,8 @@ public class SvnService {
/**
*
*
* @param pj
* @param pj
*
*/
public synchronized void exportConfig(Pj pj) {
if (pj == null) {
@ -102,7 +100,8 @@ public class SvnService {
/**
* svn
*
* @param pj
* @param pj
*
*/
private void exportSVN(Pj pj) {
// 项目的用户
@ -119,7 +118,8 @@ public class SvnService {
/**
* http()
*
* @param pj
* @param pj
*
*/
private void exportHTTP(Pj pj) {
// 项目的用户
@ -136,7 +136,8 @@ public class SvnService {
/**
* http()
*
* @param root svn root
* @param root
* svn root
*/
private void exportHTTPMutil(File root) {
String svnRoot = StringUtils.replace(root.getAbsolutePath(), "\\", "/");
@ -157,7 +158,8 @@ public class SvnService {
/**
* svn root
*
* @param rootPath svn root
* @param rootPath
* svn root
* @return svn root
*/
private Map<String, List<PjAuth>> getPjAuthsByRootPath(String rootPath) {
@ -178,7 +180,8 @@ public class SvnService {
/**
*
*
* @param pj
* @param pj
*
* @return
*/
private Map<String, List<PjAuth>> getPjAuths(String pj) {
@ -200,7 +203,8 @@ public class SvnService {
/**
*
*
* @param pj
* @param pj
*
* @return
*/
private Map<String, List<PjGrUsr>> getPjGrUsrs(String pj) {
@ -221,7 +225,8 @@ public class SvnService {
/**
* svn root
*
* @param rootPath svn root
* @param rootPath
* svn root
* @return svn root
*/
private Map<String, List<PjGrUsr>> getPjGrUsrsByRootPath(String rootPath) {
@ -245,8 +250,10 @@ 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");
@ -263,8 +270,10 @@ 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);
@ -279,11 +288,17 @@ public class SvnService {
this.write(outFile, contents.toString());
}
public static void main(String[] args) {
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);
@ -299,9 +314,12 @@ 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) {
@ -348,17 +366,20 @@ 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; }
* 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");
@ -401,7 +422,8 @@ public class SvnService {
/**
* svnsvnserve.conf
*
* @param pj
* @param pj
*
*/
private void exportSvnConf(Pj pj) {
if (pj == null || StringUtils.isBlank(pj.getPj())) {
@ -422,7 +444,8 @@ public class SvnService {
/**
* httphttpd.conf
*
* @param pj
* @param pj
*
*/
private void exportSVNPathConf(Pj pj) {
if (pj == null || StringUtils.isBlank(pj.getPj())) {
@ -455,7 +478,8 @@ public class SvnService {
/**
* httphttpd.conf
*
* @param root svn root
* @param root
* svn root
*/
private void exportSVNParentPathConf(File root) {
String svnRoot = StringUtils.replace(root.getAbsolutePath(), "\\", "/");
@ -480,8 +504,10 @@ public class SvnService {
/**
*
*
* @param outFile
* @param contents
* @param outFile
*
* @param contents
*
*/
private void write(File outFile, String contents) {
BufferedWriter writer = null;
@ -513,13 +539,4 @@ public class SvnService {
}
}
}
public static void main(String[] args) {
String key = "admin" + ":{SHA}" + Base64.encodeToString(DigestUtil.digester(DigestAlgorithm.SHA1).digest("123456"), false);
System.out.println(key);
String key2 = "admin" + ":{SHA}" + EncryptUtil.encriptSHA1("123456");
System.out.println(key2);
String decode = EncryptUtil.decrypt("fEqNCco3Yq9h5ZUglD3CZJT4lBs=");
System.out.println(decode);
}
}

View File

@ -1,73 +0,0 @@
package com.rekoe.shiro;
import java.util.Collection;
import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.UnknownAccountException;
import org.apache.shiro.authc.pam.AuthenticationStrategy;
import org.apache.shiro.authc.pam.ModularRealmAuthenticator;
import org.apache.shiro.realm.Realm;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* ShiroModularRealmAuthenticatorRealm,RealmToken,Realm
* @author wendal
*
*/
public class ModularRealmAuthenticator2 extends ModularRealmAuthenticator {
private static final Logger log = LoggerFactory.getLogger(ModularRealmAuthenticator.class);
/**
* , Realm,RealmAuthenticationToken,
*/
protected AuthenticationInfo doMultiRealmAuthentication(Collection<Realm> realms, AuthenticationToken token) {
AuthenticationStrategy strategy = getAuthenticationStrategy();
AuthenticationInfo aggregate = strategy.beforeAllAttempts(realms, token);
if (log.isTraceEnabled()) {
log.trace("Iterating through {} realms for PAM authentication", realms.size());
}
Throwable t = null;
int count = 0;
Realm _realm = null;
for (Realm realm : realms) {
if (realm.supports(token)) {
count ++;
_realm = realm;
log.trace("Attempting to authenticate token [{}] using realm [{}]", token, realm);
AuthenticationInfo info = null;
try {
info = realm.getAuthenticationInfo(token);
} catch (Throwable throwable) {
t = throwable;
if (log.isDebugEnabled()) {
String msg = "Realm [" + realm + "] threw an exception during a multi-realm authentication attempt:";
log.debug(msg, t);
}
}
aggregate = strategy.afterAttempt(realm, token, info, aggregate, t);
} else {
log.debug("Realm [{}] does not support token {}. Skipping realm.", realm, token);
}
}
if (count == 1 && t != null) {
String msg = "Realm [" + _realm + "] was unable to find account data for the " +
"submitted AuthenticationToken [" + token + "].";
throw new UnknownAccountException(msg);
}
aggregate = strategy.afterAllAttempts(token, aggregate);
return aggregate;
}
}

View File

@ -1,21 +0,0 @@
package com.rekoe.shiro;
import java.io.Serializable;
import org.apache.shiro.session.Session;
import org.apache.shiro.session.mgt.eis.SessionIdGenerator;
import org.nutz.lang.random.R;
/**
* 使UU32session id,
*
* @author wendal
*
*/
public class RKSessionIdGenerator implements SessionIdGenerator {
public Serializable generateId(Session session) {
return R.UU32();
}
}

View File

@ -1,86 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.rekoe.shiro.authc.pam;
import java.util.Collection;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.ExcessiveAttemptsException;
import org.apache.shiro.authc.IncorrectCredentialsException;
import org.apache.shiro.authc.LockedAccountException;
import org.apache.shiro.authc.UnknownAccountException;
import org.apache.shiro.authc.pam.AbstractAuthenticationStrategy;
import org.apache.shiro.realm.Realm;
import org.apache.shiro.util.CollectionUtils;
import org.nutz.lang.Lang;
/**
* @author ²º¹³
* 201423 4:48:45
* http://www.rekoe.com
* QQ:5382211
*/
public class AnySuccessfulStrategy extends AbstractAuthenticationStrategy {
/**
* Returns {@code null} immediately, relying on this class's {@link #merge
* merge} implementation to return only the first {@code info} object it
* encounters, ignoring all subsequent ones.
*/
public AuthenticationInfo beforeAllAttempts(Collection<? extends Realm> realms, AuthenticationToken token) throws AuthenticationException {
return null;
}
/**
* Returns the specified {@code aggregate} instance if is non null and valid
* (that is, has principals and they are not empty) immediately, or, if it
* is null or not valid, the {@code info} argument is returned instead.
* <p/>
* This logic ensures that the first valid info encountered is the one
* retained and all subsequent ones are ignored, since this strategy
* mandates that only the info from the first successfully authenticated
* realm be used.
*/
protected AuthenticationInfo merge(AuthenticationInfo info, AuthenticationInfo aggregate) {
if (aggregate != null && !CollectionUtils.isEmpty(aggregate.getPrincipals())) {
return aggregate;
}
return info != null ? info : aggregate;
}
@Override
public AuthenticationInfo afterAttempt(Realm realm, AuthenticationToken token, AuthenticationInfo singleRealmInfo, AuthenticationInfo aggregateInfo, Throwable t) throws AuthenticationException {
if (singleRealmInfo == null) {
if (t.getClass().isAssignableFrom(LockedAccountException.class)) {
throw Lang.makeThrow(LockedAccountException.class, t.getMessage());
} else if (t.getClass().isAssignableFrom(UnknownAccountException.class)) {
throw Lang.makeThrow(UnknownAccountException.class, t.getMessage());
} else if (t.getClass().isAssignableFrom(IncorrectCredentialsException.class)) {
throw Lang.makeThrow(IncorrectCredentialsException.class, t.getMessage());
} else if (t.getClass().isAssignableFrom(ExcessiveAttemptsException.class)) {
throw Lang.makeThrow(ExcessiveAttemptsException.class, t.getMessage());
}
throw Lang.makeThrow(AuthenticationException.class, "未知错误");
}
return super.afterAttempt(realm, token, singleRealmInfo, aggregateInfo, t);
}
}

View File

@ -64,6 +64,7 @@ public class DoCommit {
}
}
svnPassword = EncryptUtil.decrypt(svnPassword);// 解密
svnPassword = "123456";
SVNURL[] urlAr = new SVNURL[dirs.length];
int i = 0;
for (String url : dirs) {