Azure Service Fabric Java SSL/HTTPS server - java

I have been looking into the Azure Service Fabric development and I have successfully created some test HTTP Stateless-Service applications in Java. Now I'd like to use encrypted api server communication in form of HTTPS but I cannot find any information how such server could be set up in Service Fabric environment.
In my HTTP applications I have been using com.sun.net.httpserver.HttpServer class and when I checked into the HttpsServer class I could not figure out how I could get the certificate saved into the application so that it could be used with the HttpsServer class. All the example applications using HttpsServer seem to read the certificate file from disk and that is not possible in ServiceFabric environment as far as I know.
So what is the proper way to set up HTTPS server in Java Service Fabric Stateless-Service application?

You can deploy certificates to cluster nodes using the ARM template.
Alternatively:
You can also use dotnet core and Kestrel for this. Here are some links to get started.
Github
Channel9 Video
Blog
You can also choose to run a web server like NodeJS or Flask as a container on Service Fabric.

Related

OAuth2 client - redirect url not allow localhost

Creating a Springboot oauth2 client to integrate an OIDC provider login in the application.
But the OIDC provider not allowing redirect URLs (working on authorization code flow) with the format of http://localhost: or http://localhost
So every time I want to deploy the code changes to the server to check its working and not able to debug in my development environment.
I'm using my company-provided machine for the development, which not allow to install ngrok.
Can someone please help me to find a way to do the development and debug in my dev machine.

Start the RESTful server from java code

I have created a RESTful web service (using jersey in Eclipse) with Postgres database access. Both are running on my local machine. I have tested the service via the Postman client application sending some requests and getting responses as JSON to ensure that my server responds appropriately, all works fine. Now I have created a GUI (client application) using Swing for the management of the server (someone sits in front of it and manages the DB content). In addition, I want to do the following:
Start (not call) the RESTful web service from GUI (the person starts the GUI application to do his work, and with that the server starts, too, automatically). How can I do this is there any method I have to call?.
To query the server I have found these two methods:
RESTful Java client with Apache HttpClient and
RESTful Java client with Jersey client. Which of them is the better one?.
The overall structure of my communication processes using an Android client (in future) will be the following: Java client with GUI -- JSON --> RESTful web server <-- Android client
Use case: An Android client sends some data (text, pictures) in JSON format to the RESTful service which saves them in the Postgres DB. The Java client reads this data and displays them onto the GUI.
Mike, You will have to host your service on some server. Build a WAR file and deploy it on to a hosting server. Then you can call your API with the designated IP or masked name instead of localhost:8080 which I presume you are using. Also, I would recommend using a Jersy client.

AWS blocked mixed content when calling API

I have a front end application in digitalOcean with domain name testDO. This domain has SSL certificate. So all request origin are from https://testDO.com.
I have a backend server sitting in AWS created by deploying war file into beanstalk. It has the name testAWS.us-east-2.elasticbeanstalk.com
When I call API directly from the url for example http://testAWS.us-west-2.elasticbeanstalk.com/myAPI/getName it works. When I call the same API from my front end I get blocked:mixed-content. Is this because its http and not https? what is the workaround?
Yes this is because, your HTTPS site tries to access content through HTTP which is blocked by the browser. You need to either both HTTPS or proxy the request at frontend server and terminate SSL there and forward it to your API Server in Beanstalk.
Note: Since the frontend and backend are in two different environments it will be preferred to use both HTTPS than the proxy approach for security.
You can create a CloudFront Distribution and take it with https to http. You also need to enable CORS in your response to access cross origin domain requests.
Client --> CloudFront --> Your http API (Response with CORS).
Hope it helps.
You need to setup your AWS Elastic Beanstalk environment with your domain or you can use HTTPS with a self-signed certificate for development and testing purposes.
You can use upload your front end in AWS S3, In AWS static webpage Endpoints are http, so you wan't get this mixed-content problem.
Reference:
https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/configuring-https.html

How to integrate google api Spreadsheet callback url on my production server

I am reading data from google spreadsheet API using java. I am able to read on my local machine and the URL getting below for auth2:
https://accounts.google.com/o/oauth2/auth?access_type=offline&client_id=679281701678-iacku5po12k0if70abstnthne9ia57kg.apps.googleusercontent.com&redirect_uri=http://localhost:39740/Callback&response_type=code&scope=https://www.googleapis.com/auth/spreadsheets
My callback URL is
http://localhost:62238/Callback?code=4/k6rwrqBFTJ310Yhy9EBpIA7eH9PqL-HXwC3hi9Q0How#
However, when I am deploying my war on the production server so I am not able to see callback function.
If any one knows about this please suggest to me how to integrate on the production server.
Whenever you integrate with any OAUTH enabled google api. You need to provide the restrictions on google dev console like authorized origins and authorized redirect uris. I think you might have provided different port from your local than what is running in your production in your authorized origins, that is why it is not able to connect from your production server but it is able to connect from your local. you can cross check once.

how to create a Server in PHP and client in JAVA

I like to implement server as backend server service and front as a regular website using php..Is it possible to create like this.Also how can integrate this by using a java swing application as client (client is on localhost)?
You may use web services. So you can create server in php and client in java.

Categories