How to add a graphical image signature using CoSign Signature Soap API - java

If possible add some code snippet. I have used Java for coding.
DSS: I would like to add multiple graphical image signature using CoSign Signature Soap API, how can I achieve it? If possible add some code snippet.

Here is a code sample in Java that demonstrates how to add a graphical signature using CoSign Signature SOAP API:
public static void AddGraphicalImage(String username, String domain, String password, byte[] imageBuffer, String imageName) throws Exception {
try {
SignRequest request = new SignRequest();
RequestBaseType.OptionalInputs optInputs = new RequestBaseType.OptionalInputs();
// Set signature type
optInputs.setSignatureType("http://arx.com/SAPIWS/DSS/1.0/set-graphic-image");
// Set user credentials
ClaimedIdentity claimedIdentity = new ClaimedIdentity();
NameIdentifierType nameIdentifier = new NameIdentifierType();
nameIdentifier.setValue(username);
nameIdentifier.setNameQualifier(domain);
CoSignAuthDataType coSignAuthData = new CoSignAuthDataType();
coSignAuthData.setLogonPassword(password);
claimedIdentity.setName(nameIdentifier);
claimedIdentity.setSupportingInfo(coSignAuthData);
optInputs.setClaimedIdentity(claimedIdentity);
// Set graphical image data
GraphicImageType graphicImage = new GraphicImageType();
graphicImage.setGraphicImage(imageBuffer);
graphicImage.setDataFormat(Long.valueOf(6)); //JPG
graphicImage.setGraphicImageName(imageName);
optInputs.setGraphicImageToSet(graphicImage);
request.setOptionalInputs(optInputs);
// Initiate service client
DSS client = new DSS(new URL("https://prime.cosigntrial.com:8080/sapiws/dss.asmx"));
// Send the request
DssSignResult response = client.getDSSSoap().dssSign(request);
// Check result
String errmsg = "" + response.getResult().getResultMajor();
if (errmsg.compareTo("urn:oasis:names:tc:dss:1.0:resultmajor:Success") == 0) {
System.out.println("Graphical image was added successfully!");
return;
}
else {
throw new Exception(response.getResult().getResultMessage().toString());
}
}
catch (Exception e) {
System.out.println("Error: " + e.getMessage());
e.printStackTrace();
}
}

Related

send message to single device using Firebase cloud with Java

I'm trying to send messages to single devices using their token from a Java application. I'm using the Firebase Admin SDK. Below is what I have
FileInputStream serviceAccount = null;
try {
serviceAccount = new FileInputStream("google-services.json");
} catch (FileNotFoundException e2) {
e2.printStackTrace();
}
FirebaseOptions options = null;
try {
options = new FirebaseOptions.Builder()
.setCredentials(GoogleCredentials.fromStream(serviceAccount))
.setDatabaseUrl("https://MYPROJECTID.firebaseio.com/")
.build();
} catch (IOException e1) {
e1.printStackTrace();
}
FirebaseApp.initializeApp(options);
String registrationToken = "MYDEVICETOKEN";
// See documentation on defining a message payload.
Message message = Message.builder().putData("time", "2:45").setToken(registrationToken)
.build();
// Send a message to the device corresponding to the provided
// registration token.
String response = null;
try {
response = FirebaseMessaging.getInstance().sendAsync(message).get();
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}
// Response is a message ID string.
System.out.println("Successfully sent message: " + response);
But I get the following exception
java.io.IOException: Error reading credentials from stream, 'type' field not specified.
What am I doing wrong here?
Click on Generate new private key button.
The error means that your google-services.json file contains invalid data. GoogleCredentials class expects your file to have a type property, but it's not there.
Brief googling gave me this post regarding very similar problem. It says:
From the API Manager, just create select "Create credentials" >
"Service Account key" and generate a new key for the Service
that is associated to your Google Play account.

How to add images to Watson Conversation response?

