473,406 Members | 2,208 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Secure transfer of username and password

Nepomuk
3,112 Expert 2GB
Hi everybody!
For a current project, I have a Servlet and a Client and they communicate via HTTP. Now the Client has to login and therefore must send a username and a password.
I have 3 questions:
  1. How much (if at all) does HTTPS encrypt data, which is sent to and from it?
  2. Can HTTPS be accessed in the same way as HTTP? (With a java.net.URLConnection)
  3. Which java-classes can be used to manually encrypt and decrypt the password and how are they used? (Small examples would be great!)
Aug 22 '07 #1
11 1802
Nepomuk
3,112 Expert 2GB
A partial answer would be fine too! ^^
Aug 23 '07 #2
Nepomuk
3,112 Expert 2GB
Hm, as nobody seems to be answering, I'll just change the question (although feel free to answer the original questions ^^):

Does anyone have any experience using the javax.security package? Is that package a good idea or are there better solutions, when all I want to do is encrypt a password within the client and decrypt it in the server?
Aug 24 '07 #3
JosAH
11,448 Expert 8TB
Why don't you use a one-way encryption? Let E(x) == y be a one-way encryption
function, i.e. given the key x it is quite easy to produce an encrypted version y,
but given y it is (almost) impossible to find x again.

Your database/server stores the y values, while the client produces a value y
given a value x and sends y over the wire to the server.

The MessageDigest class can be of help here for the encryption purposes.

kind regards,

Jos
Aug 24 '07 #4
Nepomuk
3,112 Expert 2GB
Why don't you use a one-way encryption?
The username and password should be checked by an external application and there will be loads of users. As I have no influence on the external application, I have to decrypt the password within the Server. Or did I misunderstand your suggestion?
Aug 24 '07 #5
JosAH
11,448 Expert 8TB
The username and password should be checked by an external application and there will be loads of users. As I have no influence on the external application, I have to decrypt the password within the Server. Or did I misunderstand your suggestion?
Is that external application capable of adding new users? If so, you feed it with
the values E(user), E(password) and simply do the one-way encryption on the
clients. The external application couldn't care less what exactly it compares
and the user,password pairs are send encrypted over the wire. There's no
need for decryption.

kind regards,

Jos
Aug 24 '07 #6
Nepomuk
3,112 Expert 2GB
Is that external application capable of adding new users? If so, you feed it with the values E(user), E(password) and simply do the one-way encryption on the clients. The external application couldn't care less what exactly it compares and the user,password pairs are send encrypted over the wire. There's no need for decryption.
Hm, it's a thought, but I don't know, if it's possible. The external application already has a database and having every user twice (as it is used by several other applications) wouldn't be optimal. Also, adding every existing user with encrypted data would probably be a time consuming task, as it is a format specially designed for this particular database (as far as I know) and probably the application doesn't implement adding a series of users. I'll just have to find out about all of this.
Anyway, further suggestions are welcome! ^^
Aug 24 '07 #7
JosAH
11,448 Expert 8TB
Hm, it's a thought, but I don't know, if it's possible. The external application already has a database and having every user twice (as it is used by several other applications) wouldn't be optimal. Also, adding every existing user with encrypted data would probably be a time consuming task, as it is a format specially designed for this particular database (as far as I know) and probably the application doesn't implement adding a series of users. I'll just have to find out about all of this.
Anyway, further suggestions are welcome! ^^
Well, you could try to use a secure socket layer or the https protocol ...

kind regards,

Jos
Aug 24 '07 #8
Nepomuk
3,112 Expert 2GB
Well, you could try to use a secure socket layer or the https protocol ...
...which brings me back to the questions:
  1. How much (if at all) does HTTPS encrypt data, which is sent to and from it?
  2. Can HTTPS be accessed in the same way as HTTP? (With a java.net.URLConnection)
And no, I don't think, that I could use SSL, as the server runs as a servlet on tomcat and I'm not surposed to use any other Ports than the http standard 80 and possibly the tomcat standard 8080, as others are often blocked. (And, although I guess, people could change those settings, those people often don't.)
Aug 24 '07 #9
JosAH
11,448 Expert 8TB
...which brings me back to the questions:
  1. How much (if at all) does HTTPS encrypt data, which is sent to and from it?
  2. Can HTTPS be accessed in the same way as HTTP? (With a java.net.URLConnection)
And no, I don't think, that I could use SSL, as the server runs as a servlet on tomcat and I'm not surposed to use any other Ports than the http standard 80 and possibly the tomcat standard 8080, as others are often blocked. (And, although I guess, people could change those settings, those people often don't.)
Well, then you're stuck with doing the encryption yourself then. Tomcat can do
a bit of encryption for usernames and passwords (base64) but the encryption
is almost decyphered when you even look at it for a bit.

If the Servlet is yours keep track of an ever changing magic number and send it
to the client when it hits the login page (hide it in a hidden field). The server keeps
that number in its session object. The client uses that number to encrypt the
data and send it to the server; the server also knows that number (its in the
session object) and decrypts the data again.

That magic number could be any random number supplied by, say, the Random
class. If the data happens to be incorrect, the server destroys the session object.

kind regards,

Jos
Aug 24 '07 #10
Nepomuk
3,112 Expert 2GB
Hm, I guess so. Is org.apache.commons.codec.binary.Base64 a good choice? I will however encrypt it further, and as nobody knows, what algorithm I'm using (while anyone can use the Base64 codec), that should enhance safety quite a lot, shouldn't it?
Aug 24 '07 #11
JosAH
11,448 Expert 8TB
Hm, I guess so. Is org.apache.commons.codec.binary.Base64 a good choice? I will however encrypt it further, and as nobody knows, what algorithm I'm using (while anyone can use the Base64 codec), that should enhance safety quite a lot, shouldn't it?
You'd better. Base64 encrypting isn't really encrypting; it's merely encoding the
data into readable (ASCII) characters. See my previous reply for a nice encrypting
trick (if applicable to your situation).

About that Base63 stuff: there are lots of en/decoders available; everybody seems
to find it interesting to build that functionality.

kind regards,

Jos
Aug 24 '07 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: danubian | last post by:
Hi, I'm a newbie in php/mysql programming,really am. I'm working on a web-site that allows registration and posterior logging in. Already registered user logs in with valid username and...
12
by: Pete..... | last post by:
Hi all. I have made a webpage where there is a webform where people can fill in their personel information: The code is below: I want to transfer the data to a postgreSQL database ( I have...
3
by: danubian | last post by:
Hi, I'm a newbie in php/mysql programming,really am. I'm working on a web-site that allows registration and posterior logging in. Already registered user logs in with valid username and...
5
topher23
by: topher23 | last post by:
I've seen a lot of questions about how to make secure database passwords. I'm going to go over a method of encrypting a password using the MD5 encryption algorithm for maximum security. First,...
1
by: hk777 | last post by:
Hi I have Access 2007 installed at work, and last week it suddenly started asking me for a username and password whenever I try to open anything, even a new database. If I log in to my computer...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.