We have a site with Kerberos authentication. I've never used Java and Eclipse before, thus my knowledge is very limited.
What I wish to achieve is something like I did with python:
def DownloadFileFromSite(url):
FileName = ''
if 'download' not in url:
print ('ERROR: Change the following url to the proper download link.\n' + url)
else:
try:
# Disable SSL warnings
requests.packages.urllib3.disable_warnings()
kerberos_auth = HTTPKerberosAuth(mutual_authentication=OPTIONAL)
response = requests.get(url, auth=kerberos_auth)
response.raise_for_status() # Check for exceptions
except:
print ('ERROR: HTTP Connection error. Check the network connection, and the inside links in CQ.')
# If the response has Content-Disposition, we take file name from it
if 'content-disposition' in response.headers:
FileName = re.findall("filename=(.+)", response.headers['content-disposition'])
if FileName:
FileName = FileName[0]
# if we were redirected, we take the real file name from the final URL
else:
FileName = re.search(r'/([^/;]+)(;.*)?$', response.url)
if FileName:
FileName = FileName.group(1)
# Save the downloaded file to C:\temp
if FileName:
try:
with open(strWorkspace + '\\' + FileName, 'wb') as DownloadedFile:
DownloadedFile.write(response.content)
except:
print ('\nError occured while saving downloaded contents from site.\n')
else:
print ('ERROR: ' + url)
I would like to achieve this in Java, however I have no idea how to start. I've seen examples, but I'm such a newbie in Java that I have no idea what to do with them.