Laliwala IT Services

Laliwala IT Services
Website Development

Wednesday, February 23, 2011

Servlet in portlet, restricting access using CAS / accessing themedisplay, liferay theme display, liferay resource, liferay information, tomcat, root

Baptiste Grenier : Hi,








Using the Plugins SDK I've developed a portlet containing a servlet (outputting a JavaScript file) that is mapped into the web.xml of a portlet. They are both packaged in the same WAR.








The servlet works fine, but I would like to restrict access to it and to add logged-in user related information.








As I am using CAS (version 3.x) to authenticate the users I would like to now how I could restrict access (make private) to the servlet.








I tried to add the CAS filters from the portal's web.xml to the portlet's web.xml and then to add filter-mapping for the servlet but it was failing on deploy of the portlet (Filter start error I think).








I also tried to get themeDisplay from the request to be able to check if someone is signed-in but themeDisplay is desperately null.








I even tried to call my servlet through PortalDelegateServlet, the call did work, but themeDisplay is still null.








And as for now it didn't go through any authentication filter is looks normal to me.








I also think that I can't use the JSR286 serveResource to send the generated JavaScript as my servlet is intended to be linked from another external CAS-protected site and I need to have a clear and descent URL.








I've searched the forums/net but I wasn't able to find any information that could help me.








Please, does anybody have any idea on how to achieve this?








Regards,

Baptiste






Baptiste Grenier : I was able to fix the problem with the CAS mapping, now the servlet is protected by CAS after having added CAS filters to the web.xml of the portlet:
















My previous problem seems to have been only related to missing libs, now it is working with the following ones:









  • opensaml-1.1b.jar

  • xmlsec.jar

  • cas-client-core-3.1.10.jar









As they were already copied to $TOMCAT_HOME/ROOT/WEB-INF/lib I was assuming that they were accessible from all the others webapps, but that's false.








From the servlet I am now able to access the logged-in user using the following code:













But I am still missing previous information available in the ThemeDisplay object such as the edit my account url and others things that are quite painful to recreate.








So if someone does have an idea on how to retrieve a themeDisplay from my servlet... emoticon








Cheers,

Baptiste






Mazhar Anwar :


Hey Baptiste,








Rather than writing a different servlet, Cau you give a try to ServerResource() method of portlet API? I think you can achieve your functionlities without worrying about new servlet and CAS Integration and all and you can get all portlet request object in that method with ease.








Regards,

Mazhar






Baptiste Grenier : Hey Mazhar,








Thanks for your input, I already took a look at the serveResource() method of the portlet API 2.0, but I need to be able to map the serveResource to a clean URL, and I am not aware of a way of creating a clean resourceURL.








To explain a bit more: my servlet is now generating JavaScript code that is linked from other web sites that are too protected by CAS. For now I am linking to the generated JavaScript file using a URL like: http://plop.com/menu-portlet/js/dashboard.js and I would like to keep that "clean" URL.








Is there a way to do such a thing ?






Amedeo Falanga : Hi,








I have problems configuring my portlet





can you post the CAS configuration of your portlet?








Thanks

cubillas

9 comments:

  1. Can you say about Liferay training?..

    Before joining the training, I would like to know about life ray training and clear idea about liferay training?

    Cegonsoft

    ReplyDelete
  2. My brother recommended I may like this blog.
    He was once entirely right. This submit actually
    made my day. You can not believe just how much time I had spent for this information!
    Thanks!
    Have a look at my page :: panic attack

    ReplyDelete
  3. With havin so much written content do you ever run into any problems of plagorism or copyright
    violation? My site has a lot of unique content I've either created myself or outsourced but it looks like a lot of it is popping it up all over the internet without my agreement. Do you know any techniques to help reduce content from being ripped off? I'd certainly appreciate
    it.
    Also visit my webpage : piano lessons

    ReplyDelete
  4. Great goods from you, man. I've understand your stuff previous to and you are just extremely magnificent. I really like what you have acquired here, really like what you're saying and the way in which you say it.
    You make it enjoyable and you still take care of to keep it smart.
    I cant wait to read far more from you. This is
    really a wonderful website.
    Feel free to visit my web-site ... direct download movies

    ReplyDelete
  5. I rarely drop responses, but i did some searching and
    wound up here "Servlet in portlet, restricting access using CAS / accessing themedisplay, liferay theme display, liferay resource, liferay information, tomcat, root".
    And I do have 2 questions for you if it's allright. Could it be only me or does it give the impression like some of these responses come across like coming from brain dead people? :-P And, if you are writing at other online sites, I'd like to
    keep up with anything new you have to post. Could you make
    a list of every one of all your social sites like your Facebook page, twitter feed, or linkedin profile?
    my web page: boligityrkia.net

    ReplyDelete
  6. Hi there! Do you know if they make any plugins to assist
    with SEO? I'm trying to get my blog to rank for some targeted keywords but I'm not seeing very good results.
    If you know of any please share. Thanks!
    Also visit my web page : acne cure

    ReplyDelete
  7. Hi there this is kind of of off topic but I was wanting to know if blogs use WYSIWYG editors or if you have to manually code with HTML.
    I'm starting a blog soon but have no coding knowledge so I wanted to get advice from someone with experience. Any help would be greatly appreciated!
    Take a look at my site powerful steps to clear acne

    ReplyDelete
  8. Hi there this is kind of of off topic but I was wanting to know if blogs use WYSIWYG editors
    or if you have to manually code with HTML. I'm starting a blog soon but have no coding knowledge so I wanted to get advice from someone with experience. Any help would be greatly appreciated!
    Also see my website > powerful steps to clear acne

    ReplyDelete
  9. Hey thеrе wοuld yοu
    mind sharing whiсh blog рlatform you're using? I'm goіng
    tο staгt my oωn blοg soon but I'm having a difficult time deciding between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your design and style seems different then most blogs and I'm looκing
    for sοmethіng uniquе.
    P.S My apοlogies for getting off-topic but I had
    to аѕk!

    Herе is my blog post :: amazon

    ReplyDelete