We are passing all credentials from the user on the application.
Through a persister class we are passing this info, somehow the
HTMLWorker when parses the tags for the images doesn't validate with
the persister.
Any ideas how can I overcome this? Thanks
Here is the code:
<%@
page language="java"
import="java.io.*,java.util.*,java.net.*,com.lowagie.text.*,com.lowagie.
text.pdf.*,com.lowagie.text.html.*,com.lowagie.text.html.simpleparser.*,
java.sql.*,java.awt.Color,
blackboard.platform.plugin.PlugInUtil,
blackboard.data.course.*,
blackboard.data.content.*,
blackboard.data.user.*,
blackboard.data.navigation.*,
blackboard.persist.*,
blackboard.persist.content.*,
blackboard.persist.navigation.*,
blackboard.platform.*,
blackboard.servlet.util.*" %><%@
taglib uri="/bbUI" prefix="bbUI" %><%@
taglib uri="/bbData" prefix="bb"%><bb:context id="ctx"><%
//******BLACKBOARD STUFF********//
// / retrieve the Db persistence manager from the persistence
service
BbPersistenceManager bbPm =
BbServiceManager.getPersistenceService().getDbPersistenceManager();
//Get Course Info from Context
Course crs = ctx.getCourse();
Id courseId = crs.getId();
String strCourseId=crs.getCourseId();
String strCourseTitle=crs.getTitle();
String strBannerFile=crs.getBannerImageFile().getPath();
//Get User Info from Context
User usr = ctx.getUser();
//String strUsername = usr.getUserName();
//String strFirstname = usr.getGivenName();
//String strLastname = usr.getFamilyName();
Id userId = usr.getId();
// get the information from the Table of Contents or Navigation
Items for this course
CourseTocDbLoader tocLoader = (CourseTocDbLoader)
bbPm.getLoader( CourseTocDbLoader.TYPE );
CourseToc toc = null;
String tocMessage = "";
String contentTitle = "none";
String subContentTitle = "none";
Id startContent, firstChapter = null;
int i = 0;
int j = 0;
////
//Adding Content to PDF
//Init PDF
response.setContentType( "application/pdf" );
Document document = new Document(PageSize.LETTER);
ByteArrayOutputStream buffer = new
ByteArrayOutputStream();
PdfWriter.getInstance(document, buffer);
document.open();
//Defining Fonts
Font titleFont = new Font(Font.COURIER, 14, Font.BOLD);
Font sectionFont = new Font(Font.HELVETICA, 12,
Font.ITALIC);
titleFont.setColor(new Color(0x99, 0x00, 0x00));
sectionFont.setColor(new Color(0x23, 0x5C, 0xDD));
//
StyleSheet style = new StyleSheet();
//StringReader r = new StringReader( "<b>test
<i>this</i></b>" );
ArrayList objects;
String moduleContentStr;
////
boolean tocIsAvailable = false;
try {
toc = tocLoader.loadByCourseIdAndLabel(courseId,
"Course Contents");
tocIsAvailable = toc.getIsEnabled();
if (!tocIsAvailable) {
tocMessage="disabled";
} else {
tocMessage="enabled";
Id contentId = toc.getContentId();
ContentDbLoader contentLoader =
(ContentDbLoader)bbPm.getLoader(ContentDbLoader.TYPE);
java.util.List firstLevelList =
contentLoader.loadAvailableChildren(contentId, userId, false, null);
Iterator firstLevelIterator =
firstLevelList.iterator();
while(firstLevelIterator.hasNext()) {
Content
firstLevelContentItem = (Content)firstLevelIterator.next();
contentTitle =
firstLevelContentItem.getTitle();
Id firstLevelItemId =
firstLevelContentItem.getId();
i = i+1;
j = 0;
Chapter pdfChapter = new Chapter (new
Paragraph(contentTitle, titleFont), i);
pdfChapter.setBookmarkTitle(contentTitle);
pdfChapter.setBookmarkOpen(false);
document.add(pdfChapter);
java.util.List secondLevelList =
contentLoader.loadAvailableChildren(firstLevelItemId, userId, false,
null);
Iterator secondLevelIterator
= secondLevelList.iterator();
while
(secondLevelIterator.hasNext()) {
Content
secondLevelContentItem = (Content)secondLevelIterator.next();
subContentTitle =
secondLevelContentItem.getTitle();
Id
secondLevelItemParentId = secondLevelContentItem.getParentId();
Id secondLevelItemId
= secondLevelContentItem.getId();
j = j+1;
Section pdfSection = pdfChapter.addSection
( new Paragraph (subContentTitle, sectionFont),j);
moduleContentStr =
ContentRendererUtil.renderContentBody(request, ctx,
secondLevelContentItem);
StringReader sr = new StringReader
( moduleContentStr);
objects = HTMLWorker.parseToList( sr , null );
Paragraph parrafo = new Paragraph();
for (int k=0; k < objects.size(); ++k)
{
parrafo.add( (Element)objects.get(k) );
pdfSection.add( parrafo );
}
/* Content with tags */
// Paragraph moduleParagraph =
new Paragraph();
// moduleParagraph.add
(moduleContentStr);
// pdfSection.add (
moduleParagraph );
/* END */
document.add(pdfSection);
} // end while
secondLevelIterator.hasNext
} // end while
firstLevelIterator.hasNext
}
}catch (KeyNotFoundException e) {
tocMessage="error";
}
document.close();
DataOutput output = new DataOutputStream( response.getOutputStream() );
byte[] bytes = buffer.toByteArray();
response.setContentLength(bytes.length);
for( int k = 0; k < bytes.length; k++) { output.writeByte ( bytes
[k] ); }
%></bb:context>
On Oct 24, 2007, at 2:12 PM, Bruno Lowagie wrote:
> Alvaro Sanchez wrote:
>> These images are stored on a "content collection" area specific to
>> the
>> instructor, but the images are public to the people enrolled in
>> the class.
>
> Your application is not enrolled in the class, is it?
>
> There's a huge difference between calling an image from a browser
> (where somebody is logged in and has the right credentials) and
> calling an image from a servlet (even if the servlet is called
> from a browser by somebody that is logged in).
>
> Look at the server logs on the server that provides the images.
> You'll see that a hit from an IP of a student that is logged in
> is processed correctly. You'll see that hits from your app don't
> come from the IP address of the student, but from your application
> server; this is a totally different user!
>
> Solving this problem is a matter of administration.
> br,
> Bruno
>
> ----------------------------------------------------------------------
> ---
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems? Stop.
> Now Search log events and configuration files using AJAX and a
> browser.
> Download your FREE copy of Splunk now >> http://get.splunk.com/
> _______________________________________________
> iText-questions mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/itext-questions
> Buy the iText book: http://itext.ugent.be/itext-in-action/
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/