[Security & JAAS/JBoss] - Set Principal in a web application
by hubaer
Hi all,
I don't know if this here is the right forum, but hopefully I get some answers from the experts.
We are migration a devided application (web, batch processing, web services all single applications) into a JEE application, running on JBoss.
As far, most of the parts are running correctly, but we have a little problem with the interaction of the web with our EJB3 session / entity beans. For auditing purpose we must store the name of the user which created or modified an entity. Therefore we write an interceptor with get the principal from the SecurityAssociation class.
To access the session beans we make a JNDI lookup like
| environment.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.security.jndi.JndiLoginInitialContextFactory");
| environment.put(Context.SECURITY_PRINCIPAL, "testName");
| environment.put(Context.SECURITY_CREDENTIALS, "testPassw");
| environment.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
| environment.put("java.naming.provider.url", "jnp://localhost:1099");
| InitialContext context = new InitialContext(environment);
| context.lookup(jndiName);
|
But always we call SecurityAssociation.getPrincipal() in our audit interceptor we get a null object.
We tried the same with a remote client setting the same JNDI values and got the principal from the SecurityAssociation.
Do I miss something accessing the the session beans via JNDI inside JBoss from the web layer to the EJB layer?
Any help is welcome.
Thanks,
Marco
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4210339#4210339
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4210339
17 years, 2 months
[Beginners Corner] - Re: SQLException
by jotnarta
Ok, following is my msql-ds.xml file, and the configuration to connect to MySQL database, specifically, mysql schema:
| <?xml version="1.0" encoding="UTF-8"?>
|
| <datasources>
|
| <local-tx-datasource>
|
| <jndi-name>DefaultDS</jndi-name>
|
| <connection-url>jdbc:mysql://localhost:3306/mysql</connection-url>
|
| <driver-class>com.mysql.jdbc.Driver</driver-class>
|
| <user-name>root</user-name>
|
| <password>admin</password>
|
| <valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLValidConnectionChecker</valid-connection-checker-class-name>
|
| <metadata>
|
| <type-mapping>mySQL</type-mapping>
|
| </metadata>
|
| </local-tx-datasource>
|
| </datasources>
|
and following is the jsp file that I am trying to connect my schema which was defined in the previous xml file:
| <%@page import="java.util.*,javax.naming.*,javax.sql.DataSource,java.sql.*"%>
| <%
| DataSource ds = null;
| Connection con = null;
| //Statement st = null;
| InitialContext ic;
|
| try {
| ic = new InitialContext();
| ds = (DataSource) ic.lookup("java:/DefaultDS");
| con = ds.getConnection();
| Statement st = con.createStatement();
| ResultSet rs = st.executeQuery("select * from db");
|
| while(rs.next()) {
| out.println("<br> " + rs.getString("ID"));
| }
| rs.close();
| st.close();
|
| out.println("DONE");
| } catch (Exception e) {
| out.println("Exception thrown " + e );
| //e.printStackTrace();
| } finally {
| if (con != null) {
| con.close();
| }
| }
| %>
|
Do you have any comments ????
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4210336#4210336
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4210336
17 years, 2 months
[Beginners Corner] - Re: JBoss 5.0.0.GA and RedHat compatibility
by jaikiran
"ramboid" wrote :
| [root@pbsiemr log]# cat server.log|grep ERROR
| 2009-02-14 13:49:33,412 ERROR [org.jboss.kernel.plugins.dependency.AbstractKernelController] (main) Error installing to Create: name=TransactionManager state=Configured
| 2009-02-14 13:49:34,747 ERROR [org.jboss.system.server.profileservice.ProfileServiceBootstrap] (main) Failed to load profile: Summary of incomplete deployments (SEE PREVIOUS ERRORS FOR DETAILS):
| -> TransactionManager{Configured:**ERROR**}
| -> TransactionManager{Instantiated:**ERROR**}
| -> TransactionManager{Create:**ERROR**}
| -> TransactionManager{Configured:**ERROR**}
| *** CONTEXTS IN ERROR: Name -> Error
| TransactionManager -> **ERROR** | com.arjuna.ats.arjuna.exceptions.FatalError: [com.arjuna.ats.internal.arjuna.utils.SocketProcessId_2] - SocketProcessId.getpid could not get unique port.
|
Looks related to this http://www.jboss.org/index.html?module=bb&op=viewtopic&t=146880. Can you post the contents of your hosts file?
While posting logs or xml content or code, please remember to wrap it in a code block by using the Code button in the message editor window. Please use the Preview button to ensure that your post is correctly formatted.
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4210320#4210320
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4210320
17 years, 2 months