Setting up permissions...should I, and how?

I have a servlet that reads images from a database. When the image isn't there, I want to read a default image.
Now, I know that I can have a default image on disk, but since there is already a default image inside of the resource of my web app, I thought that it would be best to read it from there. When I try that though I get this:
[#|2005-06-20T15:13:50.917-0500|INFO|sun-appserver-pe8.0.0_01|javax.enterprise.system.stream.out|_ThreadID=16;|
access denied (org.apache.naming.JndiPermission jndi:/server/myapp/resources/noimage.JPG)|#]
[#|2005-06-20T15:13:50.917-0500|WARNING|sun-appserver-pe8.0.0_01|javax.enterprise.system.stream.err|_ThreadID=16;|
java.security.AccessControlException: access denied (org.apache.naming.JndiPermission jndi:/server/myapp/resources/noimage.JPG)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:269)
at java.security.AccessController.checkPermission(AccessController.java:401)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:524)
at sun.awt.SunToolkit.getImageFromHash(SunToolkit.java:437)
at sun.awt.SunToolkit.getImage(SunToolkit.java:490)
at javax.swing.ImageIcon.<init>(ImageIcon.java:119)
The code I'm using looks like this:
   URL imageURL;               
   try      
            imageURL = request.getSession().getServletContext().getResource("/resources/noimage.JPG");       
   catch(MalformedURLException me)       
            System.out.println("MalformedURL exception caught. Error was: " + me.toString());
            return null;       
   ImageIcon icon = new ImageIcon(imageURL);I think that you should be able to set the permission in the server.policy file up to allow this, but the bigger issue is should this even be done to begin with? In other words, is this really a "bad thing" to do (read the image that the servlet needs from the resources)?
If not, any pointers on what the permission should look like?
My guess is:
grant {     permission  org.apache.naming.JndiPermission  "jndi://MyServerName/MyAppName/*"; };but that is just a guess!
Thanks.

