Welcome Guest Search | Active Topics | Members

PRB: Image Uploader for Java looses HTTP-only cookies Options
Dmitry
Posted: Tuesday, September 23, 2008 5:04:10 AM
Rank: Advanced Member
Groups: Administration , Member

Joined: 8/3/2003
Posts: 587
Points: 591
Hello Nikola,

It is a good example, and the only way to fix this problem is to increase timeout.

Sincerely yours,
Dmitry Sevostyanov.
nicola.baldi
Posted: Friday, October 10, 2008 5:32:42 AM
Rank: Newbie
Groups: Member

Joined: 9/23/2008
Posts: 3
Points: 9
Hello Dmitry.
Ok, we changed the configuration file of our application.
This is the forms section:

Code:
<forms name=".ASPXAUTH" loginUrl="~/SignIn.aspx"
    defaultUrl="~/Admin/Default.aspx" timeout="40"
    slidingExpiration="true" />


And this is the code behind file for the login procedure:
Code:
DateTime now = DateTime.Now;
DateTime expiration = now.AddMinutes(ConfigurationService.FormsAuthenticationTimeout);
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, user.UserName, now, expiration, false, null, FormsAuthentication.FormsCookiePath);
String encryptedTicket = FormsAuthentication.Encrypt(ticket);
Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket));
Response.Redirect(FormsAuthentication.GetRedirectUrl(user.UserName, false));


ConfigurationService.FormsAuthenticationTimeout is a static property, and it retrieves the timeout value from configuration file (FormsAuthentication class does not provide access to timeout property).
Something like this:

Code:
private static readonly Int32 _formsAuthenticationTimeout = 30;
public static Int32 FormsAuthenticationTimeout
{
    get { return _formsAuthenticationTimeout; }
}

static ConfigurationService()
{
    // ...
    System.Configuration.Configuration configuration = WebConfigurationManager.OpenWebConfiguration("~");
    AuthenticationSection authenticationSection = configuration.GetSection("system.web/authentication") as AuthenticationSection;
    if (authenticationSection != null)
                    _formsAuthenticationTimeout = (Int32)authenticationSection.Forms.Timeout.TotalMinutes;
}


This code works properly.

Anyway, we still have problems with firefox, by including following code too:

Code:
if (getImageUploader("ImageUploader").getControlType == "Java")
    getImageUploader("ImageUploader").AddCookie('.ASPXAUTH=XXXXXXXXXX');


In Internet Explorer we didn't encounter any problem.
So, I'm asking if the "AddCookie" can receive a parameter about cookie's expiration, because Firefox seems to discard the web.config timeout value.

Thanks in advance,
Nicola Baldi
Dmitry
Posted: Monday, October 13, 2008 4:08:35 AM
Rank: Advanced Member
Groups: Administration , Member

Joined: 8/3/2003
Posts: 587
Points: 591
Hello Nikola,

Could you give me the content of Java console (see article Using Java Console) after Image Uploader finishes uploading?

Sincerely yours,
Dmitry Sevostyanov.
nicola.baldi
Posted: Tuesday, October 14, 2008 1:24:40 AM
Rank: Newbie
Groups: Member

Joined: 9/23/2008
Posts: 3
Points: 9
Hi Dmitry, we appreciate your support.
This is the output of java console (I omitted irrilevant parts).

First upload
Code:
Aurigma ImageUploader version: 2.7.16.0
Current document URL: http://fotoadmin.aruba.it/Admin/AddPhotos.aspx
Reading cookies
Cookies: .ASPXAUTH=2F8BD0E78__OMITTED__16D95F0AC44030DD202E31; bmv/ll2VPubV/ezt7flqAA##=OYS__OMITTED__QO4#
Reading referer
Referer: http://fotoadmin.aruba.it/Admin/AddPhotos.aspx
Reading additional form content
..
__OMITTED__
..
Additional form processing done
Uploading to http://fotoadmin.aruba.it/Admin/Upload.aspx
Setting HTTP params: Host=fotoadmin.aruba.it
Cookies:<.ASPXAUTH=2F8BD0E78__OMITTED__16D95F0AC44030DD202E31; bmv/ll2VPubV/ezt7flqAA##=OYS__OMITTED__QO4#>
Starting upload
Status =[200]
Upload complete. Result page:

