Authentification with Java, PHP, .htaccess

Hi there,
I am thinking about creating a Java project that requires some authentification routines.
Users (which are given a unique user ID) are employing a client software (Java) that retrieves specific data from a webserver (available ressources HTML, SSI, PHP, .htaccess).
A user should be able to use any client to get his data from the webserver, so unique client IDs are a non-option. Probably two users might even use two instances of the same client on the same machine (means, same IP).
I want this to be reasonably secure, so no plaintext protocol. I thought about something like a challenge - response architecture, BUT...
...how can I do this with only PHP (server) and Java (client) as options?
I don�t need a polished, smooth, perfect solution - a rough idea will do. Are there any secret / public key architectures with ready-to-use PHP modules that are also implemented in Java? Or has anybody a completely different idea I haven�t thought about yet?

Have a look on RFC 2617 from IETF (www.ietf.org). This RFC specifies two mechanisms for authenticated access to HTTP resources. .htaccess is based on these mechanisms. Unfurtonately, they are not secure enough. The first protocol, BASIC, sends clear text username/password. The second, DIGEST, sends digests of the username/password using a challenge-response scheme. The disadvantage of DIGEST is that the username/password needs to be stored in clear on the server-side.
What you could do, which is something I am currently working on myself, is to implement your own protocol, based on this RFC. This is possible because you are in control of both the clients and the server. It wouldn't be possible if standard browsers where used as clients.
Good luck!
/Christer