Wow! That's a lot of code just to get an image out of the resource, but if it works....
What I need to do with the image is place it on a button and I didn't think that going out to a servlet to read it in from a database or a flat file made sense given it was already in the resource. I think the button will take an ImageIcon so this should work for me.
Anyway, I'll give it a try on Monday and report back here.
Thanks!
The following seems to work for me;-) But I don't
know what you want to do with the ImageIcon after
that;-)
ExternalContext context =
ontext = (ExternalContext)getExternalContext();
HttpSession session = (HttpSession)
Session)
((HttpServletRequest)context.getRequest()).getSession(
InputStream is =
eam is =
session.getServletContext().getResourceAsStream("/reso
urces/marco.jpg");
ByteArrayOutputStream os = new
os = new ByteArrayOutputStream();
byte[] buf = new byte[1024];
try {
int len = 0;
while ((len = is.read(buf, 0, 1024)) > 0)
1024)) > 0) {
os.write(buf, 0, len);
} catch(IOException e) {
System.out.println("IOException caught.
tion caught. Error was: " + e.toString());
return null;
ImageIcon icon = new
on = new ImageIcon(os.toByteArray());
System.err.println("mw icon=" + icon);Thanks,
-- Marco

Similar Messages

  • I have been trying to download photos. It keeps saying can't create file, please check permissions on destination folder. Ihave made sure I have set the permissions on read and write. What am I doing wrong?

    I have been trying to download photos too my MAC. It keeps saying can't create file, please check permissions on destination folder. Ihave made sure I have set the permissions on read and write. What am I doing wrong?

    Lanakivee
    Try this it worked for me Pat Willener gave it to me off the site :
    I have not read all you wrote, so I may have missed some points. As I understand it, you installed FP 10 on IE7, but it won't play any Flash content?
    Try this
    download the FP uninstaller from http://www.adobe.com/go/tn_14157
    close all browser windows, then run the uninstaller
    download the offline ActivX installer for Internet Explorer from http://fpdownload.macromedia.com/get/flashplayer/current/install_flash_player_ax.exe
    close all browser windows, then run the installer

  • Why does the App Store keep telling me I've got to set three security questions? And how do I Make them?

    Every time I try to download a new app, a pop-up comes up telling me to set three security questions. And when I try to set them using the provided link it takes me to a page and keeps asking for my password even after I enter it in multiple times. So, is there another way to set my security questions or is there a way to just get rid of the pop-ups? Thanks.

    This is for additional security to protect your Apple ID.
    Try setting your security questions for your Apple ID with a browser on your computer instead.
    https://appleid.apple.com/cgi-bin/WebObjects/MyAppleId.woa/

  • How to set default permissions for files and folders

    We have mac and windows computers on a network where we use Mac OSX Server 10.4 to share files. When files are created on windows computer, no problem, all users can read/write these files. However on our 2 macs (1 10.3 and 1 10.4), other users are blocked from using the files, only the owner has "read/write", group and others are "read only". As far as I can tell, file sharing is turned on ok in Workgroup Manager for the folders we share files from. How can we establish sharing for all users on our network?

    Niel's suggestion is good. You might also try posting your question in the Tiger Server forums. I'm sure Tiger Server has several ways of dealing with this.

  • Set desktop permissions to 666?  How?

    I'm always processing images to my desktop so I can zip them up and send them off somewhere. Lately I've had to change permissions to 666 on every folder/image I send out because I was getting complaints they were corrupt under 644.
    I've tried changing my User folder, Desktop folder, Original Image folder, etc. NOTHING fixes this problem. I've tried dumping the images in a new folder with 666 permissions and they STILL show up 644. Tried duplicating the desktop folder and even used the system disk to reset my ACLs. Nothing changes it.
    Can someone offer some advice to solve this? It's very annoying. Thanks.

    Sorry to butt in here, V.K., but I don't think 664 is supposed to be the default. I checked on two different macs running 10.5.6 and both give the following results from uMask -S:
    Last login: Mon Feb 9 23:25:05 on console
    MacPro:~ josh$ umask -S
    u=rwx,g=rx,o=rx
    I take it the default should in fact be 755, correct? Is it possible it is not applying the correct permissions in the first place? Seems by 644 you would be missing executable altogether so that might possibly cause problems when opening on other operating systems...
    Correct me if I am wrong as I do not really know a lot about Unix... still learning :P

  • I set an alarm with Siri. Can she only set one at a time, and how can I see/cancel it?

    Title. I set an alarm, then shortly after asked her to set another alarm.
    1) are both alarms in effect?
    2) where can I see/cancel them? It says it can't modify or delete them.

    Go to the Clock app and see if they are listed.  I just set two via Siri on my iPad and both are listed. I can turn them off or deleted (via edit button) the alarms.

  • I would like to buy used  Ipad 3gen 32 or 64 GB   .What are the things I should check for.(and how to check it) It is cash deal -no warranty.

    I would like to buy used Ipad 3 32 or 64 GB.It is cash deal and no warranty. What are the things I should check and how to do it ?

    Make sure it is in perfect working order before you turn over any money.
    Test connected to Internet.   Test Safari and several other apps for crashes.
    If it passes this test, it must now have find my iPhone turned off by the seller.   They must also remove the device from their iCloud account.  
    *****Please observe this.   If the seller can't turn off find my iPhone, then it is not his iPad to sell.   It will lock when you try to activate and will be worthless.****
    If this is the owner of the iPad he can also remotely erase the iPad with iCloud.
    http://support.apple.com/kb/HT5661

  • Most efficient/quickest way to set NTFS permissions in PowerShell

    Hello all,
    Trying to figure out what the most efficient/quickest way to set NTFS permissions via PowerShell is. I am currently using ICACLS but it is taking FOREVER as I can't figure out how to make inheritance work with this command.
    This has prompted me to begin looking at other options for setting NTFS permissions in PowerShell, and I wondered what everyone here likes to use for this task in PowerShell?

    Ah ok. Unfortunately, my ICACLS is taking FOREVER. Here is the code I'm using:
    ICACLS "C:\users\[user]\Desktop\test" /grant:r ("[user]" + ':r') /T /C /Q
    However:
    1.  I can't figure out how to make the inheritance parameter work with ICACLS
    2. If I do make the inheritance parameter work with ICACLS, I still need a way to add the permission to child objects that aren't inheriting.
    Any tips on how to improve performance of ICACLS?
    1. icacls folder /grant GROUPNAME:(OI)(CI)(F)  (i will post corrected code later, this works in CMD but not powershell couse of bracers)
    2.  get-childitem -recurse -force |?{$_.psiscontainer} |%{icacls ....}  (or u can list only folders where inheritance is disabled and apply icacls just on them)
    I think jrv and Mekac answered the first question about inheritance flags. I would just add that you probably don't want to use the /T switch with icacls.exe because that appears to set an explicit entry on all child items (that's probably why it's taking
    so long).
    For your second question, I'd suggest using the Get-Acl cmdlet. It throws terminating errors, so I usually wrap it in a try/catch block. Something like this might work if you just wanted the paths to files/folders that aren't inheriting permissions:
    dir $Path -Recurse | ForEach-Object {
    try {
    Get-Acl $_.FullName | where { $_.AreAccessRulesProtected } | ForEach-Object { Convert-Path $_.Path }
    catch {
    Write-Error ("Get-Acl error: {0}" -f $_.Exception.Message)
    return
    If you're looking for speed/performance, you don't want to just use the PowerShell Access Control (PAC) module that Mike linked to above by itself. It's implemented entirely in PowerShell, so it's incredibly slow right now (unless you use it along with Get-Acl
    / see below for an example). I'm slowly working on creating a compiled version that is much faster, and I think I'm pretty close to having something that I can put in the gallery.
    Since I wasn't sure which command would give you the best results, I used Measure-Command to test a few different ones. Each of the following four commands should do the exact same thing. Here are my results (note that I just ran the commands a few times
    and averaged the results on a test system; this wasn't very rigorous testing):
    # Make sure that this folder and user/group exist:
    $Path = "D:\TestFolder"
    $Principal = "TestUser"
    # Native PowerShell/.NET -- Took about 15 ms
    $Acl = Get-Acl $Path
    $Acl.AddAccessRule((New-Object System.Security.AccessControl.FileSystemAccessRule(
    $Principal,
    "Read", # [System.Security.AccessControl.FileSystemRights]
    "ContainerInherit, ObjectInherit", # [System.Security.AccessControl.InheritanceFlags]
    "None", # [System.Security.AccessControl.PropagationFlags]
    "Allow" # [System.Security.AccessControl.AccessControlType]
    (Get-Item $Path).SetAccessControl($Acl)
    # PAC Module 3.0 w/ PowerShell/.NET commands -- Took about 35 ms
    $Acl = Get-Acl $Path | Add-AccessControlEntry -Principal $Principal -FolderRights Read -PassThru
    (Get-Item $Path).SetAccessControl($Acl)
    # icacls.exe -- Took about 40ms
    icacls.exe $Path /grant "${Principal}:(OI)(CI)(R)"
    # PAC Module 3.0 w/o Get-Acl -- Took about 350 ms
    Add-AccessControlEntry -Path $Path -Principal $Principal -FolderRights Read -Force
    Unless I messed something up, it looks like the native PowerShell/.NET commands are faster than icacls.exe, at least for modifying a single folder's DACL.

  • How can I see what, when and how much has been downloaded from the net?

    I use a satellite internet service which limits me to only 200Mb of downloads in a 24 hr period. Should I go over, I am "locked out" of my internet service for the next 24 hr period. Lately I have been locked out without thinking I have downloaded anything. I am wondering if there is a place on the computer I can look to give me an idea what has been downloaded and when? I did change the Apple software update to not "automatically update important files" but I am wondering are there any other programs or anything the system may be downloading automatically without me knowing and what can be done to rectify it?
    Thanks

    Thanks for the thoughts. Here is some more for consideration. I was locked out yesterday and when I finally got out of "lock up" today, I went to my satellite internet provider's site to see how much and when it was downloaded. I booted my machine at about 10 AM yesterday and according to their site between 10 and 11 AM I downloaded 188MB of data. Then from 11 AM to Noon they said I downloaded another 28MB which then resulted in my being locked out of the internet until noon today. During that time I was on the net, I initiated no downloading from any site nor did I have any video streaming. What is frustrating is I have no idea what is being downloaded or how much. Most other days of the week it appears that downloaded material is 75Mb or less and I can remember generating the downloads.Looking at their site, the "downloading" of mystery material begins quickly after booting the computer which leads me to believe, as Kappy was saying, this is likely something like Apple Software updater or such set to "Download on Startup". I guess I'm not quite sure how to check to see what is set to "Download on Startup" and how to make sure nothing downloads at startup unless approved by me. Any thoughts?

  • What is the little blue bell icon and HOW do I get rid of it?

    Hi all,
    I keep getting a little blue bell icon with 2 red curved lines up at the top right corner of my screen. I do not have any alarms or alerts set. What is this and how do I get rid of it? (permanently would be nice). Thanks in advance for any wisdom y'all can impart.

    Actually neither of the above (I had said I have no alarm set).
    Turns out it is the symbol for voicemail calls I didn't receive (thank you from someone else who also has the same problem with their Pearl). To get rid of it one must go into the voicemail area and manually delete those calls.

  • IMac at work, iMac at home. (Latest Yosemite and Apple Remote Desktop updates installed) Need to work from home at night. I don't know how to set my permissions so that I can just control my iMac at work.

    iMac at work, iMac at home. (Latest Yosemite and Apple Remote Desktop updates installed) Need to work from home at night. I don't know how to set my permissions so that I can just control my iMac at work.

         If they have set up port forwarding for you already then that is different.  In that case, then you could be experiencing the bug with the most recent release of ARD (3.7.2) and in particular ARD 3.7.2 and Yosemite ARD version 3.8 clients.  It has been reported numerous times in the forums and to Apple that since 3.7.2, clients are frequently unavailable to connect to despite there being no network issue between the remote computer and client computer.  I have not seen anyone report it who was working from outside the LAN to inside the LAN, but I have the same issue with a number of my own computers that are simply on a different subnet, so it stands rot reason that it would happen from a port forwarding location.
         I am sometimes able to resolve the issue locally by SSH connecting into the client computer using Terminal on my admin machine and restarting or relaunching the ARD agent on the remote device, then trying to connect to it again after about 30 seconds.
    The Terminal commands for this procedure are as follows, though you might need to include a port number from outside the LAN:
    First:
    ssh ipaddress -l adminusername
    (example: ssh 192.168.1.1 -l macadmin)
    Second:
    sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/k ickstart -restart -agent
    After that, waiting about 30 seconds and trying to observe or control usually works, though the computer may still fail to show an online or lit-up status indicator.

  • My friend changed the language in my apple setting and took english off... i can no longer inputmy password due to it having an accent. What should i do and how should i do it ? all help is appreciated

    My friend changed the language on my phone.... i can no longer input my password due to him taking of the english language,  it is currently in the chinese language and my password has accents in it so i cant access my phone, i dont mind re-storing my phone if required... \whatshout i do and how do i do it ? help is appreciated !

    Hi there,
    You're running an old version of Safari. Before troubleshooting, try updating it to the latest version: 6.0. You can do this by clicking the Apple logo in the top left, then clicking Software update.
    You can also update to the latest version of OS X, 10.8 Mountain Lion, from the Mac App Store for $19.99, which will automatically install Safari 6 as well, but this isn't essential, only reccomended.
    Thanks, let me know if the update helps,
    Nathan

  • How do I use the time capsule to share itunes music between multiple apple devices? Also, is it possible to control the music on one device using another, and how do you set this up?

    How do I use the time capsule to share itunes music between multiple apple devices? Also, is it possible to control the music on one device using another, and how do you set this up?

    unless i'm missing something, i think you got mixed up, this is easy google for walk throughs
    i'm assuming this is the new 3tb tc AC or 'tower' shape, if so, its wifi will run circles around your at&t device
    unplug the at&t box for a minute and plug it back in
    factory reset your tc - unplug it, hold down reset and keep holding while you plug it back in - only release reset when amber light flashes in 10-20s
    connect the tc to your at&t box via eth in the wan port, wait 1 minute, open airport utility look in 'other wifi devices' to setup the tc
    create a new wifi network (give it a different name than your at&t one) and put the tc in bridge mode (it may do this automatically for you, but you should double check) under the 'network' tab
    login to your at&t router and disable wifi on it
    add new clients to the new wifi network, and point your Macs to the time machine for backups

  • Set up a Home Network? How do I do it & should I merge my accounts?

    Hi Folks - this is my first post and its quite long, so please bear with me as I give you a bit of history of my problem.
    I bought a iMac and hooked it up to a Seagate 500GB hard disk using Time Machine in my study and connect to my ISP via WiFi using a standard router. I then set up two user accounts - one for me & one for my wife and sync'd them both to our MobileMe accounts.
    Later I bought a Mac mini to use as a media centre in my lounge. It hooks into my HD TV through the mini-DVI port and I have a Elgato Eye hooked up via a USB port that links up to my Sky HD+ satellite box via a S-Video cable and AV component leads. I'm using a Mighty Mouse and an Apple Bluetooth keyboard via bluetooth. It has no external back-up hard disk and Time Machine is not set-up.
    When I set the Mac mini up, I wasn't quite sure what was the best way to set it up, but I used the Apple Set-up function to copy files & settings over WiFi from the iMac to the Mac mini for both user accounts. So I ended up with a compete copy of my iMac desktop/settings/files on my Mac mini with both accounts set-up with access to our MobileMe accounts.
    I wanted to change the layout of my dock on the Mac mini to remove some Apps (iWorks & MS Office). When I then subsequently logged into my iMac, the dock there was now different ie. the same as the Mac mini. So in order to keep my iMac dock different from my Mac mini dock, I changed the user account names on the Mac mini to a new naming convention 'Name - Mac mini'.
    I only wanted my media files on the Mac mini and all my other docs (spreadsheets, word processing etc) on the iMac, the idea being the iMac becomes a workstation and the Mac mini the media centre.
    So I deleted the relevant files off each mac. I then set-up network file sharing on both and can log into either via Finder to be able to get access to retrieve/access any files I need from either Mac - but this only works if both are on. Now I'm not so sure this is the best set-up.
    I've now started to fill up my Mac mini hard drive and I thought I would add some more storage and it would be great if I could back up both the iMac and Mac mini via Time Machine to a hard drive. A friend suggested using NAS storage for this as he does that with his iMac & Apple TV.
    So here's my two-part dilemma (appreciate your patience so far)....
    Dilemma No. 1: - What should I do for my storage solution?
    I can see the advantage of moving all my media & documents to the one shared network and being able to access them no matter what Mac I am using without the other having to be turning the other one on.
    I'm considering buying something like a Buffalo Linkstation NAS and connecting to the Mac mini via ethernet.
    Dilemma No. 2: - What should I do with my multiple accounts? Merge or keep separate?
    I get a little fed-up having to go downstairs and switch on the Mac mini to watch a TV show if I am upstairs on the iMac or if we are in the lounge browsing the web and want a file from the desktop iMac I have to run upstairs and switch that on.
    I know I could leave them both on sleep mode but I do like to turn them off now and again.
    I fI go for a NAS solution, should I keep the accounts separate?
    What's the best solution for both my dilemmas and are they interlinked? As an aside, I know very little about home-networking and what equipment I would need and how I would go about setting it up.
    Any help you can give [if you're still awake after reading this ] would be most appreciated.
    Cheers.

    I personally suggest the new Drobo FS. Since it has an iTunes server built in and you can use any size sata hard drive in it it is better and a NAS that has to use the same size drives.

  • I want to set up the Time Machine and I would love to use the Time  Capsule but since I already have a wireless router I need suggestions on  what other external disks Apple could recommend to use with the Time Machine and  how to configure that disk

    I want to set up the Time Machine and I would love to use the Time
    Capsule but since I already have a wireless router I need suggestions on
    what other
    external disks Apple could recommend to use with the Time Machine and
    how to configure that disk.
    A complication that I need to resolve is the fact that I am using Vmware
    Fusion to be able to use Windows on my Mac. Now it seems that Time
    Machine is not backing up my files
    on that virtual Windows without additional configuration and my question
    is whether you can advise me here or whether this is only a matter for
    the Fusion virtual machine.

    If you want to use Time Capsule you can.. you simply bridge it and plug it into the existing router.. wireless can be either turned off or used to reinforce the existing wireless.. eg use 5ghz in the TC which is much faster than your 2.4ghz.
    You can also use a NAS.. many brands available but the top brands are synology, qnap and netgear readynas  series. These will all do Time Machine backups although how well always depends on Apple sticking to a standard. There are cheaper ones.. I bought a single disk zyxel which was rebadged and sold through my local supermarket. It actually works very well for TM at least on Snow Leopard. Major changes were made in Lion and again ML so do not instantly think it will work on later versions. I haven't tried it yet with those versions.
    Any external drive can be plugged into the mac. Use the one with the fastest connection or cheapest price according to your budget. USB2 drives are cheap and plentiful. But no where near as fast as USB3 or FW800. So just pick whichever suits the ports on your Mac. Interesting Apple finally moved to USB3 on their latest computers.
    TM should exclude the VM partition file.. it is useless backing it up from Mac OS side.. and will slow TM as it needs to backup that partition everyday for no purpose.. TM cannot see the files inside it to backup just the changes.
    You need to backup windows from windows. Use MSbackup to external drive.. if you have pro or ultimate versions you can backup to network drive. But MSbackup is a dog.. at least until the latest version it cannot restore the partition without first loading windows. There are about a zillion backup software versions for windows.. look up reviews and buy one which works for you. I use a free one Macrium Reflect which does full disk backups and is easy to restore.. to do incremental backups though you have to pay for it.

Maybe you are looking for