1. 程式人生 > >oracle wallet使用與維護---oracle無密碼登入

oracle wallet使用與維護---oracle無密碼登入

分享一下我老師大神的人工智慧教程!零基礎,通俗易懂!http://blog.csdn.net/jiangjunshow

也歡迎大家轉載本篇文章。分享知識,造福人民,實現我們中華民族偉大復興!

               

author:skate
time:2012/07/24

 

oracle wallet使用與維護

 

從Oracle10gR2開始, 通過使用Oracle Wallet達到任意使用者不使用密碼登入資料庫(非作業系統認證方式),這對於用指令碼登入資料庫進行操作來說是非常有用的;尤其對於企業安全要求很高,不希望使用者名稱和密碼明文存在配置檔案中,而且對於密碼的維護是極為方便的,比如我把wallet放在指定路徑下,當修改密碼時,只需統一覆蓋wallet即可,對於有大量應用伺服器尤為方便。

 

在客戶端建立一個wallet

 

用法:
E:\app\Administrator\product\11.2.0\dbhome_1\BIN>mkstore --help
Oracle Secret Store Tool: 版本 11.2.0.1.0 - Production
版權所有 (c) 2004, 2009, Oracle 和/或其子公司。保留所有權利。

未指定 Wallet 的位置。
mkstore [-wrl wrl] [-create] [-createSSO] [-createLSSO] [-createALO] [-delete] [
-deleteSSO] [-list] [-createEntry alias secret] [-viewEntry alias] [-modifyEntry
 alias secret] [-deleteEntry alias] [-createCredential connect_string username p
assword] [-listCredential] [-modifyCredential connect_string username password]
[-deleteCredential connect_string] [-help] [-nologo]

E:\app\Administrator\product\11.2.0\dbhome_1\BIN>


1. 建立wallet
 語法: mkstore -wrl <wallet_location> -create

eg:
E:\app\Administrator\product\11.2.0\dbhome_1\BIN>mkstore -wrl e:\temp\wallet -create
Oracle Secret Store Tool: 版本 11.2.0.1.0 - Production
版權所有 (c) 2004, 2009, Oracle 和/或其子公司。保留所有權利。

輸入口令:(輸入wallet的密碼,要設定的複雜些,否則失敗

再次輸入口令:(輸入wallet的密碼

E:\app\Administrator\product\11.2.0\dbhome_1\BIN>

 

檢視建立wallet

e:\temp\wallet>dir
 驅動器 E 中的卷是 data
 卷的序列號是 DCEE-F1D9

 e:\temp\wallet 的目錄

2012/07/24  17:19    <DIR>          .
2012/07/24  17:19    <DIR>          ..
2012/07/24  17:19             3,589 cwallet.sso
2012/07/24  17:19             3,512 ewallet.p12
               2 個檔案          7,101 位元組
               2 個目錄 212,962,336,768 可用位元組

e:\temp\wallet>


2.建立客戶端連線服務端的網路連線串,每個連線串對應一個數據庫使用者
skate_192.168.1.9 =
  (DESCRIPTION =      
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.9)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = skate)
    )
  )
 
 
 
3.把登入資料庫的使用者認證資訊新增到wallet中

E:\app\Administrator\product\11.2.0\dbhome_1\BIN>mkstore -wrl e:\temp\wallet -createCredential skate_192.168.1.9 skate skatepwd
Oracle Secret Store Tool: 版本 11.2.0.1.0 - Production
版權所有 (c) 2004, 2009, Oracle 和/或其子公司。保留所有權利。

輸入 Wallet 口令:

Create credential oracle.security.client.connect_string1


4.在客戶端的sqlnet.ora檔案裡,編輯引數“WALLET_LOCATION ”

WALLET_LOCATION=(SOURCE=(METHOD=FILE)(METHOD_DATA=(DIRECTORY=e:\temp\wallet)))
SQLNET.WALLET_OVERRIDE = TRUE


5.測試在客戶端無需密碼連線資料庫測試


E:\app\Administrator\product\11.2.0\dbhome_1\BIN>sqlplus /@skate_192.168.1.9

SQL*Plus: Release 11.2.0.1.0 Production on 星期二 7月 24 17:59:21 2012

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

連線到:
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> show user;
USER 為 "SKATE"
SQL>