EndOf Result page
Aurigma ImageUploader version: 2.7.16.0


Here, everything seems ok.
Let's start with second try.

Second upload
Code:
Aurigma ImageUploader version: 2.7.16.0
Current document URL: http://fotoadmin.aruba.it/Admin/AddPhotos.aspx
Reading cookies
Cookies: .ASPXAUTH=2F8BD0E78__OMITTED__16D95F0AC44030DD202E31; bmv/ll2VPubV/ezt7flqAA##=OYS__OMITTED__QO4#
Reading referer
Referer: http://fotoadmin.aruba.it/Admin/AddPhotos.aspx
Exception in thread "Image Fetcher 0" java.lang.OutOfMemoryError: Java heap space
    at java.awt.image.DataBufferInt.<init>(Unknown Source)
    at java.awt.image.Raster.createPackedRaster(Unknown Source)
    at java.awt.image.DirectColorModel.createCompatibleWritableRaster(Unknown Source)
    at sun.awt.image.ImageRepresentation.createBufferedImage(Unknown Source)
    at sun.awt.image.ImageRepresentation.setPixels(Unknown Source)
    at sun.awt.image.ImageDecoder.setPixels(Unknown Source)
    at sun.awt.image.JPEGImageDecoder.sendPixels(Unknown Source)
    at sun.awt.image.JPEGImageDecoder.readImage(Native Method)
    at sun.awt.image.JPEGImageDecoder.produceImage(Unknown Source)
    at sun.awt.image.InputStreamImageSource.doFetch(Unknown Source)
    at sun.awt.image.ImageFetcher.fetchloop(Unknown Source)
    at sun.awt.image.ImageFetcher.run(Unknown Source)
Exception in thread "Image Fetcher 2" java.lang.OutOfMemoryError: Java heap space
    at java.awt.image.DataBufferInt.<init>(Unknown Source)
    at java.awt.image.Raster.createPackedRaster(Unknown Source)
    at java.awt.image.DirectColorModel.createCompatibleWritableRaster(Unknown Source)
    at sun.awt.image.ImageRepresentation.createBufferedImage(Unknown Source)
    at sun.awt.image.ImageRepresentation.setPixels(Unknown Source)
    at sun.awt.image.ImageDecoder.setPixels(Unknown Source)
    at sun.awt.image.JPEGImageDecoder.sendPixels(Unknown Source)
    at sun.awt.image.JPEGImageDecoder.readImage(Native Method)
    at sun.awt.image.JPEGImageDecoder.produceImage(Unknown Source)
    at sun.awt.image.InputStreamImageSource.doFetch(Unknown Source)
    at sun.awt.image.ImageFetcher.fetchloop(Unknown Source)
    at sun.awt.image.ImageFetcher.run(Unknown Source)
Exception in thread "Image Fetcher 3" java.lang.OutOfMemoryError: Java heap space
    at java.awt.image.DataBufferInt.<init>(Unknown Source)
    at java.awt.image.Raster.createPackedRaster(Unknown Source)
    at java.awt.image.DirectColorModel.createCompatibleWritableRaster(Unknown Source)
    at sun.awt.image.ImageRepresentation.createBufferedImage(Unknown Source)
    at sun.awt.image.ImageRepresentation.setPixels(Unknown Source)
    at sun.awt.image.ImageDecoder.setPixels(Unknown Source)
    at sun.awt.image.JPEGImageDecoder.sendPixels(Unknown Source)
    at sun.awt.image.JPEGImageDecoder.readImage(Native Method)
    at sun.awt.image.JPEGImageDecoder.produceImage(Unknown Source)
    at sun.awt.image.InputStreamImageSource.doFetch(Unknown Source)
    at sun.awt.image.ImageFetcher.fetchloop(Unknown Source)
    at sun.awt.image.ImageFetcher.run(Unknown Source)
