[Security & JAAS/JBoss] - Got 403 Error with own LoginModule
by userand
Hi,
I need to implement a LoginModule for the JBoss Portal and I got stuck.
By now I use the plain jboss-portal-2.4.0.
The LoginModule is extending the UsernamePasswordLoginModule class and the methods are
called sucessfully.
I wrote some dummy methods to test if all goes well:
| protected String getUsersPassword()
| throws LoginException {
|
| String userName;
|
|
| MyLoginModule.log.info( "getUsersPassword() aufgerufen" );
|
| userName = this.getUsername();
| MyLoginModule.log.info(
| "getUsersPassword(): Benutzername: " + userName );
|
| if( userName.equals( "andreas" ) == true )
| {
| return "pwd_andreas";
| }
| else
| {
| return "";
| }
| }
|
| protected boolean validatePassword(
| String inputPassword,
| String expected )
| {
| boolean result;
|
|
| MyLoginModule.log.info(
| "validatePassword(): [" +
| inputPassword +
| "] [" +
| expected +
| "]" );
|
| result = super.validatePassword( inputPassword, expected );
|
| MyLoginModule.log.info( "validatePassword(): " + result );
| return result;
| }
|
| protected Group[] getRoleSets()
| throws LoginException {
|
| SimpleGroup actGroup[];
|
|
| MyLoginModule.log.info( "getRoleSets(): aufgerufen" );
| actGroup = new SimpleGroup[1];
|
|
| actGroup[0] = new SimpleGroup( "Roles" );
| actGroup[0].addMember(
| new SimplePrincipal( "Admin" ) );
|
| MyLoginModule.log.info( "getRoleSets(): fertig." );
| return actGroup;
| }
|
When I authenticate, I will get an 403 error and the following output in the server logs:
anonymous wrote :
| LoginModule Class: de.abracon.jboss.AbraLoginModule
| ControlFlag: Anmeldemodul-Steuerflag: required
| Options:
| 2006-11-22 16:09:40,218 INFO [de.abracon.jboss.AbraLoginModule] LoginModule instanziiert.
| 2006-11-22 16:09:40,218 INFO [de.abracon.jboss.AbraLoginModule] getUsersPassword() aufgerufen
| 2006-11-22 16:09:40,218 INFO [de.abracon.jboss.AbraLoginModule] getUsersPassword(): Benutzername: andreas
| 2006-11-22 16:09:40,218 INFO [de.abracon.jboss.AbraLoginModule] validatePassword(): [pwd_andreas] [pwd_andreas]
| 2006-11-22 16:09:40,218 INFO [de.abracon.jboss.AbraLoginModule] validatePassword(): true
| 2006-11-22 16:09:40,218 INFO [de.abracon.jboss.AbraLoginModule] getRoleSets(): aufgerufen
| 2006-11-22 16:09:40,218 INFO [de.abracon.jboss.AbraLoginModule] getRoleSets(): fertig.
| 2006-11-22 16:09:40,234 TRACE [org.jboss.security.plugins.JaasSecurityManager.portal] defaultLogin, lc=javax.security.auth.login.LoginContext@17ea32c, subject=Subject(17484699).principals=org.jboss.security.SimplePrincipal@27542048(andreas)org.jboss.security.SimpleGroup@29176256(Roles(members:Admin))
| 2006-11-22 16:09:40,234 TRACE [org.jboss.security.plugins.JaasSecurityManager.portal] updateCache, inputSubject=Subject(17484699).principals=org.jboss.security.SimplePrincipal@27542048(andreas)org.jboss.security.SimpleGroup@29176256(Roles(members:Admin)), cacheSubject=Subject(870036).principals=org.jboss.security.SimplePrincipal@27542048(andreas)org.jboss.security.SimpleGroup@29176256(Roles(members:Admin))
| 2006-11-22 16:09:40,234 TRACE [org.jboss.security.plugins.JaasSecurityManager.portal] Inserted cache info: org.jboss.security.plugins.JaasSecurityManager$DomainInfo@194ccbc[Subject(870036).principals=org.jboss.security.SimplePrincipal@27542048(andreas)org.jboss.security.SimpleGroup@29176256(Roles(members:Admin)),credential.class=java.lang.String@24659469,expirationTime=1164209980203]
| 2006-11-22 16:09:40,234 TRACE [org.jboss.security.plugins.JaasSecurityManager.portal] End isValid, true
| 2006-11-22 16:09:40,234 TRACE [org.jboss.security.SecurityAssociation] pushSubjectContext, subject=Betreff:
| Principal: andreas
| Principal: Roles(members:Admin)
| , sc=org.jboss.security.SecurityAssociation$SubjectContext@16de797{principal=andreas,subject=8366806}
| 2006-11-22 16:09:40,234 TRACE [org.jboss.security.plugins.JaasSecurityManager.portal] getPrincipal, cache info: org.jboss.security.plugins.JaasSecurityManager$DomainInfo@194ccbc[Subject(870036).principals=org.jboss.security.SimplePrincipal@27542048(andreas)org.jboss.security.SimpleGroup@29176256(Roles(members:Admin)),credential.class=java.lang.String@24659469,expirationTime=1164209980203]
| 2006-11-22 16:09:40,234 TRACE [org.jboss.security.SecurityAssociation] getSubject, sc=org.jboss.security.SecurityAssociation$SubjectContext@16de797{principal=andreas,subject=8366806}
| 2006-11-22 16:09:40,234 TRACE [org.jboss.security.plugins.JaasSecurityManager.portal] getUserRoles, subject: Betreff:
| Principal: andreas
| Principal: Roles(members:Admin)
|
| 2006-11-22 16:09:40,234 TRACE [org.jboss.security.SecurityAssociation] clear, server=true
| 2006-11-22 16:09:40,250 TRACE [org.jboss.security.SecurityAssociation] clear, server=true
| 2006-11-22 16:16:31,453 DEBUG [org.jboss.resource.connectionmanager.IdleRemover] run: IdleRemover notifying pools, interval: 450000
|
Any idea what went wrong ...
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3987918#3987918
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3987918
19Â years, 5Â months
[JBoss Seam] - Persist and Seam Managed Lifecycle
by valtoni
Hello!
I´m a newbie, but with some direction.
I´m trying to do persistence with EJB3 injected EntityManager by annotation @PersistenceContext, but appear witch this EntityManager close the session all time that a call is made in page, because after the first call (all good occurs), in the second call, this appear:
"org.hibernate.PersistentObjectException: detached entity passed to persist: br.com.bdh.view.seam.entity.FuncionarioEntity".
I put all code from the registration seam example and the code of EJB appear well simpler then mine.
My ejb:
| import static org.jboss.seam.ScopeType.EVENT;
| import java.util.List;
|
| import javax.annotation.Resource;
| import javax.ejb.Remove;
| import javax.ejb.SessionContext;
| import javax.ejb.Stateful;
| import javax.persistence.EntityManager;
| import javax.persistence.PersistenceContext;
|
| import org.hibernate.validator.InvalidValue;
| import org.jboss.seam.annotations.Destroy;
| import org.jboss.seam.annotations.Factory;
| import org.jboss.seam.annotations.In;
| import org.jboss.seam.annotations.Logger;
| import org.jboss.seam.annotations.Name;
| import org.jboss.seam.annotations.Out;
| import org.jboss.seam.annotations.Scope;
| import org.jboss.seam.annotations.datamodel.DataModel;
| import org.jboss.seam.annotations.datamodel.DataModelSelection;
| import org.jboss.seam.core.FacesMessages;
| import org.jboss.seam.log.Log;
|
| import br.com.bdh.view.seam.ejb.Funcionario;
| import br.com.bdh.view.seam.entity.FuncionarioEntity;
|
| @Stateful
| @Scope(EVENT)
| @Name("cadastrofuncionario")
| public class FuncionarioBean
| implements Funcionario {
|
| @DataModel
| private List<FuncionarioEntity> listaFuncionarios;
|
| @In(create = true)
| private FuncionarioEntity funcionario;
|
| @Out(required = false)
| @DataModelSelection
| private FuncionarioEntity funcionarioDaLista;
|
| @PersistenceContext
| private EntityManager em;
|
| @In(create=true)
| private transient FacesMessages facesMessages;
|
| @Logger
| private Log log;
|
| private boolean isExists(FuncionarioEntity funcionario) {
| return em.createQuery("from FuncionarioEntity f where f.nome = :nome")
| .setParameter("nome", funcionario.getNome())
| .getResultList().size() > 0;
| }
|
| public String criar() {
| log.info("Tentativa de input de funcionário.");
| if (em.contains(funcionario)) {
| facesMessages.add("O funcionário #{funcionario.nome} já está cadastrado");
| return null;
| }
| else {
| try {
| log.info("Funcionário a persistir: " + funcionario);
| if (isExists(funcionario)) {
| facesMessages.add("Este funcionário já existe. Não pode ser cadastrado novamente");
| }
| else {
| //funcionario = em.merge(funcionario);
| em.persist(funcionario);
| //em.flush();
| log.info("Novo funcionário #{funcionario.nome} cadastrado com sucesso");
| facesMessages.add("O funcionário #{funcionario.nome} foi cadastrado com sucesso");
| }
| } catch (org.hibernate.validator.InvalidStateException e) {
| InvalidValue[] vals = e.getInvalidValues();
| String message = "Estados inválidos: ";
| for (InvalidValue val: vals) {
| message += "- " + val + "\n";
| }
| facesMessages.add(message);
| return "/cadastroFuncionario.jsp";
| } catch (RuntimeException e) {
| ctx.setRollbackOnly();
| facesMessages.add("Erro: " + e.getMessage());
| }
| return "/cadastroFuncionario.jsp";
| }
| }
|
| @Factory("listaFuncionarios")
| public void findFuncionarios() {
| listaFuncionarios = em.createQuery("from FuncionarioEntity f order by f.nome desc")
| .setMaxResults(100)
| .getResultList();
| log.debug("Lista de funcionários obtida: " + listaFuncionarios.size());
| }
|
| @Destroy @Remove
| public void destroy() {
| listaFuncionarios = null;
| }
|
| }
|
PS.: When i remove the comment of //funcionario = em.merge(funcionario); it´s works perfectly. But in the examples this was not necessary... I don´t know the reason!!!
PS2.: I try to do @Transient field in entity and when his trying to read field "diasTrabalhados", the error "org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: br.com.bdh.view.seam.entity.FuncionarioEntity.diasTrabalhados, no session or session was closed" appear.
The code of entity:
| import static org.jboss.seam.ScopeType.SESSION;
|
| import java.io.Serializable;
| import java.util.List;
|
| import javax.persistence.Column;
| import javax.persistence.Entity;
| import javax.persistence.GeneratedValue;
| import javax.persistence.GenerationType;
| import javax.persistence.Id;
| import javax.persistence.OneToMany;
| import javax.persistence.OrderBy;
| import javax.persistence.Table;
| import javax.persistence.Transient;
|
| import org.hibernate.validator.Length;
| import org.hibernate.validator.NotNull;
| import org.jboss.seam.annotations.Name;
| import org.jboss.seam.annotations.Scope;
|
| @Entity
| @Name("funcionario")
| @Scope(SESSION)
| @Table(name = "FUNCIONARIO")
| public class FuncionarioEntity implements Serializable {
|
| private static final long serialVersionUID = -7360165347366125305L;
|
| @Id
| @GeneratedValue(strategy = GenerationType.SEQUENCE)
| @Column(name="IDFUNCIONARIO")
| private int id;
| @NotNull @Length(min=10, max=100)
| private String nome;
| @OneToMany(mappedBy="funcionario")
| @OrderBy("data desc")
| private List<DiaUtilEntity> diasTrabalhados;
|
| @Transient
| public int getHorasTrabalhadas() {
| if (diasTrabalhados == null) {
| return 0;
| }
| else {
| return diasTrabalhados.size();
| }
| //return 0;
| }
|
| public FuncionarioEntity() {
|
| }
|
| public FuncionarioEntity(int id, String nome) {
| this.id = id;
| this.nome = nome;
| }
|
| public int getId() {
| return id;
| }
|
| public void setId(int id) {
| this.id = id;
| }
|
| public String getNome() {
| return nome;
| }
|
| public void setNome(String nome) {
| this.nome = nome;
| }
|
| public List<DiaUtilEntity> getDiasTrabalhados() {
| return diasTrabalhados;
| }
|
| public void setDiasTrabalhados(List<DiaUtilEntity> diasTrabalhados) {
| this.diasTrabalhados = diasTrabalhados;
| }
|
| public String toString() {
| int noDiasTrabalhados = 0;
| if (getDiasTrabalhados() != null) {
| noDiasTrabalhados = getDiasTrabalhados().size();
| }
| return "Id: " + id + " nome: " + nome + " dias trabalhados: " + noDiasTrabalhados;
| }
|
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3987916#3987916
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3987916
19Â years, 5Â months
[JBossWS] - BUG JBossWS 1.0.4 : WsdlGenerator crashes on void-methods.
by minime
The automatic generation of a wsdl to deploy time crashes, if there is a method which returns void. Changing the return parameter to everything else besides void (i.e. String, boolean, ..) fixes the problem.
Using JBoss 4.04 with JBossWS 1.0.4 + jboss-xml-binding.jar 1.0.0.CR7.
Seems this bug http://jira.jboss.org/jira/browse/JBWS-647 is back in 1.0.4 again.
anonymous wrote : 2006-11-22 16:16:35,181 ERROR [org.jboss.deployment.MainDeployer] Could not create deployment: file:/D:/jzx/zxdev_jboss/server/default/tmp/deploy/tmp19079zxapp_webservices.ear-contents/zxapp_webservices_logic.jar
| java.lang.NullPointerException
| at java.lang.Class.isAssignableFrom(Native Method)
| at org.jboss.ws.tools.helpers.JavaToWSDLHelper.generateType(JavaToWSDLHelper.java:559)
| at org.jboss.ws.tools.helpers.JavaToWSDLHelper.generateTypesForXSD(JavaToWSDLHelper.java:146)
| at org.jboss.ws.tools.JavaToWSDL11.handleJavaToWSDLGeneration(JavaToWSDL11.java:249)
| at org.jboss.ws.tools.JavaToWSDL11.generate(JavaToWSDL11.java:170)
| at org.jboss.ws.tools.JavaToWSDL.generate(JavaToWSDL.java:321)
| at org.jboss.ws.deployment.AnnotationsMetaDataBuilder.processOrGenerateWSDL(AnnotationsMetaDataBuilder.java:93)
| at org.jboss.ws.deployment.JSR181MetaDataBuilder.setupEndpointFromAnnotations(JSR181MetaDataBuilder.java:177)
| at org.jboss.ws.deployment.JSR181MetaDataBuilderEJB3.buildMetaData(JSR181MetaDataBuilderEJB3.java:75)
| at org.jboss.ws.deployment.ServiceEndpointDeployer.create(ServiceEndpointDeployer.java:106)
| at org.jboss.ws.integration.jboss.DeployerInterceptor.create(DeployerInterceptor.java:80)
| at org.jboss.ws.integration.jboss.DeployerInterceptorEJB.create(DeployerInterceptorEJB.java:44)
| at org.jboss.deployment.SubDeployerInterceptorSupport$XMBeanInterceptor.create(SubDeployerInterceptorSupport.java:180)
| at org.jboss.deployment.SubDeployerInterceptor.invoke(SubDeployerInterceptor.java:91)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
| at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
| at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
| at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
| at $Proxy35.create(Unknown Source)
| at org.jboss.deployment.MainDeployer.create(MainDeployer.java:953)
| at org.jboss.deployment.MainDeployer.create(MainDeployer.java:943)
| at org.jboss.deployment.MainDeployer.create(MainDeployer.java:943)
| at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:807)
| at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:771)
| at sun.reflect.GeneratedMethodAccessor13.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
| at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
| at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
| at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
| at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
| at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
| at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
| at $Proxy6.deploy(Unknown Source)
| at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:421)
| at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:610)
| at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:263)
| at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploymentScanner.java:274)
| at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeploymentScanner.java:225)
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3987912#3987912
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3987912
19Â years, 5Â months