Java MySQL Authentication System - java

I am trying to create my own authentication system that connects from a Java program to MySQL database or to a PHP page that accesses the MySQL page. The Java program would check to see if the user is in the database and if it is, it would determine the list of features to display. I am currently trying to work on something simple, then work my way up.
I have searched on Google, but there are quite a few things out there; I wasn't sure which was the best way to go about doing this and what technologies to use from what I saw. I was wondering if anyone had any recommendations on how I should go about doing this or if they had an document, article, blog, etc that I could use to learn more about this.

Try Apache Shiro, its well documented and you can configure it with mysql(jdbc) database http://shiro.apache.org/

Related

Java web application working with Scrutmydocs

Does anyone know of a good example with a Java web application that uses Scrutmydocs, or any other ElasticSearch Client. I have a sample web app running: www.TenantTalk.com that I need to add a search box to. The search will call Scrutmydocs or Elasticsearch. The Database will be much larger.
Right now it is a java jsp app using MySQL using JDBC and SQL on Tomcat. When a new record or change is made to the database it must make it into Scrutmydocs or Elasaticsearch.
You help will be greatly appreciated.
The login for www.TenantTalk.com is demo/demo
I have searched everywhere but cannot find an example that spells out where you call Scrutmydocs from a Java application when the user adds, edits, or deletes a record from the database and perform searches on that date.
scrutmydocs is not an elasticsearch client. It is a full web application.
It basically uses elasticsearch native client. So you can have a look at its source code.
That said, you probably want to look directly at elasticsearch java API documentation.
Also, this hands-on source code could help you. See answers branch.

what are the steps to make a word search for a website?

I want to write a word search,which connects to a specific website(huge one),takes the word from user,searches the site and returns the strings which contain the word;this should be written in java and as an applet.I have read some tutorials and questions on this,and understood what have to be done is:
1.connect to a website and get the content of a website and save it to a string.(this should be done with a webcrawler which will be made from my own code for connecting to website and save the content to a string + jsoup library to parse the html code).
2.save the datas to a database(in my case nosql database).
3.index the datas in database.
4.query the database to show the results.
5.make a UI for showing the search results(I use swing.japplet).
now my qustions are:
1.have I understood correctly the steps which I have to go?(please explain me in details if a step is unnecessary or necessary)
2.Is it necessary to have a database?
notice:I want to implement it myself,without using ready things such as lucene,nutch,solr,...
edit:3 people told me applet is not suitable for such a thing,so what should be the replacement?
many many thanks for your help.
You should look at using Lucene, as it does most of what you want here.
You should not use applets.
For small data set, database should be sufficient. Databases like mysql comes with full text search functions.
For bigger data set, you might want to consider Lucene or Solr.
That is one way way to implement this. Another (simpler) way would be to use an existing text search / indexing engine like Lucene / Solr. Going to the effort of reimplementing the "text search / indexing" wheel using database technology strikes me as a waste of effort, unless you have a sound technical reason for doing so.
You do need to has some kind of database, because indexing a website on the fly would simply not work. Lucene will handle that.
I think your choice of Java applets to build the UI is a bad idea. There are other technologies that give results that are as good or better ... without the security risk of a Java browser plugin.
Finally, another way to make your website searchable is to get Google to do it for you. Make your website content indexable, and then use Google's search APIs.

How can I query to LDAP the e-mail from Windows User from Java/JNDI?

