`
kylinsoong
  • 浏览: 240157 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

JBoss LoginInitialContext Factory Implementation

阅读更多

      Jboss has a series of implementation of InitialContext Factory, but  this blog only concentrated on org.jboss.security.jndi.LoginInitialContextFactory, and I was planned to prestent this issue as Two main part, Part One: Theroy-based(including some definition of LoginInitialContextFactory, InitialContext Properties description), and Part Two: Demo-based(Complete a simple demo which use LoginInitialContextFactory).

 

PART ONE: The Login InitialContext Factory Implementation

1. why LoginInitialContextFactory?

      JAAS is the preferred method for authenticating a remote client to JBoss. However, for simplicity and to ease the migration from other application server environment that does not use JAAS, JBoss allows you the security credentials to be passed through the InitialContext, so the LoginInitialContextFactory came out.

 

2. Originally or Old version JBoss DO NOT support LoginInitialContextFactory.

      Historically JBoss has not supported providing login information via the InitialContext factory environment. The reason being that is JAAS provides a much more flexible framework. For simplicity and migration from other application server environment that do make use of this mechanism, since jboss-3.0.3 there has been an InitialContext factory implementation that allow this.

 

3. How the LoginInitialContextFactory work(authenticating clients through JAAS)?

      Authough this kinds of authentication is thought as J2EE JAAS, but there is no manifest use of the JAAS interface in the client application, Only be taken placed in Server which we can say what JAASis used under the covers.

      What this basically does is that when the client is trying to download the naming proxy on the client side, JAAS login is performed with the login configuration name to be equal to the name passed in Context.SECURITY_PROTOCOL, username and credential from the context information. Only after the login succeeds, will the naming proxy be returned.

 

4. InitialContext environment properties for LoginInitialContextFactory

      The factory class that provides this capability is the org.jboss.security.jndi.LoginInitialContextFactory. The complete set of supported InitialContext environment properties for this factory as the below Table:

Name Description Value

java.naming.factory.initial

(Context.INITIAL_CONTEXT_FACTORY )

The name of the environment property for specifying the initial context factory, org.jboss.security.jndi.LoginInitialContextFactory

java.naming.provider.url

(java.naming.provider.url )

   

java.naming.security.principal

(Context.SECURITY_PRINCIPAL )

The principal to authenticate This may be either a java.security.Principal implementation or a string representing the name of a principal.

java.naming.security.credentials

(Context.SECURITY_CREDENTIALS )

The credentials that should be used to authenticate the principal  
java.naming.factory.url.pkgs   For all JBoss JNDI provider this must be
org.jboss.naming:org.jnp.interfaces

java.naming.security.protocol

(Context.SECURITY_PROTOCOL)

This gives the name of the
JAAS login module to use for the authentication of the principal and credentials.
 

Sample Java Code for this properties:

Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.security.jndi.LoginInitialContextFactory");
env.put(Context.PROVIDER_URL, "jnp://192.168.68.83");
env.put(Context.SECURITY_PRINCIPAL, "principal ");
env.put(Context.SECURITY_CREDENTIALS, "credentials ");
new InitialContext(env);

 

PART TWO: a simple Demo to use The Login InitialContext Factory Implementation

1. deploy a ejb on JBoss, the session bean class and remote interfaces as following:

public interface TestService {
	public abstract String ping();
	public abstract String getDate();
}

 

public interface TestServiceLocal extends TestService {

}

 

@Stateless
@Remote(TestService.class)
@Local(TestServiceLocal.class)
@TransactionManagement(TransactionManagementType.CONTAINER)
@TransactionAttribute(TransactionAttributeType.REQUIRED)
@PermitAll
public class LoginInitialContextFactoryTestSession implements TestServiceLocal{

	public String ping() {
		return "Ping LoginInitialContextFactoryTestSession suceessful...";
	}

	public String getDate() {
		return "[" + new SimpleDateFormat("yyyy-MM-dd'T'kk:mm:ss").format(new Date()) + "]";
	}

}

 as depicted: LoginInitialContextFactoryTestSession is a stateless seeion bean, it own a remote interface and local interface, also need transaction attribute and security setting. when we complete the deploy we can use LoginInitialContextFactory as factoty and pass the princial and credencials what to execute JAAS authentication and authrization, as fllowing code:

File authFile = new File("D:/dev-tools/jboss-eap-4.3/jboss-as/client/auth.conf");   
System.setProperty("java.security.auth.login.config", "file:///" + authFile.getAbsolutePath()); 
		
        Properties properties = new Properties();
        properties.setProperty(Context.INITIAL_CONTEXT_FACTORY , "org.jboss.security.jndi.LoginInitialContextFactory");
        properties.setProperty(Context.PROVIDER_URL, "jnp://192.168.68.83:1099");
        properties.setProperty(Context.SECURITY_PRINCIPAL, "homeTest");
        properties.setProperty(Context.SECURITY_CREDENTIALS, "kylin");
        
        Context ctx = new InitialContext(properties);
        TestService stub = (TestService) ctx.lookup("home-test-v2/LoginInitialContextFactoryTestSession/remote");
        System.out.println(stub);
        System.out.println(stub.ping());
        System.out.println(stub.getDate());

 

run the method the output stream will print:

jboss.j2ee:ear=home-test-v2.ear,jar=LoginInitialContextFactoryTestSession.jar,name=LoginInitialContextFactoryTestSession,service=EJB3
Ping LoginInitialContextFactoryTestSession suceessful...
[2011-05-19T16:28:36]

 

ENDING...

0
2
分享到:
评论

相关推荐

    Jboss项目部署文档

    Jboss 项目部署文档 Jboss 项目部署文档是指在 Jboss 服务器上部署项目的详细步骤,包括环境变量的配置、项目打包、配置文件的修改、JNDI 的配置等。以下是 Jboss 项目部署文档的详细知识点: 一、环境变量配置 ...

    JBOSS,JBoss安装部署

    【JBOSS,JBoss安装部署】 JBoss是Red Hat公司开发的一款开源的应用服务器,它基于Java EE(Enterprise Edition)规范,提供了全面的企业级应用程序部署和管理解决方案。本篇文章将详细讲解JBoss的安装和部署过程,...

    jboss 下载(httpwww.jboss.org)

    【JBoss 应用服务器详解】 JBoss 是一个开源的、基于 J2EE(Java 2 Platform, Enterprise Edition)的应用服务器,由全球开发者社区共同维护和开发。它最初以 LGPL 许可协议发布,允许商业应用免费使用。2006年,...

    jboss7.1 linux版本

    JBoss AS 7.1.0.Final是在Linux环境下运行的一款开源Java应用服务器,由Red Hat公司维护。这个版本发布于2012年,它引入了许多改进和新特性,旨在提供更快的启动速度、更高的性能以及更好的模块化。在这个环境中,...

    MyEclipse中配置JBoss

    【标题】:“MyEclipse中配置JBoss” 在IT行业中,MyEclipse是一款深受开发者喜爱的集成开发环境(IDE),尤其对于Java EE项目开发来说,它提供了强大的支持。而JBoss则是一个开源的应用服务器,广泛用于部署和管理...

    在jboss上部署web应用

    【JBoss 概述】 JBoss 是一个开源的、基于Java的、全面实现了J2EE规范的应用服务器。它提供了企业级的功能,如EJB(Enterprise JavaBeans)、JMS(Java Message Service)、JTS/JTA(Java Transaction Service / ...

    在IntelliJ idea8中部署Jboss服务器图解

    "在IntelliJ IDEA 8中部署Jboss服务器图解" IntelliJ IDEA 8是 JetBrains 公司开发的一款功能强大且灵活的集成开发环境(IDE),它支持多种programming语言,包括Java、Python、Ruby、PHP等。Jboss则是一款流行的...

    JavaEE源代码 jboss-common

    JavaEE源代码 jboss-commonJavaEE源代码 jboss-commonJavaEE源代码 jboss-commonJavaEE源代码 jboss-commonJavaEE源代码 jboss-commonJavaEE源代码 jboss-commonJavaEE源代码 jboss-commonJavaEE源代码 jboss-...

    jboss配置入门,jboss的初级配置

    jboss配置入门 jboss系统是一种基于Java的应用服务器,具有高性能、可扩展、安全性强等特点。在本文中,我们将对jboss的基本配置进行介绍,包括其文件夹结构、配置文件、负载均衡配置等。 jboss文件夹结构 jboss的...

    jboss-eap-7.2.6-patch

    【JBoss EAP 7.2.6 补丁包详解】 JBoss Enterprise Application Platform (EAP) 是 Red Hat 提供的一款开源中间件,用于构建、部署和管理企业级 Java 应用程序。JBoss EAP 7.2.6 版本是一个重要的更新,包含了多个...

    jboss-4.0.5.GA.zip

    JBoss是著名的开源Java应用服务器,它基于Java EE(Enterprise Edition)规范,为开发者提供了全面的中间件服务。4.0.5.GA版本是JBoss的一个稳定版本,发布于2006年,适用于那些需要可靠且成熟的Java应用程序部署的...

    jboss热部署配置

    JBoss是一款著名的开源Java应用服务器,它提供了许多企业级服务,包括事务管理、安全性和集群功能。在开发过程中,为了提高效率,我们通常希望在不中断应用服务的情况下更新部署的应用程序,这就是所谓的“热部署”...

    jboss7开发部署详细文档

    本文档提供了jboss7开发和部署的详细指导,涵盖了jboss7的下载与安装、Eclipse中配置jboss7、项目部署和JNDI获取等方面的内容,旨在帮助开发者快速上手jboss7,并将jboss4.2版本平滑地移植到jboss7。

    jboss7ejb配置文件

    在JBoss 7及以上版本中,对EJB的配置过程相较于之前的版本有所变化,主要涉及到两个关键的配置文件:`jboss-ejb3.xml`和`ejb-jar.xml`。 `ejb-jar.xml`文件是EJB模块的标准配置文件,遵循Java EE规范。在这个文件中...

    jboss-exp.rar

    某大牛写的jboss-exp 1. 查看系统名称 java -jar jboss_exploit_fat.jar -i http://192.168.7.84:10081/invoker/JMXInvokerServlet get jboss.system:type=ServerInfo OSName 2. 查看系统版本 java -jar jboss_...

    Jboss7官方手册

    JBoss AS7 是一个开源的Java应用服务器,它是JBoss企业应用平台(EAP)的社区版本。JBoss AS7官方手册是关于如何配置、部署和管理JBoss AS7应用服务器的一份权威指南。该手册由Francesco Marchioni撰写,旨在帮助读者...

    jboss如何在windows系统服务中启动

    在IT行业中,JBoss是一个广泛使用的Java应用服务器,它提供了许多功能,如部署和管理Web应用程序、事务处理、安全管理等。对于Windows用户来说,将JBoss配置为系统服务可以实现自动启动,避免每次开机时手动开启,...

Global site tag (gtag.js) - Google Analytics