Skip to main content
This forum is closed to new posts and responses. The content has been migrated to the Digital Solutions Community. Please join us there for new content as well as this content. For customer support, please visit the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal

HCL Notes/Domino 8.5 Forum (includes Notes Traveler)

HCL Notes/Domino 8.5 Forum (includes Notes Traveler)

Previous Next
Subject: Problem to read SSL based URL content....
Feedback Type: Problem
Product Area: Notes Client
Technical Area: Application Development
Platform: Windows
Release: 8.5.3
Reproducible: Always

We need programatically read URL (image) into application.

The code is based on Java library "GetHTML" accessed via LS2J based agen "Read image" (listing is below).

When the image is on HTTP:// url address, the download works fine. However, when image is on SSL based url (HTTPS://), the dwnload fails.

Thanks for any advice....



1) GetHTML Java script library:

public class GetHTML {

public String getHTML(String urlToRead, String filename, String username, String password) {
URL url; // The URL to read
HttpURLConnection conn; // The actual connection to the web page
BufferedReader rd; // Used to read results from the web page
String line; // An individual line of the web page HTML
String result = ""; // A long string containing all the HTML
try {
url = new URL(urlToRead);
conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");

String userpass = username + ":" + password;

BASE64Encoder encoder = new BASE64Encoder();
String encodedStr = encoder.encode(userpass.getBytes());

String basicAuth = "Basic " + encodedStr;
conn.setRequestProperty ("Authorization", basicAuth);

InputStream is = conn.getInputStream();
OutputStream os = new FileOutputStream(filename);
byte[] b = new byte[2048];
int length;
while ((length = is.read(b)) != -1) {
os.write(b, 0, length);
}
is.close();
os.close();

} catch (Exception e) {
e.printStackTrace();
}
return result;
}
}


2) LotusScript agent "Read image":
Option Public
UseLSX "*javacon"
Use "GetHTML"


Option Declare

Sub Initialize

Dim html As String, sFile As String
sFile="c:/myObr1.jpg"

Dim uiwork As New NotesUIWorkspace
Dim uidoc As NotesUIDocument

Dim js As JAVASESSION
Dim getHTMLClass As JAVACLASS
Dim getHTMLObject As JavaObject

Set js = New JAVASESSION
Set getHTMLClass = js.GetClass("GetHTML")
Set getHTMLObject = getHTMLClass.CreateObject




html = getHTMLObject.getHTML("http://www.edevelopment.sk/web/ocweb.nsf/Kalendar.jpg", sFile, "UserName", "UserPassword")

Dim session As New NotesSession
Dim db As NotesDatabase, doc As NotesDocument
Set db=session.CurrentDatabase

session.ConvertMIME=False

Set doc=New NotesDocument(db)
doc.Form="formViewer"

Dim jpeg As NotesMIMEEntity, stream As NotesStream
Set jpeg=doc.CreateMIMEEntity("JPEG")
Set stream=session.CreateStream()
If (stream.open(sFile,"binary")) Then
If (stream.Bytes>0) Then
jpeg.setContentFromBytes stream, "image/jpeg", ENC_IDENTITY_BINARY

End If
End If

stream.close
Call doc.save( True,False)
session.ConvertMIME=True

Set uidoc=uiwork.EditDocument(False, doc)

End Sub


Feedback number WEBB9HYAVY created by ~Holly Lopweburakoi on 04/08/2014

Status: Open
Comments:

Problem to read SSL based URL conte... (~Holly Lopwebur... 8.Apr.14)
. . SSL in Java requires some set up. (~Cheryl Opfreet... 8.Apr.14)
. . . . Solved, thanks Simon.... (~Holly Lopwebur... 4.May.14)
. . . . Simon, thanks for hint... (~Holly Lopwebur... 9.Apr.14)
. . . . . . Yes to some extent. (~Cheryl Opfreet... 9.Apr.14)




Printer-friendly

Search this forum

Member Tools


RSS Feeds

 RSS feedsRSS
All forum posts RSS
All main topics RSS