0 Replies Latest reply on Oct 5, 2015 9:56 PM by tmvolpato

    Problem with RelationshipManager

    tmvolpato

      Hi guys,

       

      I'm with problem to populate the table with user admin default

       

      error in console

       

      2:15:02,514 ERROR [stderr] (ServerService Thread Pool -- 54) org.picketlink.idm.IdentityManagementException: PLIDM000600: Could not add AttributedType [br.com.tmvolpato.security.picketlink.GroupMembership@0].
      22:15:02,514 ERROR [stderr] (ServerService Thread Pool -- 54)     at org.picketlink.idm.internal.AbstractAttributedTypeManager.add(AbstractAttributedTypeManager.java:78)
      22:15:02,514 ERROR [stderr] (ServerService Thread Pool -- 54)     at org.picketlink.idm.internal.ContextualRelationshipManager.add(ContextualRelationshipManager.java:44)
      22:15:02,514 ERROR [stderr] (ServerService Thread Pool -- 54)     at br.com.tmvolpato.webdental.security.config.SecurityInitializer.init(SecurityInitializer.java:77)
      22:15:02,515 ERROR [stderr] (ServerService Thread Pool -- 54)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      22:15:02,515 ERROR [stderr] (ServerService Thread Pool -- 54)     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      22:15:02,515 ERROR [stderr] (ServerService Thread Pool -- 54)     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      22:15:02,515 ERROR [stderr] (ServerService Thread Pool -- 54)     at java.lang.reflect.Method.invoke(Method.java:497)
      22:15:02,515 ERROR [stderr] (ServerService Thread Pool -- 54)     at org.jboss.as.ee.component.ManagedReferenceLifecycleMethodInterceptor.processInvocation(ManagedReferenceLifecycleMethodInterceptor.java:96)
      22:15:02,516 ERROR [stderr] (ServerService Thread Pool -- 54)     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
      22:15:02,516 ERROR [stderr] (ServerService Thread Pool -- 54)     at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)
      22:15:02,516 ERROR [stderr] (ServerService Thread Pool -- 54)     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
      22:15:02,516 ERROR [stderr] (ServerService Thread Pool -- 54)     at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.doLifecycleInterception(Jsr299BindingsInterceptor.java:114)
      22:15:02,516 ERROR [stderr] (ServerService Thread Pool -- 54)     at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.processInvocation(Jsr299BindingsInterceptor.java:103)
      22:15:02,517 ERROR [stderr] (ServerService Thread Pool -- 54)     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
      22:15:02,517 ERROR [stderr] (ServerService Thread Pool -- 54)     at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:407)
      22:15:02,517 ERROR [stderr] (ServerService Thread Pool -- 54)     at org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:55)
      22:15:02,517 ERROR [stderr] (ServerService Thread Pool -- 54)     at org.jboss.as.weld.ejb.EjbRequestScopeActivationInterceptor.processInvocation(EjbRequestScopeActivationInterceptor.java:83)
      22:15:02,517 ERROR [stderr] (ServerService Thread Pool -- 54)     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
      22:15:02,518 ERROR [stderr] (ServerService Thread Pool -- 54)     at org.jboss.as.weld.injection.WeldInjectionInterceptor.processInvocation(WeldInjectionInterceptor.java:53)
      22:15:02,518 ERROR [stderr] (ServerService Thread Pool -- 54)     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
      22:15:02,518 ERROR [stderr] (ServerService Thread Pool -- 54)     at org.jboss.as.ee.component.AroundConstructInterceptorFactory$1.processInvocation(AroundConstructInterceptorFactory.java:28)
      22:15:02,518 ERROR [stderr] (ServerService Thread Pool -- 54)     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
      22:15:02,518 ERROR [stderr] (ServerService Thread Pool -- 54)     at org.jboss.as.weld.injection.WeldInterceptorInjectionInterceptor.processInvocation(WeldInterceptorInjectionInterceptor.java:56)
      22:15:02,519 ERROR [stderr] (ServerService Thread Pool -- 54)     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
      22:15:02,519 ERROR [stderr] (ServerService Thread Pool -- 54)     at org.jboss.as.weld.ejb.Jsr299BindingsCreateInterceptor.processInvocation(Jsr299BindingsCreateInterceptor.java:94)
      22:15:02,519 ERROR [stderr] (ServerService Thread Pool -- 54)     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
      22:15:02,519 ERROR [stderr] (ServerService Thread Pool -- 54)     at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50)
      22:15:02,519 ERROR [stderr] (ServerService Thread Pool -- 54)     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
      22:15:02,520 ERROR [stderr] (ServerService Thread Pool -- 54)     at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:273)
      22:15:02,520 ERROR [stderr] (ServerService Thread Pool -- 54)     at org.jboss.as.ejb3.tx.CMTTxInterceptor.requiresNew(CMTTxInterceptor.java:369)
      22:15:02,520 ERROR [stderr] (ServerService Thread Pool -- 54)     at org.jboss.as.ejb3.tx.LifecycleCMTTxInterceptor.processInvocation(LifecycleCMTTxInterceptor.java:66)
      22:15:02,520 ERROR [stderr] (ServerService Thread Pool -- 54)     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
      22:15:02,520 ERROR [stderr] (ServerService Thread Pool -- 54)     at org.jboss.as.weld.injection.WeldInjectionContextInterceptor.processInvocation(WeldInjectionContextInterceptor.java:43)
      22:15:02,520 ERROR [stderr] (ServerService Thread Pool -- 54)     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
      22:15:02,521 ERROR [stderr] (ServerService Thread Pool -- 54)     at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41)
      22:15:02,521 ERROR [stderr] (ServerService Thread Pool -- 54)     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
      22:15:02,521 ERROR [stderr] (ServerService Thread Pool -- 54)     at org.jboss.as.ee.concurrent.ConcurrentContextInterceptor.processInvocation(ConcurrentContextInterceptor.java:45)
      22:15:02,521 ERROR [stderr] (ServerService Thread Pool -- 54)     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
      22:15:02,521 ERROR [stderr] (ServerService Thread Pool -- 54)     at org.jboss.invocation.ContextClassLoaderInterceptor.processInvocation(ContextClassLoaderInterceptor.java:64)
      22:15:02,522 ERROR [stderr] (ServerService Thread Pool -- 54)     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
      22:15:02,522 ERROR [stderr] (ServerService Thread Pool -- 54)     at org.jboss.invocation.InterceptorContext.run(InterceptorContext.java:326)
      22:15:02,522 ERROR [stderr] (ServerService Thread Pool -- 54)     at org.jboss.invocation.PrivilegedWithCombinerInterceptor.processInvocation(PrivilegedWithCombinerInterceptor.java:80)
      22:15:02,522 ERROR [stderr] (ServerService Thread Pool -- 54)     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)
      22:15:02,522 ERROR [stderr] (ServerService Thread Pool -- 54)     at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
      22:15:02,523 ERROR [stderr] (ServerService Thread Pool -- 54)     at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:160)
      22:15:02,523 ERROR [stderr] (ServerService Thread Pool -- 54)     at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:133)
      22:15:02,523 ERROR [stderr] (ServerService Thread Pool -- 54)     at org.jboss.as.ee.component.BasicComponent.createInstance(BasicComponent.java:89)
      22:15:02,523 ERROR [stderr] (ServerService Thread Pool -- 54)     at org.jboss.as.ejb3.component.singleton.SingletonComponent.getComponentInstance(SingletonComponent.java:122)
      22:15:02,523 ERROR [stderr] (ServerService Thread Pool -- 54)     at org.jboss.as.ejb3.component.singleton.SingletonComponent.start(SingletonComponent.java:137)
      22:15:02,524 ERROR [stderr] (ServerService Thread Pool -- 54)     at org.jboss.as.ee.component.ComponentStartService$1.run(ComponentStartService.java:54)
      22:15:02,524 ERROR [stderr] (ServerService Thread Pool -- 54)     at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      22:15:02,524 ERROR [stderr] (ServerService Thread Pool -- 54)     at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      22:15:02,524 ERROR [stderr] (ServerService Thread Pool -- 54)     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      22:15:02,524 ERROR [stderr] (ServerService Thread Pool -- 54)     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      22:15:02,524 ERROR [stderr] (ServerService Thread Pool -- 54)     at java.lang.Thread.run(Thread.java:745)
      22:15:02,524 ERROR [stderr] (ServerService Thread Pool -- 54)     at org.jboss.threads.JBossThread.run(JBossThread.java:122)
      22:15:02,525 ERROR [stderr] (ServerService Thread Pool -- 54) Caused by: org.picketlink.idm.config.OperationNotSupportedException: PLIDM000604: No identity store configuration found for requested type operation [class br.com.tmvolpato.security.picketlink.GroupMembership.create].
      22:15:02,525 ERROR [stderr] (ServerService Thread Pool -- 54)     at org.picketlink.idm.internal.DefaultStoreSelector.getStoreForRelationshipOperation(DefaultStoreSelector.java:280)
      22:15:02,525 ERROR [stderr] (ServerService Thread Pool -- 54)     at org.picketlink.idm.internal.ContextualRelationshipManager.doAdd(ContextualRelationshipManager.java:57)
      22:15:02,525 ERROR [stderr] (ServerService Thread Pool -- 54)     at org.picketlink.idm.internal.ContextualRelationshipManager.doAdd(ContextualRelationshipManager.java:44)
      22:15:02,525 ERROR [stderr] (ServerService Thread Pool -- 54)     at org.picketlink.idm.internal.AbstractAttributedTypeManager.add(AbstractAttributedTypeManager.java:72)
      
      
      

       

       

      My class GroupMembership

       

      @RelationshipStereotype(GROUP_MEMBERSHIP)
      public class GroupMembership extends AbstractAttributedType implements Relationship{
      
          /**
           *
           */
          private static final long serialVersionUID = 1L;  
        
          public static final RelationshipQueryParameter MEMBER = RELATIONSHIP_QUERY_ATTRIBUTE.byName("member");
          public static final RelationshipQueryParameter GROUP = RELATIONSHIP_QUERY_ATTRIBUTE.byName("group");
        
        
          @InheritsPrivileges("group")
          @StereotypeProperty(RELATIONSHIP_GROUP_MEMBERSHIP_MEMBER)
          private Account member;
        
          @StereotypeProperty(RELATIONSHIP_GROUP_MEMBERSHIP_GROUP)
          private Group group;      
        
          public GroupMembership() {}
        
          public GroupMembership(Account member, Group group){
              this.member = member;
              this.group = group;      
          }
      
          public Group getGroup() {
              return group;
          }
      
          public void setGroup(Group group) {
              this.group = group;
          }
      
          public Account getMember() {
              return member;
          }
      
          public void setMember(Account member) {
              this.member = member;
          }
      
      
      

       

      My class SecurityInitializer

       

      @Singleton
      @Startup
      public class SecurityInitializer {
      
          private IdentityManager identityManager;
          @Inject
          private Authorization authorization;
          @Inject
          private PartitionManager partitionManager;
      
          private static final String DEFAULT_ADMIN_USER = "admin";
          private static final String DEFAULT_ADMIN_PASSWORD = "admin";
          private static final String DEFAULT_ADMIN_GROUP = "Administrators";
      
          @PostConstruct
          protected void init() {
      
              final Partition partition = this.checkPartition();
      
              this.identityManager = this.partitionManager.createIdentityManager(partition);
      
              for (String role : this.authorization.listAuthorizations()) {
                  if (!this.hasRole(role)) {
                      this.identityManager.add(new Role(role));
                  }
              }
      
              if (!this.hasGroup(DEFAULT_ADMIN_GROUP)) {
                  this.identityManager.add(new Group(DEFAULT_ADMIN_GROUP));
              }
      
              if (!this.hasUser(DEFAULT_ADMIN_USER)) {
                  final User user = new User(DEFAULT_ADMIN_USER);
      
                  user.setName("Administrator");
                  user.setCreatedDate(new Date());
                  user.setExpirationDate(null);
                  user.setEmail("admin@dentalsys.com");
      
                  this.identityManager.add(user);
                  this.identityManager.updateCredential(user, new Password(DEFAULT_ADMIN_PASSWORD));
      
                  final Group group = this.getGroup(DEFAULT_ADMIN_GROUP);
                  RelationshipManager relationshipManager = this.partitionManager.createRelationshipManager();
                
      
                  for (Role role : this.getRoles()) {
                      relationshipManager.add(new Grant(role, group));
                  }
                     //problem here
                     relationshipManager.add(new GroupMembership(user, group));
                
              }
      
      
      
          }