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.
Related
I have a java (Spring boot) web service which does not have any UI.
I want to send a dynamic Email (created using Thymeleaf and injecting values from a database) using my web service on a daily Cron schedule, using Microsoft Graph and O365 APIs.
Right now I use SMTP to send emails, but I cannot use it anymore as that is no longer going to be supported by the O365 account that I am using.
I found the SendMail APIs on the Graph Documentation which looks pretty straightforward.
But, using the Graph AIPs requires you to create an Azure AD project first and use their Microsoft Identity platform - which I created.
Now, the problem is that most of the flows also require a user to manually login from a login window.
This is where things get complicated.
I do not have a place to show a Login window to any user from my web service, because it is just a backend service there is no UI. I intend to use a service account for sending the emails through the Application.
I found a Daemon support as well, but it seems to only support Python or .Net code.
Migrating my code from Java to either of those platforms just to be able to send emails
does not feel like a good solution.
And, I'm not even sure if they even offer similar capabilities of sending dynamic emails like Java+Thylemeaf do?
Is there a way to be able to continue doing this using my existing code in Java?
If not, then as the worst case scenario, are there any libraries in Python which can allow me to send dynamic emails like thymeleaf does in Java?
As you don't want to manually login from a login window, you can use the client credential flow.
Here is the guide regarding how to access graph api without user.
Reference:
msgraph-sdk-java-auth (You can choose to use Client credential provider)
I need to invoke my Informatica PC wf through Java and once the WF is completed or failed give the response to java program to continue it process.
I tried command line but java is not reading response. Looking for detail suggestion on Java and as well as on informatica end
it does not matter if the informatica job is failed or succeeded it need to give the response back to Java
Note that there are many ways to do this--perhaps the easiest is to have Java touch a file somewhere that your workflow is monitoring, and then have the workflow put a result in a database or file that Java can see.
However, a more formal approach is to use web services.
See if your Informatica administrator can enable Web Service Hub and then read up on it in the PowerCenter documentation. I have provided the best information I can here from a document I wrote some years back.
There may be better ways of doing this, but Informatica hasn't changed much over the years, and WSH was the way to go some years back if you wanted to launch a workflow remotely from Java or any other language and monitor its progress.
Once the admin has enabled WSH, you then can navigate to a console (likely at /wsh) that shows various actions that can be performed and various objects.
Here's a quick-and-dirty go at running a workflow using web services from the WSH console:
Open Web Services Hub and navigate to Batch WebService and Integration WebService
Click the Try-It button (the WSDL for the Integration web service is available here as well)
Select the login operation on the left side
Fill in the Domain, Repository, Username, and Password and click Send
Obtain the Session ID in the SOAP response
Select the startWorkflow operation on the left
Provide the SessionId value obtained from the login
Provide FolderName, WorkflowName, RequestMode, DomainName, ServiceName
Click Send
At this point you should receive a successful response.
The web service does not wait until the workflow completes.
Once you can use the web services to control workflows, you can use a Java web service framework like Axis to generate web service client classes for the generic batch-processing.
This approach is covered well in the Informatica documentation
Unfortunately it is a somewhat cumbersome process, but it works. Web services can be invoked as follows from Java:
Create a new Data Integration Service Locator and use that to obtain the Data Integration Interface. This is used to execute all Informatica WS calls. This is based on the service location embedded in the WSDL.
Log in to Informatica and obtain a session ID for the connection
Create a session header, holding the session ID, and place in the Data Integration Interface.
Create a Service Info object that identifies the Informatica Domain Name and Service Name.
Create an object to hold workflow, folder, run mode, and Service Info object
Launch workflow using startWorkflowEx in order to return the run ID
Build a WorkflowRequest object with all of the same workflow information in order to wait for completion
Call waitTillWorkflowComplete in order to block until the Informatica workflow completes
Other features are available, so you should be able to check return codes and such.
You should try something like this.
String cmd="C:\\Informatica\\9.6.1\\clients\\PowerCenterClient\\CommandLineUtilities\\PC\\server\\bin\\pmcmd.exe";
final Process cmdProcess;
cmdProcess = Runtime.getRuntime().exec(new String[]{cmd,""});
OutputStream out = cmdProcess.getOutputStream();
out.write("connect -sv IS_NAME -d DOMAIN_NAME -u USER -p PWD".getBytes());
out.close;
I have a web PHP web application that has a link to a java web application. The php application has a login page, and a link to the the java application, but not every user has permission to access the java web application. What I was trying to do is send user credentials from the php application to the java application, and then the java application checks the credentials and if correct logs in the user. I was thinking of using http headers to do this.
So my question is what is how to send user credentials from a PHP application to a java application?
If it helps I am using a Java web framework called Vaadin.
Do a normal POST request from the PHP application to the java application. This can be done as simply as having a normal HTML form in the PHP application, set the form's method to "POST" and action to the java application's URL. If you want to catch HTTP parameters in a Vaadin application, you can do it by using request handlers (https://vaadin.com/book/vaadin7/-/page/advanced.requesthandler.html).
Then a few words of advice or something to at least consider. If your login page is in the PHP application and your "admin" application is the Vaadin application, then I discourage you from doing the credential checking in the Vaadin application. This is because when you enter the Vaadin application, a new application instance is created. This means that your UI will be initialized and whatever else you do in the UI's init method. What you probably want to do, is to hinder the user from entering the Vaadin application unless she is logged in - which means that you need to do the credential checking somewhere else - for example, have a separate servlet whose only responsibility is to log in the user. If login is granted, then give access to the Vaadin application, if access is denied, forward the user to the PHP login screen. The next question is, how do you hinder the user from accessing the Vaadin application until she is logged in? Typically, this is done using servlet filters.
I highly encourage you to use a 3rd party framework for doing the authentication and authorization. Take a look at http://shiro.apache.org/, it's easy to install and seems to work nicely together with Vaadin. All you need to do is to configure it and implement a login screen, the framework will take care of the rest.
If I understood your question, you want to be able to provide an "auto-login-link" to some specific users that are logged in to the PHP application. This link should automatically login the user to the java application, right?
Without knowing any details about this case, like are both apps running on the same domain or do they use the same database (same user credentials in both apps), etc., I would propose the following solution:
Create an action (link) on the java application, which receives the necessary parameters (as GET) needed for creating the session (probably userId is sufficient), timestamp and a signature of all parameters. For example:
http://javaapp.example.com/autologin?userId=123&timeStamp=123456789&sign=hj23kh4j234jk324h
Where the signature is calculated with some strong encryption algorithm. Then you verify that the signature is correct at the receiving end (java app). If it is correct, you create the session. Signature calculation could be something like:
$signature = sha1($userId . $timeStamp . 'some salt' . $sharedSecretBetweenBothApps);
With the timeStamp you are able to check that an old link is not used. For example not allow older than 15 min old links and store used links in the java app to make sure they are never re-used. You do not have to keep history of links older than the expiration time.
Another idea, as discussed in the comments, is creating an API on the java side, which is able to provide a one-time link.
The sha1 algorithm is probably not strong enough, but shows the idea and is simple to implement.
Does this answer your question?
I have studied the java in app billing code snippet at
https://developers.google.com/in-app-payments/docs/tutorial
and I am unable to use it to make my application capable of doing in app payments.
My first question is how do I set up a servlet to handle payment requests. Do I put the getJWT() method in the servlet and call it from the doPost() method?
My second question is what do I do with the String that getJWT() returns? It should be the json object that holds the purchasing information, but I don't know how the jsp file I have should process it.
I have searched for example code using java servlets and jsps to study but found none. I have found python code, but I can't translate python into java yet. If anyone knows of an example (complete) of google in app billing using java servlets and jsps I would appreciate it if you could post a link also.
Thank you.
On the server you need an HttpServlet derived class that takes the order request (in doPost()), calls the JWT libraries together with the Seller Secret to generate the signed JWT string, then returns the result in the response.
On the client side in the HTML page you can use a templating system (e.g. AppEngine + JSPs) or Ajax calls to your servlet to get the generated JWT.
The generated JWT is one of the paramenters to the goog.payments.inapp.buy() JavaScript API.
Below is a simple AppEngine Python implementation of In-App Payments. You can re-use the client-side code and replace the server-side with the Java implementation:
https://code.google.com/p/iap-python/
I want to know how to do authenticate for REST web service in java?
My supervisor want to get the format like amazon s3curl.
Everytime user request, they need to give id key and access key.
Which API should i used or for reference or sample code?
Amazon has an AWS SDK for Java that includes a sample S3 project, from which you could learn how they do authentication.