I'm a newbie to Java and Watson Conversation. Is this possible to add images to Watson Conversation response? I want to add an image to Watson Conversation I made a Chatbot on Watson Conversation and integrated it with Facebook as Java web application.I want to add images in Watson response.
public class TestConversation {
public static void main(String[] args) {
BufferedReader br = null;
MessageResponse response = null;
Map context = new HashMap();
try {
br = new BufferedReader(new InputStreamReader(System.in));
String userName = br.readLine();
// Add userName to context to be used by Conversation.
context.put("userName", userName);
while (true) {
String input = br.readLine();
response = conversationAPI(input, context);
System.out.println("Watson Response: " + response.getText().get(0));
context = response.getContext();
System.out.println("———–");
}
} catch (IOException e) {
e.printStackTrace();
}
}
public static MessageResponse conversationAPI(String input, Map context) {
ConversationService service = new ConversationService(ConversationService.VERSION_DATE_2016_07_11);
// Credentials of Workspace of Conversation
service.setUsernameAndPassword("******************", "****************");
MessageRequest newMessage = new MessageRequest.Builder().inputText(input).context(context).build();
// Workspace ID of Conversation current workspace
String workspaceId = "******************";
MessageResponse response = service.message(workspaceId, newMessage).execute();
return response;
}
}
Watson conversation is just text that is sent back. So it is up to your application to render the image.
If you use the conversation simple application, you can use HTML to render. For example, set the output text to the following value.
Here is a picture of a tiger:<br><img src="https://upload.wikimedia.org/wikipedia/commons/0/01/Tiger.25.jpg">
When you display that text in conversation simple it will show the following:
Another option is you can store the image within conversation by saving as base64 format. However you have a limit of 10MB on a conversation file, so it's unlikely to be useful except for small icons.
Example:
Smile: <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPAAAADwCAYAAAA+VemSAAAABmJLR0QA/wD/AP+gvaeTAAAgAElEQVR4nO3deXxU5b0/8M/3nJlsk52EbBNkR4ggq1ogIK64oai4tlqtS6tW21qq16tW6a+KXmzdqt57UYt1u1ZURGkVNZAEhAquBQXZJAtJSCDrzGTmnPP9/RGWAElmJpmZM2fyfb9evoTMmTPfDPOZ5znPec55ACGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQoQcmV2A8I/XOjPh03M0UgcSGfkEJRvgFMPgFAJlgJAKIAVAPACAoBJT6hH7IG4GQz/w13aAmsHcwuD9ikItALUwG3UMZY+N9TrY1VqaWrkvsr+pCJYEOArwG1CRnz9c15UigjGUiYYCPJRBQwgYDCDOpNLaGfiBwDvAtIOAHazQDhW8CXuqttNlh74QhEkkwBHGH+Q4tET7ZAXGSQycSKAxDIzBwdbTOjwEfMvAJmL+yoD6L5vHu5HOrm0zu7D+RAIcZlxemK8bfBqYi4lwCgNFAFSz6woTjYBNTFgHg8pUUj+hGT/sMbuoWCYBDjEuyU7WlfizQHwGA6cRMMrsmszEwLfEKIFCH6ku34fSQoeWBDgEeK2zwND4AmbMAWEWgASza4pSHgCfEONdRVWW0/SKarMLsjoJcC9x2aAMHfoFYMwDcA5it1scLgaAT4np74rN9xpNq60zuyArkgAHgTdMsuuu2jkAXw/gLAA2s2uKET4AH4DoBVWrXE6zoJldkFVIgAPAZYOGaqzfQODrAMo1u54Yt4cZ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oAIKqplpG6EjrDaFvqfpFdVmF2hlEuAw6jjOPi7HB1+eQpRPBgoMUB6RUQBQHgFO7hhIS4P1JqS0AGgioIGBSoD3MCtVioJqBlcbzNV2Pa4ap+6qlS5v+EiAowS/ARVOZxp0Jd3HWjoZlEYqpYM5jZjSQEaaAUonhgMAQLDjcPedAKR32l0qgdQj9g/WATR3+lEjcChYrWD4AIAJrQq4Caw0MXETwI1sUBMr3GQnWyNUoxE/qmzsr4NGQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGE6Af+P+HhSrt5F5C5AAAAAElFTkSuQmCC">

