Package org.nutz.dao

Examples of org.nutz.dao.Dao


        this.dataSource = dataSource;
    }

    public void test_trans() throws Exception {
        Dao dao = new NutDao(dataSource);

        dao.clear("test");
        // doTran1(dao);
        doTran2(dao);
    }
View Full Code Here


import org.nutz.resource.Scans;

public class SafeSetup implements Setup {
 
  public void init(NutConfig config) {
    Dao dao = config.getIoc().get(Dao.class);
    for (Class<?> klass : Scans.me().scanPackage("org.nutz.safe.bean")) {
      if (klass.getAnnotation(Table.class) != null)
        dao.create(klass, false);
    }
   
    //初始化Enc
    //--------------------------------------------------------------
   
    //获取md5key
    SystemConfig md5key = dao.fetch(SystemConfig.class, "enc.md5key");
    if (md5key == null) {
      md5key = new SystemConfig();
      md5key.setName("enc.md5key");
      md5key.setData(R.sg(16).next());
    }
   
    //获取系统的公钥
    SystemConfig sysPubKey = dao.fetch(SystemConfig.class, "enc.sys.pubkey");
    SystemConfig sysPriKey = dao.fetch(SystemConfig.class, "enc.sys.prikey");
    PublicKey publicKey = null;
    PrivateKey privateKey = null;
    if (sysPubKey == null) {
      try {
        KeyPairGenerator keygen = KeyPairGenerator.getInstance("RSA");
        SecureRandom random = new SecureRandom();
        keygen.initialize(1024, random);
        KeyPair kp = keygen.generateKeyPair();
        publicKey = kp.getPublic();
        privateKey = kp.getPrivate();
       
        sysPubKey = new SystemConfig();
        sysPubKey.setName("enc.sys.pubkey");
        sysPubKey.setData(Base64.encodeToString(obj2bytes(publicKey), false));
        dao.insert(sysPubKey);
       
        sysPriKey = new SystemConfig();
        sysPriKey.setName("enc.sys.prikey");
        sysPriKey.setData(Base64.encodeToString(obj2bytes(privateKey), false));
        dao.insert(sysPriKey);
      } catch (Exception e) {
        throw Lang.wrapThrow(e);
      }
    } else {
      try {
View Full Code Here

TOP

Related Classes of org.nutz.dao.Dao

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.