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认证和
授权服务→申请登录,并指定任何参数
要求。 当连接到资源是必需的,指定的模块
用于获取传递给连接器的凭据。
相关推荐
JNDI测试项目JNDI测试项目JNDI测试项目JNDI测试项目JNDI测试项目JNDI测试项目JNDI测试项目JNDI测试项目JNDI测试项目JNDI测试项目JNDI测试项目JNDI测试项目JNDI测试项目JNDI测试项目JNDI测试项目JNDI测试项目JNDI测试...
配置WAS中的JNDI时,配置DB2 连接池需要的jar包,包括 db2jcc.jar db2jcc_license_cisuz.jar db2jcc_license_cu.jar
was应用服务器部署、调优、JNDI配置、应用平台部署;IHS部署
简单我tomcat5.0中的JNDI应用
jndi获取数据库连接,当前软件版本tomcat8jdk8. Tomcat 为每个在其上运行的 Web 应用都提供了一个 JNDI 的 ...Tomcat中的默认数据源支持基于Commons 项目中的DBCP 1.x连接池,也可以使用实现任何其他连接池
JNDI测试的一个小项目,对您希望有帮助
简要描述项目中Jndi的使用过程,完成servlet通过池连接的方式访问数据库
自定义jndi数据源factory类,用于解密jndi中的加密数据,解密方式为DES,具体可根据实际需求修改。
java 采用JNDI访问数据库(三种方法)
java的JNDI 技术介绍及应用 以及整理的代码。很适合学习与交流用
配置了tomcat之后发现jndi好简单啊,可是碰到了hibernate该怎么做呢,本例详细解析
WebSphere配置JNDI方法(以配置Oracle数据库为例)【附图】
帆软报表FineReport中数据连接中的Tomcat配置JNDI连接,要通过JNDI方式定义数据连接,首先在Tomcat服务器配置好JNDI,然后在设计器中直接调用JNDI的名字,即可成功使用JNDI连接,本文进行详细演示。
连接数据库有JDBC和JNDI等多种方式,该文件详细的描述了如何在tomcat6下配置JNDI的方法,本人测试多次很有效,绝对正确。
jndi配置,jndi配置jndi配置jndi配置jndi配置jndi配置jndi配置jndi配置
jndi入门学习资料,介绍jndi基本原理,安装和使用,基本配置
JNDI服务利用工具 RMI/LDAP,支持部分场景回显、内存shell,高版本JDK场景下利用等,fastjson rce命令执行,log4j rce命令执行 漏洞检测辅助工具
jndi 有关的几个jar 在网上下的一些全要分,有点生气!
在JAVA编程中对JNDI的支持.是一个开放的源码.
java asm jndi_JNDI-Injection-Exploit,用于log4j2漏洞验证 可执行程序为jar包,在命令行中运行以下命令: $ java -jar JNDI-Injection-Exploit-1.0-SNAPSHOT-all.jar [-C] [command] [-A] [address] 其中: -C ...