How to parse DFT_P03 message with ZPM segment

I am coding a server application that will receive DFT_P03 messages with an added ZPM segment (which i have created a class for as per the HAPI documentation). Currently i am able to access this field as a generic segment when doing the following :
#Override
public Message processMessage(Message t, Map map) throws ReceivingApplicationException, HL7Exception
{
String encodedMessage = new DefaultHapiContext().getPipeParser().encode(t);
logEntryService.logDebug(LogEntry.CONNECTIVITY, "Received message:\n" + encodedMessage + "\n\n");
try
{
InboundMessage inboundMessage = new InboundMessage();
inboundMessage.setMessageTime(new Date());
inboundMessage.setMessageType("Usage");
DFT_P03 usageMessage = (DFT_P03) t;
Segment ZPMSegment = (Segment)usageMessage.get("ZPM");
inboundMessage.setMessage(usageMessage.toString());
Facility facility = facilityService.findByCode(usageMessage.getMSH().getReceivingFacility().getNamespaceID().getValue());
inboundMessage.setTargetFacility(facility);
String controlID = usageMessage.getMSH().getMessageControlID().encode();
controlID = controlID.substring(controlID.indexOf("^") + 1, controlID.length());
inboundMessage.setControlId(controlID);
Message response;
try
{
inboundMessageService.save(inboundMessage);
response = t.generateACK();
logEntryService.logDebug(LogEntry.CONNECTIVITY, "Message ACKed");
}
catch (Exception ex)
{
response = t.generateACK(AcknowledgmentCode.AE, new HL7Exception(ex));
logEntryService.logDebug(LogEntry.CONNECTIVITY, "Message NACKed");
}
return response;
}
catch (IOException e)
{
logEntryService.logDebug(LogEntry.CONNECTIVITY, "Message rejected");
throw new HL7Exception(e);
}
}
I have created a DFT_P03_Custom class as following :
public class DFT_P03_Custom extends DFT_P03
{
public DFT_P03_Custom() throws HL7Exception
{
this(new DefaultModelClassFactory());
}
public DFT_P03_Custom(ModelClassFactory factory) throws HL7Exception
{
super(factory);
String[] segmentNames = getNames();
int indexOfPid = Arrays.asList(segmentNames).indexOf("FT1");
int index = indexOfPid + 1;
Class<ZPM> type = ZPM.class;
boolean required = true;
boolean repeating = false;
this.add(type, required, repeating, index);
}
public ZPM getZPM()
{
return getTyped("ZPM", ZPM.class);
}
}
When trying to typecast the message to a DFT_P03_Custom instance i get a ClassCastException. As per their documentation, i did create the CustomModelClassFactory class but using this i just get tons of validation errors on the controlId field.
I am already using an identical logic to send custom MFN_M01 messages with an added ZFX segment and that works flawlessly. I understand there is some automatic typecasting being done by HAPI when it receives a DFT_P03 message and that is likely what i need to somehow override for it to be able to give me a DFT_P03_Custom instance instead.
If you have some insight on how i can achieve this without having to use a generic segment instance please help!
Thank you!
I finally figured this out. The only way i got this to work was to generate a conformance profile XML file (using an example message from our application as a base) with the messaging workbench on the HAPI site and use the maven plugin to generate the message and segment classes. Only with these classes am i able to correctly parse a message to my custom class. One thing to note is that it DOES NOT work if i try to use the MSH, PID, PV1 or FT1 classes provided by HAPI and use my Z-segment class. It only works if all the segments are the classes generated by the conformance plugin. This combined with a CustomModelClassFactory class (as shown on the HAPI website) and the proper package structure finally allowed me to access my Z-segment.

What is the right way to use Espresso in android?

