tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Geoff Callender <abc_...@mac.com>
Subject How to propagate security context from Jetty to OpenEJB?
Date Mon, 25 Jan 2010 05:32:42 GMT

I need advice on how to propagate the security context from (Jetty 6.1.6) to
OpenEJB (3.1.1). My web pages can retrieve the Principal correctly but my
EJB session bean methods only get "guest". Is this a known problem or am I
doing something wrong?

>From web.xml…

	<!-- Authentication -->
	
	<login-config>
		<auth-method>FORM</auth-method>
		<realm-name>MyRealm</realm-name>
		<form-login-config>
			<form-login-page>/jsp/login.html</form-login-page>
			<form-error-page>/jsp/error.html</form-error-page>
		</form-login-config>
	</login-config>

	<security-constraint>
		…
	</security-constraint>

>From jetty.xml...

	<Call name="addUserRealm">
		<Arg>
			<New class="org.mortbay.jetty.plus.jaas.JAASUserRealm">
				<Set name="name">MyRealm</Set>
				<Set name="LoginModuleName">JDBCLoginModule</Set>
			</New>
		</Arg>
	</Call>

>From login.conf...

	JDBCLoginModule {
		org.mortbay.jetty.plus.jaas.spi.JDBCLoginModule required
		debug="true"
		dbUrl="jdbc:mysql://localhost:3306/my_db"
		dbUserName="myuser"
		dbPassword="mypassword"
		dbDriver="com.mysql.jdbc.Driver"
		userTable="blah"
		userField="blah"
		credentialField="blah"
		userRoleTable="blah"
		userRoleUserField="blah"
		userRoleRoleField="blah";
	};

>From web page code…

		// The following name will be, correctly, whatever we logged in with.
		String name = httpServletRequest.getUserPrincipal().getName();
		...
		InitialContext ctx = new InitialContext();
		IMyServiceLocal myService = (IMyServiceLocal)
ctx.lookup("MyServiceLocal"); 
		result = myService.doSomething();

The EJB method doSomething() thinks the Principal is "guest"…

	@Resource
	SessionContext _context;

	public String doSomething() {
		...
		// This name will be, wrongly, "guest".
		String name = context.getCallerPrincipal().getName();
		...
	}

Any pointers appreciated.

Geoff

-- 
View this message in context: http://n4.nabble.com/How-to-propagate-security-context-from-Jetty-to-OpenEJB-tp1289042p1289042.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Mime
View raw message