Is it possible to access localstorage object using Java directly? If yes how?
Update: I am aware that localstorage is client side and java is server side but I read on net that GWT have api that allow to read localstorage.
The local storage, as its name indicates, stores information locally, which means in the browser, at client-side. The servlet filter executes at server-side. There is no way to access the local storage at server-side.
If you need to access some ID stored in the local storage from a servlet filter, then retrieve this ID from the local storage in JavaSCript, and send a request containing this ID to the server.
Localstorage is better alternative thamn Cookie. So, I am waiting JAVA support without external library for accessing local web storage, too. Now I am using sellenium support. Please, look at https://gist.github.com/dariodiaz/5079695
Related
Looking at the Twilio documentation it seems that "you create [Access Tokens] on your server to verify a user’s identity and grant access to client API features."
Here, Twilio provides a few different ways to programmatically create Access Tokens on the Server side - it looks pretty straight forward.
I am developing an Android app-to-app calling feature and for this I've have been using the Android quickstart-project to go about it. However, for this code, the implementation and execution are done by copying and pasting Access Tokens generated through either the Twilio Console or Twilio-CLI commands.
Say we have our Server set up, a TwiML app and its associated URL, what would be the simplest and most straight-forward way to generate but then retrieve the access token from the Server to the Client app?
From my understanding, you would like to access Twilio API using an access token. In that case, you should have a backend server that stores the access token because you shouldn't store such tokens in the client-side (android app). Your app would send request to your backend which would then use the access code to access the api and forward you the result back.
Let's say we have a very simple Java application, that edits resources on remote servers, that it authenticates with using Access Tokens. Application always uses the same identity, so it is always using the same client id, secret and refresh token to obtain access token.
The whole authentication process is supposed to go through without user intervention and app should perform actions automatically triggered by the user from another application. The other app is sending HTTP requests, but the whole thing would only be accessed in internal network and there would be no "legal" way to access it outside of it.
Is there a way to keep this data (refresh token, client id, secret...) securely within my application?
I have seen similar questions, but they all talked about websites and cookies, but this is supposed to happen under the hood, without any frontend etc. so I don't think those apply to my issue.
Edit: the application will be deployed on an internal server so it's not a Desktop solution. Basically there is an internal app that will send HTTP request to mine, triggering edit on a remote server that is outside of the internal network.
It is not a good idea to store client secrets, access tokens, refresh tokens etc in persistence storage unless it is stored in a secret store (like Vault). But there are other options.
If you are using Spring then you can use Spring OAuth2RestTemplate or else you can write something similar by looking at the code.
It acquires or renews an access token transparently and caches to avoid round trips to Authorization server.
The simplest option is to use memory storage, but if that diesn't work because you need to deal with restarts etc, operating systems provide per-user secure storage. This is a model sometimes used by OAuth desktop or console clients:
Credential Manager on Windows
Keychain on macOS
Passwords and Keys on Linux
It would require some native interop to interact with these credential stores, via use of a library such as java-keytar.
DESKTOP EXAMPLE
For something to compare against see these resources of mine:
Node.js desktop keytar code
This blog post has some related screenshots towards the end
I have been working with Laravel for a little less than a month; so, not aware of all the pre-defined functionality it has to offer. I have a bunch of CSV files in my Laravel application storage and I want to access them from another application (a Java application that processes those CSV files to produce some results).
What would be the best way to go about it?
I have a basic user management system set up and the users fill in an application form (which is where the csv files come from). These files are stored in the Laravel storage.
My current approach without using any built-in authentication (because I am not confident about how to use it in this case) is to have a controller return a downloadable file on a POST request (the file just gets downloaded upon request). The data sent with the POST request is the filename and a password, which if correct, returns the file; otherwise, gives an error. Is this a good way to approach the problem?
I simply want to retrieve the files by making a request from the Java application. Also, some basic protection is required so that everyone cannot access the files by making such requests. Any help or resources would be helpful. Thanks!
Use digitalocean space as additional shared storage between two servers (php and java) then make storage access private using digitalocean dashboard and finally add new website cors on space settings has your java domain and its http verbs (get post delete...). With this configuration you could access your cloud storage between two servers safely using access key and secret key.
We have requirement that we need to store the data on the server using java servlet instead of using the session storage which is used to store the on the browser window/tab on client side.
There are multiple ways to do that, below are some common ways for the same.
If your data is file then you need to see File Upload using Servlet API.
You can use JDBC API in your Servlet to write data into relational databases like
MySQL, PostgreSQL in tabular format and can retrieve later on as well.
If you can describe what kind of data you want to store at server side then answer can be given more in detail.
I want to implement a service for my customers which allows them to fill in a HTML form (with their user info, email for example). When submitting the form, a Java Servlet will store the details sent and will share an Amazon AMI and. The response of the servlet will be a bookmark URL to the AMI.
What is the right way of invoking AWS related commands from a Java Servlet?
Have you tried the AWS SDK for Java? There are three packages dealing specifically with EC2. The key method you want is probably AmazonEC2Client.modifyImageAttribute (or the asynchronous class method).
The alternatives would be to use the underlying REST Query API directly or to create a private local service that calls a command-line tool. I would go with the SDK.