[EJB3] - Custom principal is not propagated to ejb session context (resteasy3 + oauth)
by Marcel Rovira
Marcel Rovira [https://community.jboss.org/people/marcel.rovira] created the discussion
"Custom principal is not propagated to ejb session context (resteasy3 + oauth)"
To view the discussion, visit: https://community.jboss.org/message/826545#826545
--------------------------------------------------------------
Hello,
I'm using resteasy 3.0.1 Final with oauth in JBoss 6.1 EAP and my custom principal class is not propagated to sessioncontext in an EJB3.
Oauth is configured as BearerTokenAuthenticator
My login-module configuration in standalone.xml to use extended login module
<login-module code="es.gc.epsilon.secure.api.shared.resources.MyDatabaseServerLoginModule" flag="required">
<module-option name="dsJndiName" value="java:jboss/datasources/EpsilonXADS"/>
<module-option name="principalsQuery" value="select PASSWORD from EP_USER where name=?"/>
<module-option name="rolesQuery" value="select ROLE_NAME, 'Roles' from EP_USER_ROLE where USER_NAME = ?"/>
<module-option name="hashAlgorithm" value="MD5"/>
<module-option name="hashEncoding" value="base64"/>
<module-option name="unauthenticatedIdentity" value="guest"/>
</login-module>
My DatabaseServerLoginModule:
public class MyDatabaseServerLoginModule extends DatabaseServerLoginModule {
@Override
protected java.security.Principal createIdentity(String username) throws Exception {
System.out.println("createIdentity BEGIN");
MyCustomPrincipal p = null;
if (principalClassName == null) {
p = new MyCustomPrincipal(username);
} else {
p = (MyCustomPrincipal) super.createIdentity(username);
}
return p;
}
...
My custom principal
public class MyCustomPrincipal extends SimplePrincipal implements Serializable {
private static final long serialVersionUID = 1L;
private String tenant;
public MyCustomPrincipal(String name) {
super(name);
// TODO Auto-generated constructor stub
}
...
My oauth server configuration:
*jboss-web.xml*
<jboss-web>
<security-domain>java:/jaas/jaasEpsilon</security-domain>
<valve>
<class-name>org.jboss.resteasy.skeleton.key.as7.OAuthAuthenticationServerValve</class-name>
</valve>
</jboss-web>
My api rest configuration project:
*web.xml*
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>jaasEpsilon</realm-name>
</login-config>
<security-constraint>
<web-resource-collection>
<web-resource-name>All resources</web-resource-name>
<description>Protects all resources</description>
<url-pattern>/api/secure/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>admin</role-name>
<role-name>employee</role-name>
</auth-constraint>
</security-constraint>
<context-param>
<param-name>resteasy.role.based.security</param-name>
<param-value>true</param-value>
</context-param>
*jboss-deployment-structure*
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="org.jboss.resteasy.resteasy-jaxrs" services="import"/>
<module name="org.jboss.resteasy.resteasy-jackson-provider" services="import"/>
<module name="org.jboss.resteasy.skeleton-key"/>
</dependencies>
</deployment>
</jboss-deployment-structure>
*jboss-web.xml*
<jboss-web>
<valve>
<class-name>org.jboss.resteasy.skeleton.key.as7.BearerTokenAuthenticatorValve</class-name>
</valve>
</jboss-web>
>From an EJB I extract principal info as
@Resource(name = "sessionContext")
private SessionContext sctx;
...
Principal principal = sctx.getCallerPrincipal();
if (!(principal instanceof MyCustomPrincipal)) {
System.out.println("I expected a " + MyCustomPrincipal.class.getName() + " but got a "
+ principal.getClass().getName() + " instead !!!!!!");
and the result is:
I expected a es.gc.epsilon.secure.api.shared.resources.MyCustomPrincipal but got a org.jboss.resteasy.skeleton.key.SkeletonKeyPrincipal instead
Is this a bug, is there another way to retrieve the caller principal, is there any wrong configuration?
Thanks.
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/826545#826545]
Start a new discussion in EJB3 at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&con...]
12 years, 4 months
[jBPM] - How to use different implementation of UserGroupCallback for each Process?
by Thomas Setiabudi
Thomas Setiabudi [https://community.jboss.org/people/thomas.setiabudi] created the discussion
"How to use different implementation of UserGroupCallback for each Process?"
To view the discussion, visit: https://community.jboss.org/message/826502#826502
--------------------------------------------------------------
Hi,
in JBPM (currently I am using JBPM 5.4 Final ), is it possible to have different implementation of UserGroupCallback for every process definition?
Sample case is I have two different process, say Process A and Process B
Process A has its own user and group store and structure while Process B also has its own user and group store and structure.
Is it possible to have different implementation of UserGroupCallback for each Process Definition?
Currently this is my setup:
1. I use JBPM 5.4 Final
2. My JBPM jars and Human Task jars are bundled in one WebApp
3. I use Spring to setup single StatefulKnowledgeSession that lives as long as the WebApp lives.
4. I also setup a Local Task Service and set the UserGroupCallback implementation via Spring
this is how my the UserGroupCallback registered in Spring
<bean id="userGroupCallbackManager" class="org.jbpm.task.identity.UserGroupCallbackManager"
factory-method="getInstance">
<property name="callback" ref="chameleonUGC"></property>
</bean>
A brief chat with Salaboy (Mauricio Salatino) in IRC, he says that I can set multiple Knowledge Session for each process definition
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/826502#826502]
Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&con...]
12 years, 4 months
[jBPM] - jBPM noob questions
by Viktor Alexandrov
Viktor Alexandrov [https://community.jboss.org/people/synclpz] created the discussion
"jBPM noob questions"
To view the discussion, visit: https://community.jboss.org/message/825487#825487
--------------------------------------------------------------
Hello, all. I got some noob (maybe) questions concerning implementing existing scenarios in jBPM. I got some proprietary workflow manager runtime (running on AS7) and tooling to define workflows via graphical editor. The workflows are rather simple and consist of nodes (with in/out parameters) and arrows pointing to the next node (or nodes if current node makes some decisions). Every node is a simple java class that allows to perform some operation: math operations, database lookups/stores, invoke HTTP GET's, log, start another workflows, some proprietary actions and so on.
Now I want to migrate existing service logic to jBPM (actually may be to SwitchYard with jBPM as process orchestrator). Beacause of almost no knowledge in "perfect" BPMN I'm afraid of making wrong architectural decisions :)
I would be very glad if someone could propose me the right solutions or just post some links to the right places to read!
My simple process looks like this:
1. Log some input vars
2. Prepare (map) some additional parameters
3. Query some application properties (config)
4. Query DB with request based on prepared data
5. Modify data (e.g. update modification time)
6. Update data in DB
7. Invoke some sub-process
8. Execute some action through, for example, HTTP or other (proprietary) interface
9. If everything ok, commit data in DB, else rollback and write log
10. Map some paramerers for output
11. Finish
I cannot understand clearly how this should be implemented using jBPM tools. As I could imagine, logging and parameter mapping and runtime bean fileds updating could be performed via Script Node with java expressions, but may be I should use some other tools for it? I cannot find how do I query DB, update DB: is it only done through custom Service Node? Is there a possibility (examples) to use ORM for domain-specific data model? How could I invoke sub-process with, for example, process name and parameters derived in run-time? If someone could supply any more or less complex examples of jBPM usage: with custom data model or custom services invocations, it would be very appreciated.
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/825487#825487]
Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&con...]
12 years, 4 months
[JBoss Messaging] - Spring JMS error with JBoss 7.1.1-Final
by Marcio B.
Marcio B. [https://community.jboss.org/people/romarcio] created the discussion
"Spring JMS error with JBoss 7.1.1-Final"
To view the discussion, visit: https://community.jboss.org/message/730037#730037
--------------------------------------------------------------
Hello!
I am trying to configure a JMS Listener with Spring 3.1 in JBoss 7.1.1-Final.
But this exception is thrown:
21:05:20,184 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-12) MSC00001: Failed to start service jboss.deployment.unit."jms-receiver.war".PARSE: org.jboss.msc.service.StartException in service jboss.deployment.unit."jms-receiver.war".PARSE: Failed to process phase PARSE of deployment "jms-receiver.war"
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0_03]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0_03]
at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_03]
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS011666: Could not parse file C:\jboss-as-7.1.1.Final\standalone\tmp\vfs\temp22a1673201a833b9\jms-receiver.war-1a83767da3f83ba\WEB-INF\spring-jms.xml
at org.jboss.as.messaging.deployment.MessagingXmlParsingDeploymentUnitProcessor.deploy(MessagingXmlParsingDeploymentUnitProcessor.java:76)
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
... 5 more
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS011666: Could not parse file C:\jboss-as-7.1.1.Final\standalone\tmp\vfs\temp22a1673201a833b9\jms-receiver.war-1a83767da3f83ba\WEB-INF\spring-jms.xml
at org.jboss.as.messaging.deployment.MessagingXmlParsingDeploymentUnitProcessor.deploy(MessagingXmlParsingDeploymentUnitProcessor.java:73)
... 6 more
Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[2,1]
Message: Unexpected element '{ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans}beans'
at org.jboss.staxmapper.XMLMapperImpl.processNested(XMLMapperImpl.java:108) [staxmapper-1.1.0.Final.jar:1.1.0.Final]
at org.jboss.staxmapper.XMLMapperImpl.parseDocument(XMLMapperImpl.java:69) [staxmapper-1.1.0.Final.jar:1.1.0.Final]
at org.jboss.as.messaging.deployment.MessagingXmlParsingDeploymentUnitProcessor.deploy(MessagingXmlParsingDeploymentUnitProcessor.java:67)
... 6 more
21:05:20,198 INFO [org.jboss.as.server] (management-handler-thread - 2) JBAS015870: Deploy of deployment "jms-receiver.war" was rolled back with failure message {"JBAS014671: Failed services" => {"jboss.deployment.unit.\"jms-receiver.war\".PARSE" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"jms-receiver.war\".PARSE: Failed to process phase PARSE of deployment \"jms-receiver.war\""}}
21:05:20,351 INFO [org.jboss.as.server.deployment] (MSC service thread 1-11) JBAS015877: Stopped deployment jms-receiver.war in 153ms
21:05:20,352 INFO [org.jboss.as.controller] (management-handler-thread - 2) JBAS014774: Service status report
JBAS014777: Services which failed to start: service jboss.deployment.unit."jms-receiver.war".PARSE: org.jboss.msc.service.StartException in service jboss.deployment.unit."jms-receiver.war".PARSE: Failed to process phase PARSE of deployment "jms-receiver.war"
File spring-jms.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans"
xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
<property name="environment">
<props>
<prop key="java.naming.factory.initial">org.jboss.naming.remote.client.InitialContextFactory</prop>
<prop key="java.naming.provider.url">remote://localhost:4447</prop>
<prop key="java.naming.security.principal">user</prop>
<prop key="java.naming.security.credentials">pass</prop>
</props>
</property>
</bean>
<bean id="queueConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="jms/RemoteConnectionFactory"/>
<property name="jndiTemplate" ref="jndiTemplate"/>
</bean>
<bean id="secureConnectionFactory" class="org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter">
<property name="targetConnectionFactory" ref="queueConnectionFactory"/>
<property name="username" value="user"/>
<property name="password" value="pass"/>
</bean>
<bean id="queueName" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="jms/queue/test"/>
<property name="jndiTemplate" ref="jndiTemplate"/>
</bean>
<bean id="messageListener" class="org.springframework.jms.listener.adapter.MessageListenerAdapter">
<constructor-arg>
<bean class="com.tecnoil.consumer.jms.JMSConsumer"/>
</constructor-arg>
<property name="messageConverter">
<null/>
</property>
</bean>
<bean id="jmsContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
<property name="connectionFactory" ref="secureConnectionFactory"/>
<property name="destination" ref="queueName"/>
<property name="sessionAcknowledgeModeName" value="AUTO_ACKNOWLEDGE"/>
<property name="messageListener" ref="messageListener"/>
<property name="receiveTimeout" value="1000"/>
</bean>
</beans>
What is the solution?
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/730037#730037]
Start a new discussion in JBoss Messaging at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&con...]
12 years, 4 months
[Datasource Configuration] - Need help accessing a jdbc datasource inside ejb on jboss 7.1.1
by tareq zaman
tareq zaman [https://community.jboss.org/people/tareq_zaman] created the discussion
"Need help accessing a jdbc datasource inside ejb on jboss 7.1.1"
To view the discussion, visit: https://community.jboss.org/message/826053#826053
--------------------------------------------------------------
Hi,
I would appreciate any help on this. I have tried so many ways but no success yet. I am trying to test a datasource inside an session ejb in JBoss AS 7.1.1.Final. Using MS SQL server.
Getting name not found exception, here is the stack trace. Please note in the code I am using the full JNDI name as java:jboss/datasources/ezsystemDS.
19:20:57,293 ERROR [stderr] (EJB default - 1) javax.naming.NameNotFoundException: jboss/datasources/ezsystemDS -- service jboss.naming.context.java.jboss.exported.jboss.datasources.ezsystemDS
19:20:57,306 ERROR [stderr] (EJB default - 1) at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:97)
19:20:57,317 ERROR [stderr] (EJB default - 1) at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:178)
19:20:57,325 ERROR [stderr] (EJB default - 1) at org.jboss.naming.remote.protocol.v1.Protocol$1.handleServerMessage(Protocol.java:127)
19:20:57,332 ERROR [stderr] (EJB default - 1) at org.jboss.naming.remote.protocol.v1.RemoteNamingServerV1$MessageReciever$1.run(RemoteNamingServerV1.java:73)
19:20:57,337 ERROR [stderr] (EJB default - 1) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
19:20:57,341 ERROR [stderr] (EJB default - 1) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
19:20:57,344 ERROR [stderr] (EJB default - 1) at java.lang.Thread.run(Thread.java:724)
19:20:57,646 INFO [org.jboss.as.naming] (Remoting "sc1-mis99" task-3) JBAS011806: Channel end notification received, closing channel Channel ID 5643bfb0 (inbound) of Remoting connection 0148380c to null
When Jboss starts I can see datasources are bound correctly. Also verified that from JBOSS console naming tree view.
[org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-14) JBAS010400: Bound data source [java:jboss/datasources/ezsystemSeqDS]
19:15:45,643 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-7) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]
19:15:45,643 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-11) JBAS010400: Bound data source [java:jboss/datasources/ezsystemDS]
19:15:45,947 INFO [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://127.0.0.1:9990 http://127.0.0.1:9990
19:15:45,948 INFO [org.jboss.as] (Controller Boot Thread) JBAS015874: JBoss AS 7.1.1.Final
Here is my ejb code
public String echo(String input){
try {
InitialContext ctx = new InitialContext();
DataSource datasrc = (DataSource)ctx.lookup("java:jboss/datasources/ezsystemDS");
if(datasrc != null) {
Connection con = datasrc.getConnection();
con.close();
}
} catch (Exception e) {
// TODO Auto-generated catch block
String x = e.getMessage();
e.printStackTrace();
}
return "Echoing back " + input ;
}
Data sources are configured in module.xml and created using admin console. Thanks.
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/826053#826053]
Start a new discussion in Datasource Configuration at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&con...]
12 years, 4 months