隨筆-69  評(píng)論-0  文章-5  trackbacks-0
           
          fisheye(1.4.3):
              cenqua_com_licensing.atlassian.license.DefaultLicense
                 isExpired(),getExpiryDate()
              cenqua_com_licensing.atlassian.license.DefaultLicenseType(重點(diǎn))
                 isEvaluationLicenseType(),expires().....

          posted @ 2008-05-28 11:13 liunix 閱讀(518) | 評(píng)論 (0)編輯 收藏

          一,將pem格式的key文件導(dǎo)入keystore

          摘抄備用:http://www.agentbob.info/agentbob/79-AB.html

          說明: 經(jīng)試驗(yàn)證書的pem文件可能通過keytool直接導(dǎo)入keystore中的

          Apache Tomcat and many other Java applications expect to retrieve SSL/TLS certificates from a Java Key Store (JKS). Jave Virtual Machines usually come with keytool  to help you create a new key store.

          Keytool helps you to:

          • create a new JKS with a new private key
          • generate a Certificate Signung Request (CSR) for the private key in this JKS
          • import a certificate that you received for this CSR into your JKS

          Keytool does not let you import an existing private key for which you already have a certificate. So you need to do this yourself, here's how:

          Let's assume you have a private key (key.pem) and a certificate (cert.pem), both in PEM format as the file names suggest.

          PEM format is 'kind-of-human-readable' and looks like e.g.

          -----BEGIN CERTIFICATE-----
          Ulv6GtdFbjzLeqlkelqwewlq822OrEPdH+zxKUkKGX/eN
          .
          . (snip)
          .
          9801asds3BCfu52dm7JHzPAOqWKaEwIgymlk=
          ----END CERTIFICATE-----

          Convert both, the key and the certificate into DER format using openssl :

          openssl pkcs8 -topk8 -nocrypt -in key.pem -inform PEM -out key.der -outform DER
          openssl x509 -in cert.pem -inform PEM -out cert.der -outform DER

          Now comes the tricky bit, you need something to import these files into the JKS. ImportKey will do this for you, get the ImportKey.java (text/x-java-source, 6.6 kB, info) source or the compiled (Java 1.5 !) ImportKey.class (application/octet-stream, 3.3 kB, info) and run it like

          user@host:~$ java ImportKey key.der cert.der
          Using keystore-file : /home/user/keystore.ImportKey
          One certificate, no chain.
          Key and certificate stored.
          Alias:importkey Password:importkey

          Now we have a proper JKS containing our private key and certificate in a file called keystore.ImportKey, using 'importkey' as alias and also as password. For any further changes, like changing the password we can use keytool.



          二、將私鑰導(dǎo)出成pem文件(默認(rèn)keytool是不能導(dǎo)出私鑰的)
          import sun.misc.BASE64Encoder;
          import java.security.cert.Certificate;
          import java.security.*;
          import java.io.File;
          import java.io.FileInputStream;
           
          class ExportPriv {
              
          public static void main(String args[]) throws Exception{
              ExportPriv myep 
          = new ExportPriv();
              myep.doit();
              }
           
              
          public void doit() throws Exception{
           
              KeyStore ks 
          = KeyStore.getInstance("JKS");
              String fileName 
          = "store.jks";
           
              
          char[] passPhrase = "password".toCharArray();
              BASE64Encoder myB64 
          = new BASE64Encoder();
              
           
              File certificateFile 
          = new File(fileName);
              ks.load(
          new FileInputStream(certificateFile), passPhrase);
           
              KeyPair kp 
          = getPrivateKey(ks, "alias", passPhrase);
                  
              PrivateKey privKey 
          = kp.getPrivate();
              
           
              String b64 
          = myB64.encode(privKey.getEncoded());
           
              System.out.println(
          "-----BEGIN PRIVATE KEY-----");
              System.out.println(b64);
              System.out.println(
          "-----END PRIVATE KEY-----");
           
              }
           
          // From http://javaalmanac.com/egs/java.security/GetKeyFromKs.html
           
             
          public KeyPair getPrivateKey(KeyStore keystore, String alias, char[] password) {
                  
          try {
                      
          // Get private key
                      Key key = keystore.getKey(alias, password);
                      
          if (key instanceof PrivateKey) {
                          
          // Get certificate of public key
                          Certificate cert = keystore.getCertificate(alias);
              
                          
          // Get public key
                          PublicKey publicKey = cert.getPublicKey();
              
                          
          // Return a key pair
                          return new KeyPair(publicKey, (PrivateKey)key);
                      }
                  } 
          catch (UnrecoverableKeyException e) {
                  } 
          catch (NoSuchAlgorithmException e) {
                  } 
          catch (KeyStoreException e) {
                  }
                  
          return null;
              }
           
          }
           

          posted @ 2008-04-17 16:27 liunix 閱讀(8006) | 評(píng)論 (0)編輯 收藏
          去年rails正火的時(shí)候,仿active record用hibernate實(shí)現(xiàn)了一個(gè)BasePo,當(dāng)時(shí)用的是一個(gè)
          靜態(tài)sessionfactory注入的方式,感覺很不好,當(dāng)明也沒想到好的方案,后來發(fā)現(xiàn)有人通過
          threadlocal實(shí)現(xiàn)了下面這個(gè),可以看看:
           1 public class Persistent implements Lifecycle, Validatable, Serializable {
           2    
           3    protected Serializable _id;
           4    protected int _version;
           5 
           6    public Serializable getIdentifier() {
           7       return _id;
           8    }
           9    public void setIdentifier(Serializable id) {
          10       _id = id;
          11    }
          12    public int getVersion() {
          13       return _version;
          14    }
          15    public void setVersion(int version) {
          16       _version = version;
          17    }
          18 
          19    public Long persist() throws HibernateException, SQLException {
          20       HibernateSession.currentSession().saveOrUpdate(this);
          21       return _id;
          22    }
          23    public void delete() throws HibernateException, SQLException {
          24       HibernateSession.currentSession().delete(this);
          25    }
          26    public void refresh() throws HibernateException, SQLException {
          27       HibernateSession.currentSession().load(this, _id);
          28    }
          29    public void lock() throws HibernateException, SQLException {
          30       HibernateSession.currentSession().lock(this, LockMode.UPGRADE);
          31    }
          32 
          33    public boolean onSave(Session s) throws CallbackException {
          34       return NO_VETO;
          35    }
          36    public boolean onDelete(Session s) throws CallbackException {
          37       return NO_VETO;
          38    }
          39    public boolean onUpdate(Session s) throws CallbackException {
          40       return NO_VETO;
          41    }
          42    public void onLoad(Session s, Serializable id) {
          43       _id = id;
          44    }
          45 
          46    public void validate() throws ValidationFailure {
          47    }
          48 }

          原文:http://hibernate.bluemars.net/46.html?cmd=prntdoc

          下面是hibernatesession的源碼,應(yīng)該考濾一下如何與spring事務(wù)結(jié)合的問題(還是加一個(gè)doInTransaction 的callback?)
           1 import java.util.Collection;
           2 
           3 import net.sf.hibernate.HibernateException;
           4 import net.sf.hibernate.Session;
           5 import net.sf.hibernate.Transaction;
           6 
           7 import org.apache.commons.logging.Log;
           8 import org.apache.commons.logging.LogFactory;
           9 
          10 /**
          11  * @author Ralph Schaer
          12  * @version $Revision: 1.6 $ $Date: 2004/05/22 12:24:32 $
          13  */
          14 public class HibernateSession {
          15 
          16   private static final Log LOG = LogFactory.getLog(HibernateSession.class);
          17   public static final ThreadLocal SESSION = new ThreadLocal();
          18 
          19   public static Session currentSession() throws HibernateException {
          20 
          21     Session s = (Session) SESSION.get();
          22     if (s == null) {
          23       s = HibernateFactoryManager.getSessionFactory().openSession();
          24       SESSION.set(s);
          25     }
          26     return s;
          27   }
          28 
          29   public static Session getSession() throws HibernateException {
          30     return HibernateFactoryManager.getSessionFactory().openSession();
          31   }
          32 
          33   public static void closeSession() {
          34     try {
          35       Session s = (Session) SESSION.get();
          36       SESSION.set(null);
          37       if (s != null) {
          38         s.close();
          39       }
          40 
          41     } catch (HibernateException e) {
          42       LOG.error("HibernateSession:  closeSession", e);
          43     }
          44 
          45   }
          46 
          47   public static void rollback(Transaction tx) {
          48     if (tx != null) {
          49       try {
          50         tx.rollback();
          51         closeSession();
          52       } catch (HibernateException he) {
          53         LOG.error("HibernateSession: rollback", he);
          54       }
          55     }
          56   }
          57 
          58   //Utility methods
          59   public static int collectionSize(Collection coll) throws HibernateException {
          60     return ((Integer) currentSession().createFilter(coll, "select count(*)").iterate().next()).intValue();
          61   }
          62 
          63 }


          還有一種考慮泛型的方式可以參考:
          http://privacyneed.info/index.php?hl=f5&q=uggc%3A%2F%2Fcrgreonpxyhaq.oybtfcbg.pbz%2F2007%2F07%2Fvzcyrzragvat-npgvirerpbeq-va-wnin.ugzy
          posted @ 2008-03-28 11:30 liunix 閱讀(483) | 評(píng)論 (0)編輯 收藏
          從網(wǎng)上找了一段,寫得挺麻煩,但可以借一下思路
          cat watch.sh

          #!/bin/sh
          cd /root/bin

          PID
          =`ps -aef | grep Xms500M | grep -grep | gawk '{print $2}'`
          PID
          =`expr $PID + 1 - 1`

          date
          free
          echo 
          $PID
          echo 
          "------------------"

          if [ $PID -eq 0 ]
          then
          sleep 10
          /usr/java/tomcat/bin/startup.sh
          sleep 160
          fi

          while [ 1 ]
          do
          date
          free
          echo 
          "Tomcat process ID is $PID"
          wget http
          ://192.168.1.101/jsp/w_blog/blog.jsp -O working.jpg 2>> /dev/null &
          sleep 120
          touch working
          .jpg
          SIZE
          =`du working.jpg | gawk '{print $1}'`
          if [ $SIZE -le 20 ]
          then


          WID
          =`ps -aef | grep 192.168.1.101 | grep -grep | gawk '{print $2}'`
          WID
          =`expr $WID + 1 - 1`

          if ! test -$WID
          then
          killall wget
          fi


          echo 
          "Tomcat restart checking"
          free
          vmstat
          FREEMEM
          =`free | grep Mem | gawk '{print $4}'`

          if [ $FREEMEM -le 15000 ]
          then

          if [ $PID -ne 0 ]
          then
          kill -9 $PID
          ls 
          -l
          /usr/java/tomcat/bin/shutdown.sh
          fi

          /usr/java/tomcat/bin/shutdown.sh
          sleep 10
          /usr/java/tomcat/bin/startup.sh
          sleep 30
          fi

          date
          ps 
          -aef | grep -v httpd
          ls 
          -l
          PID
          =`ps -aef | grep Xms500M | grep -grep | gawk '{print $2}'`
          PID
          =`expr $PID + 1 - 1`

          fi

          rm 
          -f working.jpg

          done


          posted @ 2008-03-24 19:25 liunix 閱讀(1300) | 評(píng)論 (0)編輯 收藏
          1,設(shè)置好WEB-INF/classes/xplanner-customer.properties中的數(shù)據(jù)連接,建mysql庫[xplanner]
          2, 運(yùn)行會(huì)自動(dòng)創(chuàng)建數(shù)據(jù)庫表和sysadmin/admin用戶
          3, 中文亂碼,先導(dǎo)出數(shù)據(jù)庫[主要保存用戶維護(hù)數(shù)據(jù)]
              mysqldump --opt --database xplanner > xplanner.sql
          4, 將sql中的create database語句改成default charset utf8;
          5, souce xplanner.sql
          6, 將server-config.wsdd[WEB-INF]下的附件上傳位置改成合適目錄
          7, 重啟xplanner即可

          posted @ 2008-03-20 20:22 liunix 閱讀(257) | 評(píng)論 (0)編輯 收藏
          概念:
              唯一的就是一個(gè)候選鍵(數(shù)據(jù)庫理論基礎(chǔ))
          所以要增加唯一性就是增加一個(gè)Alternate key

          操作:
              單擊表模型,選中keys簽,增加一個(gè)key,不選primary即可

          信息來源sybooks online:
              http://infocenter.sybase.com/help/index.jsp
          查找unique constraint找出和PDM相關(guān)的內(nèi)容

          posted @ 2008-03-19 15:36 liunix 閱讀(179) | 評(píng)論 (0)編輯 收藏
          網(wǎng)上說的比較多
          不過一定要記住看服務(wù)進(jìn)程的log:
          view /var/log/mysql.log
          在我這里問題是:


          /usr/libexec/mysqld: Can't create/write to file '/tmp/'


          說明mysql用戶無權(quán)使用/tmp目錄,改一下目錄權(quán)限就好了
          chmow -R 777 /tmp

          posted @ 2008-03-18 14:29 liunix 閱讀(176) | 評(píng)論 (0)編輯 收藏
          一,JIRA安裝
              1, 下載最新的JIRA(要注冊(cè)才能得到測(cè)試liense)
              2,  創(chuàng)建數(shù)據(jù)庫用戶[注意:jira用的utf8],create database jira default charset utf8; (mysql)
              3,  按官網(wǎng)WIKI配置數(shù)據(jù)庫,所有表會(huì)自動(dòng)創(chuàng)建


          二,SUBVERSION-PLUGIN
              1, 下載插件
              2,  拷完lib到指定位置即可(不要拷properties)   
              3, 在管理端增加倉庫位置

          三,svnwebclient
              1, enscript不是語法加亮,只是加彩而已(而且大部分linux版本自帶)

          posted @ 2008-03-18 14:04 liunix 閱讀(221) | 評(píng)論 (0)編輯 收藏
          1, 下載http://www.allwiki.com/wiki/Mediawiki
          2,  解壓放到/var/www/html下,將config目錄權(quán)限改為777
          3,  給apache增加一個(gè)配置文件mediawiki.conf,內(nèi)容如下:
          <Directory "/var/www/html/mediawiki">
              AllowOverride None
              Options +ExecCGI
              Order allow,deny
              Allow from all
          </Directory>
          4,瀏覽器中輸入:http://hostname/mediawiki/index.php
          5,安裝看是否缺php-mysql,如果缺到fc5的cd-rom中安裝
          6, 創(chuàng)建數(shù)據(jù)庫
              mysql -u root
              create database mediawiki;
              grant all on mediawiki.* to mediawiki@'localhost' identified by 'mediawiki';
          6, 輸入各項(xiàng)配置
          7, mysql5創(chuàng)建表有問題,尚未解決,實(shí)在不行只能換個(gè)wiki看看了

          posted @ 2008-03-15 15:59 liunix 閱讀(156) | 評(píng)論 (0)編輯 收藏
          1, 下載bugzilla
              運(yùn)行./checksetup.pl
          2, 根據(jù)提示安裝perl模塊
              位置:http://search.cpan.org/search?query=IO%3A%3AScalarArray&mode=all
              下載后:
              perl Makefile.pl
              make
              make test
              make install
              (過程如果有依整性錯(cuò)誤,請(qǐng)安裝相應(yīng)模塊)
          3,配置mysql
              mysql -u root
              create database bugs
              grant all on bugs.* to bugzilla@'localhost' identified by 'bugs'
          4,配置vi ./localconfig設(shè)置數(shù)據(jù)庫
          5, 再次運(yùn)行./checksetup.pl會(huì)創(chuàng)建數(shù)據(jù)庫和設(shè)置bugzilla管理員(以mail作為登錄名)
          6, 將bugzilla目錄拷到/www/html/下
          7, 在/etc/httpd/conf.d/下增加bugzilla.conf內(nèi)容如下:
          AddHandler cgi-script .cgi .pl
          <Directory "/var/www/html/bugzilla">
              AllowOverride None
              Options +ExecCGI
              Order allow,deny
              Allow from all
          </Directory>
          8,運(yùn)行apachectl restart
          9,訪問:http://hostname/bugzilla/index.cgi
             

          posted @ 2008-03-15 14:41 liunix 閱讀(166) | 評(píng)論 (0)編輯 收藏
          僅列出標(biāo)題
          共7頁: 上一頁 1 2 3 4 5 6 7 下一頁 
          主站蜘蛛池模板: 准格尔旗| 太保市| 乌鲁木齐市| 永泰县| 峡江县| 广州市| 松原市| 广丰县| 台湾省| 宜宾市| 定结县| 合阳县| 佛坪县| 恩平市| 五指山市| 攀枝花市| 大渡口区| 焦作市| 十堰市| 阿拉善左旗| 蕲春县| 盐山县| 麻阳| 工布江达县| 清新县| 山西省| 泌阳县| 乌苏市| 酒泉市| 休宁县| 自贡市| 龙胜| 宁海县| 石城县| 武城县| 浏阳市| 长沙市| 祁东县| 富源县| 普宁市| 辰溪县|