[JBoss Portal] - Re: what action does it do?
by wendy8
Hi all,
I use the version 2.2.0 and the Login is handle by org.jboss.portal.core.security.jaas.ModelLoginModule.
the code is :
public class ModelLoginModule
extends UsernamePasswordLoginModule
{
protected String userModuleJNDIName;
protected String additionalRole;
protected String havingRole;
public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options)
{
super.initialize(subject, callbackHandler, sharedState, options);
// Get data
userModuleJNDIName = (String)options.get("userModuleJNDIName");
additionalRole = (String)options.get("additionalRole");
havingRole = (String)options.get("havingRole");
// Some info
log.trace("userModuleJNDIName = " + userModuleJNDIName);
log.trace("additionalRole = " + additionalRole);
log.trace("havingRole = " + havingRole);
}
private UserModule userModule;
protected UserModule getUserModule() throws NamingException
{
if (userModule == null)
{
userModule = (UserModule)new InitialContext().lookup(userModuleJNDIName);
}
return userModule;
}
protected String getUsersPassword() throws LoginException
{
try
{
TransactionManager tm = (TransactionManager)new InitialContext().lookup("java:/TransactionManager");
String password = (String)Transactions.required(tm, new Transactions.Runnable()
{
public Object run() throws Exception
{
try
{
UserModule module = getUserModule();
User user = module.findUserByUserName(getUsername());
if (havingRole == null || user.getRoleNames().contains(havingRole))
{
return user.getPassword();
}
else
{
return null;
}
}
catch (NoSuchUserException e)
{
return null;
}
catch (Exception e)
{
throw new LoginException(e.toString());
}
}
});
// Returning null as password is enough to veto the login
return password;
}
catch (Exception e)
{
Throwable cause = e.getCause();
throw new LoginException(cause.toString());
}
}
protected Group[] getRoleSets() throws LoginException
{
try
{
TransactionManager tm = (TransactionManager)new InitialContext().lookup("java:/TransactionManager");
return (Group[])Transactions.required(tm, new Transactions.Runnable()
{
public Object run() throws Exception
{
try
{
UserModule module = getUserModule();
User user = module.findUserByUserName(getUsername());
Set roleNames = user.getRoleNames();
//
Group rolesGroup = new SimpleGroup("Roles");
//
if (additionalRole != null)
{
rolesGroup.addMember(createIdentity(additionalRole));
}
//
for (Iterator iterator = roleNames.iterator(); iterator.hasNext();)
{
String roleName = (String)iterator.next();
try
{
Principal p = createIdentity(roleName);
rolesGroup.addMember(p);
}
catch (Exception e)
{
log.debug("Failed to create principal " + roleName, e);
}
}
//
return new Group[]{rolesGroup};
}
catch (Exception e)
{
throw new LoginException(e.toString());
}
}
});
}
catch (Exception e)
{
Throwable cause = e.getCause();
throw new LoginException(cause.toString());
}
}
}
How does it login, I still confused. and how does the page forward? do not have the portlet control it.
could you explain that to me? Thanks very much!
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3974207#3974207
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3974207
19 years, 7 months
[JBossCache] - Two nodes updating cache concurrently using a PojoCacheMBean
by jbirkenmaier
I have a 3 node cluster and one node goes away. The two remaining nodes receive notice at exactly the same time and update their cache accordingly. Each is basically removing references to the disappeared node from cache. The problem occurs when the commit is done on the 2 nodes. Each one has a lock that the other node wants. Here is the exception:
Caused by: java.lang.IllegalStateException: there is already a writer holding the lock: GlobalTransaction:<192.168.69.253:41197>:65
at org.jboss.cache.lock.LockMap.setWriterIfNotNull(LockMap.java:96)
at org.jboss.cache.lock.IdentityLock.acquireWriteLock(IdentityLock.java:204)
at org.jboss.cache.Node.acquireWriteLock(Node.java:431)
at org.jboss.cache.Node.acquire(Node.java:386)
at org.jboss.cache.interceptors.OptimisticLockingInterceptor.lockNodes(OptimisticLockingInterceptor.java:149)
at org.jboss.cache.interceptors.OptimisticLockingInterceptor.invoke(OptimisticLockingInterceptor.java:76)
at org.jboss.cache.interceptors.Interceptor.invoke(Interceptor.java:68)
at org.jboss.cache.interceptors.OptimisticReplicationInterceptor.invoke(OptimisticReplicationInterceptor.java:74)
at org.jboss.cache.interceptors.Interceptor.invoke(Interceptor.java:68)
at org.jboss.cache.interceptors.TxInterceptor.runPreparePhase(TxInterceptor.java:804)
at org.jboss.cache.interceptors.TxInterceptor$LocalSynchronizationHandler.beforeCompletion(TxInterceptor.java:1069)
... 83 more
07:13:13,767 ERROR [ResourceReplicatorBase] (JBoss Shutdown Hook) removeResourceDescriptor: org.jboss.tm.JBossRollbackException: Unable to commit, tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=dragoneyes/119, BranchQual=, localId=119] status=STATUS_NO_TRANSACTION; - nested throwable: (java.lang.RuntimeException: ), retry the operation, current iteration: 0
Each node throws this exception with an IP and port of the other node. I have retry code in there to retry my operations but when this exception is thrown, the cache becomes corrupt and I am unable to remove the data (again) from the cache. This works perfectly if one node gets there first but when they hit the cache at the same time....trouble.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3974206#3974206
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3974206
19 years, 7 months
[JBoss Seam] - s:validateAll does not work, s:validate does. Why?
by jaulich
I try to use the s:validateAll tag in conjunction with ADF Faces and Faclets, but it does not work. I get an an uncought exception. If I try to use s:validate on the specific tags it works as I want.
Did I do something wrong or is it a bug?
Here my JSP that does not work:
| <?xml version="1.0" encoding="UTF-8" ?>
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
| <ui:composition xmlns="http://www.w3.org/1999/xhtml"
| xmlns:ui="http://java.sun.com/jsf/facelets"
| xmlns:s="http://jboss.com/products/seam/taglib"
| xmlns:af="http://xmlns.oracle.com/adf/faces"
| xmlns:afh="http://xmlns.oracle.com/adf/faces/html"
| template="template.xhtml">
|
|
| <ui:define name="content">
| <af:form>
| <af:messages/>
| <af:commandButton text="Neu" action="#{contracttypeAction.create}" rendered="#{!contracttypeAction.editMode}"/>
| <af:commandButton text="Bearbeiten" action="#{contracttypeAction.edit}" rendered="#{(!contracttypeAction.editMode) and (contracttypeAction.loadedEntity)}"/>
| <af:commandButton text="Save" action="#{contracttypeAction.save}" rendered="#{contracttypeAction.editMode}"/>
| <af:commandButton text="Cancel" action="#{contracttypeAction.cancel}" rendered="#{contracttypeAction.editMode}" immediate="true"/>
| <af:panelGroup rendered="#{(contracttypeAction.editMode) or (contracttypeAction.loadedEntity)}" layout="horizontal">
| <s:validateAll>
| <table>
| <tr>
| <td>
| <af:outputLabel for="value" value="Bezeichnung:"/>
| </td>
| <td>
| <af:inputText id="value" readOnly="#{!contracttypeAction.editMode}" required="true" showRequired="false" value="#{contracttype.value}"/>
| </td>
| <td>
| <af:message for="value"/>
| </td>
| </tr>
| <tr>
| <td>
| <af:outputLabel for="orderNumber" value="Gliederungsnummer:"/>
| </td>
| <td>
| <af:inputText id="orderNumber" readOnly="#{!contracttypeAction.editMode}" required="tue" value="#{contracttype.orderNumber}" />
| </td>
| <td>
| <af:message for="orderNumber"/>
| </td>
| </tr>
| </table>
| </s:validateAll>
| </af:panelGroup>
| </af:form>
| </ui:define>
|
| </ui:composition>
|
This one works fine (e.g. when I enter more than 40 characters in the orderNumber field, see entity bean):
| <?xml version="1.0" encoding="UTF-8" ?>
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
| <ui:composition xmlns="http://www.w3.org/1999/xhtml"
| xmlns:ui="http://java.sun.com/jsf/facelets"
| xmlns:s="http://jboss.com/products/seam/taglib"
| xmlns:af="http://xmlns.oracle.com/adf/faces"
| xmlns:afh="http://xmlns.oracle.com/adf/faces/html"
| template="template.xhtml">
|
|
| <ui:define name="content">
| <af:form>
| <af:messages/>
| <af:commandButton text="Neu" action="#{contracttypeAction.create}" rendered="#{!contracttypeAction.editMode}"/>
| <af:commandButton text="Bearbeiten" action="#{contracttypeAction.edit}" rendered="#{(!contracttypeAction.editMode) and (contracttypeAction.loadedEntity)}"/>
| <af:commandButton text="Save" action="#{contracttypeAction.save}" rendered="#{contracttypeAction.editMode}"/>
| <af:commandButton text="Cancel" action="#{contracttypeAction.cancel}" rendered="#{contracttypeAction.editMode}" immediate="true"/>
| <af:panelGroup rendered="#{(contracttypeAction.editMode) or (contracttypeAction.loadedEntity)}" layout="horizontal">
| <table>
| <tr>
| <td>
| <af:outputLabel for="value" value="Bezeichnung:"/>
| </td>
| <td>
| <af:inputText id="value" readOnly="#{!contracttypeAction.editMode}" required="true" showRequired="false" value="#{contracttype.value}">
| <s:validate/>
| </af:inputText>
| </td>
| <td>
| <af:message for="value"/>
| </td>
| </tr>
| <tr>
| <td>
| <af:outputLabel for="orderNumber" value="Gliederungsnummer:"/>
| </td>
| <td>
| <af:inputText id="orderNumber" readOnly="#{!contracttypeAction.editMode}" required="tue" value="#{contracttype.orderNumber}">
| <s:validate/>
| </af:inputText>
| </td>
| <td>
| <af:message for="orderNumber"/>
| </td>
| </tr>
| </table>
| </af:panelGroup>
| </af:form>
| </ui:define>
|
| </ui:composition>
|
|
My entity bean:
| package de.cogitum.contra.model;
|
| import static org.jboss.seam.ScopeType.CONVERSATION;
|
| import javax.persistence.Entity;
|
| import org.hibernate.validator.Length;
| import org.hibernate.validator.NotNull;
| import org.jboss.seam.annotations.Name;
| import org.jboss.seam.annotations.Scope;
|
| @Entity
| @Name("contracttype")
| @Scope(CONVERSATION)
| public class ContractType extends Taxonomy {
|
| private static final long serialVersionUID = 1530145534100005653L;
|
| private String orderNumber;
|
| @NotNull
| @Length(min=1, max=40)
| public String getOrderNumber() {
| return orderNumber;
| }
|
| public void setOrderNumber(String orderNumber) {
| this.orderNumber = orderNumber;
| }
|
| }
|
Any idea? My understanding of the Seam validation tags is that I can use both. Am I wrong?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3974203#3974203
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3974203
19 years, 7 months
[JBossWS] - Re: Inject EJB problem in web service method !!
by boby
I forgot to specify that I use jboss-4.0.4.GA with jbossws by default.
And my code :
| @Stateless
| @SecurityDomain("Protected-Web-Services")
| @Interceptors( { LoggerInterceptor.class, ConnectionInterceptor.class })
| @RemoteBinding(jndiBinding = "TestSession")
| @WebService(name = "Test")
| public class TestSessionBean implements TestSession {
|
| private static Logger logger = Logger.getLogger(TestSessionBean.class.getSimpleName());
| @EJB
| ResourcesDAOSession resourcesDAOSession;
|
| @RolesAllowed("ws_resources")
| @WebMethod
| public Resource echo(int idResource) {
| logger.info("DAO : " + this.resourcesDAOSession);
| Resource resource = this.resourcesDAOSession.getResource(idResource);
| logger.info("resource : " + resource);
| return resource;
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3974200#3974200
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3974200
19 years, 7 months