81,110
社区成员
发帖
与我相关
我的任务
分享
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3)
// Source File Name: Config.java
package com.aljoin.oa.core.component;
import com.aljoin.oa.core.misc.DbcfgException;
import com.aljoin.oa.core.model.SystemAdmin;
import com.aljoin.oa.core.session.LoginPoolManager;
import com.aljoin.oa.core.version.SystemVersion;
import com.aljoin.oa.util.web.Base64;
import com.opensymphony.webwork.config.Configuration;
import com.opensymphony.xwork.interceptor.component.Disposable;
import java.io.Serializable;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Properties;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
// Referenced classes of package com.aljoin.oa.core.component:
// AljoinContext
public class Config
implements Disposable, Serializable
{
public Config()
{
}
public static String getAttachPath()
{
String path = Configuration.getString("webwork.multipart.saveDir");
if(!path.endsWith("/") && !path.endsWith("\\"))
path = (new StringBuilder(String.valueOf(path))).append("/").toString();
return path;
}
public static String getProperty(String key)
{
return getProperty().getProperty(key);
}
public static String getProperty(String key, String defalutValue)
{
return getProperty().getProperty(key, defalutValue);
}
public static Properties getProperty()
{
return prop;
}
public static void setProperties(Properties properties)
{
prop = properties;
}
public static Properties getProperties()
{
return prop;
}
public static String getVersion()
{
String v = getProperty("Version");
if(v == null || v.equals(""))
v = STANDARD;
return v;
}
public static Boolean getNeedPass()
{
if(needPass == null)
needPass = new Boolean((String)getProperty().get("common.needpass"));
return needPass;
}
public SystemAdmin loadSystemAdmin(String username)
{
Session session = getSessionFactory().openSession();
SystemAdmin sa = (SystemAdmin)session.load(com/aljoin/oa/core/model/SystemAdmin, username);
session.close();
return sa;
}
public boolean changeSystemAdminPwd(String username, String oldPwd, String newPwd)
{
Session session;
Transaction tran;
session = getSessionFactory().openSession();
tran = session.beginTransaction();
SystemAdmin admin = (SystemAdmin)session.load(com/aljoin/oa/core/model/SystemAdmin, username);
String encryPwd = encryPassword(oldPwd);
LOG.debug(encryPwd);
LOG.debug(admin.getPassword());
if(!admin.getPassword().equals(encryPwd))
break MISSING_BLOCK_LABEL_125;
admin.setPassword(encryPassword(newPwd));
session.save(admin);
LOG.debug(admin.getPassword());
tran.commit();
session.close();
return true;
_L2:
session.close();
return false;
HibernateException ex;
ex;
if(true) goto _L2; else goto _L1
_L1:
Exception exception;
exception;
session.close();
throw exception;
}
public static String encryPassword(String pwd)
{
try
{
MessageDigest md = MessageDigest.getInstance("SHA-1");
md.update(pwd.getBytes());
byte digesta[] = md.digest();
String encry = Base64.toBase64(digesta);
return encry;
}
catch(NoSuchAlgorithmException ex)
{
return pwd;
}
}
public static String datediff(String fstTime, String scdTime)
throws DbcfgException
{
String sql = "";
String dialect = configuration.getProperty("hibernate.dialect");
if(dialect.indexOf("MySQLDialect") != -1)
sql = (new StringBuilder("TO_DAYS(")).append(scdTime).append(") - TO_DAYS(").append(fstTime).append(")").toString();
else
if(dialect.indexOf("SQLServerDialect") != -1)
sql = (new StringBuilder("datediff(day,")).append(fstTime).append(",").append(scdTime).append(")").toString();
if(sql.equals(""))
throw new DbcfgException();
else
return sql;
}
public static SessionFactory getSessionFactory()
{
return systemFactory;
}
public static org.hibernate.cfg.Configuration getConfiguration()
{
return configuration;
}
public void dispose()
{
try
{
systemFactory.close();
}
catch(Exception e)
{
LOG.error("error closing", e);
throw new RuntimeException(e.getMessage());
}
}
public static SystemVersion getSystemVersion()
{
return systemVersion;
}
public static void setSystemVersion(SystemVersion systemVersion)
{
systemVersion = systemVersion;
}
public static LoginPoolManager getLoginManager()
{
return loginManager;
}
public static void setLoginManager(LoginPoolManager loginManager)
{
loginManager = loginManager;
}
public static AljoinContext getAljoinContext()
{
return aljoinContext;
}
public static void setAljoinContext(AljoinContext aljoinContext)
{
aljoinContext = aljoinContext;
}
public static SessionFactory getSystemFactory()
{
return systemFactory;
}
public static void setSystemFactory(SessionFactory systemFactory)
{
systemFactory = systemFactory;
}
public static void setConfiguration(org.hibernate.cfg.Configuration configuration)
{
configuration = configuration;
}
private static final Log LOG = LogFactory.getLog(com/aljoin/oa/core/component/Config);
private static Properties prop;
private static Boolean needPass;
private static SessionFactory systemFactory;
private static org.hibernate.cfg.Configuration configuration;
private static SystemVersion systemVersion;
private static LoginPoolManager loginManager;
private static AljoinContext aljoinContext;
public static String STANDARD = "standard";
public static String XMDX = "xmdx";
public static String SDWT = "sdwt";
public static String GZDX = "gzdx";
public static String HBSW = "hbsw";
public static String QHDX = "qhdx";
public static String XJDX = "xjdx";
public static String NORTH = "north";
public static String HNDX = "hndx";
public static String GXDX = "gxdx";
public static String SXDX = "sxdx";
public static String AHDX = "ahdx";
public static String QDWT = "qdwt";
public static String YNDX = "yndx";
public static String SHDX = "shdx";
public static String GSDX = "gsdx";
public static String SCDX = "scdx";
}