Similar Messages

  • Issue with Java - PHP interoperability

    Hi,
    There are some converts written in PHP that can take raw wikipedia data and output a good HTML. I wanted to make use of these in my Java code.
    So in my Java Web App, I wanted to run the PHP parser, get hold of the InputStream and push it to my ServletOutputStream.
    Code Snippet:
       String command="php testparser.php Anarchism.wikimarkup";
       proc = Runtime.getRuntime().exec(command);
       InputStream in = proc.getInputStream();
       InputStreamReader isr = new InputStreamReader(in);
       BufferedReader br = new BufferedReader(isr);
       String line = null;
       while ((line = br.readLine()) != null) {
         System.out.println(line);
       }But the problem here is that the PHP Process never stops and hence the Buffer never ends. THe program is waiting in infinite loop in readLine().
    Please let me know if anyone has tried this and whats a better way to handle interoperability between PHP and Java.
    Thanks,
    Phani

    Phanikumar_Bhamidipati wrote:
    Yeah, I had a look at the document. But as per my understanding, the way the PHP engine runs is different from normal execs. I don't see how it can 'run different' and in my experience it doesn't. PHP sends output to stdout and stderr and reads from stdin. When PHP terminates it will close stdout and stderr and, if you have followed the recommendations in the reference, your readLine() will return 'null'.
    Because the same code ran fine when I automated unzipping a set of files using "bunzip2" command.If you read the article it explains a possible reason for this BUT until you implement the recommendations you will not know what is wrong.
    >
    I tried using Process.waitFor() method as well, but the result is same (Infinite Loop).This almost certainly is nothing to do with Process.waitFor() and probably everything to do with buffers filling (probably stderr).
    Until you post the code with the recommendations implemented that exhibits the same blocking problem it is a waste of time anyone responding further.

  • Ldap connection with weblogic console and authentification with java

    Hello,
    I want that my web application use ldap authentification for users and that all parameters (host, port, base, ...) are configured by weblogic console.
    I managed to do it by security-->realms-->.... , but now, I want to perform authentification in my java code.
    I don't know how realized it because I don't know how use my ldap connection in java code without redefine parameters into my code...
    can anyone help me please?
    thanks a lot for your help.

    Hey,
    on a windows server system you have to put the target system CA Certificate in the local Trusted System Certificate Store of Microsoft Server. Then the connection should work.
    On a Java System you have to put the CA in the Key Storage of the SAP System.
    I think on Unix you could use the SAPCRYPTOLIB to place the CA in  the abap system.
    Kind regards,
    Sven Walter

  • PHP with JAVA

    I was working on one of the most common examples of getting system date, system property etc by calling Date and System classes of java from a PHP script. I have set up apache as the webserver on RedHat linux 7.2. Compiled PHP for java and i believe its properly compiled since it doesn't give error like "Fatal error: Cannot instantiate non-existent class:"
    When i try to access the script using the browser, the script itself is displayed instead of the output of the script.

    Is the problem with java or php?
    Check your apache.conf (or httpd.conf) settings.
    Find the lines and remove # if any.
    LoadModule php4_module libexec/libphp4.so
    AddModule mod_php4.c
    AddType application/x-httpd-php .php
    For further help try php lists.

  • How to get php content with java ??

    i have made a php file what will display a number,
    here's a example
    <?php
    if ($action == "answer"){
    echo "18274926";
    ?>
    no i want to get the number with java
    so here's my java code
    import java.io.*;
    import java.net.*;
    import java.util.Date;
    class URLConnecties
        public static void main(String args[]) throws Exception
            int teken;
            URL url = new URL("http://www.gamer.mineurwar.nl/net/javachallenge.php?command=DaTe");
            URLConnection urlconnection = url.openConnection();
            System.out.println("Type inhoud: " +
                urlconnection.getContentType());
            System.out.println("Datum document: " +
                new Date(urlconnection.getDate()));
            System.out.println("Laatst gewijzigd: " +
                new Date(urlconnection.getLastModified()));
            System.out.println("Document vervalt: " +
                urlconnection.getExpiration());
            int lengteinhoud = urlconnection.getContentLength();
            System.out.println("Lengte inhoud: " + lengteinhoud);
            if (lengteinhoud > 0) {
                InputStream in = urlconnection.getInputStream();
                while ((teken = in.read()) != -1) {
                    System.out.print((char) teken);
                in.close();
    }if you change the url ro a .html file it displays the code correctly(source),
    but when trying to get the content of a php file (the number)
    it says that there is no content from the php file
    yhe source of the original php file what's in the code can be found at
    www.gamer.mineurwar.nl/net/javachallenge.txt

    The 'content' is generated dynamically by a PHP script so the "content lenght" can't be known in advance by the server. For this reason connection.getContentLenght() returns -1; it doesn't mean that there is no content, only that it can't be known how much there will be.
    To solve the issue, remove the if statement from around the while-loop:// if (lengteinhoud > 0) { DELETE THIS LINE
    InputStream in = urlconnection.getInputStream();
    while ((teken = in.read()) != -1) {
        System.out.print((char) teken);
    // } and this too

  • Html files with included php: related files, code color?

    Hi there,
    Wow, what an active forum!
    I have two questions about html files that include php.
    Almost all my html files have this structure:
    <?php
    (php stuff)
    require_once 'somefile.php';
    ?>
    (html stuff)
    My first question is, is there any way for DW CS4 to display the files included this way? At the moment, they don't show up in related file view.
    My second question is, is there any way for DW CS4 to display the html and php code in the file in a pleasant way? The php is not red as it is in pure php files.
    Definitely not wanting to change the way I code or to change the file extensions...
    Instead, wanting to change the SW settings to make my work easier.
    With gratitude,
    Smiles
    Andy

    Hi Brad,
    Thanks for your reply!
    > The PHP coding in a regular HTML page likely won't even work in a  browser
    That's a standard coding technique...LOL... Maybe I didn't explain correctly...
    My hundreds of pages validate XHTML transitional...
    You are quite right that browsers do not interpret php code, but the  browser never sees php code.
    I will try to explain again
    The html file starts with <? php (code> ?>
    When the browser calls the html file, the server knows to process the file as php.
    It processes the php, then returns some html headers, and follows up with all the html that is after the <? php (code> ?> section.
    Thousands of php coders work like this.It's a very efficient way of building a modular website while keeping html extensions.
    By the way, related files already show in CS4 if they are in the html code.
    Are you 100% sure you are correct about the CS5 inclusion situation? You won't know unless you have built an html file that looks like this.
    <?php
    require_once 'myfile.php'>
    ?>
    <body>
    hello html
    </body>
    Your myfile.php might look like this:
    <?php
    echo 'hello php <br />';
    ?>
    If you have never used php in an html file, you will probably need to add something like this to your .htaccess file:
    AddHandler application/x-httpd-php5 .php .htm .html
    It tells your server that php processes not only php files but also html files.
    Warmest wishes to all,
    Andy

  • Never programmed with Java

    Hello
    I have never programmed with Java, and dont know, what i can do, I use PHP, but, i am only a novice at it.
    I was wondering, is it possable to get data from a page, and put it into an image? if there is no data from the page, it will ask for the data to be added, and this will update every so often?
    Also, Most of you know about google maps, where you can search for something, well, can i do this same thing in java, have a map, not of the earth, but for a game, and make it easy to add different parts, so that we can search for it, and people can find it easy to look for what they are looking for?

    I think Google Maps is programmed in JavaScript using AJAX (short for Asynchronous JavaScript and XML) and is what as known as a web application. Google has released an API (still in beta) for working with Google Maps. The webpage for this API is http://www.google.com/apis/maps/. More about the development facilities Google provides can be found at http://code.google.com/.
    I've never read the source code to Google Maps before (a lot of which is available by just viewing the source code of the Google Maps webpage, which can be done by clicking, View > Source in Internet Explorer and View > Page Source in Mozilla Firefox), however I don't think it is a terribly complex application (this does not mean, however, that the source code is easy to read). I think the way it works is by requesting individual images as needed from the Google server and piecing them together on the client side (i.e. in the browser). Basically what you would need to do to use their existing code is to replace all requests made to the Google server with requests to a server of your own and have the server return the corresponding images. This might not be particularly easy to do.
    In my opinion, a better approach is just to write your own custom application (probably in Java) which simply mimics the behavior of Google maps, except with your own custom images. This way, you don't have to reverse engineer an entire web application before beginning to write one.
    Writing your own application for this purpose is not as difficult as it sounds, especially not in Java. Once understanding the basics, you will not be too far off from being able to write your application.
    Let's start with the most basic program (this program would be located in a file called Program.java):
    public class Program {
       public static void main(String[] args) {
    }This program simply starts, does nothing, and exits. I will explain this piece of code line by line, but first, I would like to gauge how much you already know to figure out how best to explain this. Have you used classes in PHP before?

  • How to make sure an applet runs with Java 5?

    Hi all,
    First let me say thanks for all the help in the past. You've help me go from noob to intermediate noob. I've just about finished my first applet game which can be checked out here .
    Now I've been reading about problems with mac and 1.6. (note it works on Linux). I want to make sure that it runs fine and of course I don't own a mac. So I downloaded the 5 JDK. Selected it as the java platform in Netbeans, compiled and it ran fine.
    Questions:
    Do I have to always use 1.5 to compile and perhaps set it as default?
    Since it works in 1.5, do I compile it with 1.6 and just upload?
    I'm worried I'm not testing it correctly. I mean if I have both 1.5 and 1.6 installed on my machine, how to I make sure the applet is only using 1.5 to run?
    Thanks
    Darrin

    corlettk wrote:
    I haven't got a clue RE your problem other than for max-portability you should compile with [-target 1.5|http://java.sun.com/j2se/1.5.0/docs/tooldocs/solaris/javac.html].
    I must say I'm impressed, except I suspect my PC must be substantially faster than any of your test platforms... can you throttle it to CPU performance somehow? Or maybe it's just that my reflexes aren't what they once where.Thanks.
    There seem to be two issues. The first is what people are using. This web stats shows pretty poor penetration of 1.6.
    [http://www.statowl.com/java.php|http://www.statowl.com/java.php] Penetration: 54% with JRE1.6 + 19% with JRE 1.5. Total 73%.
    The second is I've read that mac and 1.6 do not get along except on a 64bit platform.
    So for applets there is not much choice but to compile on 1.5 for the broadest user base. I guess the good news is 1.4 and earlier are almost non-existent.
    Edited by: Darrin.A on Apr 27, 2009 8:11 AM

  • How can I compact a MSAccess database with java?

    Hi.
    I have a question (Please Help!!!):
    How can I compact a MSAccess database with java-jdbc? Is it posible?
    Thanks

    MS Access database has a max length limitation of 2.14GB for Access 2000( 1.07G for Access 97), and won't recycle basically space for update/delete sql so tha it's a good idea to use MS Access database for program, which need update/delete frequent ly data. The programmers of HXTT Access(www.hxtt.net) are writing code for CREATE TABLE/DATABASE sql now. If you need a pure Java solution for PACK TABLE/DATABSE urgently in your project, you should send such a requirement to the Support page of www.hxtt.net so that they can schedule complementing such a fucntion. Otherwise, you should pack your databae manually or visit C++ code for Compact an Access Database Programmatically at
    http://www.codeguru.com/Cpp/data/mfc_database/microsoftaccess/article.php/c4327/ , or use Easy Microsoft Access MDB MDE Compactor at http://www.easyhr.com.au/software/easy_mdb_mde_compactor.htm.

  • Java+php+linuxruntime  error

    Dear all i have one java class i amm using php pages to to use this class
    currently i am getting below error
    Fatal error: Uncaught exception 'java_RuntimeException' with message 'Could
    not connect to the context server . Error message: Connection refused (111)
    ' in /usr/local/apache2/htdocs/java/Java.inc:1163 Stack trace: #0
    /usr/local/apache2/htdocs/java/Java.inc(1180):
    java_Protocol->createSimpleHandler('@java-bridge-10...') #1
    /usr/local/apache2/htdocs/java/Java.inc(1187):
    java_Protocol->createHandler() #2
    /usr/local/apache2/htdocs/java/Java.inc(365):
    java_Protocol->java_Protocol(Object(java_Client)) #3
    /usr/local/apache2/htdocs/java/Java.inc(1541): java_Client->java_Client() #4
    /usr/local/apache2/htdocs/java/Java.inc(1650):
    __javaproxy_Client_getClient() #5
    /usr/local/apache2/htdocs/java/Java.inc(1665): java_session_array(Array) #6
    /usr/local/apache2/htdocs/java.php(3): java_session() #7 {main} thrown in
    /usr/local/apache2/htdocs/java/Java.inc on line 1163

    "Connection refused"
    I think it is safe to assume your network settings are wrong and it actually has nothing to do with java. Firewall problem perhaps?

  • Java/php bridge

    Hi All,
    i am working on jdeveloper10.1.3 & OracleApps Server.
    suggests some possible ways to bridge Java/PHP?
    I am facing problem integrating with jsp page and php page . if any one know its great help me.
    What are the software’s required for bridge between java and php.
    Request is so needful.
    thq,
    elisha.

    Judging by your later response, I'd say Gene got it right first time in that it is a memory issue.
    It looks like your application needs more than 512m heap size. I guess there isn't enough on the box where WebLogic is installed, otherwise you would have used the same sizes as TomCat.
    Apologies if I'm stating the obvious

  • SOAP - Java & PHP

    Hi all!
    I am developing now a SOAP extension for my web. I am using nusoap.php for PHP. Now I have the WSDL file and would like to connect to the server with Java. With WSDL2JAVA I create the Java Classes, but I could't connect to the server. Can anyone post me a link for more information about this?
    Thanks!
    Regards
    Nikolay

    how did you solve this? I am having a similar problem :(

  • Guided research with Java and XML

    Hi all,
    I'm a last year student and now I have to choose a topic for my Guided Research Project.
    My interest in XML and databases pushes me in this direction. However, I still cannot come up with an interesting proposal for the project. At first I considered implementing a "XML <-> databaseSchema" converter, but then I found out that many similar tools already exist. I have background in Java, PHP and mysql which could be useful.
    I was wondering if you could give me an idea about a possible topic.
    Thank you very much!
    Regards,
    J

    For parsing you can use SAX Parser and for document generation you can use DOM Parser.

  • In program written with Java Swing, I can't input Chinese

    In program written with Java Swing, I can't input Chinese.
    But if I change my language first, then change the input method tu U.S, open the Java Swing application, finally I can input Chinese. I want to know how to fix this bug.
    My OS is Mac OS X 10.6.8.
    At the JDK version 1.6.0_29, I can input Chinese friendly in Java Swing applications. But after 1.6.0_31, I can't do it anymore. The input methods can input Chinese in other non Java Swing applications so the problem must create by JDK or JRE's Swing part. What's the different between 1.6.0_29's Swing and 1.6.0_31's ? Why ? I heard that Java Swing apps not support Chinese input methods seens 2009... Why haven't fix these yet?

    Chazza wrote:
    Perhaps you need to change your keyboard layout in Xorg?
    https://wiki.archlinux.org/index.php/Ke … ard_layout
    Thanks for your answer!
    I have tried to change the keyboard layout from "en" to "cn", but it is still not work.
    The input method coin on the righttop is right when I change the method.But it still output english even I use ibus-pinyin.There is not a box for my choosing chinese words.
    Last edited by Dilingg (2015-05-15 16:18:43)

  • Read GUID with java

    Hi to all, I need some help with java to retrieve the eDirectory GUID. I
    know it's a binary data field and I need to decode it to read the value,
    but I'm not able to retrieve anything, even if I name the attribute
    because it is operational.
    This is my code. What am I doing wrong?
    import com.novell.ldap.*;
    import java.io.UnsupportedEncodingException;
    public class GuidReader {
    public static void main( String[] args ) {
    String loginDN = "cn=admin,o=system";
    String password = "MYPASSWORD";
    String searchBase = "MYCONTEXT";
    String searchFilter = "(cn=MYUSERNAME)";
    int searchScope = LDAPConnection.SCOPE_SUB;
    LDAPConnection lc = new LDAPConnection();
    try {
    lc.connect( "MYIPADDRESS", 389 );
    try {
    lc.bind( LDAPConnection.LDAP_V3, loginDN,
    password.getBytes("UTF8"));
    } catch (UnsupportedEncodingException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
    LDAPSearchResults searchResults = lc.search(
    searchBase,
    searchScope,
    searchFilter,
    null,
    false );
    while ( searchResults.hasMore() ) {
    LDAPEntry nextEntry = null;
    try {
    nextEntry = searchResults.next();
    } catch(LDAPException e ) {
    System.out.println("Error: " + e.toString());
    continue;
    LDAPAttribute attribute =
    nextEntry.getAttribute("objectGuid");
    if (attribute == null) System.out.println("not
    returned");
    attribute = nextEntry.getAttribute("GUID");
    if (attribute == null) System.out.println("not
    returned");
    attribute = nextEntry.getAttribute("cn");
    if (attribute == null) System.out.println("not
    returned");
    else System.out.println("returned");
    } catch( LDAPException e ) {
    System.out.println("Error " + e.toString() );
    If I run it, i get this result:
    not returned
    not returned
    returned
    Thank you,
    Natan Sanson
    nsanson
    nsanson's Profile: http://forums.novell.com/member.php?userid=1637
    View this thread: http://forums.novell.com/showthread.php?t=410589

    So I did it this way:
    LDAPAttribute attr = nextEntry.getAttribute( "GUID" );
    Enumeration allValues = attr.getByteValues();
    if ( allValues != null )
    System.out.println( getGUID( allValues ) );
    public static String getGUID( Enumeration values )
    String returnThis = "";
    while ( values.hasMoreElements() )
    int offset = 0;
    byte Value[] = ( byte[] ) values.nextElement();
    while ( offset < Value.length )
    int val = Value[offset++] & 0xff;
    String s = Integer.toHexString( val );
    if ( s.length() == 1 )
    s = "0" + s;
    returnThis = returnThis + s + " ";
    return returnThis;
    -jim
    On 5/14/2010 11:56 AM, nsanson wrote:
    >
    > Hi to all, I need some help with java to retrieve the eDirectory GUID. I
    > know it's a binary data field and I need to decode it to read the value,
    > but I'm not able to retrieve anything, even if I name the attribute
    > because it is operational.
    >
    > This is my code. What am I doing wrong?
    >
    > import com.novell.ldap.*;
    >
    > import java.io.UnsupportedEncodingException;
    >
    >
    > public class GuidReader {
    > public static void main( String[] args ) {
    > String loginDN = "cn=admin,o=system";
    > String password = "MYPASSWORD";
    > String searchBase = "MYCONTEXT";
    > String searchFilter = "(cn=MYUSERNAME)";
    > int searchScope = LDAPConnection.SCOPE_SUB;
    >
    > LDAPConnection lc = new LDAPConnection();
    > try {
    > lc.connect( "MYIPADDRESS", 389 );
    > try {
    > lc.bind( LDAPConnection.LDAP_V3, loginDN,
    > password.getBytes("UTF8"));
    > } catch (UnsupportedEncodingException e1) {
    > // TODO Auto-generated catch block
    > e1.printStackTrace();
    > }
    > LDAPSearchResults searchResults = lc.search(
    > searchBase,
    > searchScope,
    > searchFilter,
    > null,
    > false );
    > while ( searchResults.hasMore() ) {
    > LDAPEntry nextEntry = null;
    > try {
    > nextEntry = searchResults.next();
    > } catch(LDAPException e ) {
    > System.out.println("Error: " + e.toString());
    > continue;
    > }
    > LDAPAttribute attribute =
    > nextEntry.getAttribute("objectGuid");
    > if (attribute == null) System.out.println("not
    > returned");
    > attribute = nextEntry.getAttribute("GUID");
    > if (attribute == null) System.out.println("not
    > returned");
    > attribute = nextEntry.getAttribute("cn");
    > if (attribute == null) System.out.println("not
    > returned");
    > else System.out.println("returned");
    >
    >
    > } catch( LDAPException e ) {
    > System.out.println("Error " + e.toString() );
    > }
    > }
    >
    > }
    >
    >
    > If I run it, i get this result:
    >
    > not returned
    > not returned
    > returned
    >
    > Thank you,
    >
    > Natan Sanson
    >
    >

Maybe you are looking for

  • FTP adapter  (10.1.3.3) on Solaris

    Hi, I am trying to setup ftp adapter (10.1.3.3) on solaris with sftp set to true. I made all the necessary configuration changes to $ORACLE_HOME/j2ee/oc4j_soa/application-deployments/default/FtpAdapter/oc4j-ra.xml. Following properties are updated in

  • MY MACBOOK PRO HAS PROBLEMS.

    Hello. I got this MacBook pro off of eBay and I loved it until April. It would not turn on so I gave up hopeand left it sitting, collecting dust. Today I decided to try it and it turned on! IT WORKED!!! I was so happy that i had my mac back and runni

  • HT3728 after soft resetting how to set a new password to my airport express

    after soft resetting the airport exppress how to set a new password to my airport express

  • Replacement internal battery... is there an easy way ?

    I need a new internal battery for a MacBook Pro 17" Mid-2009.  The old one doesn't last any more, and has bulged and distorted the base so that the thing now rocks from side to side. Given that batteries are a consumable, and 3rd party batteries are

  • How best to manage global forms

    Looking for the best way to manage "Global forms". Where the same form (Output) may have different data displayed based on the country it is printed from. Let's just use BA00, Order Confirmation as an example. In the U.S. this output is on 8.5 X 11 i