6.如何管理wallet

6.1 檢視wallet裡的連線認證資訊
E:\app\Administrator\product\11.2.0\dbhome_1\BIN>mkstore -wrl e:\temp\wallet -listCredential
Oracle Secret Store Tool: 版本 11.2.0.1.0 - Production
版權所有 (c) 2004, 2009, Oracle 和/或其子公司。保留所有權利。

輸入 Wallet 口令:

List credential (index: connect_string username)
1: skate_192.168.1.9 skate

 

6.2 新增一個新的認證資訊到wallet裡,在wallet是以連線串為唯一標識的
E:\app\Administrator\product\11.2.0\dbhome_1\BIN>mkstore -wrl e:\temp\wallet -createCredential test_skate_s_192.168.1.9 skate skatepwd
Oracle Secret Store Tool: 版本 11.2.0.1.0 - Production
版權所有 (c) 2004, 2009, Oracle 和/或其子公司。保留所有權利。

輸入 Wallet 口令:

Create credential oracle.security.client.connect_string2

 

檢視已經新增使用者認證資訊
E:\app\Administrator\product\11.2.0\dbhome_1\BIN>mkstore -wrl e:\temp\wallet -listCredential
Oracle Secret Store Tool: 版本 11.2.0.1.0 - Production
版權所有 (c) 2004, 2009, Oracle 和/或其子公司。保留所有權利。

輸入 Wallet 口令:

List credential (index: connect_string username)
2: test_skate_s_192.168.1.9 skate
1: skate_192.168.1.9 skate


6.3 編輯wallet裡的使用者密碼
E:\app\Administrator\product\11.2.0\dbhome_1\BIN>mkstore -wrl e:\temp\wallet -modifyCredential test_skate_s_192.168.1.9 skate skatepwd1
Oracle Secret Store Tool: 版本 11.2.0.1.0 - Production
版權所有 (c) 2004, 2009, Oracle 和/或其子公司。保留所有權利。

輸入 Wallet 口令:

Modify credential
Modify 2

E:\app\Administrator\product\11.2.0\dbhome_1\BIN>

 

6.4 刪除wallet的使用者認證資訊

E:\app\Administrator\product\11.2.0\dbhome_1\BIN>mkstore -wrl e:\temp\wallet -listCredential
Oracle Secret Store Tool: 版本 11.2.0.1.0 - Production
版權所有 (c) 2004, 2009, Oracle 和/或其子公司。保留所有權利。

輸入 Wallet 口令:

List credential (index: connect_string username)
2: test_skate_s_192.168.1.9 skate
1: skate_192.168.1.9 skate

E:\app\Administrator\product\11.2.0\dbhome_1\BIN>mkstore -wrl e:\temp\wallet -deleteCredential test_prodb_s_192.168.1.9
Oracle Secret Store Tool: 版本 11.2.0.1.0 - Production
版權所有 (c) 2004, 2009, Oracle 和/或其子公司。保留所有權利。

輸入 Wallet 口令:

Delete credential
Delete 2

E:\app\Administrator\product\11.2.0\dbhome_1\BIN>mkstore -wrl e:\temp\wallet -listCredential
Oracle Secret Store Tool: 版本 11.2.0.1.0 - Production
版權所有 (c) 2004, 2009, Oracle 和/或其子公司。保留所有權利。

輸入 Wallet 口令:

List credential (index: connect_string username)
1: skate_192.168.1.9 skate

E:\app\Administrator\product\11.2.0\dbhome_1\BIN>

 

7.檢視wallet裡的詳細認證資訊

E:\app\Administrator\product\11.2.0\dbhome_1\BIN>mkstore -wrl e:\temp\wallet -list
Oracle Secret Store Tool: 版本 11.2.0.1.0 - Production
版權所有 (c) 2004, 2009, Oracle 和/或其子公司。保留所有權利。

輸入 Wallet 口令:

Oracle 金鑰儲存條目:
oracle.security.client.connect_string1
oracle.security.client.password1
oracle.security.client.username1

 

E:\app\Administrator\product\11.2.0\dbhome_1\BIN>mkstore -wrl e:\temp\wallet -viewEntry oracle.security.client.connect_string1
Oracle Secret Store Tool: 版本 11.2.0.1.0 - Production
版權所有 (c) 2004, 2009, Oracle 和/或其子公司。保留所有權利。