Exception in thread "Image Fetcher 2" java.lang.OutOfMemoryError: Java heap space
    at java.awt.image.DataBufferInt.<init>(Unknown Source)
    at java.awt.image.Raster.createPackedRaster(Unknown Source)
    at java.awt.image.DirectColorModel.createCompatibleWritableRaster(Unknown Source)
    at sun.awt.image.ImageRepresentation.createBufferedImage(Unknown Source)
    at sun.awt.image.ImageRepresentation.setPixels(Unknown Source)
    at sun.awt.image.ImageDecoder.setPixels(Unknown Source)
    at sun.awt.image.JPEGImageDecoder.sendPixels(Unknown Source)
    at sun.awt.image.JPEGImageDecoder.readImage(Native Method)
    at sun.awt.image.JPEGImageDecoder.produceImage(Unknown Source)
    at sun.awt.image.InputStreamImageSource.doFetch(Unknown Source)
    at sun.awt.image.ImageFetcher.fetchloop(Unknown Source)
    at sun.awt.image.ImageFetcher.run(Unknown Source)
Exception in thread "Image Fetcher 3" java.lang.OutOfMemoryError: Java heap space
Exception in thread "Image Fetcher 2" java.lang.OutOfMemoryError: Java heap space
Exception in thread "Image Fetcher 0" java.lang.OutOfMemoryError: Java heap space
Exception in thread "Image Fetcher 3" java.lang.OutOfMemoryError: Java heap space
Exception in thread "Image Fetcher 1" java.lang.OutOfMemoryError: Java heap space
Exception in thread "Image Fetcher 0" java.lang.OutOfMemoryError: Java heap space
Exception in thread "Image Fetcher 0" java.lang.OutOfMemoryError: Java heap space
Exception in thread "Image Fetcher 2" java.lang.OutOfMemoryError: Java heap space
Exception in thread "Image Fetcher 0" java.lang.OutOfMemoryError: Java heap space
Reading additional form content
..
__OMITTED__
..
Additional form processing done
Uploading to http://fotoadmin.aruba.it/Admin/Upload.aspx
Setting HTTP params: Host=fotoadmin.aruba.it
Exception in thread "Image Fetcher 0" java.lang.OutOfMemoryError: Java heap space
Exception in thread "Image Fetcher 1" java.lang.OutOfMemoryError: Java heap space
Exception in thread "Image Fetcher 0" java.lang.OutOfMemoryError: Java heap space
OutOfMemoryError catched in function getBufferedImageFromFile_ImageIO()
Total garbage collection started.
Exception in thread "Image Fetcher 1" java.lang.OutOfMemoryError: Java heap space
Exception in thread "Image Fetcher 0" java.lang.OutOfMemoryError: Java heap space
Cookies:<.ASPXAUTH=2F8BD0E78__OMITTED__16D95F0AC44030DD202E31; bmv/ll2VPubV/ezt7flqAA##=OYS__OMITTED__QO4#>
Starting upload

Status =[200]
Upload complete. Result page:

EndOf Result page
Aurigma ImageUploader version: 2.7.16.0
Current document URL: http://fotoadmin.aruba.it/Admin/AddPhotos.aspx
Reading cookies
Cookies: bmv/ll2VPubV/ezt7flqAA##=OYS__OMITTED__QO4#
Reading referer
Referer: http://fotoadmin.aruba.it/Admin/AddPhotos.aspx


As you can see, value of authentication cookie is missing!
That's so strange, because within the page rendering we can clearly see the cookie initialization:

Code:
function ImageUploader1_BeforeUpload()
{
    if (getImageUploader("ImageUploader").getControlType == "Java")
        getImageUploader("ImageUploader").AddCookie('.ASPXAUTH=3AEBD8FE8D39078__OMITTED__AE51E3E3B1E70207EFB3C2;bmv/ll2VPubV/ezt7flqAA##=OYS__OMITTED__QO4#');
}


