Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-19557

Inconsistent resolution of serialized guest user reference

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 14.2, 13.10.4
    • 13.10.3
    • User
    • Unit
    • Unknown
    • N/A
    • N/A

    Description

      A guest user reference (of type GuestUserReference) is serialized as XWiki.XWikiGuest which is then resolved by default as a new DocumentUserReference containing a reference to XWiki.XWikiGuest: this is not consistent as it should be resolved back to a GuestUserReference.

      Here's a snippet showing the bug:

      {{groovy}}
      import org.xwiki.user.UserReference;
      import org.xwiki.user.UserReferenceResolver;
      import org.xwiki.user.UserReferenceSerializer;
      import org.xwiki.user.GuestUserReference;
      import org.xwiki.component.util.DefaultParameterizedType;
      import javax.inject.Inject;
      import javax.inject.Named;
      import org.xwiki.model.reference.DocumentReference;
      
      // Get UserReferenceResolver for the test
      def resolverType = new DefaultParameterizedType(null, UserReferenceResolver.class, String.class);
      def userReferenceResolver = services.component.getInstance(resolverType);
      
      // Get a UserReferenceSerializer
      def serializerType = new DefaultParameterizedType(null, UserReferenceSerializer.class, String.class);
      def userReferenceSerializer = services.component.getInstance(serializerType);
      
      def guestUser = GuestUserReference.INSTANCE;
      println "guest user reference: " + guestUser;
        
      def serializedGuest = userReferenceSerializer.serialize(guestUser);
      
      println "Serialized guest user reference: " + serializedGuest;
      
      // Resolved back the serialized guest user reference to UserReference
      def resolvedBackReference = userReferenceResolver.resolve(serializedGuest);
      println "Obtained user reference: " + resolvedBackReference;
      
      // Check if both references are equals
      def areReferenceEquals = guestUser.equals(resolvedBackReference);
      println "Obtained reference is equal to the original reference: " + areReferenceEquals;
      {{/groovy}}
      

      Attachments

        Issue Links

          Activity

            People

              surli Simon Urli
              surli Simon Urli
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: