[opencms-dev] unauthenticated user writing to vfs

Ariel Spivakovsky ariels11230 at lycos.com
Sun Dec 5 08:30:55 CET 2004


I want an anonymous (guest) user to be  able to write to the vfs.

I wrote a JSP that does this and it works when authenticated as a CMS user, but it fails when the user is not logged it.

I'm running opencms 5.0.1

Any help is appreciated.

Thanks
Ari

This is the JSP

<%@ page import="com.opencms.flex.jsp.CmsJspActionElement,
                 com.opencms.file.CmsObject,
                 com.opencms.file.CmsFile,
                 com.opencms.file.CmsResource,
                 java.util.*,
                 java.lang.*" 
%>
<%


try{

CmsJspActionElement cms =   new CmsJspActionElement( pageContext, request, response );
CmsObject cmso = cms.getCmsObject();

int sd2 = new Date().hashCode();
String SHashDate = String.valueOf(sd2); // just a hash code so the file names are unique.
String sd = new Date().toString();
out.println(sd + "<BR>" + SHashDate  );
String formType = request.getParameter("actionDescription");

String foldername = "/FormSubmits/";
String filename   = "FormResult" +  formType + SHashDate + ".txt";
String myFileName = foldername + "/" + filename;
String title = formType;
String desc = "Submited form";

// int type = 3; // 1 = page, 3 = plain, 5 = binary, 8 = jsp
String outType = "plain"; 

Hashtable props = new Hashtable();
// Map props = new HashMap();

props.put( "Title", title );
props.put( "Description", desc );

String content =  request.getParameter("formContent");  //"Form Submits.<P>" + sd ;
if(null == content){
  content = "Error: content is null";
}

try{
      CmsResource newFile2 = cmso.createResource(foldername, filename, outType, props, content.getBytes());
     
     // send user to thank you page
     // response.sendRedirect(  );


}catch(Exception e){
     out.println("<font color=red>Error: Could not write file: "+ myFileName + "<br>" + foldername  + filename + "</font>" + e.toString());
}


}catch(Exception e){
           out.println("<font color=red>Error: write_file Global Exception<br>Make sure <B>actionDescription is set</B></font>" + e.toString());


}
%>
-- 
_______________________________________________
Find what you are looking for with the Lycos Yellow Pages
http://r.lycos.com/r/yp_emailfooter/http://yellowpages.lycos.com/default.asp?SRC=lycos10




More information about the opencms-dev mailing list