Anyway, this is the third upload:

Third upload
Code:
Aurigma ImageUploader version: 2.7.16.0
Current document URL: http://fotoadmin.aruba.it/Admin/AddPhotos.aspx
Reading cookies
Cookies: bmv/ll2VPubV/ezt7flqAA##=OYS4uRZTQO4#
Reading referer
Referer: http://fotoadmin.aruba.it/Admin/AddPhotos.aspx
Exception in thread "Image Fetcher 3" java.lang.OutOfMemoryError: Java heap space
Exception in thread "Image Fetcher 2" java.lang.OutOfMemoryError: Java heap space
Exception in thread "Image Fetcher 0" java.lang.OutOfMemoryError: Java heap space
Exception in thread "Image Fetcher 0" java.lang.OutOfMemoryError: Java heap space
Exception in thread "Image Fetcher 2" java.lang.OutOfMemoryError: Java heap space
Exception in thread "Image Fetcher 0" java.lang.OutOfMemoryError: Java heap space
Exception in thread "Image Fetcher 0" java.lang.OutOfMemoryError: Java heap space
Exception in thread "Image Fetcher 2" java.lang.OutOfMemoryError: Java heap space
Exception in thread "Image Fetcher 1" java.lang.OutOfMemoryError: Java heap space
Exception in thread "Image Fetcher 0" java.lang.OutOfMemoryError: Java heap space
Exception in thread "Image Fetcher 3" java.lang.OutOfMemoryError: Java heap space
Exception in thread "Image Fetcher 2" java.lang.OutOfMemoryError: Java heap space
Reading additional form content
..
__OMITTED__
..
Additional form processing done
Uploading to http://fotoadmin.aruba.it/Admin/Upload.aspx
Setting HTTP params: Host=fotoadmin.aruba.it
Exception in thread "Image Fetcher 3" java.lang.OutOfMemoryError: Java heap space
Exception in thread "Image Fetcher 1" java.lang.OutOfMemoryError: Java heap space
Exception in thread "Image Fetcher 0" java.lang.OutOfMemoryError: Java heap space
Exception in thread "Image Fetcher 2" java.lang.OutOfMemoryError: Java heap space
Exception in thread "Image Fetcher 0" java.lang.OutOfMemoryError: Java heap space
Exception in thread "Image Fetcher 1" java.lang.OutOfMemoryError: Java heap space
Exception in thread "Image Fetcher 1" java.lang.OutOfMemoryError: Java heap space
Exception in thread "Image Fetcher 3" java.lang.OutOfMemoryError: Java heap space
Total garbage collection started.


You can notice that cookie value is different (may be the asp.net runtime refreshed the ticket), but cookie is initialized correctly, by method "AddCookie" you provide us.
Thanks in advance.

Regards,
Nicola Baldi
Dmitry
Posted: Wednesday, October 15, 2008 1:17:41 AM
Rank: Advanced Member
Groups: Administration , Member

Joined: 8/3/2003
Posts: 587
Points: 591
Hello Nicola,

Thank you for your feedback.

I looked through the code you provided and found the following problem: ImageUploader object does not have getControlType method, this method is in ImageUploaderWriter object instead. That is why your code in ImageUploader1_BeforeUpload never executes.

So you need to change this method:
Code:

var iu = new ImageUploaderWriter("ImageUploader1", 650, 400);
...
iu.writeHtml();
...
function ImageUploader1_BeforeUpload()
{
    if (iu.getControlType() == "Java")
        getImageUploader("ImageUploader1").AddCookie(...);
}

You can see that I used iu variable to launch getControlType method.

Sincerely yours,
Dmitry Sevostyanov.
Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

YAFVision Theme Created by Jaben Cargman (Tiny Gecko)
Yet Another Forum.net version 1.9.1.6 running under Cuyahoga.
Copyright © 2003-2006 Yet Another Forum.net. All rights reserved.