Assignment 4 – Encryption Keys and Inheritance Everyone does Option A. Option B is only done along w

Assignment 4 – Encryption Keys and Inheritance Everyone does Option A. Option B is only done along with andafter completing Option A for 4 points extra credit. Option B getsno points if Option A is not working reasonably well. Make sure youhave read and understood both modules A and B this week, and

module 2R – Lab Homework Requirements

before submitting this assignment. File Structure: I prefer one file for the entire program, so thenon-Foothill classes should be non-public. (For Option B, you wouldhave two Foothill main()s, in the same file, which is fine – youcan comment one out.) You are welcome to organize your code inmultiple files, but in that case append them all into a single .txtwith your original files clearly delimited with horizontal linesand labels. OPTION A: InternetUser, Communicator and Two HelperClasses

Understand the Classes and Problem

Every internet user — perhaps better thought of as an Internetconnection — has certain data associated with him/her/it. We willoversimplify this by symbolizing such data with only two fields: aname (“Aristotle”) and a globally accessible IP address(“139.12.85.191”). We could enhance these by adding other –sometimes optional, sometimes needed — data (such as a MACaddress, port, local IP address, gateway, etc), but we keep thingssimple and use only these two for the assignment — any more wouldnot satisfy spec. Also, name is not technically a true datum forthis emulation, but we use it to signify the the Englishdescription of an individual or process that is interacting withthe Internet. Most internet users, however, need more — they want tocommunicate securely with other internet users. For example, Bob(bob, “139.12.85.191”) might want to order something from Amazon(amazon, “54.239.26.128”), a transaction that requires Bob totransmit a credit card number to Amazon over the Internet. Today,this is done using a two-key (public key + private key) systemcalled an RSA cryptosystem. You don’t see it, but it’s alwaysthere. Such a special internet user could be called a communicator.To use RSA encryption, every internet user would need a pair ofkeys, the public-private key pair, above and beyond their basicname/ip address data. Everyone gets to see everyone else’s publickey, but the private key is only known to the one user: Bob’sconnection knows his private key, and Amazon’s connection knows itsprivate key. But Bob will know Amazon’s public key and Amazon willknow Bob’s public key. We will not be encrypting actual messages this week, but perhapswe will do so in a later assignment. For those of you interested ina more complete explanation of RSA encyption, you can starthere: Wikipedia page for RSA (cryptosystem) (链接到外部网站。)链接到外部网站。 Using OOP vocabulary and tools, a communicator would thenconsist of a normal internet user plus at least one other item: akey pair, that contains two keys: the public key and the privatekey. Enter inheritance. Two Helper Classes: IntPair and EncryptionSupport

I will supply you with two support classes, as follows. Class IntPair

This class consists of two integers bundled together for easyhandling. Examples of IntPair objects are (32, 195), (-983, 0) and(1000, 212078). As you can see, there is a first integer and asecond integer, which we’ll call firstInt and secondInt. Everythingis public and no filtering is involved, so that our classes can getto the data easily and quickly. Details will be found in the textfile to be downloaded, below. Class EncryptionSupport

This class has no member data, only four static methods that willbe used by our Communication class methods. Since they are generalenough, we encapsulate them in a separate class. For example one ofits methods, isPrime( long x), determines whether or not the passedparameter, x, is a prime number, a useful method for many otherclasses. The methods of the class can be examined in the source,but they need not be fully absorbed or analyzed for the purpose ofthis assignment. You can simply call them and expect that they dothe right thing relative to the methods that you will write. Both classes and the imports for the assignment can bedownloaded here: zipped RSA support files (链接到外部网站。)链接到外部网站。 The Base Class: InternetUser

Your base class is named InternetUser. Public Static Class Constants

Define a full set of limits and defaults, like MAX_NAME_LENGTH,MIN_IP_LENGTH , and DEFAULT_IP for both min, max lengths anddefault data of each member. names should be between 2 and 50characters, and IP addresses between 7 and 15 characters. Thedefault name should reveal an undefined string, and the default IPaddress should be “0.0.0.0”, also an indicator of an error orundefined address to the user. Private Member Data

String name;

String ip;

Public Methods

Default and 2-parameter constructors.

Mutator and Accessor for each member.

a toString() method that provides a nicely formatted return stringfor potential screen I/O.

Private Methods

private static validation helpers to filter client parameters.These will support your public methods. You should only testlengths here, since we don’t really need to check the number ofperiods or size of each of the four ints in an IP address. We’lllet that slide for this assignment. (If you don’t know what an IPaddress looks like, now’s a good time to Google it. We’re usingIP4, not IP6, format.)

Client Test of Class InternetUser (first part of main())

Instantiate two or more InternetUser objects, some using thedefault constructor and some using the parameter-takingconstructor. Mutate one or more of the members and, after that, usethe toString() to assist a screen output so we can see what yourobjects contain. Next, test one or more accessors. Finally, calltwo or more mutators and constructors, providing both legal andillegal arguments and checking the return values (thusdemonstrating that the mutators do the right thing). Here is asample run from my test (but you will have to imagine/deduce thesource I used and create your own source for your testing, whichwill produce a different output). . . .