WEB开发网
开发学院数据库DB2 WebSphere Federation Server V9.5 中的端到端联合... 阅读

WebSphere Federation Server V9.5 中的端到端联合可信上下文

 2009-12-24 00:00:00 来源:WEB开发网   
核心提示: 建立端到端联合可信连接 启用应用程序后,应用程序用户 APP_USER 需要可信入站连接,WebSphere Federation Server V9.5 中的端到端联合可信上下文(8),第一个访问远程 DB2 数据源的联合请求将为 APP_USER 建立可信出站连接,如 图 3 中的步骤 4d

建立端到端联合可信连接

启用应用程序后,应用程序用户 APP_USER 需要可信入站连接。第一个访问远程 DB2 数据源的联合请求将为 APP_USER 建立可信出站连接。如 图 3 中的步骤 4d 所示,APP_USER 可以使用此显式的端到端联合可信连接执行数据源上的一些日常任务,并为企业最终用户的使用做好准备。

切换端到端的联合可信连接上的用户

最终用户(比如 Bob)开始使用应用程序时,入站用户 ID 将从 APP_USER 切换为 BOB。BOB 发出第一个联合请求(即访问远程 DB2 数据源)时,出站可信连接用户 ID 也切换为 BOB。从 图 3 中的步骤 5d 可以看到,BOB 的身份现在一直断言到 DB2 数据源,他的身份将用于准确地授权、审计等。



清单 6. 建立和使用端到端联合可信连接

int main(int argc, char *argv[]) 
{ 
 SQLHANDLE henv;        /* environment handle */ 
 SQLHANDLE hdbc1;        /* connection handle */ 
 SQLHANDLE hstmt;        /* statement handle */ 
 char origUserid[10] = "APP_USER"; 
 char origPassword[10] = "secret"; 
 char reuseUserid[10] = "BOB"; 
 char dbName[10] = "testdb"; 
 
 /* Allocate the handles */ 
 SQLAllocHandle( SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv ); 
 SQLAllocHandle( SQL_HANDLE_DBC, henv, &hdbc1 ); 
 
 /* Set the trusted connection attribute */ 
 SQLSetConnectAttr( hdbc1, SQL_ATTR_USE_TRUSTED_CONTEXT, (SQLPOINTER)SQL_TRUE, 
   SQL_IS_INTEGER ); 
 
 /* Establish a trusted inbound connection for user APP_USER from WAS 
   to WFS. This requires a password to be specified. */ 
 SQLConnect( hdbc1, (SQLCHAR *)dbName, SQL_NTS, origUserid, SQL_NTS, 
   origPassword, SQL_NTS ); 
 
 /* Allocate statement handle */ 
 SQLAllocHandle(SQL_HANDLE_STMT, hdbc1, &hstmt); 
 
 /* The first call to remote DB2 data source will setup trusted outbound 
   connection for user APP_USER from WFS to remote DB2 data source. */ 
 SQLExecDirect (hstmt, (SQLCHAR *) "SELECT * FROM patents_nn", SQL_NTS); 
 
 /* Perform some work under user ID "APP_USER" */ 
 . . . . . . . . . . . 
 
 /* Commit the work. End the transaction. */ 
 SQLEndTran(SQL_HANDLE_DBC, hdbc1, SQL_COMMIT); 
 
 /* Free statement handle */ 
 SQLFreeHandle(SQL_HANDLE_DBC, hstmt); 
 
 /* At the transaction boundary, switch the inbound user ID on the trusted 
   connection from APP_USER to BOB. Note: Password is not required 
   since PUBLIC appears in the "with use for" clause "without authentication" 
   in the MY_WFS_TCX trusted context object. */ 
 SQLSetConnectAttr (hdbc1, SQL_ATTR_TRUSTED_CONTEXT_USERID, 
   reuseUserid, SQL_IS_POINTER ); 
 
 /* Allocate statement handle */ 
 SQLAllocHandle(SQL_HANDLE_STMT, hdbc1, &hstmt); 
 
 /* The first call to the remote data source after switching inbound user will 
   switch the outbound user ID as well (from APP_USER to BOB). 
   Since no user mapping was specified for user BOB, the same user ID 
   will be passed on to the outbound connection. 
   Password is not required since PUBLIC appears in the "with use for" clause 
   "without authentication" in the MY_DB2_TCX trusted context object. */ 
 SQLExecDirect (hstmt, (SQLCHAR *) "SELECT * FROM patents_nn", SQL_NTS); 
 
 /* Perform new work using user ID "BOB" */ 
 . . . . . . . . . 
 
 /* Commit the work. End the transaction. */ 
 SQLEndTran(SQL_HANDLE_DBC, hdbc1, SQL_COMMIT); 
 
 . . . . . . . . . 
 
 /* Disconnect from the database */ 
 SQLDisconnect( hdbc1 ); 
 
 /* Cleanup, free handles, etc */ 
 . . . . . . . . . 
 
 return 0; 
} /* end of main */ 

上一页  3 4 5 6 7 8 9 10  下一页

Tags:WebSphere Federation Server

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接