you will have to alter the web.xml also to deploy that servlet see attached
Same can be done to upload files
there is a commented area in the file where you can add some auth stuff
you get a file by: downloadhandler?fileName=myfile.jpg
regards
sebastian
2006/9/23, Michael Elsdoerfer <[EMAIL PROTECTED]
>:
> The stream directory can be forbidden for everybody and you make a simple
> servlet which outputs the file after it checks the userrights (wether
> based on IP or whatever kind of authentification you use).
Sounds complicated, I'm venturing in unknown waters here. I need the file
accessible via HTTP - can a servlet do that? Any examples or documentation
on how I would go about implementing that?
Also, judging from the responses I've gotten (thanks everbody!), am I
correct to assume that what I need can not be achieved via the normal Jetty
configuration? There seems to be the <ip-constraint>-Tag, but as I said, I
did not manage to get it working.
Michael
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf
> Of Sebastian Wagner
> Sent: Saturday, September 23, 2006 10:19 AM
> To: [email protected]
> Subject: Re: [Red5] ip-based security-constraints
>
> hi,
>
> The stream directory can be forbidden for everybody and you make a simple
> servlet which outputs the file after it checks the userrights (wether
> based on IP or whatever kind of authentification you use).
>
> regards
> sebastian
>
>
> 2006/9/23, Michael Elsdoerfer <[EMAIL PROTECTED] >:
>
> Hi list,
>
> I would like to have the "/streams" directory of a webapp not
> accessible,
> except for one trused ip address. I did some googling, tried
> different
> things with ip-constaint, but it didn't manage to get it work.
>
> I guess my main problem is that I don't understand how the
> "<web-resource-name>Forbidden</web-resource-name>" line actually
> works.
>
> Anyway, I would greatly appreciate any examples of how this could be
> achieved, or pointers in the right direction.
>
> Thanks,
>
> Michael
>
>
> _______________________________________________
> Red5 mailing list
> [email protected]
> http://osflash.org/mailman/listinfo/red5_osflash.org
>
>
>
>
>
> --
> Sebastian Wagner
> http://www.webbase-design.de < http://www.webbase-design.de>
> http://www.laszlo-forum.de
> Bleichstraße 92
> 75173 Pforzheim
> Tel.: 0177-7341829
> Home: 07231-417456
> [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
_______________________________________________
Red5 mailing list
[email protected]
http://osflash.org/mailman/listinfo/red5_osflash.org
--
Sebastian Wagner
http://www.webbase-design.de
http://www.laszlo-forum.de
Bleichstraße 92
75173 Pforzheim
Tel.: 0177-7341829
Home: 07231-417456
[EMAIL PROTECTED]
package org.dokeos.servlet; import java.io.OutputStream; import java.io.RandomAccessFile;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;
public class DownloadHandler implements Controller {
public DownloadHandler() {
}
public ModelAndView handleRequest(HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse)
throws Exception {
try {
/*
* TODO: Adding authentification stuff
*/
String current_dir = System.getProperty("user.dir");
System.out.println("Current_dir: "+current_dir);
String working_dir =
current_dir+"/webapps/dokeos/upload/";
String requestedFile =
httpServletRequest.getParameter("fileName");
System.out.println("requestedFile: "+requestedFile);
String full_path = working_dir + requestedFile;
RandomAccessFile rf = new RandomAccessFile(full_path,"r");
httpServletResponse.reset();
httpServletResponse.resetBuffer();
OutputStream out =
httpServletResponse.getOutputStream();
httpServletResponse.setContentType("APPLICATION/OCTET-STREAM");
httpServletResponse.setHeader("Content-Disposition",
"attachment; filename=\""+requestedFile+"\"" );
httpServletResponse.setHeader("Content-Length",""+rf.length());
byte[] buffer = new byte[1024];
int readed = -1;
while( (readed = rf.read(buffer, 0, buffer.length)) >
-1)
{
out.write(buffer, 0, readed);
}
rf.close();
out.flush();
out.close();
} catch (Exception er){
System.out.println("Error downloading: "+er);
}
return null;
}
}
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans> <bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="location" value="/WEB-INF/red5-web.properties" /> </bean> <bean id="web.context" class="org.red5.server.Context" autowire="byType" /> <bean id="web.scope" class="org.red5.server.WebScope" init-method="register"> <property name="server" ref="red5.server" /> <property name="parent" ref="global.scope" /> <property name="context" ref="web.context" /> <property name="handler" ref="web.handler" /> <property name="contextPath" value="${webapp.contextPath}" /> <property name="virtualHosts" value="${webapp.virtualHosts}" /> </bean> <!-- Class for the Streaming Handlers --> <bean id="web.handler" class="org.dokeos.videoconference.Application" singleton="true" /> <!-- Class for Methods which can be invoked be the client --> <bean id="dokeosService.service" class="org.dokeos.videoconference.RemoteService" singleton="true" /> </beans>
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans default-lazy-init="false" default-autowire="no" default-dependency-check="none"> <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping" abstract="false" singleton="true" lazy-init="default" autowire="default" dependency-check="default"> <property name="mappings"> <props> <prop key="downloadhandler.html">DownloadHandlerController</prop> </props> </property> </bean> <bean id="DownloadHandlerController" class="org.dokeos.servlet.DownloadHandler" abstract="false" singleton="true" lazy-init="default" autowire="default" dependency-check="default" /> </beans>
_______________________________________________ Red5 mailing list [email protected] http://osflash.org/mailman/listinfo/red5_osflash.org