輸入 Wallet 口令:

oracle.security.client.connect_string1 = skate_192.168.1.9

E:\app\Administrator\product\11.2.0\dbhome_1\BIN>mkstore -wrl e:\temp\wallet -viewEntry oracle.security.client.password1
Oracle Secret Store Tool: 版本 11.2.0.1.0 - Production
版權所有 (c) 2004, 2009, Oracle 和/或其子公司。保留所有權利。

輸入 Wallet 口令:

oracle.security.client.password1 = skatepwd

E:\app\Administrator\product\11.2.0\dbhome_1\BIN>mkstore -wrl e:\temp\wallet -viewEntry oracle.security.client.username1
Oracle Secret Store Tool: 版本 11.2.0.1.0 - Production
版權所有 (c) 2004, 2009, Oracle 和/或其子公司。保留所有權利。

輸入 Wallet 口令:

oracle.security.client.username1 = skate

E:\app\Administrator\product\11.2.0\dbhome_1\BIN>


8.更改wallet裡使用者認證資訊的內容

8.1 更改密碼
E:\app\Administrator\product\11.2.0\dbhome_1\BIN>mkstore -wrl e:\temp\wallet -modifyEntry oracle.security.client.password1 skatepwd1
Oracle Secret Store Tool: 版本 11.2.0.1.0 - Production
版權所有 (c) 2004, 2009, Oracle 和/或其子公司。保留所有權利。

輸入 Wallet 口令:


8.2 更改密碼
E:\app\Administrator\product\11.2.0\dbhome_1\BIN>mkstore -wrl e:\temp\wallet -modifyEntry oracle.security.client.username1 skate1
Oracle Secret Store Tool: 版本 11.2.0.1.0 - Production
版權所有 (c) 2004, 2009, Oracle 和/或其子公司。保留所有權利。

輸入 Wallet 口令:


E:\app\Administrator\product\11.2.0\dbhome_1\BIN>


和6.3步驟裡(-modifyCredential)的區別是,這裡不僅僅改密碼,連線串和密碼都可以改


我們這裡是本地建立wallet,從本地客戶端可以登入,那從其他地方可以嗎?

A.
在win7+oracle11g客戶端上建立的wallet,無密碼訪問linux+oracle10g服務服務端沒有問題,但是把wallet複製到linux+oracle10g的服務端,再無密碼登入是報錯“ORA-12534: TNS:operation not supported”,需要用如下命令編輯一下,就可以無密碼登入了。雖然語句沒有改任何內容。

[[email protected] ~]$ mkstore -wrl /tmp/wallet1 -createCredential skate_192.168.1.9 skate skatepwd1

 

B. 在linux+oracle10g服務端上建立的wallet,無密碼訪問linux+oracle10g服務服務端沒有問題,把wallet複製到win7+oracle11g客戶端,無密碼登入也沒問題。

 

猜測可能是版本問題。

 


在客戶端使用wallet無密碼登入的步驟:


1.建立wallet(tnsname.ora裡面的連線串,sqlnet.ora檔案內容都要複製到客戶端)
2.把wallet複製到客戶端指定路徑(注意檔案許可權和屬主)
3.修改客戶端的tnsname.ora檔案裡連線伺服器的連線串為建立時的連線串,在sqlnet.ora檔案裡新增如下內容:

WALLET_LOCATION=(SOURCE=(METHOD=FILE)(METHOD_DATA=(DIRECTORY=e:\temp\wallet)))
SQLNET.WALLET_OVERRIDE = TRUE

4.在sqlplus無密碼等裡測試
  sqlplus /@skate_192.168.1.9

 

在jdbc裡連線資料庫密碼形式如下:
   public static Connection getConnection() throws SQLException {
      DriverManager.registerDriver(new OracleDriver());
      Connection conn = DriverManager
              .getConnection("jdbc:oracle:oci:/@tnskate");
      conn.setAutoCommit(false);
      return conn;
   }


  
參考: [ID 340559.1] [ID 741810.1]

 

 

 

-----end----

 

 

           

給我老師的人工智慧教程打call!http://blog.csdn.net/jiangjunshow

這裡寫圖片描述