On 07/16/2010 07:48 PM, xManish wrote: > > > Sergiu Dumitriu-2 wrote: >> >> XWiki authenticates using cookies. You could duplicate the code that >> adds the right cookies >> (com.xpn.xwiki.user.impl.xwiki.MyPersistentLoginManager#rememberLogin) >> into your application, and XWiki will automatically see them and login >> the right user. Don't forget to remove those cookies on logout >> (#forgetLogin). >> > > Hi, > Thankyou for the reply. I tried to reuse the code from > (com.xpn.xwiki.user.impl.xwiki.MyPersistentLoginManager#rememberLogin) > I found that it requires two variables to be set beforehand, which I believe > would come from xwiki.cfg. These are > this.secretkey and this.validationkey > So, I tried to instantiate them myself in myProject > for secretkey, I did following > byte[] theKey = stringToHex("secret").getBytes(); > KeySpec ks = new DESKeySpec(theKey); > SecretKeyFactory kf = SecretKeyFactory.getInstance("DES"); > this.secretKey = kf.generateSecret(ks); > > Since validationkey was just a string, I did following > this.validationKey = "validt"; > > Then I edited the xwiki.cfg file of my xwiki installation > xwiki.authentication.validationKey=validt > xwiki.authentication.encryptionKey=secret > > After loggin into the system, I found that cookies are set. However that > user aren't automatically logged in xwiki.
I'm not sure what the format of the keys should be, but trying your keys ends up with an error in the logs: Error: java.security.InvalidKeyException: Wrong key size Actually, it says this in xwiki.cfg, above the keys: #-# Cookie encryption keys. You SHOULD replace these values with any random string, #-# as long as the length is the same. So you should generate keys with 32 characters. > I'm sure I've been missing something in the process. > Can you please looked into it and identify it. -- Sergiu Dumitriu http://purl.org/net/sergiu/ _______________________________________________ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users