[JBoss Messaging] - What does JMSUserManager do?
by sappenin
I'm using jboss-messaging, and am wondering what the difference between the JMSUserManager and the 'messaging' application-policy defined in login-conf.xml is. Which one determines my users/roles???
I'm using Mysql for persistent messaging, and in the file called server/deploy/jboss-messaging.sar/mysql-persistence-service.xml, at the bottom, is an mbean that seems to also define users/roles.
Do I need to use both?
| <mbean code="org.jboss.jms.server.plugin.JDBCJMSUserManagerService"
| name="jboss.messaging:service=JMSUserManager"
| xmbean-dd="xmdesc/JMSUserManager-xmbean.xml">
| <depends>jboss.jca:service=DataSourceBinding,name=DefaultDS</depends>
| <depends optional-attribute-name="TransactionManager">jboss:service=TransactionManager</depends>
| <attribute name="DataSource">java:/DefaultDS</attribute>
| <attribute name="CreateTablesOnStartup">true</attribute>
| <attribute name="SqlProperties"><![CDATA[
| CREATE_USER_TABLE=CREATE TABLE JBM_USER (USER_ID VARCHAR(32) NOT NULL, PASSWD VARCHAR(32) NOT NULL, CLIENTID VARCHAR(128), PRIMARY KEY(USER_ID)) ENGINE = INNODB
| CREATE_ROLE_TABLE=CREATE TABLE JBM_ROLE (ROLE_ID VARCHAR(32) NOT NULL, USER_ID VARCHAR(32) NOT NULL, PRIMARY KEY(USER_ID, ROLE_ID)) ENGINE = INNODB
| SELECT_PRECONF_CLIENTID=SELECT CLIENTID FROM JBM_USER WHERE USER_ID=?
| POPULATE.TABLES.1=INSERT INTO JBM_USER (USER_ID,PASSWD,CLIENTID) VALUES ('dilbert','dogbert','dilbert-id')
| ]]></attribute>
| </mbean>
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4125706#4125706
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4125706
18 years, 2 months
[JBoss Seam] - Named conversation and new instance redirected to Home? Best
by enda
Hi lets say that I have an elements table. I can pick one element and go to entityHome so my conversation name is entity.id and everything is ok.
But I also have a navigation from my table to create new instance so I go to entityHomeEdit and my conversation is named new. After I save the new instance I want to redirect to entityHome , new entity has already id so it redirects as conversation namedentity.id ;(. That is wrong. Lets show you a code:
| <conversation name="personHome"
| parameter-name="personName"
| parameter-value="person-#{empty person.id ? 'new' : person.username}"/>
|
| <page view-id="/private/search/people/personHomeView.xhtml"
| conversation="personHome"
| conversation-required="true"
| no-conversation-view-id="/private/home.xhtml"/>
| <page view-id="/private/search/people/personHomeEdit.xhtml"
| conversation="personHome"
| conversation-required="true"
| no-conversation-view-id="/private/home.xhtml"/>
| <page view-id="/private/search/people/personHomeAjax.xhtml"
| conversation="personHome"
| conversation-required="true"
| no-conversation-view-id="/private/home.xhtml"/>
|
So I can stick in my ManagerBean some condition but it is ugly. Do you have some better solution? Eg something like kill conversation when new entity is saved and create new conversation with different name.
But it is in one request, can I do that? Is there access to the conversation from my ManagerBean, so I could kill the old named one (new) and build new named one (id).
I am sure that we all goes through it. What is the best solution?
Tomas
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4125705#4125705
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4125705
18 years, 2 months
[JBoss Seam] - @PersistenceContext
by msystems
I have a hard time to understand why a seam-managed persistence context (SMPC) @PersistenceContext behaves differently from a non-managed persistence context @PersistenceContext.
I know I have to use @In to use the SMPC entitymanger - but it looks like Seam also changes the behaviour for @PersistenceContext when SMPC is enabled.
Example - non-managed (expected behaviour):
| @Stateful
| @Name("authenticatorService")
| @Scope(ScopeType.SESSION)
| public class AuthenticatorBean implements AuthenticatorLocal {
| private static final String CONTEXT_PARAMETER_MAX_ATTEMPTS = "sine.login.max.attempts";
| private static final String CONTEXT_PARAMETER_TIME_LOCK = "sine.login.time.lock";
|
| @Logger
| private Log log;
|
| @PersistenceContext
| private EntityManager em;
|
| @In
| FacesMessages facesMessages;
|
| @EJB
| private UserLocal userService;
|
| @In(create = false, required = false)
| @Out(required = false)
| private User userDomain;
|
| @Out(required = false)
| private User loggedInUserDomain;
|
| private boolean authenticateError;
| private HashMap<String, Integer>loginAttempts = new HashMap<String, Integer>();
|
| public boolean authenticate() {
| authenticateError = false;
|
| userDomain = userService.getUserByUsername(Identity.instance().getUsername());
| if (userDomain != null) {
| if (userDomain.isTimeLocked()) {
| if (System.currentTimeMillis() - userDomain.getTimeLock().getTime()
| > (Long.parseLong(Util.getContextParameter(CONTEXT_PARAMETER_TIME_LOCK)) * 60000)) {
| loginAttempts.put(userDomain.getUsername(), 0);
| userDomain.setTimeLock(null);
| } else {
| facesMessages.addToControlFromResourceBundle("username", FacesMessage.SEVERITY_ERROR,
| "loginTimeLocked");
|
| authenticateError = true;
| return false;
| }
| }
|
| if (userDomain.getPassword()
| .equals(Password.encodePasswordMD5(Identity.instance().getPassword(), userDomain.getId()))) {
| if (!userDomain.isLocked()) {
| for (Role role : userDomain.getRoles()) {
| Identity.instance().addRole(role.getName());
| }
|
| loginAttempts.put(userDomain.getUsername(), 0);
| loggedInUserDomain = userDomain; // Store userDomain in Session
|
| return true;
| }
| }
| } else {
| log.info("Login error - user don't exist: {0}", Identity.instance().getUsername());
| }
|
| facesMessages.addToControlFromResourceBundle("username", FacesMessage.SEVERITY_ERROR, "loginError");
|
| authenticateError = true;
| return false;
| }
|
| @Observer(value = Identity.EVENT_LOGIN_FAILED, create = false)
| public void failedLoginEvent() {
| if ((userDomain != null) && !userDomain.isTimeLocked()) {
| int attempts = loginAttempts.containsKey(userDomain.getUsername())
| ? loginAttempts.get(userDomain.getUsername()) : 0;
|
| if (++attempts >= Integer.parseInt(Util.getContextParameter(CONTEXT_PARAMETER_MAX_ATTEMPTS))) {
| userDomain.setTimeLock(new Date());
| em.merge(userDomain); // I need to merge because entity is detached *************************** ATTENTION ***********
| em.flush();
| log.info("Time lock on user: {0}", userDomain.getUsername());
| } else {
| loginAttempts.put(userDomain.getUsername(), attempts);
| }
| }
| }
|
| public boolean isAuthenticateError() {
| return authenticateError;
| }
|
| @Remove // Seam needs this one for stateful beans
| public void destroy() {
| }
| }
|
Above example works fine and the database is updated correctly.
Example - SMPC (I don't need the merge anymore - looks like @PersistenceContext is extended, but why?):
| @Stateful
| @Name("authenticatorService")
| @Scope(ScopeType.SESSION)
| public class AuthenticatorBean implements AuthenticatorLocal {
| private static final String CONTEXT_PARAMETER_MAX_ATTEMPTS = "sine.login.max.attempts";
| private static final String CONTEXT_PARAMETER_TIME_LOCK = "sine.login.time.lock";
|
| @Logger
| private Log log;
|
| @PersistenceContext
| private EntityManager em;
|
| @In
| FacesMessages facesMessages;
|
| @EJB
| private UserLocal userService;
|
| @In(create = false, required = false)
| @Out(required = false)
| private User userDomain;
|
| @Out(required = false)
| private User loggedInUserDomain;
|
| private boolean authenticateError;
| private HashMap<String, Integer>loginAttempts = new HashMap<String, Integer>();
|
| public boolean authenticate() {
| authenticateError = false;
|
| userDomain = userService.getUserByUsername(Identity.instance().getUsername());
| if (userDomain != null) {
| if (userDomain.isTimeLocked()) {
| if (System.currentTimeMillis() - userDomain.getTimeLock().getTime()
| > (Long.parseLong(Util.getContextParameter(CONTEXT_PARAMETER_TIME_LOCK)) * 60000)) {
| loginAttempts.put(userDomain.getUsername(), 0);
| userDomain.setTimeLock(null);
| } else {
| facesMessages.addToControlFromResourceBundle("username", FacesMessage.SEVERITY_ERROR,
| "loginTimeLocked");
|
| authenticateError = true;
| return false;
| }
| }
|
| if (userDomain.getPassword()
| .equals(Password.encodePasswordMD5(Identity.instance().getPassword(), userDomain.getId()))) {
| if (!userDomain.isLocked()) {
| for (Role role : userDomain.getRoles()) {
| Identity.instance().addRole(role.getName());
| }
|
| loginAttempts.put(userDomain.getUsername(), 0);
| loggedInUserDomain = userDomain; // Store userDomain in Session
|
| return true;
| }
| }
| } else {
| log.info("Login error - user don't exist: {0}", Identity.instance().getUsername());
| }
|
| facesMessages.addToControlFromResourceBundle("username", FacesMessage.SEVERITY_ERROR, "loginError");
|
| authenticateError = true;
| return false;
| }
|
| @Observer(value = Identity.EVENT_LOGIN_FAILED, create = false)
| public void failedLoginEvent() {
| if ((userDomain != null) && !userDomain.isTimeLocked()) {
| int attempts = loginAttempts.containsKey(userDomain.getUsername())
| ? loginAttempts.get(userDomain.getUsername()) : 0;
|
| if (++attempts >= Integer.parseInt(Util.getContextParameter(CONTEXT_PARAMETER_MAX_ATTEMPTS))) {
| userDomain.setTimeLock(new Date());
| em.flush();
| log.info("Time lock on user: {0}", userDomain.getUsername());
| } else {
| loginAttempts.put(userDomain.getUsername(), attempts);
| }
| }
| }
|
| public boolean isAuthenticateError() {
| return authenticateError;
| }
|
| @Remove // Seam needs this one for stateful beans
| public void destroy() {
| }
| }
|
Above example works fine and the database is updated correctly, but I don't need to merge anymore - looks like @PersistenceContext is extended when running under SMPC.
Could someone explain why @PersistenceContext behaves differently under a SMPC?
Thanks.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4125702#4125702
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4125702
18 years, 2 months
[Beginners Corner] - Creating Drop-Down from Foreign-Key-Constraint with Seam
by pete007
Hello,
I have some table definitions according to the following schema (simplified for better understanding):
create table department
| (
| id int not null auto_increment,
| name text,
| primary key (id)
| );
|
| create table user
| (
| id int not null auto_increment,
| username text,
| department_id int,
| primary key (id),
| foreign key (department_id) references department(id)
| );
|
| insert into department set name='alpha';
| insert into department set name='beta';
| insert into department set name='gamma';
|
Then I created a CRUD-application with these commands:
| seam setup
| seam new-project
| seam generate-entities
| seam explode
|
Started JBoss, and everything works fine. Thanks a lot for this tool!
Now I need some hints, how to continue programming.
I am supposed to replace the "Select department"-Button by a drop-down-box containing all names of existing departments. Is there an easy way, to change the application to do this?
I have several roles, which are all allowed to modify different tables.
Where can I define Access-Rights for viewing and editing the lists?
And last one (for now :), where is the equivalent to the Tomcat-Manager in JBoss AS? I especially need the functions undeployment and deploy by war/ear-file-upload.
I appreciate any help, examples or links.
Thanks a lot, Peter
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4125699#4125699
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4125699
18 years, 2 months