I am trying to run an Espresso test for my android app, but there is a problem that has been troubling me. In MainActivity, some views' visibility depends on data loaded from net, but in MainActivityTest, I can't manipulate the process of loading data, so I don't know the real data and which view should show and which view should not show. As a result, I don't know how to continue my test. Anyone can tell me how to handle this situation? Thanks!
Try using the MockWebServer library. It lets you mock http responses in your tests, like this:
/**
* Constructor for the test. Set up the mock web server here, so that the base
* URL for the application can be changed before the application loads
*/
public MyActivityTest() {
MockWebServer server = new MockWebServer();
try {
server.start();
} catch (IOException e) {
e.printStackTrace();
}
//Set the base URL for the application
MyApplication.sBaseUrl = server.url("/").toString();
//Create a dispatcher to handle requests to the mock web server
Dispatcher dispatcher = new Dispatcher() {
#Override
public MockResponse dispatch(RecordedRequest recordedRequest) throws InterruptedException {
try {
//When the activity requests the profile data, send it this
if(recordedRequest.getPath().startsWith("/users/self")) {
String fileName = "profile_200.json";
InputStream in = this.getClass().getClassLoader().getResourceAsStream(fileName);
String jsonString = new String(ByteStreams.toByteArray(in));
return new MockResponse().setResponseCode(200).setBody(jsonString);
}
//When the activity requests the image data, send it this
if(recordedRequest.getPath().startsWith("/users/self/media/recent")) {
String fileName = "media_collection_model_test.json";
InputStream in = this.getClass().getClassLoader().getResourceAsStream(fileName);
String jsonString = new String(ByteStreams.toByteArray(in));
return new MockResponse().setResponseCode(200).setBody(jsonString);
}
} catch (IOException e) {
e.printStackTrace();
}
return new MockResponse().setResponseCode(404);
}
};
server.setDispatcher(dispatcher);
}

Quickbooks Online Rest API Reporting Java ERROR

I have used a tutorial and the Java SDK to pull reports from the new REST reporting API.
https://developer.intuit.com/docs/0025_quickbooksapi/0055_devkits/0201_ipp_java_devkit_3.0/reports
I have used the following code as specified by the tutorial:
String consumerKey = "XXXXXXXXXXXTDF2GEP0tlzdGxxpQRfSb4";
String consumerSecret = "XXXXXXXXXXYuy9CLaWiyAVHTowK0NuGMKN1X";
String accessToken = "XXXXXXXXXXXGPU4SUGAaeyhRJFp05NUg4s8QnbY4eI4U";
String accessTokenSecret = "XXXXXXXXXXXgkz50A8Ho3Z3pgMO8QFh2ZBv3XjI";
OAuthAuthorizer oauth = new OAuthAuthorizer(consumerKey, consumerSecret, accessToken, accessTokenSecret);
String appToken = "011e510ebf68ab4683b8a06b21f6228dfa03";
String companyID = "1067363490";
try {
Context context = new Context(oauth, appToken, ServiceType.QBO, companyID);
ReportService service = new ReportService(context);
service.setStart_date("2014-02-01");
service.setEnd_date("2014-04-20");
service.setAccounting_method("Accrual");
Object report = service.executeReport(ReportName.PROFITANDLOSS.toString());
String name = "ryan";
//System.out.println(report.toString());
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Inside service.executeReport it keeps throwing a java.lang.ClassCastException: com.intuit.ipp.data.Report cannot be cast to com.intuit.ipp.core.Response
Has anyone got these reports to work with the Java SDK? Am I doing something wrong?
At present reports support only Json.
Please verify that you are specifying:
Config.setProperty(Config.SERIALIZATION_RESPONSE_FORMAT, "json");
Update Line:
Object report = service.executeReport(ReportName.PROFITANDLOSS.toString());
To:
Report report = service.executeReport(ReportName.PROFITANDLOSS.toString());
As shown here: https://developer.intuit.com/docs/0100_accounting/0500_developer_kits/0201_ipp_java_devkit_3.0/reports

Categories

Resources