I have searched around the web but could not find any solution.
Also, I have tried a lot of different solutions, but none works.
Please, keep an open mind while looking to this situation.
Requirements:
Should use Java/J2SE (Console, GUI, any).
Do not use any external or third party jar/package only JNDI.
Do not ask or store user password.
Get the e-mail from Windows logged in user in LDAP.
Assumptions:
Do not need to dive into the details of LDAP server, it is working on other languages like VBS/.Net/etc. but not Java.
Note:
The piece of VBS is working even asking for other users (not the one logged in).
I do not know about LDAP server configuration but the information above should make sense for those who knows it.
Piece of VBS code that is working fine:
Dim objSysInfo, objUser<br>
Set objSysInfo = CreateObject("ADSystemInfo")
Set objUser = GetObject("LDAP://" & objSysInfo.UserName)
MsgBox objUser.mail
How can I make it work?
The problem here is not the JNDI part, it is getting the user's login name in the same format as provided by ADSystemInfo.UserName. You could see whether System.getProperty("user.name") returns the right thing, otherwise you are into some ActiveX Bridge thing to emulate the VB code you posted.
The LDAP part just maps very straightforwardly into JNDI, you shouldn't have any problem with that part.
Windows and the VBS APIs use a "SASL GSSAPI mechanism to achieve Single Sign-on (SSO)" form the client to a Active Directory Server.
There are many versions of Windows Active Directory and countless different methods that various parameters could be set in your implementation. So your success may vary.
I found an article that might help point you in the right direction:
http://dmdaa.wordpress.com/2010/04/10/utilize-sasl-gssapi-mechanism-to-achieve-single-sign-on-sso-for-jndi-ldap-client/

How to access online mysql database in android?

I have created an online database about the restaurants and I need to access this database through my android application, so that I can display the data to the users after filtering. My application does not need to update the database, but my problem is how to connect to my online mysql database and provide it to the users? I have looked on many suggestions on this site as well as on others, and I just found I have to use JSON parser while accessing but do not how to do it.
The best solution is provide a public API, managed for example with PHP, which delivers your database data filtered and displayed as your Android application needs.
This link might help you . http://www.androidhive.info/2012/01/android-login-and-registration-with-php-mysql-and-sqlite/
Just get an understanding of JSON parsers and how it can be used in android for retrieving data from database on server... you can write webservices in php..
You need to provide a server side solution that the Android application can speak to. PHP scripts are a good way to go, that can directly interface with the MySQL database, and return results to the device.
You can then be creative with the PHP script, by sorting the results etc, and providing a more comprehensive solution by taking away some of the processing from the Android device, and doing it server side where battery life isn't as much of a problem.
You simply need to implement web service calls on the Android device, simple GET/POST requests over HTTP suffice depending on what you intend to do. Have a look into REST APIs for guidelines on how to implement properly.
You can easily add a PHP script to the same server as the MySQL database for this

How can i determine using java what sites have been opened up in browsers?

I need to understand the directions in need to look into to Writing a program that figures out what all websites have been hit by a user using his browser. I want to write a standalone program. Can anybody direct me to some API which may help me figure this out.
Well, first of all that depends on which browser do you need to check. I'm guessing that you need to check the currently set default system browser. Anyway, that will require a lot of browser research and few JNI calls.
To find a default browser you would need to check HKEY_CLASSES_ROOT\http\shell\open\command (for Windows) and various configuration files under different linux for different window managers.
Then you would need to read the history of the specific browser from the format of that browser. For example, Firefox stores it's history in sqlite format in the profile directory in places.sqlite file. Chrome on other hand stores it in %home%/User Data/Default/history. So you would need a separate parser for each browser.
Basically, if you need a universal browser history reader - it's a load of work and research.
As it was clarified by the author in his comments - he needs to check what is user currently browsing.
The only truly browser and OS independent way is through proxy. You need to create a HTTP(S) proxy with Java (there are some implementations out there already) and then reconfigure the desired browser to use the proxy running at localhost. When your proxy is used - it will be able to track every bit of traffic the user tries to load.
This information is stored in a SQLite database in firefox:
The file "places.sqlite" stores the annotations, bookmarks, favorite
icons, input history, keywords, and browsing history (a record of
visited pages).
http://kb.mozillazine.org/Places.sqlite
Other browsers probably have similar approaches.
Any language with drivers for SQLite, and that includes Java, C, C#, C++, ruby, and, yes, even javascript, should be equally capable of accessing this database.
Speaking for myself, I would be interested collaborating on such a stand-alone program in Java should the OP put his code on github.

Categories

Resources