`
wdw8217
  • 浏览: 1098 次
  • 性别: Icon_minigender_1
  • 来自: 广州
最近访客 更多访客>>
文章分类
社区版块
存档分类
最新评论

关于项目中多线程访问was v5 jndi 相关

阅读更多

Hi,Please take a look at this:

Component-managed authentication
In the case of component-managed authentication, the application component
accessing the resource or adapter is responsible for programmatically supplying
the credentials, or WebSphere Application Server can supply a default
component-managed authentication alias, if available.

After obtaining the connection factory for the resource from Java Naming and
Directory Interface (JNDI), the application component creates a connection to the
resource using the create method on the connection factory supplying the
credentials. If no credentials are supplied when creating a connection and a
component-managed authentication alias has been specified on the Java 2
Connector (J2C) connection factory, the credentials from the authentication alias
are used. Assuming the credentials are valid, future requests using the same
connection make use of the same credentials.

Note: Component-managed authentication is specified by setting the
res-auth entry in the deployment descriptor for the resource reference to
Application.

Creating a sample EIS resource adapter is beyond the scope of this book. You
can find sample code for looking up a resource adapter connection factory and
connecting to the resource in Example 17-1. The code assumes that a Resource
Reference has been defined and named EISResourceName and maps to a J2EE
Resource Adapter connection factory.
The basic steps are as follows:
1. Get initial JNDI context.
2. Look up the connection factory for the resource adapter.
3. Create a ConnectionSpec object holding credentials.
4. Obtain the Connection Object from the Connection Factory by supplying the
ConnectionSpec object.
After a connection is obtained using the credentials specified in the
ConnectionSpec object, all future interactions, through interaction objects, carry
the user credentials and the EIS fulfills the request or denies it based on the
Authorization properties in EIS.
Example 17-1 Get resource connection
try
{
Context ic = new InitialContext();
ConnectionFactory cf = (ConnectionFactory)
ic.lookup("java:comp/env/EISResourceName");
try {
//Use the following if res-auth=Application
//This is for Component Managed Authentication with
//no JAAS Authentication Alias set on the Connection Factory
WSConnectionSpecImpl conSpec = new WSConnectionSpecImpl();
conSpec.setUserName("username"); // replace the username with the
value

conSpec.setPassword("password"); // replace the password with the
value
Connection con = cf.getConnection(conSpec);
//Use the following if res-auth=Container
//This is for Container Managed Authentication
//Connection con = cf.getConnection();
} catch (ResourceException re) {
System.out.println(re.toString());
}
}
catch(NamingException ne) {
System.out.println(ne.toString());
}

Container-managed authentication
Container-managed authentication removes the requirement of the component
to programmatically supply the credentials for accessing the EIS. Instead of
calling the getConnection() method with a ConnectionSpec object,
getConnection() is called with no arguments. See Example 17-1 for sample code.
The authentication credentials used for connecting to the EIS are then supplied
by the Web container, the application container, or the Enterprise JavaBeans
(EJB) container, depending on where the resource is accessed from.
WebSphere Application Server V6.1 supports the Java Authentication and
Authorization Service (JAAS) specification. Therefore, you can map the
credentials for accessing the EIS from any of the configured JAAS Authentication
login modules, including any custom JAAS Authentication login module.

When defining the Resource Reference in the deployment descriptor, either Web
application deployment descriptor or EJB deployment descriptor, after the
Authentication is set to Container and the WebSphere Bindings JNDI Name has
been entered, three options become available for the JAAS Login Configuration.
The three options are explained in the following sections.
Container-managed authentication (deprecated)
This option uses the container-managed authentication settings that are defined
for the resource’s connection factory. The credentials can come from a JAAS
Authentication Alias when using the DefaultPrincipalMapping
Mapping-configuration alias setting, or be mapped from another JAAS
Authentication login module.

Note: Selecting this option and specifying DefaultPrincipalMapping and
selecting a JAAS Authentication Alias when defining the resource’s
Connection Factory provides the same functionality as WebSphere
Application Server V5.
We no longer recommend this method. We recommend you to use the Use
Default Method option, which is discussed next.

Use Default Method
The Use Default Method setting behaves very similarly to container-managed
authentication using the DefaultPrincipalMapping option. A JAAS authentication
alias is linked to the Connection Factory and all container-managed
authentication requests using the resource reference use the credentials from
the alias when connecting to the EIS. The difference is that the linking from the
JAAS authentication alias to Connection Factory is done at the resource
reference level within the application. This alleviates a security exposure by
limiting the scope of the credentials to the application defining the resource
reference. All other applications would have to supply their own credentials when
accessing the Connection Factory directly from JNDI. We recommend this
method for mapping JAAS authentication aliases to Connection Factories.


Use Custom Login Configuration
This option allows you to use any defined JAAS authentication module. Enter the
name of the JAAS authentication modules as it is defined in Security → Secure
administration, applications, and infrastructure → Java Authentication and
Authorization Service → Application logins and specify any parameters
required. When a connection to the resource is required, the specified module is
used to obtain the credentials that are passed to the connector.


---------------------------------中文翻译----------------------
你好,请大家看看这个:

组件管理认证
在组件管理的认证情况下,应用程序组件
访问资源或适配器负责提供编程
的全权证书,或WebSphere应用服务器可以提供一个默认
组件管理的认证别名,如果有的话。

在取得从Java命名和资源的连接工厂
目录接口(JNDI),应用程序组件创建一个连接
资源使用连接工厂创建方法供应
凭据。 如果没有提供凭据当创建一个连接和
组件管理的认证别名已被指定在Java 2
连接器(的J2C)连接工厂,从身份验证的凭据别名
被使用。 假设凭证有效,以后的请求使用相同的
使连接使用相同的凭据。

注:组件管理的认证是通过设置指定
水库- auth的条目在部署描述符参考资源
应用。

创建示例EIS资源适配器超出了本书的范围。 你
查找可以找到一个资源适配器连接工厂和示例代码
连接到资源为例17-1。 该代码假定一个资源
参考已定义和命名EISResourceName并映射到一个J2EE
资源适配器连接工厂。
基本步骤如下:
1。 获得初始JNDI上下文。
2。 查找该资源适配器的连接工厂。
3。 创建一个ConnectionSpec对象持有的凭据。
4。 获取从连接工厂通过提供连接对象
ConnectionSpec对象。
得到连接之后使用指定的凭据
ConnectionSpec对象,所有未来的互动,通过互动的对象,进行
用户凭据和EIS符合要求或否认它的基础上
在EIS授权属性。
例17-1获取资源的连接
尝试
{
语境集成电路=新的InitialContext();
ConnectionFactory的比照=(ConnectionFactory的)
ic.lookup(“的java:comp /包膜/ EISResourceName”);
尝试{
/ /使用下面如果解析度- auth的=应用
/ /这是与组件管理认证
/ /没有的JAAS认证别名设置在连接工厂
WSConnectionSpecImpl conSpec =新WSConnectionSpecImpl();
conSpec.setUserName(“用户名”); / /替换用的用户名


conSpec.setPassword(“密码”); / /替换密码

连接浓度= cf.getConnection(conSpec);
/ /使用下面如果解析度- auth的=集装箱
/ /这是对集装箱管理认证
/ /连接浓度= cf.getConnection();
}捕捉(ResourceException重新){
System.out.println(re.toString());
}
}
赶上(NamingException的东北){
System.out.println(ne.toString());
}

容器管理验证
容器管理验证删除组件的要求
以编程方式供应EIS的凭据访问。 取代
调用的getConnection()与ConnectionSpec对象的方法,
的getConnection()被调用不带参数。 参见例17-1的代码示例。
身份验证连接到EIS使用的凭据,然后提供
由Web容器,应用程序容器,或企业JavaBeans
(EJB)容器,对那里的资源访问的不同。
WebSphere应用服务器V6.1支持Java身份验证和
授权服务(JAAS)的规范。 因此,你可以映射
凭据访问来自任何配置JAAS认证的EIS
登录模块,包括任何自定义的JAAS认证登录模块。

当定义在部署描述符中的资源引用,无论是网络
应用程序部署描述符或EJB部署描述符后,
身份验证设置为容器和WebSphere绑定的JNDI名字
已输入,三个选项成为JAAS登录配置。
三个选项的解释在下面的章节。
容器管理认证(不推荐)
此选项使用容器管理的认证是定义的设置
对资源的连接工厂。 凭据可以来自一个JAAS
当使用身份验证别名DefaultPrincipalMapping
映射配置别名设置,或者从另一个JAAS的映射
验证登录模块。

注:选择此选项并指定DefaultPrincipalMapping和
选择一个JAAS认证别名时,定义资源的
连接工厂提供相同的功能与WebSphere
Application Server V5中。
我们不再推荐此方法。 我们建议您使用使用
默认方法的选择,这是讨论下一步。

使用默认方法
使用默认设置的方法非常类似的行为容器管理
身份验证使用DefaultPrincipalMapping选项。 一个JAAS认证
别名是联系在一起的连接工厂和所有的容器管理
认证请求使用资源引用使用的凭据,从
当连接到该别名的电化学阻抗谱。 所不同的是,从联
JAAS认证别名连接工厂是在做资源
在应用程序中的参考水平。 这减轻了安全曝光
限制范围的凭据的应用程序定义资源
参考。 所有其它应用程序必须提供他们自己的凭据时
访问连接工厂直接从JNDI。 我们建议使用此
方法JAAS认证别名映射到连接工厂。


使用自定义登录配置
此选项允许您使用任何已定义的JAAS认证模块。 输入
JAAS认证名称的模块,因为它是定义在安全性→安全
管理,应用和基础设施→Java认证和
授权服务→申请登录,并指定任何参数
要求。 当连接到资源是必需的,指定的模块
用于获取传递给连接器的凭据。
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics