#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    Thailand
    Posts
    4
    Rep Power
    0

    Unhappy How can i create jsp page that can check the username and password shadow linux


    I really need to make a jsp login page that check the user and password on linux (the /etc/shadow file). I found that it has jni can be check the user and password but i try it on jsp which user tomcat as web server on linux red hat 9,the result is not succeed. The error on jsp page is about "root cause". I don't know what is it. any one could solve my problem?

    I has download the source about this from http://www.theorem.com/ftp/java/password.zip which it contain ShadowPassword classs. I run it by using java command line. It succeed. but when i use it on tomcat(jsp) it error. I don't know what the problem is. I 'm really new on linux and jsp. or are there another way to check linux username and passwond on jsp? I really seriouse need to check user.

    Thanks you in advance for advise me.
    Attached Files
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    78
    Rep Power
    12
    I have never tried to access system directories from inside of a web apps environment but a couple of things you might check...

    1. When you run the command line class are you running as root or a user with adminsitrator access?

    2. When you run tomcat or whatever your server is who are you starting the server as?

    The reason being that I believe that the server process needs to be running as a user that has the same level of security access as the file you want to read.

    Also, there might be an issue when trying to access a directory from a web app that's outside of the web apps directory structure. You may need to create a symbolic link in your web application directory that points to the shodow file's directory.

    By the way, 'Root cause' is just an indicator that the text that follows is the MAIN reason that your app failed. It doen't mean anything outside of that. You need to post the whole error msg, so that we can examine it.
    Last edited by Sm00ve; July 11th, 2003 at 08:48 AM.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    Thailand
    Posts
    4
    Rep Power
    0

    Unhappy


    <em>Thank you for your advice and i'm sorry for my slowly response to this.<br>
    <br>
    All right, I will try to give more detail about my problem.</em><br>
    <br>
    First I have extract password.zip to WEB-INF/classeswhich it contain com.theorem.password.ShadowPassword.class
    and many files. so i try to execute java command like this:<br>
    java -Djava.library.path=./com/theorem/password:/usr/lib com.theorem.password.ShadowPassword
    root xxx
    <p>&quot;./com/theorem/password&quot; is the library path that this class need
    the &quot;.so&quot; file to be call and also the system library &quot;/usr/lib&quot;
    which contain many &quot;.so&quot; file.<br>
    the parameter &quot;root&quot; is user name and &quot;xxx&quot; is password<br>
    if i give the correct password it will show &quot;Authenticated&quot; <br>
    I have read it's source code, I foud that this class contain the method call
    &quot;boolean check(String user,String password&quot; <br>
    so after i can execute this class by java comman next i try to use in jsp pag
    which the code in my jsp page look like this</p>
    <p><br>
    <br>
    <font color="#000099">&lt;%@ page import=&quot;com.theorem.password.*&quot;%&gt;<br>
    &lt;%</font></p>
    <p><font color="#000099"> boolean success;<br>
    ShadowPassword sp = new ShadowPassword();<br>
    success = sp.check(&quot;root&quot;,&quot;xxx&quot;<br>
    %&gt;<br>
    &lt;%=success%&gt;</font><br>
    </p>
    <p><br>
    So if anything no wrog it must show &quot;true&quot; of &quot;false&quot; depend
    of my username and password that i give to that method<br>
    so first time i execute this page i return error which it contain many line
    like this</p>
    <p><br>
    <br>
    <font color="#990000">Apache Tomcat/4.0.3 - HTTP Status 500 - Internal Server
    Error</font></p>
    <p><font color="#990000">--------------------------------------------------------------------------------</font></p>
    <p><font color="#990000">type Exception report</font></p>
    <p><font color="#990000">message Internal Server Error</font></p>
    <p><font color="#990000">description The server encountered an internal error
    (Internal Server Error) that prevented it from fulfilling this request.</font></p>
    <p><font color="#990000">exception </font></p>
    <p><font color="#990000">javax.servlet.ServletException: no java-axl-shpwd in
    java.library.path<br>
    at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:463)<br>
    at org.apache.jsp.login2$jsp._jspService(login2$jsp.java:80)<br>
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)<br>
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)<br>
    at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:202)<br>
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:382)<br>
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:474)<br>
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)<br>
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)<br >
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)<br>
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)<br>
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)<br>
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)<br>
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)<br>
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)<br>
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)<br>
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)<br>
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)<br>
    at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2343)<br>
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)<br>
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)<br>
    at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)<br>
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)<br>
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)<br>
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)<br>
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)<br>
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)<br>
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)<br>
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)<br>
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)<br>
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)<br>
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)<br>
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)<br>
    at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1012)<br>
    at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1107)<br>
    at java.lang.Thread.run(Thread.java:484)</font></p>
    <p><font color="#990000"><br>
    root cause </font></p>
    <p><font color="#990000">java.lang.UnsatisfiedLinkError: no java-axl-shpwd in
    java.library.path<br>
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1312)<br>
    at java.lang.Runtime.loadLibrary0(Runtime.java:749)<br>
    at java.lang.System.loadLibrary(System.java:820)<br>
    at com.theorem.password.ShadowPassword.(ShadowPassword.java:68)<br>
    at org.apache.jsp.login2$jsp._jspService(login2$jsp.java:62)<br>
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)<br>
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)<br>
    at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:202)<br>
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:382)<br>
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:474)<br>
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)<br>
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)<br >
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)<br>
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)<br>
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)<br>
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)<br>
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)<br>
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)<br>
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)<br>
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)<br>
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)<br>
    at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2343)<br>
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)<br>
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)<br>
    at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)<br>
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)<br>
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)<br>
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)<br>
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)<br>
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)<br>
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)<br>
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)<br>
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)<br>
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)<br>
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)<br>
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)<br>
    at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1012)<br>
    at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1107)<br>
    at java.lang.Thread.run(Thread.java:484)</font></p>
    <p><br>
    <br>
    I have seen about <strong>&quot;java.library.path&quot;</strong> from this error
    so i think it about &quot;/usr/lib&quot; and the file &quot;<strong>java-axl-shpwd
    .so&quot;</strong> in &quot;com.theorem.password&quot; so i try to add<br>
    this to the first line in catalina.sh --&gt; &quot; JAVA_OPTS=&quot;-Djava.library.path=.:/usr/lib:/usr/local/lib&quot;</p>
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    Thailand
    Posts
    4
    Rep Power
    0
    then i restart tomcat again but it also the same error which i think tomcat could not found the file libjava-axl-shpwd.so so i copy to tomcat/bin directory
    and another error message has occur

    Apache Tomcat/4.0.3 - HTTP Status 500 - Internal Server Error

    --------------------------------------------------------------------------------

    type Exception report

    message Internal Server Error

    description The server encountered an internal error (Internal Server Error) that prevented it from fulfilling this request.

    exception

    javax.servlet.ServletException
    at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:463)
    at org.apache.jsp.login2$jsp._jspService(login2$jsp.java:80)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:202)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:382)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:474)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
    at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2343)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
    at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
    at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1012)
    at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1107)
    at java.lang.Thread.run(Thread.java:484)


    root cause

    java.lang.NoClassDefFoundError
    at org.apache.jsp.login2$jsp._jspService(login2$jsp.java:62)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:202)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:382)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:474)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
    at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2343)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
    at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
    at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1012)
    at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1107)
    at java.lang.Thread.run(Thread.java:484)

    I coud not solve this error so which i guess, it about "java.library.path" that tomcat cannot see or anything i was mistake?
    or how i can add "java.library.path" to tomcat
    I have no way to solve this problem but i really need to check user in OS on my jsp application

    thank you in advance advise me.
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    Thailand
    Posts
    4
    Rep Power
    0
    Yahoooo! I could do it!....

    It was my mistake that i do not see which proper catalina.sh execute java option
    so i change add the -Djava.library.path=/usr/lib to the
    Line below this comment in catalina.sh
    # ----- Execute The Requested Command -----------------------------------------
    and i add this option by this syntax

    JAVA_OPTS="$JAVA_OPTS -Djava.library.path=/usr/local/tomcat/bin:/usr/lib"

    after i done this and restart tomcat and run my jsp page again.
    It return the result.
    However I don't under stand that i add this systax in the first line of catalina.sh it will not include when tomcat execute java command....


    Many thanks to every body to see my problem... and give me some advise...

IMN logo majestic logo threadwatch logo seochat tools logo