I have made school management software...for the server side I have designed the admin panel using servlet and jsp technology.and have used mysql database and for the client I have created an Android app. I want to perform login and logout authentication and fetch data of that particular user on his app.. but I m unable to integrate. I need to know what are ways through which this thing is done professionally....
Thanks in advance
At your backend side you have your servlet which handles incoming requests GET or POST. So in android app you just need to make call to your servlet and handle the response.
In android
1. Get the user credentials and pass it along with your request.Either make GET request and append your credentials to servlet url or pass the parameters as POST request.2. To make network calls use libraries such as Volley, Retrofit or you can even use android built-in AsyncTask.(If you are a beginner start with AsyncTask first and then upgrade to libraries mentioned).
Professional way is to develop REST apis at your backend and call them from your android app.
Related
I have wrote a simple web application with few tables. It has it's administration area where you can manage it's table. Basic CRUD operations.
However, I need to develop an Android application which will retrieve information from this web application trough API. So I am going to write a simple API methods for fetching data. Also there will be sometimes when Android user will save some of its data to database.
Android application needs to be able to list items stored in database and bookmark some of those items over HTTP.
To me problem is how to implement SingIn / SignOut operations using Android's Google account. For example, application GMail is always signed in (at least on my device) and I want my application to be always signed in.
Then, how can I manage what items user bookmarked? Should I create a table android_bookmarked_items (android_user_id, item_id)? But then what should be android_user_id? Do I need to use OAuth?
I am doing this kind off sign in for the first time and I am really confused how to connect this web application with android user and manage bookmarked items per user...
You can make use of Android AccountManager. Check out How to get the Android device's primary e-mail address
I think i have found solution by using Google Sign-In for Android. I get idToken for currently login user before each POST request and verify it on server side. Also from the token I get property sub which is user id and store this in my database...
Auth with a backend server
However, I am pretty new to this stuff, tokens and authentication using google, I would like for someone more experinced to confirm that my solution is fine and secure...
Hi I want to send data from my android app to server and store in the Mysql database. But I want to use REST method to send the data and I want to create a Java app on the server side that will show the data in table format .
I have created the android app but don't know how to upload data using REST. The data which I want to send is latitude and longitude of current location.
And after refreshing the java page new data will be viewed on the page.
Please tell me how to do this task.
Thanks in advance.
You can use some framework to communicate with a server. I think retrofit is the best choice for REST API: http://square.github.io/retrofit/
But you can try the Volley. Or the HttpUrlConnection and DefaultHttpClient in android sdk.
This is a big question that would need more space than here to cover. To get started you could try looking at the spring boot or drop wizard frameworks for creating your REST service.
Coursera also has a course programming web services that might help you get started.
Alternatively, there are services like Parse that look after the backend process for you.
I have two different spring web applications with authentication,
My first application has to get some responses from second application in order to show the required details to the user. Now the problem is, Since the second app also secured I'm unable to get responses from it. Suggest me how can I authenticate second app from server code at first app.
Note: I tried to use CAS server, It returned me the login page's html text when I made a request.
Refer to this https://stackoverflow.com/a/24486898/3487801. Services could be secured using CAS. All you need to do is to add restlet module on your cas server and build a simple Java client to get the ticket and authenticate to your service.
Some says, there is no working Java client for headless CAS. But groovy example on the CAS restful API https://wiki.jasig.org/display/casum/restful+api is actually working. You need to get it modified just a little bit to get it work.
I'm working on a Java REST server serving an iPhone app. Now we have to integrate with third party service exposed by oauth2 protocol. This is new to me so I've been reading and writing some "proof of concept" code but I have a big problem or I fundamentally don't understand something...
I made a simple web page with "log in with XXX" button that the user sees in a web view. When he clicks it, login page of the third party service opens and he can approve my app, at what time they will redirect the user to an URL I've specified with the authorization code as a parameter. This URL points to a REST service on my server.
The problem is that this URL must be absolutely the same as the one I've set up when applying my app for their service. Since I'm running a REST server I have no way of knowing about which user are we talking about when the redirection to my server happens (there is no session). I wanted to do this identification with some query or path param but they are not allowing it.
Does any of this makes sense to you or am I implementing this in a wrong way? The only possible solution I can imagine now will be with the help of cookies but I'm not really fond of that...
Yes, that does make sense. You got a few different options, try one of these:
Store a cookie with some user id and read it out after redirection
Use the state parameter of the authorization request for transmitting some user id. The provider is required to return it back to you in his redirect.
I'm trying to develop an android app which needs to fetch information from a servlet hosted in my Java EE application server.
To access this servlet, I need to be first authenticated with the Application server. I searched the web to get information on how exactly this works. During authentication how dows the android app store the cookie, and then how does it transfers the cookie to the server for every request?
I got some bits and pieces of information about HttpClient. I'm not sure if this is the correct one which I should be using. It will be a great help if someone could guide me. If there are any documents available please share with me.
Maybe the HttpUrlConnection documentation page is what you are looking for?
I am assuming this is native app, if so, first you need to authenticate and get the cookie. It would be your responsibility to store the cookie some where and pass it in sussequent http calls. If it is not native, I am not sure how it works.