an authentication and authorization architecture for jini ... · jini, a technology from sun...

108
An Authentication and Authorization Architecture for Jini Services Thomas Marcus Schoch [email protected] Distributed Systems Group Computer Science Department Darmstadt University of Technical Advisors: Dr. Oliver Krone [email protected] Swisscom Prof. Dr. Friedemann Mattern [email protected] ETH Z¨ urich October 2000

Upload: others

Post on 11-Jul-2020

13 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

An AuthenticationandAuthorizationArchitecturefor Jini Services

[email protected]

DistributedSystemsGroupComputerScienceDepartment

DarmstadtUniversityof Technical

Advisors:Dr. OliverKrone

[email protected]

Prof. Dr. [email protected]

ETH Zurich

October2000

Page 2: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

Contents

1 Moti vation 5

2 Security Concepts 72.1 Digital Signatures. . . . . . . . . . . . . . . . . . . . . . . . . . . . 72.2 SecureCommunicationChannels. . . . . . . . . . . . . . . . . . . . 92.3 Authentication. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92.4 Authorization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

3 Jini Concepts 113.1 Java . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

3.1.1 History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113.1.2 Features. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

3.2 Jini . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123.2.1 ClassicalNetworking . . . . . . . . . . . . . . . . . . . . . . 123.2.2 Jini’sParadigm . . . . . . . . . . . . . . . . . . . . . . . . . 123.2.3 Discovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133.2.4 Lookup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143.2.5 Leasing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183.2.6 RemoteEvents . . . . . . . . . . . . . . . . . . . . . . . . . 183.2.7 Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . 19

4 Java Security 204.1 Securityin olderJDK Versions. . . . . . . . . . . . . . . . . . . . . 204.2 Securityin JDK1.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . 214.3 Securityin JDK1.3basedon JAAS . . . . . . . . . . . . . . . . . . . 22

4.3.1 SubjectsandPrincipals. . . . . . . . . . . . . . . . . . . . . 224.3.2 Summaryof theJAAS Concepts. . . . . . . . . . . . . . . . 25

4.4 SignedCodein Java . . . . . . . . . . . . . . . . . . . . . . . . . . . 264.4.1 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

4.5 JavaCryptographyArchitecture . . . . . . . . . . . . . . . . . . . . 284.5.1 CipherObject . . . . . . . . . . . . . . . . . . . . . . . . . . 284.5.2 SealedObject. . . . . . . . . . . . . . . . . . . . . . . . . . 294.5.3 KeyAgreement . . . . . . . . . . . . . . . . . . . . . . . . . 294.5.4 KeyPairGenerator. . . . . . . . . . . . . . . . . . . . . . . . 304.5.5 Usageof theDiffie HellmanKey AgreementAlgorithm . . . 304.5.6 SignedObject. . . . . . . . . . . . . . . . . . . . . . . . . . 314.5.7 Signature . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314.5.8 Keystore . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

1

Page 3: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

4.5.9 MAC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324.5.10 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

5 High Level Overview of the Ar chitecture 365.1 Highlights . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365.2 Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

5.2.1 ServiceAuthenticationandAuthorization . . . . . . . . . . . 365.2.2 Login Policies . . . . . . . . . . . . . . . . . . . . . . . . . 375.2.3 Client Transparency . . . . . . . . . . . . . . . . . . . . . . 37

5.3 Architecture. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375.3.1 Client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375.3.2 ServiceProxyandServiceBackend . . . . . . . . . . . . . . 37

5.4 TheComponentsof theSecurityInfrastructure. . . . . . . . . . . . . 38

6 Ar chitecture 396.1 Approach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 396.2 Definitionof AuthenticationandAuthorizationin theJini Environment 39

6.2.1 Authentication . . . . . . . . . . . . . . . . . . . . . . . . . 396.2.2 Authorization . . . . . . . . . . . . . . . . . . . . . . . . . . 40

6.3 Generaloverview . . . . . . . . . . . . . . . . . . . . . . . . . . . . 406.3.1 CommonJini schemes. . . . . . . . . . . . . . . . . . . . . 406.3.2 Client Transparency . . . . . . . . . . . . . . . . . . . . . . 406.3.3 Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 406.3.4 Authentication . . . . . . . . . . . . . . . . . . . . . . . . . 416.3.5 ExchangingData . . . . . . . . . . . . . . . . . . . . . . . . 41

6.4 CommonClasses . . . . . . . . . . . . . . . . . . . . . . . . . . . . 426.4.1 ServiceFinder. . . . . . . . . . . . . . . . . . . . . . . . . . 426.4.2 Pingable. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

6.5 Clientside . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 426.5.1 Transparency . . . . . . . . . . . . . . . . . . . . . . . . . . 426.5.2 SignedCode . . . . . . . . . . . . . . . . . . . . . . . . . . 426.5.3 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43

6.6 SecureCommunication. . . . . . . . . . . . . . . . . . . . . . . . . 436.6.1 Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436.6.2 CryptographyatApplicationLevel . . . . . . . . . . . . . . . 436.6.3 LeasingContext Information . . . . . . . . . . . . . . . . . . 446.6.4 CryptographyatSocketLevel in Future . . . . . . . . . . . . 456.6.5 SecureParametersandReturnValues . . . . . . . . . . . . . 456.6.6 SecureClient . . . . . . . . . . . . . . . . . . . . . . . . . . 476.6.7 SecureSlotProvider . . . . . . . . . . . . . . . . . . . . . . 496.6.8 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52

6.7 CommonSecureClasses . . . . . . . . . . . . . . . . . . . . . . . . 526.7.1 Refreshable. . . . . . . . . . . . . . . . . . . . . . . . . . . 526.7.2 Register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53

6.8 Objectsfor Authentication . . . . . . . . . . . . . . . . . . . . . . . 546.8.1 User . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 546.8.2 Password . . . . . . . . . . . . . . . . . . . . . . . . . . . . 556.8.3 Challenge-Response. . . . . . . . . . . . . . . . . . . . . . 556.8.4 DomainName. . . . . . . . . . . . . . . . . . . . . . . . . . 566.8.5 DefaultUser. . . . . . . . . . . . . . . . . . . . . . . . . . . 56

2

Page 4: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

6.9 RemoteCallback . . . . . . . . . . . . . . . . . . . . . . . . . . . . 576.9.1 InterfaceDefinition . . . . . . . . . . . . . . . . . . . . . . . 586.9.2 RemoteCallbackHandlerParam. . . . . . . . . . . . . . . . . 586.9.3 RemoteCallback . . . . . . . . . . . . . . . . . . . . . . . . 586.9.4 CommonCallbacks. . . . . . . . . . . . . . . . . . . . . . . 596.9.5 Remarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61

6.10 InfrastructureServices . . . . . . . . . . . . . . . . . . . . . . . . . 616.10.1 Login Policy DB Service. . . . . . . . . . . . . . . . . . . . 616.10.2 UserDB Service . . . . . . . . . . . . . . . . . . . . . . . . 636.10.3 SubjectAuthenticatorService. . . . . . . . . . . . . . . . . . 656.10.4 BlueDotService. . . . . . . . . . . . . . . . . . . . . . . . . 676.10.5 RingAuthenticatonService. . . . . . . . . . . . . . . . . . . 70

6.11 Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 706.11.1 InterfaceDefinitions . . . . . . . . . . . . . . . . . . . . . . 716.11.2 Proxy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 716.11.3 Backend. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 736.11.4 RemoteInterface . . . . . . . . . . . . . . . . . . . . . . . . 74

7 Implementation 757.1 PackageStructureandConventions. . . . . . . . . . . . . . . . . . . 75

7.1.1 ProxyInterface . . . . . . . . . . . . . . . . . . . . . . . . . 757.1.2 RMI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 767.1.3 BackendInterface . . . . . . . . . . . . . . . . . . . . . . . 76

7.2 Datacontainers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 767.2.1 ExtendedDataContainers . . . . . . . . . . . . . . . . . . . 77

7.3 CookieandToken . . . . . . . . . . . . . . . . . . . . . . . . . . . . 777.4 ExchangeData . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 787.5 SecureCommunication. . . . . . . . . . . . . . . . . . . . . . . . . 78

7.5.1 EncryptionandDecryption. . . . . . . . . . . . . . . . . . . 787.5.2 Slot Provider . . . . . . . . . . . . . . . . . . . . . . . . . . 787.5.3 SecureClient . . . . . . . . . . . . . . . . . . . . . . . . . . 79

7.6 Commonclasses . . . . . . . . . . . . . . . . . . . . . . . . . . . . 797.6.1 ServiceFinderImpl . . . . . . . . . . . . . . . . . . . . . . . 797.6.2 AbstractRingApplet . . . . . . . . . . . . . . . . . . . . . . 807.6.3 BasicUnicastService. . . . . . . . . . . . . . . . . . . . . . 807.6.4 RegisterImpl . . . . . . . . . . . . . . . . . . . . . . . . . . 807.6.5 RemoteRegisterImpl . . . . . . . . . . . . . . . . . . . . . . 81

7.7 Callback. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 817.7.1 RemoteCallbackHandler. . . . . . . . . . . . . . . . . . . . 817.7.2 LocalCallbackHandler. . . . . . . . . . . . . . . . . . . . . 82

7.8 Authenticationclasses . . . . . . . . . . . . . . . . . . . . . . . . . 827.8.1 AbstractProxy . . . . . . . . . . . . . . . . . . . . . . . . . 827.8.2 AbstractBackend . . . . . . . . . . . . . . . . . . . . . . . . 827.8.3 AuthenticatorBackendImpl . . . . . . . . . . . . . . . . . . . 83

7.9 BlueDotService. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 847.9.1 Proxy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 847.9.2 Backend. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84

7.10 RingAuthenticationService. . . . . . . . . . . . . . . . . . . . . . . 857.10.1 RingAuthenticationApplet. . . . . . . . . . . . . . . . . . . 857.10.2 Proxy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86

3

Page 5: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

7.10.3 Backend. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 867.11 UserDBservice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86

7.11.1 Proxy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 877.11.2 Backend. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87

7.12 LoginPolicyDB service . . . . . . . . . . . . . . . . . . . . . . . . . 887.12.1 Proxy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 887.12.2 Backend. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88

7.13 Jaasservice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 887.13.1 ConsolePasswordLoginModule . . . . . . . . . . . . . . . . 897.13.2 RingLoginModule . . . . . . . . . . . . . . . . . . . . . . . 897.13.3 Proxy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 897.13.4 Backend. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89

7.14 Challenge-ResponseApplet andHostfor theJava Ring . . . . . . . . 907.14.1 Applet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 907.14.2 Host . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91

8 CaseStudy 928.1 Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 928.2 SampleAction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 938.3 SampleProxy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 938.4 SampleService . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 948.5 SampleClient . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 958.6 Setupthepolicy files . . . . . . . . . . . . . . . . . . . . . . . . . . 96

8.6.1 Client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 968.6.2 Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 968.6.3 AuthenticationService . . . . . . . . . . . . . . . . . . . . . 97

8.7 Key ManagementandSigning . . . . . . . . . . . . . . . . . . . . . 978.8 Setuptheenvironment . . . . . . . . . . . . . . . . . . . . . . . . . 988.9 Loadingthekey ontotheJava Ring . . . . . . . . . . . . . . . . . . . 988.10 Startingtheexample . . . . . . . . . . . . . . . . . . . . . . . . . . 98

9 Conclusionand Futur eWork 1009.1 Jini andFriends . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1009.2 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1019.3 FutureWork . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1019.4 Acknowledgements. . . . . . . . . . . . . . . . . . . . . . . . . . . 102

4

Page 6: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

Chapter 1

Moti vation

It is likely that therewill be a new paradigmin the field of computerapplicationinthenearfuture.Thecurrentparadigmis thatworkstationsandserversareconnectedtolocal areanetworks(LANs), e.g.Ethernet.TheseLANs canbuild wide areanetworks(WANs) by interconnectingthem,e.g.theInternet.

Usingthatinfrastructure,theindustrycurrentlydefinesstandardsfor connectingalltypesof appliancesinto theInternet.Thisalsoincludeshouseholdappliances,likeTVs,refrigerators,lawn sprinklers,vacuumcleaners,lights,etc.Furtheron, it is imaginablethatalsoclothesandeveryproductinsidearefrigeratorwill beconnectedto theInternetvia smartlabels,a technologythatis alreadyavailable.

However, only connectingtheseitems to the Internetdoesnot provide any ben-efit. The addedvalueof the interconnectingoriginatesif all the appliancesprovidea well-definedapplicationprogramminginterface(API). To reacha higherdegreeoftransparency - thatmeansto hideproprietaryprotocolsandfor easieradministrationofthoseappliances- theapplianceis representedby aservicein thenet.Theservicepro-videsalsoawell-definedAPI andcarriesout thecommunicationwith theappliance.Aclient,whichitself is asoftwarecomponent,canusetheapplianceby usingthatserviceAPI. So theAPI is an interfacewhich canbeusedby differentfirms to communicatein a well-definedmanner.

Oneadvantagefor theuseris thathehasa higherdegreeof flexibility in operatingtheappliance.Theintrinsicvalueis theinteractionbetweendifferentservices.Servicescancombinesomeotherservicesto providea new functionality, e.g.a storageserviceanda TV servicecanbe combinedto a VCR service. It could alsobe possiblethatthe TV servicedetectsa defectandautomaticallycontactsthe manufacturerservice.The manufacturerservicethen instructsa robot in the storagehouseto get the rightsparepart. Scheduleserviceson bothsidesnegotiatea datefor the installationof thesparepart,andsoon. This alsomeansa reductionof thecostsfor themaintenanceofappliances.

Suchservicesrequirea distributedcommunicationinfrastructure.A communica-tion infrastructureactsasa middlewarebetweentheoperatingsystemandtheapplica-tion. Its taskis to provide servicediscovery andbrokerage,similar to a marketplace,wheremarketerandcustomerscanmeetandtrade. The protocolusedin the market-placeexampleis very informal. A customercanexpressthewish to buy aTV in manydifferentwayswhich is understoodby themarketer, whereasa client anda serviceinthe computerenvironmentneeda well-definedprotocolof how to communicate.TousetheTV servicementionedabove, thereis exactly onepossibleway to turn theTV

5

Page 7: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

on or off by calling thecorrespondingmethods.Jini, a technologyfrom SunMicrosystems,is oneof severalapproachesto provide

a middlewarefor servicediscovery andbrokerage.A key conceptof Jini is the self-healingability that fits very goodin spontaneousnetworks,whereappliancesappearanddisappearwithout notification,so that the self-healingability doesimplicitly thecleanup of no longerusedresources.The biggestadvantageof the Jini technologycomparedto UniversalPlugandPlay is currentavailability. Therefore,Jini is a goodcandidatefor theinfrastructureof thenew paradigm.

Clearly, security, in particularuserauthenticationand authorization,is very im-portantin an openserviceenvironment. Every Jini servicecancurrentlybe usedbyanyonein theInternet.For example,theownerof theTV canusethetvOff-methodoftheTV service,but anyoneelsein theInternet,especiallysomeonewho is malicious,canusethis methodof theTV servicetoo, while theownerof TV is watchingTV. Itwould bepossibleto prevent this by usinga firewall, but thenanotherproblemarose:trying to programtheVCR serviceto recorda movie from anInternet-cafewould beimpossible.Usinga firewall doesnot includeauthorization,e.g.only theownerof theTV shouldbeableto watchTV anytime,sothatauthorizationmechanismsareneeded.His childrenmayberestrictedto watchTV only in theafternoon.

Thethesisis structuredasfollows:Chapter2 is aboutsecurityconceptsin general. It explainsthe meaningof digi-

tal signatures,securecommunicationandthereforealso integrity, authenticationandauthorizationwhich areneededby this architecture.

A moredetaileddescriptionof JavaandJini,whichis averypromisingmiddlewaretechniqueto interconnectall kind of appliances,will begivenin chapter3.

Chapter4 combinesthe aspectssecurityandJava. It introducesthe Java securityconceptswhich areusedin this architecture.

Sincethedescriptionof thearchitecturewhichis givenin chapter6 is verydetailed,a generaloverview is given first in chapter5 which also includesa casestudyon ahigherlevel, whereaschapter8 providesa moredetailedcasestudy.

Chapter7 explainshow thereferenceimplementationof this architectureis madeby implementingtheJava interfaceswhich describesthearchitecture.

Finally, conclusionsandfuturework,whicharerelatedto thearchitecture,aregivenin chapter9.

6

Page 8: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

Chapter 2

Security Concepts

Thischaptergivesageneraloverview aboutsecurityconceptsthatareusedthroughoutthis thesis.They arenot Java or Jini specific.Themainfocusis on digital signatures,sinceJava providesbuilt-in supportfor digital signatures.Thesecondpart introducesthe conceptof a securecommunicationchannel.Thereforeit alsotakesa look at in-tegrity andconfidentiality. At theendof this chapterauthenticationandauthorizationaredescribedin general.

2.1 Digital Signatures

The purposeof a digital signatureon any kind of datais to verify the identity of thepersonwho digitally signedthecodeandto verify theintegrity of thedata.

A digital signatureof aninput � consistsof two phases.In thefirst phasetheinput� is transformedto�

usinga securehashfunction, sincethe result�

is muchshorterthantheinput � . In thesecondphasea signingfunctionis appliedto theinput

�using

a privatesigningkey � andreturnsthedigital signature� of input � usingthe privatesigningkey � .

������� �������������������������� � ��� �!�"�$# � ��%�& � %Thecomplementaryoperationis theverificationof a digital signature.For that,a

verificationfunction takesthe digital signature� anda public verificationkey # thatcorrespondsto the privatesigningkey � andcalculatesan output � . Using the samesecurehashfunction appliedon the input � returns . Now and � are testedforequality.' #)(��*����#��+�,#�-�� �$. �$� ' #)(��*����� � �������/��� ��������������� & # %!& � � ��� �!�"�$# � ��%0%

If the verificationsucceeds,it hasbeenverified that the given input wasdigitallysignedby someone,whohastheprivatesigningkey correspondingto thepublicverifi-cationkey if someassumptionsarehold:

1 Thesecurehashfunctioniscollisionfree: � � ������� �������������32 % �4� � ��� �����������������5276 %and 298�:2;6 is extremelyhardto compute.Thatmeansit is extremelyhardtofind aninput 276 thatcorrespondsto theoriginal input 2 andbothhavethesamehashcode.

1 Theprivatesigningkey andthepublic verificationkey mustfulfill two require-ments.Givenoneof bothkeys, it mustbeextremelyhardto computetheother.

7

Page 9: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

Both keys andonly thesebotharecorresponding,sothat it is extremelyhardtofind anotherverificationkey thatcorrespondsto thesigningkey andviceversa.

1 Thesigningfunctionmustfulfill thesamerequirementsasthehashfunctionandmustgeneratedifferentresultsfor differentsigningkeys. Therefore,thesigningfunctioncanbeseenasa hashfunctionwith aparameter:thesigningkey.

1 The verificationfunction that usesthe public verificationkey hasto reproducethe sameinput which was given to the signing function that usedthe privatesigningkey.

Only if all theseassumptionsarefulfilled, the conclusionthatonly someonewhohadknown the privatekey that correspondsto the usedpublic verificationkey couldhavesignedthedata,is a valid conclusion.And thatis theonly interpretationwhich ispossiblein this model.

Theseare the theoreticalaspectsof digital signing,but the expression“signing”suggestsoneapplicationof thatmathematicaltheory:in reallife, adocumentis signedby a personwith his signature.Thedocumentmatcheswith theinput andtheperson’shand-writtensignaturematcheswith thedigital signature.Theprivatekey correspondsto theability of thepersonthat thepersonandonly this personcansignthedocumentwith his hand-writtensignature.Theinterpretationof thepublic verificationkey is theability of ahandwritingauthenticatorto authenticateasignatureasthesignatureof thatpersonwho signedit. This is only onekind of interpretation,therecouldalsobeotherinterpretations.

Thereremainsonevery importantfact to mention.This interpretationonly worksif thepersonwho usesthe privatesigningkey is theonly personwho knows thekey.In real life a signaturecanbe faked. But this canbe detectedby an expert,whereaspublishinga privatesigningkey enableseverybodyto digitally sign an electronicallydocumentwithout thepossibilityto detectthis by anexpert.

Thus,signingcodeandtheverificationwith a public verificationkey only impliesthatsomeonewho hasthecorrespondingprivatesigningkey signedthecodeandthatthedatahasnotbeenaltered.Thatmeans,it doesnotimply authenticity, referringto theverificationof theidentityof someone,althoughit usedfor thatpurpose.As describedabove, it cannotbeusedfor thatpurpose.Authenticitycanonly beachievedby usingan indirection,but not on a technicallevel, only on a logical level, sothata misuseisstill possible.This works by assigningtrust to the privatesigningkey, wherebytwocircumstancesaretrusted.Thefirst is that theownerof theprivatekey takescarethatno third partygetstheprivatesigningkey andthat thedigital signingwith theprivatesigningkey impliesa semanticthatis thesameonbothsides.

All thefollowing aspectsconcernlegalaspects.Thesemantic,which is used,mustbeuniqueandthereforehasto bewritten down legally binding.This couldbea previ-ouscontract,or a datastructureinsidethecode.Furthermore,theprivatesigningkeymustbe kept secret. For an uniqueassignmentof the public verifying key with theownerof theprivatesigningkey, thepublicverifying key mustbecertifiedby a publicauthority. Thiscouldbedoneby signingthepublicsigningkey with theprivatesigningkey of thepublic authority. In general,anauthoritywhich signspublic keys is calledCertificateAuthority (CA). Thus,thepublic key of theCA mustbetrusted.Chainsoftrustcanbebuilt usinga treeof CAs. Thepublic key of a CA hasto besignedby theCA in thehierarchyabove. Thatmeanstheremustbea root CA which hasto sign itsown certificate. Therefore,its self-signedcertificateor the fingerprintof it hasto be

8

Page 10: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

publishedby anothermedium,e.g. an“official” newspaper. A fingerprintis a humanreadablehashvalueof theinput,e.g.a hashvalueof a certificate.

2.2 Secure Communication Channels

A securechannelis acommunicationchannel,in whichdatacannotbereador altered.An exampleof an insecurechannelis an Internetlink. Every routerhasaccessto allthedatathatheroutes.But it is possibleto secureaninsecurechannel.Confidentialityandintegrity have to beachieved. Confidentialitymeansthatonly thesenderandthetrustedreceivercanreadthemessage,whereasintegrity meansthatthereceiverknowsthatthereceiveddatais thesameasthedatasentby thesender.

Confidentiality is typically achieved by using symmetricencryption. It is alsoimaginableto useasymmetricencryption,but this is 1000timesslower thansymmetricencryption.A messageauthenticationcode(MAC) is theway to ensurethat integrityis achieved.

A mathematicalview on symmetricencryptionanddecryptionis:

1 encryption:���=<��>#�(?����(�@�<>�*�A�����������������3� � � � & ��#��!(�#��0B�#�@ %1 decryption:� � � � ����(�@�< �*�A��� ���!�������������=<�� #�( & ��#���("#)�0BC#)@ %

The assumptionsarethat the secretkey is kept secreton both sides,whereasthecryptofunctioncanbepublic. Having thecipher, but not thesecretkey, it mustbeex-tremelyhardto computetheoriginaldataor thesecretkey. It shouldalsobeextremelyhardto computethesecretkey if dataandcipheris known.

Oneapplicationof encryptionanddecryptionis theconfidentialtransmissionof anykind of dataover aninsecurechannel.If anattacker getsthecipherfrom the insecurechannel,heis notableto recovertheoriginal informationwithout thesecretkey whichis only known by partieswhich areentitled.

The MAC is computedby a hashfunction which is initialized with a secretkey.Sincesenderandreceiverknow thesecretkey, bothareableto computetheMAC. ThereceivercancomparethecomputedandthesentMAC.

Anotherproblemis the replayof networks packets. A network packet which isneitherreadnoralteredcanbereceivedby a third party. Then,thisnetwork packetcanbereplayedseveraltimesby thethird party. To preventreplays,increasingtransactionnumberscanbeused.Thatmeans,thereplayof anetwork packethasanold transactionnumberwhich is detectedby thereceiver.

2.3 Authentication

Authenticationrefersto theprocessto establishtrust thatanentity is real,e.g. theau-thenticationof a contractis achievedby theverificationof thesignatures.In thecom-puterenvironment,authenticationmeansto verify the identity of an entity, on whichbehalfcodeis executedamongotherthings. Theentity couldbea userthatentershisuser-nameandhis password for theverificationprocess.It is alsoimaginablethat theentity is a computerprogramor a device andthe verificationis doneby a challenge-responseprocedure.

9

Page 11: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

2.4 Authorization

In general,authorizationis independentof the authenticationprocess.Authorizationmeansto grantpermissionsto an entity. The permissionscanrefer to any restrictedresource:physicalor logical,e.g.accessingaprinteror executingcode.In mostcases,it is importantto know theidentityof theentity. For thatreason,authorizationnormallybuilds on authentication.In this thesis,authorizationmeansto grantanauthenticatedentity permissionsto accessa restrictedphysicalor logical resource.

10

Page 12: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

Chapter 3

Jini Concepts

This chapterconsistsof two parts.Thefirst andsmalleronetakesa look at thecom-puterlanguageJava which is usedby Jini. Building on that,Jini andits conceptsaredescribedin thesecondpart.

3.1 Java

A very short overview of Java is given in this section,sinceJini utilizes Java. Furfurtherinformationon Java thereis verymuchliteratureavailable.

3.1.1 History

Theverybeginningof thecomputerlanguageJavawasin 1991asSun’s”GreenTeam”shouldanticipateandplanfor thenext wave in computing.Their first conclusionwasthatonetrendwouldbetheconvergenceof digitally consumerdevicesandcomputers.Sothey triedto createtheinfrastructurefor ainteractivenetwork. At thattimethecablenetworkswerefocusedbut it cameout thattherewasnobusinessin thatfield. But theyfoundanothercandidate,thenewly popularInternet.Thefirst versionof Javacameoutin 1995andwasa revolution,becauseit broughtmotioninto thestaticInternet.Sincethen,Java hasstormedthecomputermarket.

3.1.2 Features

Java is a strongtypedobjectorientedlanguage.The syntaxis closeto the notion ofC++,but theconceptsof thelanguagediffersstrongly. Themostimportantfeaturesare

1 nopointerarithmetic

1 exceptionhandling

1 garbagecollection

1 platformindependentcompiledbytecode

1 appletsrunnablein a www browser

1 dynamiccodeloadingover theInternet

11

Page 13: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

1 network support

1 threadsupport

1 remotemethodinvocation

Theabsenceof pointersandthe automaticgarbagecollectionmadeit possibletovery rapidlywrite down thecode.A very importantfeaturefor theInternetis thatJavausescompiledbytecode,sothattheappletscanrun in everybrowserthatsupportsJavaindependentlyof the underlayingoperatingsystem.The Java appletsor applicationswill beexecutedin aJavaVirtual Machine(JVM) whichcanuseajust in timecompilerfor a fasterexecutionof thecode.Onedisadvantageof usingbytecodeis theexecutiontime. A native codeprogramis 20 timesfasterthana bytecodeprogram,but usingajust in timecompiler(JIT) speedsup theexecutiondramatically.

3.2 Jini

This sectiononly providesa shortoverview aboutJini. Themainfocuswill beon thesecurityarchitecture.For a moredetaileddescriptionmany booksareavailable. Jiniwill only be introducedinsofar that it is possibleto understandthe securityarchitec-ture. As mentionedin the motivation,Jini is a middlewarefor servicediscovery andlookup in a distributedenvironment. It is built on top of Java which is designedtosupportdistributedenvironmentsby usingremotemethodinvocation(RMI) andby us-ing dynamicdownloadablecode.But Jini differsfrom thefirst paradigmof distributedsystemswhichwill beintroducedin thenext subsection.

3.2.1 ClassicalNetworking

Theclassicalapproachwasto make thenetwork transparent,i.e. to hidethenonlocaleffects,e.g. performance,latency andfailuremode.Therearegoodreasonsfor it. Adistributedsystemis muchmorecomplex thana local standaloneone. To design,toimplementandto testsucha systemis muchhardercomparedto a localone.If all thecomplexity canbereduced,sothata distributedsystemlookslike a local one,no newmodelsarerequiredandeverythingcanbedonetheknown way.

But it turnedout that this simplificationis anoversimplification.Performanceandlatency areexamplesthatsimplificationcanalsobebad.In general,it is not decidableif a network entity hasbeencrashedor if it is slow, whereasin the local casethis isdeterministic,e.g. the time to accessa harddisk drive is given. So it is decidableiftheharddisk worksor hasbeencrashed.Anotherimportantpoint is thefailuremode.In thelocal case,thesystemis corrector not,whereaspartial failurescanoccurin thedistributedcase,e.g. a multicastmessageis only receivedby a few receivers,so thatnot all entitiessharethesamestate.Hiding thesefactscanleadto anundefinedstate.

3.2.2 Jini’ s Paradigm

Jini introducesa new paradigmto the distributedworld. It providesthe marketplacementionedin the first chapter. It is a middlewarefor servicesandclients. They canuseJini and its conceptsto find eachother and to communicatesynchronouslyandasynchronously. Thebig benefitof Jini is thatservicescanspontaneouslyjoin or leavethe Jini communityandthe Jini conceptsdo the discovery andthe cleanup,e.g. the

12

Page 14: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

VCR serviceusestheTV serviceto show amovie. If theVCR servicecrashes,theTVservicecanreleasetheresourcesthattheVCR serviceused,sothatanotherservicecanusetheTV service.A Jini serviceis veryflexible, it cancommunicatewith a physicaldeviceandprovidesits feature,e.g.theTV. It canbeaservicewhichusesotherservicesto provide a functionality, e.g. the VCR servicewhich usesthe TV serviceand thestorageservice.Or it canbea ”standalone”service,e.g. which providesinformationlike thecurrenttime.

To achieve thegivenpropertiesJini hasfive key conceptswhich will beexplainedin moredetail in thenext subsections:

1 discovery

1 lookup

1 leasing

1 remoteevents

1 transactions

The following subsectionsgive a very shortoverview aboutJini andits concept.Someminoraspectsareleft out which arenot relevantfor this thesis.

3.2.3 Discovery

The discovery procedureis the bootstrappingprocessof the Jini infrastructure.It isusedto find the lookup services,the corecomponentsof every Jini community. Thelookupservice,whichis aregularJini service,providesaccessto theservicesin severalgroupsin its community. A Jini communityenfoldsthesubnetthat is reachableby anIP broadcast.This restrictionis veryuseful,becausein themajorityof casesonly localservicesare relevant, e.g. to usethe TV serviceat home,all the other TV servicesin all the other householdsdo not matter. But Jini is not boundto this. A lookupservicecanalsoprovide servicesfrom othercommunities,e.g. it is possibleto startthe VCR serviceat the office. A groupwhereasis a logical restriction. Servicescanbein multiplegroupsandlookupservicescanprovideservicesfrom severalgroups.Aspecialgroupis thepublicgroupwhich is somekind of a defaultgroup.

Therearethreedifferentwaysto discovera lookupservicewhicharedrivenby theserviceor aredrivenby thelookupservice:

1 When a serviceor an applicationstarts,they find the lookup servicein theircommunityusinga multicastrequestprotocol(figure3.1).

1 Themuliticastannouncementprotocolgoesanotherway. A lookupservicecanannounceits existenceby usingthatprotocol,shown in figure3.2.

1 Theunicastdiscovery protocolis usedif a serviceor an applicationknows theaddressof a lookup servicein advance(figure 3.3). Using that information itcancontactthelookupservicedirectlywhichcanbein anothercommunity. Thesyntaxto specifythelookupserviceis quitesimple.It is aURL containingjiniasprotocolnameandahostnamewherethelookupserviceis running.TheURLcanalsocontaina port, if not, thedefault lookupserviceport4160 is used,e.g.jini://marzipan.icsi.berkeley.edu.

13

Page 15: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

startedService

Lookup-Service

Lookup-Service

response

response

request

Figure3.1: MulticastRequestProtocol

ExampleCode

First, a serviceor an applicationhasto instantiatea LookupDiscovery objectbyspecifyingthegroupsthatit is interestedin:

LookupDiscovery disco = new LookupDiscovery(groups);

Thenit registersa DiscoveryListener which is only an interfaceandneedsanimplementation:

disco.addDiscoveryListener(discListener);

If new lookupservicesarediscoveredor discardedthecorrespondingmethodsoftheDiscoveryListener arecalled:

void discarded(DiscoveryEvent e);void discovered(DiscoveryEvent e);

TheDiscoveryEvent containsthelookupservices.

3.2.4 Lookup

Lookup is theprocessof retrieving a desiredservice.SinceJini is basedon services,thisprocessisdonebyaservicecalledtheLookupService.Thisservicehasto maintainall the otherservices.That means,it hasto handleregistrationof new servicesandrequestsfor services.Lookupservicesaremorepowerful thannormalnameservices.They have to storeandretrieve serializedJava objects,known asProxies. A requestcanconsistof a ServiceID, aJava interfaceto beimplementedby theproxyor asetofattributes.TheJini packageprovidesaimplementationof aLookupService(LUS),butit canbeimplementedby anyoneelse,sincetheLUS is just aninterfacedescription.

14

Page 16: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

startedLookup-Service

Service

Service

announce

Figure3.2: MulticastAnnouncementProtocol

startedService

Lookup-Service

request

response

Figure3.3: UnicastDiscoveryProtocol

ExampleCode

As shown above, thediscovery processfinds the lookupservicesandcalls theappro-priateDiscoveryListener methods. Two things can be donewith the lookupservices:

1 registera service

1 searchfor a service

To registeror to searchfor aservice,a communicationwith thelookupservicehasto take place. The methodgetRegistrars() of theDiscoveryEvent returnsan array of ServiceRegistrars. ServiceRegistrar is an interfacewhichevery lookupservicehat to implement,sothatdifferentimplementationsbesideSun’simplementationof thelookupservicenamedreggiearepossible.

Having a lookupservice,themethod

ServiceRegistration register(ServiceItem item,long leaseDuration);

is called to registera service. leaseDuration will be explainedin the nextsection.Theserviceitself is locatedin theServeItem object.Its constructoris:

15

Page 17: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

Service Lookup-ServiceProxy

Figure3.4: ServiceRegistration

ServiceItem(ServiceID serviceID, java.lang.Object service,Entry[] attrSets)

TheServiceID uniquelyidentifiesa servicein time andplace.If a servicereg-istersitself thefirst time, it shouldstoreits informationpersistently, sothatit is abletoregisteritself on anotherlookupserviceor aftera crashwith the sameServiceID.This canbeusefulfor clientswho searchexactly thesameservice.It is alsopossiblefor servicesto re-registerthemselves,e.g. if anewerversionof theserviceis available.The third argumentof the constructoris an arrayof Entrys. Entrys areattributeswhich describethe service,andcanbe usedto searcha specificservice. A commonattributewhich mostservicesshouldprovide is theplace. In theTV serviceexample,theTV in the living roomshouldbeusedby theVCR serviceandnot theTV servicefor theTV in thebedroomif theVCR serviceis startedin theliving room.

The secondand most importantargumentis service which is declaredas anObject. This is not the serviceitself, but a proxy for that service.Theproxy mustbea serializableobjectwhich theservicehasto specifythere(figure3.4). Theuseofa proxy is the key ideaof Jini. The proxy hasto implementa well-definedinterfacewhich is known by theclient,e.g. theTV serviceinterfacewhich includesmethodstoturn the TV on or off or to choosethe AV source. If a copy of that serializedproxyis downloadedby a client, theclient canusetheproxy, becauseit knows the interfacewhich theproxy implements.Therearedifferentpossibilitiesto implementtheproxy.In mostcasesit is likely that the proxy contactsthe servicebackendvia RMI or anyotherprotocol,calls the correspondingmethodsandreturnsthe result if the methodhasto returnone. Anotherpossibility is that the proxy implementsthe whole func-tionality anddoesnot contactany otherentities.It canalsodirectlycommunicatewithanappliance.Usingthat technique,theproblemsof not installeddriversareobsolete,becausethe”implementationof thedriver” is hiddenby theproxy, sothataclientonlyhasto know theinterface.However, usingthecreatedServiceItem, theservicecanregisteritself on thelookupservice.

A servicecanalsobeaclient if it usesanotherservice,e.g.theVCR serviceis sucha servicebecauseit providesthefunctionalityof aVCR. But it is alsoa client becauseit usestwo otherservices:theTV serviceandthestorageservice.TheclientalsousesaLookupDiscovery objectto getthelookupservices.But aclienthasnot to registera service.It hasto find a serviceusingthe

public java.lang.Object lookup(ServiceTemplate tmpl)throws java.rmi.RemoteException

methodof theLookupDiscovery object(figure3.5). For thatpurposeit hastocreateaServiceTemplate object.Its constructoris:

16

Page 18: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

Client(could also

be a Service)Lookup-ServiceProxy

Figure3.5: FindingService

Lookup-ServiceProxy

Service IDAttr

Attr

Attr

Attr

Figure3.6: LookupServiceEntry

ServiceTemplate(ServiceID serviceID,java.lang.Class[] serviceTypes,Entry[] attrSetTemplates)

ServiceID andEntry have alreadybeenintroduced.A client canspecifythedesiredServiceIDandtheattributesthat theservicesmustprovide (figure3.6). nullcanbeusedaswildcard.ThesecondargumentserviceTypes is verypowerful. It ispossibleto specifywhich interfacestheproxyshouldimplement.As mentionedabovethe interfacedefinesthe protocolof how a client cancommunicatewith the service.A client doesnot careabout the implementation. It only expressesthat it needsaservice,resp. its proxy that can”speak” the protocol,i.e. that implementsthe giveninterface,e.g. a remotecontrol specifies,it needsa servicewhich ”speaks”the TVserviceprotocol. The lookup servicesthenreturnsa proxy which is ableto ”speak”this protocolif oneis available. Anotherimportantfeatureis that the proxy doesnothave to implementit directly, it canalsobeimplementedasanextendedinterface,e.g.theTV serviceprovidesaproxythatimplementstheTV serviceinterfaceversion2,butthe remotecontrolasksfor a proxy that implementsthe TV serviceinterfaceversion1. If theversion2 interfaceextendstheversion1 interface,thelookupservicesreturnstheversion2 proxy andtheremotecontrolusesonly a subsetof theversion2, i.e. theversion1 interfaceto communicatewith theservice.-

Summarizingto publisha service:

1 Registrationof aDiscoveryListener thatwill be invokedif a lookupser-vice is found.

1 Registrationof aproxyon a lookupserviceusingaServiceRegistrationobject.

Summarizingto find a service:

17

Page 19: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

1 Registrationof aDiscoveryListener thatwill be invokedif a lookupser-vice is found.

1 Lookupof aproxy ona lookupserviceusingaServiceTemplate object.

3.2.5 Leasing

Leasingis the self-healingcapability of Jini that doesimplicitly the cleanupof nolongerusedresources,e.g. the TV servicestorescontext informationaboutthe VCRservice.This couldbea GUI thatshows thestatusof theVCR on theTV screen.Forvariousreasons,the VCR servicecrashesandcannotreleasethe context informationwhich is storedin theTV service.If thathappensa few moretimes,thestorageof theTV servicewill beexhausted.The ideaof leasing,which preventssuchsituations,isnot to grantpermissionto accessa resourcefor a undefinedamountof time, but for aexplicit amountof time. If thereis no requestto renew the leaseuntil it expires,allresourcesthatareassignedto thatleasewill bereleased,e.g.if theVCR servicecannotrenew its lease,becauseit hasbeencrashed,all thecontext informationwill beclearedby theTV serviceaftertheleasehasbeenexpired.

Another importantscenariofor leasingis the useof mobile deviceswhich couldspontaneouslyjoin andleave Jini communities.And that is exactly what Jini is builtfor. A new servicecanspontaneouslyjoin theJini communityby registeringitself ona lookupservice.The lookupserviceitself usesleasingto keeptrack which servicesarestill available. If theserviceis no longeravailablefor variousreasons,the lookupservicediscardstheproxy. It is up to the servicehow to implementandhow to handout the leases.The leasehasto implementtheLease interfacewhich only definesmethodsto cancelor to renew a lease.The lookupservicefor examplehandsout theleasesvia theServiceRegistration anditsgetLease()method.Therenewalof leasesis a standardtaskwhich canbe doneby a LeaseRenewalManager. Aclient only hasto instantiatetheLeaseRenewalManager usingtheleaseasoneoftheconstructor’sarguments.

3.2.6 RemoteEvents

In general,eventscanbeusedfor asynchronouscommunication.For example,a userinteractswith a GUI asynchronously. If theusersclicks on a button,aneventwill begeneratedanddependingon the implementation,oneor morepartieswill benotified.In the local case,theeventsareorderedandthenotificationis guaranteed,whereasinthe remotecasea partial failure canoccur, i.e. a few eventsget lost or the orderingis not guaranteed.Therearealsosomeotherproblemswhich canpartly be fixed butonly with lossof performance.Jini providesa very generickind of events,i.e. onlyone type that canbe extended:RemoteEvent. A client that needsnotificationofeventshasto implementtheRemoteEventListener interfacewhich only definesthe notify() methodwhich the client hasto implement. Then it hasto registeritself on theservicewhich returnsanEventRegistration objectwhich containsthe leasefor the notification amongother things. Every time an event occurs,thenotify() methodwill be called. For example,the VCR serviceregistersitself ontheTV serviceto benotifiedif theTV servicehasbeenshutdown.

18

Page 20: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

3.2.7 Transactions

Jini alsodefinesa two phaseprotocolfor transactions.A transactionis a collectionofmorethanoneactionthat arelogically performedatomic,i.e. all actionssucceedornone.TheinterfaceTransaction providesthemethodsabort() andcommit()thatmustbeimplementedby everyclient thatperformsona transaction.A centralizedtransactionmanager- a Jini transactionmanagerserviceis includedin the package-callstheabort() methodif oneof theclientsfailed,or callsthecommit() methodif all clientssucceeded.

19

Page 21: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

Chapter 4

Java Security

This approachis basedon thesecurityfeaturesof Java. Securityis a big issuein Javabecauseit supportsdynamicloadingof codeovertheInternet.ThatmeansJavaappletswhich couldrun in a client browser, aredownloadedby a server in theInternetwhichcouldbemalicious.ThereforeJava hasto provide securityfeaturesto prevent thatanunknown appletexecutesmaliciouscode.

4.1 Security in older JDK Versions

With thefirst versionof Java (JDK1.0),SunintroducedtheSandboxmodel,in whichdownloadedcodehasnoaccessto any securityrelevantresources(figure4.1). JDK1.1extendedthe Sandboxmodel with the signing of code. A classfile and its digitalsignaturewill be checked at client side. If the signerof the codeis trustedand thesignaturecouldbeverified, theappletgetsthesamepermissionslike a local class.Ifthe signerof the codeis not trustedor the signatureis not valid, the appletwill beexecutedin theSandbox(figure4.2).

Sandbox

Res. IIIRes. IIRes. I

JavaApplet

JavaApplication

Figure4.1: SecurityModel JDK1.0

20

Page 22: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

Sandbox

Res. IIIRes. IIRes. I

untrustedJava

Applet

JavaApplicationor trusted

Java Applet

Figure4.2: SecurityModel JDK1.1

Res. IIIRes. IIRes. I

Java Appletor Application(URL, signers)

Java Appletor Application(URL, signers)

Figure4.3: SecurityModel JDK1.2

4.2 Security in JDK1.2

JDK1.2introducedfinegrainedaccesscontrolto all securityrelevantresources.It usesPermission classesandsubtypesof it to representthe rights to accessa resource,e.g. new FilePermission ("c:\config.sys", "read") representsthepermissionto accessthefile c:\config.sys for readingonly . Thesepermissionscanbe grantedon the basisof the codebase,by whom the codeis signedor withoutany restrictions(figure4.3).ThatmeanstheSandboxmodelandtheexplicit distinctionbetweenlocal anddownloadedcodeis no longerneededbecausethe functionalityofthe older modelsis a subsetof the new one. A key storeis usedto storethe privatesigningkeys andthecertificatedpublic verifying keys for digital signatures.To spec-ify wherethe key storeis locatedandwhich permissionsaregranted,a policy file isusedwhich canbean argumentto theJVM or referencedby the default securityset-tings.Thepolicy file itself is anASCII file whichcontainsthelocationof onekey storeandmultiple permissiongrantingentries.A simplifiedgrammarfor thosepermissiongrantingentriesis:

grant [codebase url] [signedby signers]{{permission}*

}

21

Page 23: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

Res. IIIRes. IIRes. I

Java Appletor Application(URL, signers,

Subject)

Java Appletor Application(URL, signers,

Subject)

Figure4.4: SecurityModel JDK1.3

Theanalysisof sucha policy file is doneby theJVM, sothat theuseronly hastospecifythepolicy. Theprogrampolicytool providesaGUI for simpleeditingof apolicy file. Certificatesandprivatesigningkeysarestoredin a key store.Anotherpro-gramkeytool providescommandline accessto thekey store.A programmaticallyaccessis providedby instantiatingaKeystore objectthatallowssigningobjectsandverifying digital signaturesat runtime. The commandline programjarsigner isusedto signclassfiles insidea jar file. A jar file is anarchive which containsclassesandotherfiles.

Theinternalpermissioncheckis very sophisticated,but alsotransparentto theau-thenticationarchitecture,sothattheseinternaldetailsareskippedhere.

4.3 Security in JDK1.3 basedon JAAS

Grantingpermissionsin JDK1.2 is basedon wherethe codeis from andwho signedthe code. Java AuthenticationandAuthorizationService(JAAS) is a standardexten-sionto theJDK1.3. JAAS extendstheJDK1.2conceptby grantingpermissionsbasedon which behalfthecodeis executed(figure 4.4). It alsocontainsmodulesto log ontheuser. JAAS is basedon thePluggableAuthenticationModules(PAM) frameworkwhich definesanAPI for applicationsto log on users.Thus,everyapplicationcanusethePAM framework whichcanbeconfiguredby anadministrator. Consequently, PAMis independentof which applicationusestheauthenticationmechanismsandconfigur-ing theauthenticationpolicy canbedoneseparately. Next, theconceptsof JAAS willbedescribedmorein detail:SubjectsandPrincipals.

4.3.1 Subjectsand Principals

Subjects andPrincipals areusedto representthe identity of a userandits lo-gin names.ThedistinctionbetweenSubjects andPrincipals is very importantbecausea real life personcanhave differentlogin namesfor differentservices.Thatmeansthata real life personhasa collectionof differentlogin names(figure4.5). InthatmannerPrinicipal is defindedas:

public interface Principal{String getName();...

22

Page 24: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

}

Thenameof thePrincipal canbe interpretedasa login name.As mentionedabove, a Subject is a collectionof Prinicipals which canalsoincludeprivateand public credentials,e.g. public certificatesor Kerberostickets. Accordingly, aSubject containsall thedatathata userneedsto log on:

public final class Subject{Set getPrincipals(){};Set getPrivateCredentials(){};Set getPublicCredentials(){};...

}

Theprivateandpublic credentialscanbeany JavaObject andthereforethey arenot typed.Credentialscanbeused,but in many situations,they arenot needed(figure4.5).

PAM demandsthat the login procedureis independentof the authenticationtech-nology, i.e. whichauthenticationisused.For thatpurpose,JAAS definesaLoginContextandaLoginModule.

A LoginModule representsoneauthenticationtechnology, e.g. usernamepass-word authentication(figure4.5). Everyauthenticationtechnologymustimplementthetwo phaseprotocolsimilar to thetwo phasetransactionprotocolusedby Jini’s Trans-actionManager:

public interface LoginModule{boolean login();boolean commit();boolean abort();boolean logout();...

}

Theregularsequenceis:

1 executionof theauthenticationtechnologyusinglogin()

1 committheresultusingcommit()

1 cleanupthesystemafterlogoutusinglogout()

Thissequencecanbeinterruptedatany time,callingabort(). Callingabort()or logout() shouldclearall confidentialdatathatarecurrentlystored.On this ac-count, all confidentialdatashouldbe storedin primitive datatypes,e.g. char[],becausethevaluesthey storecaneasilybeoverridden.

Thecentral“transactionmanager”in this scenariois theLoginContext. It co-ordinatesthe login procedureby usingmultiple LoginModules andcalls their ap-propriatemethods:

public class LoginContext{LoginContext(String, CallbackHandler){};Subject getSubject(){};

23

Page 25: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

void login(){};void logout(){};...

}

To performa login session,thefollowing stepshave to beexecuted:

1 instantiationof aLoginContext

1 calling its login() method

1 if login() returns,getSubject() canbecalled

1 in theendlogout() shouldbecalled

If aSubject hasbeenreturned,i.e. no exceptionwasthrown, e.g. thepasswordwas wrong or the user is unknown, the authenticationhasbeensucceededand theSubject representstheauthenticateduser. But a few topicsarestill unsettled.WhichLoginModules areused?How doestheLoginModule‘s interactwith the user?And at least,how is authorizationachieved?

JAAS providesastackableauthenticationframework. ThatmeansmultipleLoginModulescanbe specifiedin a login policy file (figure 4.5). The grammarfor oneentrycalled“name” in thepolicy file is:

name{{package.LoginModule flag [options]}*

};

Thenameis alsogivenasanargumentto theconstructorof theLoginContextwhichusesit to lookuptheLoginModulessin theloginpolicy file. Multiple LoginModuleincludingtheir packagenamecanbespecified.A flagcanbe

1 REQUIRED - if theLoginModule fails, theoverall login procedurefails andtheremainingLoginModuleswill beprocessed,

1 REQUISITE - if theLoginModule fails, theoverall login procedurefails andtheremainingLoginModuleswill not beprocessed

1 SUFFICIENT- if theLoginModule succeeds,theoverall login succeedsandtheremainingLoginModuleswill not beprocessed

1 OPTIONAL - if theLoginModule succeedsor fails, theoverall login doesnotdependon it andtheremainingLoginModuleswill beprocessed.

If oneof theprocessedREQUIRED or REQUISITE modulesfails,theoverall loginprocedurefails. If noneof thosemodulesare specified,at leastone SUFFICIENTor OPTIONAL must succeed. CombiningLoginModule‘s with thesefour flags:very sophisticatedlogin schemescan be built. (Note: if only oneLoginModuleis specified,is doesnot matterwhich flag is used,but it is recommendedto usetheREQUIRED flagbecauseif thelist maybeextended,no securityholecanarise.)

Thelogin policy file canbespecifiedstaticallyin theJava securitysettingsor asacommandline argumentto theJava interpreter:

-Djava.security.auth.login.config=login.config.file

24

Page 26: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

Next, the userinteractionwill be focused,e.g. promptingfor a user-nameandapassword. JAAS usesthe callbackmodel. That meansa CallbackHandler (fig-ure 4.5) hasto be instantiatedwhich handle()‘s Callback‘s, instantiatedin theLoginModule. TheCallbackHandler is thesecondargumentof theLoginContext’sconstructor.

TheCallbackHandler definesonly onemethod:

public interface CallbackHandler{void handle(Callback[] callbacks)

}

Callback is an interfacewhich definesno methodsso that it is only usedasmarker and for type safety. A LoginModule can call the handle() methodoftheCallbackHandler with anarrayof Callback‘s which will beperformedbytheCallbackHandler. To build a user-namepassword authenticationmodule,thepredefinedNameCallback andPasswordCallback canbeused.

As mentionedabove,if theauthenticationproceduresucceeds,aSubject will bereturned.ActionsthatneedauthorizationmustimplementthePrivilegedActionorPrivilegedExceptionAction interface,dependingonthrowinganexceptionis required. Theseinterfacesonly definetheObject.run() method. To performthataction,thestaticmethodSubject.doAs() will beinvoked,with theSubjectandthePrivileged{Exception}Action asarguments.ThedoAs() methodperformsa lookup in an extendedpolicy file if the givenSubject hasgot the per-mission,while it is executingtherun() methodof thePrivilegedAction. Thatalsomeansthatall thecodethatneedauthorization,mustbeput in therun()methodofaPrivilegedAction object.

grant [Codebase url,][Signedby signers,]{Principal package.PrinicipalImpl name,}*{

{permission_entry}*}

If multiplePrincipalsarespecified,theSubjectmustcontainall thePrincipals.This policy file thatextendstheJDK1.2policy file, canbestaticallystatedin theJavasecuritysettingsor givenasacommandline argumentto theJava interpreter:

-Djava.security.auth.policy=auth.policy.file

4.3.2 Summary of the JAAS Concepts

A Subject representsa user. It containsPrincipals which representsthe userslogin names.In an extendedpolicy file canbe specifiedwhich Principals a usermusthaveat least,sothataPermission canbegranted.

TogetaSubject, aLoginContextmustbeinstantiatedwith aCallbackHandlerandthe nameof a login policy which is specifiedin the login configurationfile. De-pendingon thelogin policy, multipleLoginModule which representsanauthentica-tion techniquewill beinvokedwhichin turninvokestheCallbackHandler for userinteraction.If thelogin succeeds,aSubject will becreated,otherwiseanexceptionwill bethrown.

25

Page 27: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

Subject

LoginContext

Set

Cal lbackHandler

LoginConfig

File looks up

retu

rns

Pr incipal

LoginModule

invokes

Credentials

Set

inte

ract

sw

ith

invokes

Figure4.5: JAAS ConceptsandClasses

To performanauthorizatedaction,theSubject.doAs() hasto beinvokedwiththeSubject andthePrivileged{Exception}Action. ThedoAs() methodcallstherun()methodandchecksthepermissionsduringtheexecutionof therun()method.

4.4 SignedCodein Java

A commonproblemof dynamicallyloadedcodeis the unawarenessif the codedoeswhat it is expectedto do, especiallydoesnot performany maliciousactions,e.g. for-mattingtheharddisk. For thatpurposeJavausesdigital signatureof code.

In this architecture,two assumptionaremadeaboutsignedcode:

1 thesignerof thecodekeepsits privatesigningkey secret.

1 thesemanticof signingcodeis thatthesignerguaranteesthatusingcodesignedby itself doesnot leadto any disadvantagesfor theuser, e.g. transmittingsecretdatawithoutencryptionover insecurechannelslike theInternet.

Theseassumptionsarealsomadeby Java for downloadedcode.This implies thattheuserhasto trust thesignerandhasto verify thetruthfulnessof thecertificatethattheuserutilizesto verify thedigital signatureof thecode.

It is upto bothparties,how theusergetsthecertificatefrom theowner. It is alsoupto theuserif hetrustsa self-signedcertificate.In thatcase,thecertificateis only usedasa containerfor thepublic key. It is alsopossibleto askfor thatthecertificatehastobesignedby a trustedCA.

Theseboth assumptionsabove doesnot overloadthe currentsemanticof signedcode. It is exactly the way Java intendssignedcodeto be interpreted: a negativesemanticthat sayswhat the codedoesnot do. It is not a positive semantic:thereisno notion,whatthecodeis exactlydoing.Thisfits perfectlyto thearchitecture,wheretheauthenticationprocedureis transparentto theclient. If authenticationis used,andtheusertruststhesigner, thecodeis expectedto do no maliciousactionswhich couldharmtheusersinterests.

26

Page 28: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

Theuserhasto do two thingswhich healsohasto do if heusesJini serviceswith-out authenticationbecauseunsignedcodefrom theInternetis in generalnot trustable.He hasto setupthe JDK1.2-stylepolicy file andhasto grantappropriatepermissionsonly to signedcodewhich is signedby a trustworthy entity. He alsohasto put thecertificateinto the default Java key store. The default location of the key store isfile:/userhome/.keystore. keytool is a commandline programfor thatpurpose.

4.4.1 Example

Suppose,the file johncert.cer containsa certificatefrom JohnSmith which theuserwantsto put into thekey storeusingthealiasjohn. First,hehasto makesurethecertificatecanbetrusted:

> keytool -printcert -file johncert.cer

keytool printsthefingerprintof thecertificateamongotherthingswhichtheusercanvalidate.If thefingerprintis valid, hecouldimport thecertificate:

> keytool -import -alias john -file johncert.cer

But beforea certificatecanbe importedat client side, the certificateandthe as-signedprivatesigningkey mustbegeneratedat serviceside,alsousingthecommandline programkeytool:

> keytool -genkey -alias john -keypass 123456

Thekeypass argumentspecifiesa password that is only usedto checkthe in-tegrity of thekey store. If theprogramis started,a dialogasksfor someinformation,like name,organization,etc. It alsopromptsfor a password for thekey. Whereasthispasswordis usedto encrypttheprivatekey. If returnis pressed,thesamepassword likefor the key storeintegrity is used. A usershouldbe very careful. If an attacker getstheprivatekey andtheassociatedcertificatehasbeenissuedby anpublicauthority, theattacker cansigncontractsinsteadof theauthoriziateduseror cando othermaliciousactions.

A policy file couldlook like:

keystore "file:/${user.home}/.keystore", "JKS";

grant signedBy "john"{permission java.security.AllPermission "", "";

};

grant{permission java.net.SocketPermission "*:1024-","connect,accept";

};

In thisexamplethedefaultkey storeis used.Only codethatis signedbyjohn, i.e.it is thealiasfor thecertificatein thekey store,is grantedtheAllPermission. Thelastgrantingentry is specifiedbecauseotherwisetheclassloaderusedby RMI cannot

27

Page 29: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

be instantiated.It is not insightful, why this grantentry is needed.Java coreclassesneedno permissionsandif all classes,which areused,would besignedby john, thelastgrantentryis still needed.

Usingsignedcodeasdescribedabove,theJVM detectsif thecodehasbeenalteredduring the transmission. It also detectsif an entity, who is not trustedregistersorre-registersa serviceon thelookupservice.

4.5 Java Cryptography Ar chitecture

TheJavaCryptographyArchitecture(JCA)providesseveralclasseswhichmakeit pos-sible to encryptanddecryptJava objects.All theclassesthatareneededfor thatpur-poseareintroducedin thenext sections.Theclassesneededfor encryptionareshownin figure4.6.Figure4.7givesanoverview aboutall signaturerelevantclasses.

4.5.1 Cipher Object

Theencryptionanddecryptionis doneby theCipherobjectin theJCA:

class Cipher{static final Cipher getInstance(String, String){};final void init(int, Key){};final byte[] doFinal(byte[]){};...

}

In general,every objectin theJava CryptographyArchitectureis instantiatedvia afactory. Thatmeansa cryptographyprovider hasto beregisteredwith theJVM. Thiscanbedonestaticallyin theJava securitysettingsor dynamically:

Security.addProvider(provider);

If an instanceof a cryptographyclassis needed,the mostcommonway is to callthestaticgetInstance() methodwith thealgorithmnameandtheprovider nameasparameter, e.g.

Cipher cipher = Cipher.getInstance(‘‘DES’’, ‘‘SUNJCE’’);

The provider is optional. If noneis specified,the first provider in the providerhierarchyis taken. Thehierarchyis a priority list of providers,wherebyit is possibleto specifythe priority of eachprovider. The default behaviour is thata new providerwill beaddedto theendof thelist.

This architecturedoesnot dictateto usea specificprovider. It is recommendedtousea nonUS cryptographyprovideroutsidetheUSA, becausecryptographyproductsareexport restricted.Algorithmsaresuggestedby thearchitecture.It is not obligatoryto specifythealgorithms,they couldalsobenegotiatedduringruntime.But specifyingthe algorithmsmakesit is easierto switch to anotherprovider becausethe minimumsetof to besupportedalgorithmsis known.

Thesuggestionfor thealgorithmusedby theCipherclassis DES,usingthedefaultvaluesfor modeandpadding.Themodespecifiesvariantsof theDESalgorithm,e.g.how the blocksareordered. DES is a block orientatedalgorithm. That meansthat

28

Page 30: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

not thewhole input is encryptedat once,but block by block. Thedefault valueis theElectronicCodebookMode(ECB).Paddingmeans,how missingbits in thelastblockarefilled. Thedefault is PKCS5Padding.

Thenext stepis to initialize theCipherobject.Thereareseveralways,wherebythemostcommonway is to usetheinit() methodwith modeandsecretkey asparameters.ModecanbeENCRYPT_MODE orDECRYPT_MODE. Toencryptordecryptdata,whichhave to be a byte array, the methoddoFinal() is calledwith the dataasargument. Itreturnsthetransformedbytearray.

4.5.2 SealedObject

Handlingbytearraysis notverycomfortableif objectsareused.For thatpurpose,JCEprovidestheclassSealedObject:

class SealedObject implements Serializable{SealedObject(Serializable, Cipher);final Object getObject(Key);...

}

Theconstructorexpectsaserializableobjects,becauseonly byte[] canbeencryptedanda initializedCipher objectfor encryption.After instantiation,theobjectcanbetransmittedconfidentialityoveraninsecurechannel.Ontheotherside,only themethodgetObject() with thecommonsecretkey hasto becalled. TheSealedObjectdecryptsanddeserializesthedataandreturnstheoriginalobject.

4.5.3 KeyAgreement

Cipher andSealedObject provide a very simpleway to exchangeJava objectsoveraninsecurechannelwith confidentiality.

But onepremiseis that both partiessharea commonsecretkey. Therefore,thesecretkey is veryoftenasessionkey, it mustbeexchangedoverasecurechannelor hasto encryptedasymmetrically. A betterapproachis to usea key agreementalgorithm.Both sidesgeneratea pair of privateandpublic keys for thekey agreementalgorithm.They exchangetheir public keys andgeneratewith their own privatekey andpublickey from theothersidethesamesecretkey.

class KeyAgreement{static final KeyAgreement getInstance(String, String){};final void init(Key);final Key doPhase(Key, boolean);...

}

Theusageis straightforwarded.First thegetInstance() methodis calledtogetaninstance,thenthemethodinit() is called,with theown privatekey. Depend-ing on thealgorithmused,thedoPhase() methodis calledasoften,astheprotocolrequires,theboolean valueindicatesif thelastphasehasto beperformed.

29

Page 31: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

Mac

KeyAgreement KeyPairGenerator

Cipher SealedObject

SecretKey

privateDH Key

publicDH Key

generatesgenerates

uses

uses

generates

uses

uses uses

uses

Figure4.6: EncryptionClasses

4.5.4 KeyPairGenerator

To createthekey pair, theKeyPairGenerator is used:

abstract class KeyPairGenerator {static KeyPairGenerator getInstance(String, String);void initialize(AlgorithmParameterSpec);final KeyPair genKeyPair();...

}

First, theinstanceis createdby callinggetInstance(), thenit hasto beinitial-ized with someparameterwhich the algorithmneedsandat leastthe key pair canbecreatedby calling genKeyPair(). KeyPair is only a containerclassthat storestheprivateandpublickey.

4.5.5 Usageof the Diffie Hellman KeyAgreementAlgorithm

As mentionedabove,thearchitecturesuggestsadefaultalgorithm.Thekey agreementalgorithmsuggestionis theDiffie Hellmannkey agreementalgorithm(DH) whichusesDiffie Hellmankey pairs(DH). Theparametersneededto generatethekeys- exponentandmodulus- arepregenerated,public andtakenfrom SunsDiffie Hellmanexampleprogram.DH is a onephaseprotocol,sothat thedoPhase() methodhasonly to becalledoncewith trueasargumentbecausethefirst phaseis thelastphase.

30

Page 32: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

Using DH preventspassive attackers from decryptthe data. However, an activeattacker couldstarta manin the middleattackby creatingits own privateandpublickeys, interceptsthepublic keysof bothpartiesandgivesthemhis publickey.

But thiscouldeasilyprohibitedby usingthedigital signaturewhichwasintroducedin chapterbefore. As mentionedabove, the serviceconsistsof two parts: theserviceproxy andtheservicebackend.And theserviceproxy hasto make surethat thecom-municationbetweenitself and the backendis confidentialand integer. If the publickey of theservicebackendis digital signed,theproxy candetectif therewasanactiveattacker, whoalteredthepublickey or exchangedit with its own. In theotherdirectionno digital signatureof thepublic key needed.After theclient verifiedthesignatureofthepublic key from theservicebackend,heis ableto generatethesecretkey. Thenhetransmitshis unsignedpublic key with alreadyencrypteddatato theservicebackend.If thereis anacticeattacker betweenboth,hecannotencryptthedata,becausehehasno notion aboutthe secretkey. The public key from serviceproxy is uselessfor it.Manipulatingthe public key or the encrypteddatawould be detectedby the servicebackend. The only thing is thathe is ableto generatehis own public key, encryptitsown dataandsendthatto theservicebackend.Thissituationis not dangerousbecausethat is equivalent for servicebackend to the situationthat the regular serviceproxyneverwantedto log onandtheattackerasksfor anormallog on thatis of course,whattheservicebackendis for.

4.5.6 SignedObject

It is very important to notice the differencebetweenthe signing of static codeanddynamicallydata. If the serviceproxy is digitally signedandcontainsa public keythat wasgeneratedat runtime, the public key is not signed,only the codeis signed.The explanationis very simple: the codewassigned,beforeit wasexecutedthe firsttime usingthejarsigner commandline program. The public key wasgeneratedafterwardsduring runtime. So it hasto be signedexplicitly during runtime. There-fore, the Java CryptographyArchitectureprovidesa SignedObject that is akin toSealedObject. Thedifferenceis thataSealedObject guaranteesconfidentialtyandaSignedObject guaranteesintegrity:

final class SignedObject{SignedObject(Serializable, PrivateKey, Signature){};boolean verify(PublicKey, Signature){};Object getObject(){};

}

4.5.7 Signature

To signanobject,it hasto bethefirst argumentof theconstructor. Theotherargumentsare the privatekey and the signingenginethat usesthe privatekey and the signingfunctionto computethesignature:

abstract class Signature{static Signature getInstance(String, String){};initSign(PrivateKey){};initVerify(PublicKey){};final int sign(byte[], int, int){};

31

Page 33: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

final boolean verify(byte[]){};...

}

Thedeveloperonly hasto instantiatetheSignature classanduseit asargumentto theconstructorof SignedObject, resp. theverify() method.Thealgorithmsuggestionis theSHA1withDSA algorithm. ThatmeanstheSecureHashAlgorithmthat first hashesthe input andDigital SignatureAlgorithm computeson it the digitalsignature.

4.5.8 Keystore

jarsigner, thecommandline program,usesthekey storeto retrievethekey neededfor signingandtheJVM usesit to retrievethekey for verifying. Thetooljarsignerandthe JVM useinternally the classKeystore to accessthe proprietarykey storefile. Thesamecanbe doneby a developer. That meansto sign andverify the publicDH key, noextra datais necessary. Only thealreadygiveninfrastructureis used.

class Keystore{static Keystore getInstance(String, String){};final void load(InputStream, char[]){};final Key getKey(String, char[]){};final Certificate getCertificate(String);...

}

Consequently, thesamedesignpatternis usedto getan instanceof a Keystoreclass,usingthegetInstance() methodwith key storetypeandprovider asargu-ments.Thesuggestionis to usethestandardJava formatJKSbecauseit is partof theJDK distribution. To retrieve thekey storedata,thefile hasto beloadedvia load()andanInputstream that readsthe file anda key storepassword. This passwordis only usedto checkthe integrity of thekey store. If no password is given,no checkwill beperformed.At servicebackendside,thepublicDH key hasto besigned,sotheprivatesigningkey hasto beretrievedfrom thekey storevia thegetKey() method,whereasthe aliasof the entry anda password for the key are the argumentsto thatmethod.Thepassword for thekey is requiredbecausethekey is storedpassword en-cryptedin the key store,therefore,to encryptthe key, the password is needed.Onserviceproxy sidetheCertificate andtheincludingpublic verifying key have toberetrieved.ThegetCertificate() methodonly needsthealiasnameof theen-try becauseacertificateis publicandthereforedoesnotneedto betreatedconfidential.

4.5.9 MAC

The last cryptographyconceptthat is usedby theJCA, is the messageauthenticationcode. It is importantto notice that encryptiondoesnot guaranteeintegrity. It onlyguaranteesconfidentiality. If anactiveattackermanipulatesanencryptedmessagethatcontainsa serializedJava object,it is not likely that theresultis a valid classbecausetheattacker hasno notionaboutwhat is theresultof his manipulation.But it is muchmore likely that a valid classarisesafter deserilizationof the alteredencrypteddatathanfinding the secretkey. For example,the attacker knows the positionof a fieldin the serializationstreamthat is encrypted. Only manipulatingthis location leads

32

Page 34: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

SignedObject

KeyStore

Signature

Certif icate

publicverifying

Key

privatesigning

Key

stores

cont

ains

stor

esus

es

uses

uses

Figure4.7: SignatureClasses

to a differentfield value. In a bankenvironment,wherethe correctnessof valuesiscrucial, integrity mustbeachieved. A simpleapproachwould be to sign thedatabutthentwo problemsarose. First, asymmetricoperationsarevery time consuming,sothis would pervert the useof symmetricencryption. Another lack is that the servicebackend would also needto storecertificates. Using messageauthenticationcodes(MAC) solvesbothproblems.They arecomputinghashvalueson the input usingthesecretkey asparameter. Thatmeansit is a fastsymmetricoperationandthereforenoextra certificatesareneeded.In addition,the secretkey generatedfor the symmetricencryptioncanalsobeusedto computetheMAC.

class Mac{static final Mac getInstance(String, String){};final void init (Key);final byte[] doFinal(byte[]);...

}

As shown many times,thegetInstance() methodsreturna new instanceof aMac object.Algorithm andproviderhave to bespecified.Thesuggestionis to usetheHmacMD5 algorithm.Callinginit() with theexistingsecretkey initializestheMacobject. doFinal() computesandreturnsthe MAC asbyte array. The input mustbe a byte array, too. In this situation,no wrapperclassexists, like SealedObjector SignedObject, so it is a good idea to develop sucha class. The benefitsof

33

Page 35: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

thosewrapperclassesarethattheserializationanddeserializationprocessis transparentandthatthey performthecomputationandverificationautomatically. Theverificationhasto be doneby computingthe MAC on receiverssideandcompareit to theMACattachedto themessage.

4.5.10 Summary

Thissummarygivesanoverview of all usedkeysandclasses.Following keysareused:

1 privatesigningkeys,storedin thekey storeatservicebackendside,usedto signstaticcodeandthedynamicallydata,createdalongwith thecertificatewith thecommandline programkeytool atservicebackendside,

1 self-signedcertificatecontainingthepublicverifying key, storedin thekey storeat client side,usedto verify signedcodeanddynamicallysigneddata,createdtogetherwith thecommandline programkeytool at servicebackendside,

1 privateDH key, createddynamicallyalongwith thepublicDH key onbothsides,storedlocally, neededfor creationof secretkey,

1 publicDH key, createddynamicallyalongwith theprivateDH key onbothsides,servicebackendsignsit andputsit in the serviceproxy, serviceproxy sendsitunsignedto theservicebackend,

1 secertkey, createddynamicallyon bothsideswith theown privateDH key andtheotherpublic DH key, usedto encryptanddecryptdatasymmetricallyandtocomputea MAC.

Following classesof the java.security andjavax.crypto packagesareused:

1 Cipher, usedto encryptanddecryptdata,needsthesecretkey for initialization;inputandoutputarebytearrays,

1 SealedObject, usedto encryptanddecryptJavaobjects,needsaserializableobjectandaCipher objectfor encryption,needsthesecretkey for decryption,

1 KeyAgreement, usedto computeasecretkey thatisonly knownby two partiesoveraninsecurechannel,needstheown privateDH key andtheotherpublicDHkey,

1 KeyPairGenerator, usedto generateapair of publicandprivatekeys,usedhereto generatetheprivateandthepublicDH key,

1 Signature, usedto computeandto verify adigital signature,needstheprivatesigningkey or thepublicverifyingkey for initialization,inputandoutputarebytearrays,

1 SignedObject, usedto sign andverify signatureson Java objects,needsaserializableobject,theprivatesigningkey andaSignature objectfor signing,needsthepublicverificationkey andaSignatureobjectfor verification,

34

Page 36: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

1 Keystore, usedto storeandretrieveprivatekeysandpubliccertificatespersis-tently, needsanInputStream andoptionalakey storepasswordfor initializa-tion, needsan aliasto retrieve public certificatesandprivatekeys, whereaslastoneneedsa password obligatory, usedhereto storetheprivatesigningkey andthepublicverifying key insideacertificate,

1 Mac, usedto guaranteethe integrity of a message,needsthesecretkey for ini-tialization,usedhereto guaranteetheintegrity of theencrypteddata.

35

Page 37: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

Chapter 5

High Level Overview of theAr chitecture

This chapterprovidesa high level overview of thearchitecture.It startswith thehigh-lights, followedby thegoals.Thenthearchitectureandtheircomponentsareshown inthenext two sections.

5.1 Highlights1 Built on standardoff theshelfJava technology:JAAS 1.0,JDK 1.3,JINI 1.0.1,

JCE1.2.1,JavaCard2.0

1 Transparentto theClient: existing clientsdo not haveto bemodified

1 Minimal overheadat serverside

1 Powerful Login Policiesallow flexible authenticationschemes

1 SecurityInfrastructurebuilt asJini services

1 First prototypeupandrunning,includessmartcardauthentication(Java Ring)

1 Authorizationmechanisms(JAAS 1.0+ JavaSecurityArchitecture)

5.2 Goals

Thesystemwasdesignedwith thefollowing goalsin mind:

1 ServiceAuthenticationandAuthorization

1 Definitionof differentLogin Policies

1 ClientTransparency

5.2.1 Service Authentication and Authorization

Every servicehasto authenticateandauthorizeeachclient request.Theclient hastomakesurethatit is runningonly signedcodefrom atrustedsource.

36

Page 38: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

5.2.2 Login Policies

A usershouldinteractaslittle aspossiblewith thelogin infrastructure,thereforeasin-gle signon approachis usedwhereappropriate.Especiallyin thehomeenvironment,a usertypically doesnot wantto authenticatehimself if heturnson thelight.

The login policy shouldbe asflexible aspossible.Differentservicesin differentenvironmentscanspecify differentpolicies to log on the user. For example,a userat homecanturn on the lights without authentication,in his office he hasto enterauser-nameandpassword andon theInternethemayhave to authenticateusinga JavaRing.

5.2.3 Client Transparency

Thesecurityinfrastructureshouldbetransparentto theclient implementation.Existingclientsdo not have to bechangedin orderto usethesecurityinfrastructure.Theuserdoesnothaveto specifytheauthenticationmethod,thiswill bedeterminedthroughthelogin policy at runtimeby thesystem.

5.3 Ar chitecture

Next, it is reportedhow thesegoalswereachieved.Thisarchitectureconsistsof differ-entJini servicesthatimplementthesecurityinfrastructure.

5.3.1 Client

In orderto achieveclient transparency, all securityrelatedfunctionality is packedintotheserviceproxy. Theclientusesthepublishedinterfaceof theservice,asif it wereaninsecureservice.

5.3.2 Service Proxy and Service Backend

Upon servicediscovery, the client loadsthe appropriateserviceproxy from the Jinilookup-servicethatin turncommunicateswith theservicebackend.To provideprivacyandto preventreplay, weusesymmetricencryptionof thedata,messageauthenticationcodeandadda transactionnumber. The symmetricencryptionis achievedusingtheDiffie Hellman-Algorithm: the backendservicegeneratesits public andprivatekeys,theprivatekey remainsat thebackendservice,thepublickey will betransferredto theserviceproxy. After a proxy hasbeendownloadedby the client, the proxy generatesits own privateandpublic keys andwith its own privatekey andthebackends’publickey, it generatesthe symmetricsecretsessionkey and sendsits public key back tothebackend,sothat thebackendcangeneratethesymmetricsecretkey which will bestoredin a sessiondatabase.

Sincetheclient runsonly signedandtrustedcode,andthecommunicationbetweenserviceproxy and servicebackend is secureusing the mechanismdescribedabove,privacy is achieved and replayingand changingof databetweenthe client and theserver is prevented.

37

Page 39: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

5.4 The Componentsof the Security Infrastructur e

In thefollowing, it is describedhow authenticationandauthorizationcanbeachievedusingtheaboveinfrastructure.

1. Uponserviceinvocation,theservicebackendcontactsa Jini servicecalledSub-jectAuthenticatorServicewhich returnsaSubjectobjectintroducedin JDK 1.3/JAAS 1.0. It’s up to theSubjectAuthenticatorService,how to generatetheSub-ject. In thereferenceimplementation,we usedtheJAAS technology, becauseitis alreadyavailableandit is easilyextendibleto beusedin adistributedenviron-ment.

2. TheSubjectAuthenticatorServicegetstheinformationto which servicetheuserwantsto log onincludingthenumberof attemptstheuserhasperformedalready.With this informationtheSubjectAuthenticatorServicecontactsthelogin policydatabase:LoginPolicyDB. This canbea separateJINI serviceor canbebuilt-intheServiceAuthenticatorService.

3. The LoginPolicyDB returnsa LoginPolicy which specifiesa policy of how toauthenticatetheuser. Now theSubjectAuthenticatorServicecontactsa Remote-CallbackHandlerwhich wasinstantiatedby theserviceproxy at client side.De-pendingon thelogin policy, theRemoteCallbackHandlercanpromptfor a user-nameandpassword,or initiateevenmorecomplex authenticationschemes.

4. TheRemoteCallbackHandlermaycontactaJINI RingAuthenticationServicewhichin turn contactsa JINI BlueDotServiceto run a challenge-responseappleton aJavaRing, for example.

5. After the RemoteCallbackHandlerhasreceived the resultof the authenticationprocedure,theinformationissentbackto theSubjectAuthenticatorServicewhichcontactsa userdatabase,UserDB,which againcanbea JINI serviceor built-intheSubjectAuthenticatorService.6. TheUserDBchecksif all thedatais correctandreturnsthedataneededto build aSubject.BasedonthisdatatheSubjectAu-thenticatorServicebuilds theSubjectandreturnsit to theservice.

6. The servicefinally storesthe subjectin its context information and returnsatokento theserviceproxy, to beusedby theclient. This completestheAuthen-ticationprocedure.

7. To performactionsthatneedauthorization,theservicerunstheSubject.doAs()methodsfor theclient.

38

Page 40: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

Chapter 6

Ar chitecture

Chapter5 hasalreadyintroducedthemainconceptsof this architecture.This chapterprovidesa verydetailedlook at thearchitecture.

Both, interfacedescriptionandreferenceimplementationof that architecture,areundera GNU public license. Everybodyis welcometo extendthis architectureandmayalsocontacttheauthorsfor thatpurpose.

6.1 Approach

The approachof this thesisis to show how that securityarchitecturecanbe built ontop of theexisting Jini andJava environmentwithout changingit. Thethesisdoesnotcoverdenialof serviceattacksor to securea lookupservice,e.g.hidingservices.

It usesJava interfacesto describethe architecture.A referenceimplementation,which is programedagainsttheinterfacedescription,will beexplainedin chapter7.

6.2 Definition of Authentication and Authorization inthe Jini Envir onment

Authenticationandauthorizationhavealreadybeenintroducedin general.Thissectionadditionallyexplainstheseterms,how they areusedin thetheJini environment.

6.2.1 Authentication

Authenticationin theJini servicesscenariomeans,onbehalfof whichentitytheserviceexecutescode. An entity could be a real life person,a serviceor an appliance.Theauthenticationof a real life personis clear. It canalsobereasonableto authenticateaserviceor anappliance,e.g. a light switchclient only hasto authenticateitself to thelight servicebecauseit doesnot matter, who switchesthe light on or off. This doesnot meanthat no authenticationis required. Only a light switch in the sameroom,wherethe light is, shouldbeableto turn the light on or off, sothe light switchhastoauthenticateitself asthelight switchin thesameroom.

39

Page 41: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

6.2.2 Authorization

Authorizationin this scenariois built on top of theauthenticationprocess.Authoriza-tion meansto grantanauthenticatedentityonly restrictedaccessto resources,wherebyresourcescanbephysicaldevicesor logical permissions,e.g.accesstheTV screenorthepermissionto watchTV only weekdaysbetween3pmto 5pm.

6.3 General overview

Thegeneraloverview coverstwo aspects.First, it introducesthemoduleswhichthear-chitectureis built of. Second,it refersto thesections,wherethemodulesaredescribedin detail. Theoverview usesthetop down approach,whereasthebottomup approachis usedin thedetailedsection.

6.3.1 Common Jini schemes

TheJoinManagerdoesmostof theadministrationwork for a service.Thependantfora client is missing. Therefore,the section6.4 providesclassesthat doesthe admin-istrative work for a client: finding a serviceandvalidatingif the serviceis still alive.Theseclassesareindependentfrom the securityinfrastructureandcanbe usedin allJini environments.

6.3.2 Client Transparency

Jini providesseveralwayshow a serviceinvocationcanbe done. Themostcommonway is thata client requestsaserviceproxy from thelookupservice.Sincetheserviceproxy is a regular Jini objectandthe client knows at leastoneinterfacethat the ser-vice proxy implements,the client could locally invoke methodson theserviceproxy.Then,theserviceproxycontactstheservicebackendusingRemoteMethodInvocation.Client transparency meansthatthereshouldbeno changeto existing clientswhich re-questserviceproxies.Therefore,thesecurityinfrastructuremustbeput into theservicebackendandthe downloadableserviceproxy. Although no changeis requiredat theclient,a few securitysettingshave to bedoneat client side,this is describedin section6.5.

6.3.3 Service

Sincetheclientscontainno codeof thatarchitecture,all of it hasto take placein theserviceproxy andthe servicebackend. The detaileddescriptionof both partscanbefound in section6.11. If theserviceproxy is calledthefirst time by the client, it hasto start the authenticationprocess.Therefore,the serviceproxy hasto communicatewith its servicebackend. Sincethecommunicationhasto besecurein regardof con-fidentiality andintegrity, a securecommunicationchannelhasto beestablished.Moredetailsof how a securecommunicationchannelcanbe achieved in this environment,canbe found in section6.6. In general,a serviceproxy hasto register itself on itsservicebackendto establisha securecommunication.Theseclassesthatbuild on thesecurecommunicationchannelcanbefoundin section6.7.

40

Page 42: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

6.3.4 Authentication

Summarizingthepresentfacts:theclientsregularlycallsmethodsontheserviceproxy,theserviceproxy startstheauthenticationprocessby calling theservicebackendon asecurecommunicationchannel.

Now, theservicebackendcancontinuetheauthenticationprocessby invoking theSubjectAuthenticatorservice.This is thecentralservicewhich coordinatesthewholeauthenticationprocessat servicebackendside. Thedescriptionof thatservicecanbefoundin section6.10.3.

Login Policies

Sinceseveralauthenticationschemesexist andclientscanstarttheauthenticationpro-cessin differentdomainswith different level of trust, it is a goodway to specify apolicy of how to log on independentlyof the service.Therefore,the SubjectAuthen-ticator serviceconsultsthe LoginPolicyDB servicewhich returnsa login policy, seesection6.10.1.

RemoteCallback

Dependingonthelogin policy, theSubjectAuthenticatorservicecarriesout theauthen-tication. In mostcases,theSubjectAuthenticatorneedsuserinteraction,e.g.promptingfor a user-nameandpassword. Therefore,theserviceproxy hasalreadyinstalleda re-motecallbackhandleron client sidewhich is a regularRemote object. More detailsaboutthe remotecallbackhandlercanbe found in section6.9. The remotecallbackhandlercanperformdifferentauthenticationschemes,e.g. user-namepassword dia-log.

Java Ring Authentication

It is also possibleto perform an authenticationprocessusing a challenge-responseprocedureon a Java Ring. Therefore,the remotecallbackhandlerhasto invoke theRingAuthenticationservicewhich itself usesthe BlueDot servicewhich in turn doesthe communicationwith the Java Ring. Both servicesareregular Jini serviceswhichproxiesarerequestedby a lookupservice.Theservicesaredescribedmorein detail inthesections6.10.5and6.10.4.

Verification

In mostcases,thedatareturnedfrom clientsidehasto beverified,e.g.thepasswordortheresponse.Therefore,theSubjectAuthenticatorconsultstheUserDBservicewhichstorestheseinformationsandreturnstheinformationwhichareneededto completetheauthenticationprocess.MoreabouttheUserDBservicein section6.10.2.

6.3.5 ExchangingData

Theprevioussectionsmentionedthatservicesareinvokedandthatinformationarere-turned.Therefore,differentclassesareneededtoexchangedata,e.g.User,Password,LoginPolicy andsoon. All theseclassesaredescribedin section6.8.

41

Page 43: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

6.4 CommonClasses

Thissectionprovidessomeusefulinterfaceswhich canbeusedin differentcontexts.

6.4.1 ServiceFinder

interface ServiceFinder extends Serializable, DiscoveryListener{Object getProxy();

}

is the mostimportantinterfacehere. A classthat implementsthis interfaceis re-sponsiblethatgetProxy() returnsavalid serviceproxy. If analreadyfoundserviceproxy is no longervalid, e.g.theservicebackendis down, it hasto find anotherserviceproxy that matchestheServiceTemplate which canbe given asan argumenttotheconstructor. To testif aproxy is valid, theproxy shouldimplement:

6.4.2 Pingable

interface Pingable extends Serializable{void ping();

}

so thatServiceFinder cando thecheckby calling theping() method.Forcommunicationwith the backend,theRemotePingable interfaceshouldbe used.If no proxy is available,anException shouldbethrown insteadof returningnull.Thesemanticof getProxy() is thatit alwaysreturnavalid serviceproxy, otherwisetheclient couldnot regularly continueits program,soanexceptionhandlingmustbestarted.

6.5 Client side

6.5.1 Transparency

Onegoalof thisarchitectureis transparency for theclient. A few thingshaveto bedoneatclientside,but thisdoesnotaffect theclientcode.Thatmeansanexistingclient thatusesaninsecureservicewithout authenticationandauthorizationhasnot to bealteredto usea servicethatneedsauthenticationandauthorization.Both servicesimplementthesameprotocol.Thatmeanstheextra work, which is neededto performtheauthen-ticationprocedure,hasto bedonecompletelyby theserviceandtheinfrastructurethatis availableat serviceside.

TheJini conceptsprovide thefundamentalsto do this by splitting theserviceintothe serviceproxy and the servicebackend. The serviceproxy canbe seenasclientcodethat the client doesnot know at compilationtime, andit is linked dynamicallyduringruntime.Soeveryactionneededat clientsidecanbeput into theserviceproxy,becauseit is executedby theclient in its thread(figure6.1).

6.5.2 SignedCode

A dangeroussituationarisesif the client downloadsa maliciousserviceproxy. Thatmeans,theserviceproxiescontainsmaliciouscode,e.g.deletingfilesin theusershomedirectory.

42

Page 44: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

ServiceClient

Proxy

secureService

Client

secure Proxy

Figure6.1: SecuringaService

Independentlyof this securityarchitecture,every time codeis downloaded,it ispotentialmalicious. Therefore,only signedcodefrom trustedsourcesshouldbeexe-cuted.

Althoughtheclient codedoesnot needto bechanged,theuserhasto addtrustedcertificatesto his key store. Then,he hasto edit the policy file thatonly codethat issignedby trustedentitiescouldbeexecuted.

Thishasalwaysto bedoneindependentfrom this architectureis usedor not,sincethedownloadof theserviceproxy is theproblem.

6.5.3 Summary

Summarizingthefactsabouttheclient side:1 transparency for theclient thatmeansno changeto existing clients1 editingthepolicy file: grantingonly signedandtrustedcodepermissions1 addingtrustedcertificatesto thekey store

6.6 Secure Communication

6.6.1 Goals

First of all, thearchitecturalgoalsfor implementingtheauthenticationmoduleshouldbegiven,sothatthesecurecommunicationcanbedescribedwith thesegoalsin mind:

1 anauthorof a new servicewhich usesthatarchitectureshouldinteractaslessaspossiblewith theauthenticationmodule,

1 the communicationbetweenthe serviceproxy andthe servicebackendshouldfulfill integrity andconfidentiality.

6.6.2 Cryptography at Application Level

All thesefeatures,excludingtransactionnumbers,areprovidedby theJavaCryptogra-phyExtension(JCE).Currently, all theencryptionis doneon applicationlevel, soit isnotabsolutelytransparentto theservice,i.e. aminimalsetof methodshaveto invokedto dotheencryptionanddecryptionof thesentandreceiveddata.In thenext versionofthis architectureall theencryptionwork will bedoneon socket level by implementinganown SecureRMI SocketFactory, i.e. nospecialencryptionanddecryptionmethodshave to be called,sinceon socket level all thedatapassedthroughareencryptedanddecryptedimplicitly (figure6.2).

43

Page 45: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

(De-) Enrcyption explicit

(De-) Enrcyption implicit

Application

Socket

Service

Socket

Application

Client

Figure6.2: Cryptographyat Applicationor SocketLevel

Service Backend ProxySecKey

A

ProxySecKey

C

ProxySecKey

B

Secret Key A

Secret Key C

Secret Key B

Figure6.3: Managementof SecretKeys

6.6.3 LeasingContext Inf ormation

Beforetheinterfacesfor thesecurecommunicationcanbeintroduced,two dataobjectshave to be introducedfirst. It is likely thatoneservicebackendservesmorethanoneserviceproxy. Thatmeansin general,theservicebackendhasto servemultipleserviceproxies.Therefore,it hasto storecontext information.In this architecture,theservicebackendhasat leastto storethe secretkey usedfor decryptionof incomingdataandencryptionof outgoingdata,i.e. it usesimplicitly memoryto storedata(figure 6.3).TheJini philosophypretendsthatany resourceshouldonly beleasedfor awell-definedamountof time. Serviceproxiesmay crashor the network goesdown, so that theserviceproxy hasnot the chanceto logout andreleaseits context information. It isonly a matterof time, when all the memoryis exhausted. Doing the right thing isto leasethe context information. If the leaseexpires,the associatedresourcewill bereleased.

Cookiesand Tokens

Therefore,anobjectis neededto identify theresourceto thegrantorandanobjectthatrepresentsthe right to accessthe resource.The first is definedascookieandcanbepublic,whereasthesecondis definedastokenandmustbekeptsecret.Both conceptsareverygeneralsothey havea commonsuperinterface(figure6.4):

interface CookieToken extends Serializable{boolean equals(Object);int hashCode();String toString();

}

44

Page 46: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

Secret Key AToken Cookie

Secret Key AsecretToken

publicCookie

Secret Key AToken Cookie

Secret Key AsecretToken

publicCookie

Backend Proxy

Figure6.4: Managementof CookiesandTokens

All themethodsarealreadydefinedby everyJavaobject,becausetheoverallsuperclassis Object that providesthesethreemethods.They areexplicitly specifiedtomarktheirspecialmeaning.Objectsof this typeshouldbecomparable,e.g.theclientstokencanbecomparedto the referencetoken,they shouldimplementa collision freehashcodefunction,sothatthey canefficiently mapped,e.g.thecookiecanbemappedto the leasedresource.The toString() methodshouldreturna humanreadablerepresentation.Cookie andToken themselvesdo not specifyany furthermethods.They areonly usedfor typesafety, becausethesemanticis despiteof thesameinterfacedifferent.Two instancesshouldbedifferentconcerningtheequal() methodin spaceandtime. The implementationof Cookie andToken canbe the same,sincebothinterfacesextendCookieToken andprovideno furthermethods:

interface Cookie extends CookieToken{};interface Token extends CookieToken{};

Thedifferenceis only madebecauseof thedifferentsemantic.A cookierepresentsa resource,whereasthetokenrepresentstheright to usetheresource.

6.6.4 Cryptography at Socket Level in Future

In thefirst versionof thisarchitecture,thesecurecommunicationis handledatapplica-tion level. In thenext version,this shouldbedoneat socket level, usinganown secureRMI SocketFactory. All theconceptsshown in thefollowing canbemoveddirectly tothis level. Thebenefitis thetransparency of thesecurecommunication.In thisversionit hasto bedoneexplicitly.

6.6.5 Secure Parametersand Return Values

Independentof who are the entitieswhich communicate,methodshave to be calledremotely. Thatmeansoneentity is calling themethodandtheotherentityperformstheexecutionof thatmethod.In thefollowing theentitywhocallsthemethodis definedassecureclient. Theentity who executesthemethodis calledsecureslot provider. Thenamefor thefirst entityis clear, thesecondhasbeennamedthatway, becausein generala servicehasto serve severalclients,so it hasto storecontext information. They arelogically storedin a slot. If a client is calling a method,the client hasto specify inwhich slot its context informationcan be found, whereasthe result of an executiondoesnot needto specify a cookie on client side, becauseit is a 1 : n relationship.Thatmeansthereturnvalueof a securemethodinvocationis not thatcomplex asthe

45

Page 47: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

JavaObject

SecretKey

SealedM A C

Object

new SealedObject()

Figure6.5: SealinganObject

SealedM A C

Object

JavaObject

getObject()

SecretKey

Figure6.6: UnsealinganObject

argumentsgivento thatmethod.First, it hasto bedefinedwhattheinterfaceof asecurereturnvalueis andthenwhattheinterfaceof asecureargumentis.

SealedMacObject

interface SealedMacObject extends Serializable{Object getObject(SecretKey);

}

That meansa return value hasonly to return anotherJava object by calling thegetObject()methodwith asecretkey asargument.ThenameSealedMacObjectandtheuseof a secretkey impliessomeaspects,whattheimplementationis expectedto do. The object hasto be sealedthat meansguaranteeconfidentialityby the useof symmetricencryptionandguaranteeintegrity by theuseuseof aMAC. Both thingshaveto bedonetransparently. At instantiationtime,SealedMacObject hasto com-putetheMAC andto sealthegivenobject(figure6.5).WhereasgetObject() hastoimplementthereverseoperation,i.e. it hasto unsealtheobjectandto verify theMAC(figure reffig:unsealing)).If theverificationdoesnot succeed,anexceptionhasto bethrown. Thus,thesemanticof SealedMACObject is closeto SealedObject. Inaddition,it providesintegrity.

SealedCookieMacObject

As mentionedabove, a parameterhasalsoto includea cookie,so that the secureslotprovidercanretrievethecontext informationwith thecookie.Of course,theparameterhasto guaranteeconfidentialityandintegrity, too. Therefore,a secureparameterhasonly to extendSealedMACObject:

interface SealedCookieMacObject extends SealedMacObject{

46

Page 48: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

Cookie getCookie();}

andto returntheassociatedCookie.

6.6.6 SecureClient

Next, it will be describedhow the securecommunicationcanbe encapsulated,usingoneobjecton client andoneon secureslot provider side. The namesfor thosebothobjectsarestraightforwarded:SecureClient andSecureSlotProvider. Allthe following stepscanbe found in figure6.7. First, a look on theSecureClientinterface:

Interface Definition

public interface SecureClient extends Serializablepublic final static int FIRSTTRANSNUMB = 0;public final static String KEYAGREEALG = "DH";public final static String SECRETALG = "DES";public final static String MACALG = "HmacMD5";public final static String KEYSTOREALG = "JKS";public final static String KEYSTORENAME = ".keystore";public final static String SIGALG = "SHA1withDSA";public static final byte skip1024ModulusBytes[] = {...};public static final BigInteger skip1024Modulus =

new BigInteger(1, skip1024ModulusBytes);public static final BigInteger skip1024Base =

BigInteger.valueOf(2);

public final static int ACTIVE = 0;public final static int PASSIVE = 1;

SecretKey getSecretKey();PublicKey keyGeneration(PublicKey);

SealedCookieMacObject sealObject(Serializable);Object unsealObject(SealedMacObject);

void setCookie(Cookie);void setToken(Token);

}

All the constantsthat are mentionedabove, are definedhere. This includesthepublicparametersfor theDH algorithm:moduleandbase,too.

Activeand PassiveMode

SecureClient shouldwork in differentmodes.Theregularmodeis active,becausethe client calls methodsat the otherside,but it is also imaginablethat a oneto onecommunicationshouldbe established.In that caseno secureslot provider is needed

47

Page 49: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

andoneof thetwo partieshave to bethepassive partof thecommunication,whereastheotheroneis theactivepart.

Settingsin a 1:n Communication

If theSecureClient is instantiatedto securethecommunicationof aserviceproxy,thekey generationcannotbedoneat instantiationtime,becauseit is theonly instantia-tion which would beavailableby everyoneby regularlycontactingthelookupservice.Not until theserviceproxyhasbeendeserializedby theclient,thekey generationcouldtake place. It would bepossiblethat the servicebackendput its digital signedpublickey for the DH key agreementinto the serviceproxy. But then it hasto re-registertheserviceproxy every time its signaturekeys hasbeenchanged.Therefore,themostgeneralcaseis to exchangethekeysduringruntimeof theserviceproxy at client side.For thatreasonthekeyGeneration() methodhasto usethepublic DH key givenasargumentto performtheDH key agreementcompletelyon its sideandhasto storethe secretkey. The createdown public DH key hasto be returnedas result. Afterthemethodhasbeenexecuted,thesecureclient is readyto sealandunsealobjectsinacticemode.CookieandToken- that theclient hasto specify, so that thesecureser-vice provider canretrieve the context informationandcanensurethat the client hasthe right to accessthe context information- could not be set,until the leaserequesthassucceeded.For thatreasonsetCookie() andsetToken() areprovidedto setbothaftertheleaserequesthassucceeded.

Settingsin a 1:1 communication

The secondcaseis to use the SecureClient in an one to one communication,wherebythe secretkeys arealreadyknown on both sides,so that an implementationcanbeinstantiatedwith thesecretkey andthemode.ThesecretKey() canbere-trievedby analreadyestablishedsecurecommunicationusingthegetSecretKey()method,but it isnotrestrictedto that.Therefore,in thatcasethemethodkeyGeneration(),setCookie() andsetToken() arenot needed,becausein anoneto onecommu-nicationno context informationarenecessary.

Replay

Confidentialityandintegrity areguaranteedbySealedMacObject andSealedCookieMacObject,but athirdsecurityissuehasnotbeenexplainedin detail: replays.Replaysareanattackthatdoesnot effect integrity andconfidentiality. Thatmeansthedatais not changed,andthecontext will not bepublic readable.An active attacker getstheencrypteddataon the insecurechannelandreplaysit morethanonceto the receiver. If the serviceis idempotent,theremustnot betakennotionaboutthat fact. But if theserviceis notidempotentsomethingbadcanhappen,e.g. a credit transferwill be executedtwice,so that oneparty is aggrieved andthe otherparty that is likely direct or indirect theattacker, getsillegalanadvantage.

A problemthatissimilarto this,is todeletesomemessagesontheinsecurechannel,sothatonly someactionsaretakingplaceandsomenot.

To prevent this, transactionnumbersmustbe used,so that a missingmessageora replayedmessagecanbe recognized.The starttransactionnumberis definedasansuggestion,like thecryptographyalgorithms,in the interface.Therestill remainsonesecurityhole with the transactionnumbers,a messagefrom an older sessioncanbe

48

Page 50: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

SecureClientSecureSlotProvider

KeyGenerat ion

PrivateDH Key

A

PublicDH Key

A

(1b)

(1a)

Keystore

PrivateSigningKey A

(2)

Proxy(3b) sign & put into

(3a)

LUS

(4)

Proxy

(5)

PublicDH Key

A

Keystore

PublicVerify.Key A

(6)

(7b) retrieve from & verify

(7a)

KeyGenerat ion

PrivateDH Key

B

PublicDH Key

B

(9b)

(9a)

KeyAgreement

(10)

(8)

SecretKey AB

(11)

KeyAgreement

(14)

(13) transmittedunsigned andunencrypted

SecretKey AB

(15)

(16)

SecKey ABLeaseTokenCookie

(17) returnsencrypted

using SecKey AB

SecKey ADLeaseTokenCookieSecKey ACLeaseTokenCookie

SecKey ABLeaseTokenCookie

(12)

Figure6.7: Key AgreementbetweenServiceandClient

replayedandtheoriginal couldbedeleted.To prevent this, thesecretkey hasto beasessionkey thatis valid for exactlyonesessionin spaceandtime.

A moregeneralapproachwouldbeto specifyonlyKey asargument,sothatasym-metric operationswould potentiallybe possible. Asymmetrickeys arenormally notusedassessionkeys,becauseasymmetricencryptionis veryslow. Thatmeansin gen-eral,a symmetricsessionkey is themostreasonabledecision.

TheSecureClient hasto useFIRSTTRANSNUMB asfirst transactionnumber,so that the othersideknows what to expect. In active modethe secureclient hastoincreasethe numberafter an objecthasbeenunsealed.In passive mode,the secureclienthasto increasethetransactionnumberaftersealinganobject.In bothmodes,thetransactionnumberhasto becheckedright afterunsealing,andanexceptionhasto bethrown if they do notcorrespond.

In addition,the transactionnumberandthe token which mustbe sealedtogetherwith thetokenneedacontainerobject,becausethesealingobjectsonly acceptoneob-ject to besealed.For thatreason,TransactionData andTokenData aredefined:

interface TransactionData extends Serializable{Object getObject();int getTransactioNumber();

}

interface TokenData extends TransactionData{Token getToken();

}

6.6.7 Secure Slot Provider

Thesecurecounterpartof a secureclient is thesecureslot provider which servessev-eral secureclients. A commonsuperclassfor a secureandnot secureslot provideris AbstractSlotProvider which is explainednext. Thereare also somedatacontainerswhich areneededby theaslot provider.

49

Page 51: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

AbstractSlotProvider

interface AbstractSlotProvider extends Landlord{Object getData(Cookie);void setData(Cookie, Object);

}

Every resourcehasto be leased,so AbstractSlotProvider hasto extendLandlord. Anotherinterfaceis alsoimaginable,becauseLandlorddoesnotbelongtothecoreJini classes,but thefunctionalityof theLandlord interfacefits, soextendingit, is agoodchoice.

GivenaCookie, thegetData()methodreturnstheassociatedObject, whereasthesetData()methodstoresanObject in theslotwhichis identifiedbyaCookie.

SlotRes

But anobjectnot only hasto bestoredin theslot andnot all of thedatastoredin theslot couldbegivento theclient,sothattwo interfacesareneededwhich datais storedfor theclientandwhichextra datais neededto maintaintheslot:

interface SlotRes extends Serializable{Cookie getCookie();Lease getLease();Token getToken();

}

As mentionedabove,Cookie andToken areneededby thesecureclient to spec-ify the slot and the right to accessit. The secureclient also needsthe Lease forcancelingor renewing it.

SlotData

interface SlotData extends SlotRes{Object getData();void setData(Object);

long getExpiration();void setExpiration(long);

int hashcode();}

Theeffectivedatacanbeaccessedby getData() andsetData(). SinceeveryLease expires,theexpirationdatehasto bestored.It is alsobestoredin theLease,but thedatain theLeasecanbealtered,sotheexpirationdatemanagementcanbedoneby callinggetExpiration() andsetExpiration() for a slot. For reasonsofefficient storage,SlotData shouldreturna collision free hashcodeby calling themethodhashcode().

50

Page 52: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

SecureSlotData

Thesebothdatastructuresareverygeneral.For asecureslotprovider, theSlotDatainterfacehasto beextendeda secondtime:

interface SecureSlotData extends SlotData{SecretKey getSecretKey();int getTransactionNumber();void setTransactionNumber(int);

}

Consequently, theextensionhandlesthestorageof thesecretkey andthe transac-tion numberthatis neededfor a securecommunication.

Interface definition

Onthatbasisthesecureslot providercanbeintroducedat last:

interface SecureSlotProvider extends AbstractSlotProvider{PublicKey getPublicKey();SealedMacObject sealObject(Cookie,Serializable);Object unsealObject(SealedCookieMacObject);Object unsealFirst(Cookie, SealedCookieMacObject);SlotRes leaseSlot(PublicKey, SealedCookieMacObject);SealedMacObject leaseEncryptedSlot(PublicKey,

SealedCookieMacObject);}

Sincea SecureSlotProvider is normally usedin a servicebackend, it hasto provide thepublic DH key which is neededfor thekey agreementalgorithm. ThatmeanstheSecureSlotProvider hasto createat instantiationtimetheprivateandpublicDH key. ThepublicDH key canberetrievedby callinggetPublicKey().

To sealanobject,it hasto usethetransactionnumberandthesecretkey whichcanbefoundusingtheCookie. Theserializableobject,whichisgiventosealObject(),hasto besealedtogetherwith thetransactionnumberwhich hasto beincreasedafter-wards.

Vice versa:to unsealaSealedCookieMacObject, which containsthecookieto get the context information,unsealObject() hasto be used. It hasto checkthreefacts:

1 thetransactionnumber

1 thetoken

1 expirationof thelease

If oneof the checksfail, an exceptionhasto be thrown. Otherwisethe unsealedobjecthasto bereturned.

To leaseaslot, theclientsendsaSealedCookieMacObject, withoutacookie,sincethe cookiedoesnot exist yet. So theunsealObject() methodwould fail.For thatreasonunsealFirst() getsthecookieof thenew createdslotanddoesnotperformany securitychecks.

Themostimportantmethodof thatinterfaceisleaseSlot(). It hasto doseveralthings:

51

Page 53: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

1 completethekey generation,with thegivenpublicDH key,

1 storethesecretkey in theslot

1 storethedatainsidetheSealedCookieMacObject in theslot

1 generatea tokenandstoreit in theslot

1 generateacookieandstoreit in theslot

1 generatea leaseandstoreit in theslot

1 storetheexpirationof theleasein theslot.

1 returnthetoken,cookie,leaseasaSlotRes

A combinationof leasinga slot andtheencryptionof the returnedSlotRes hasto bedoneby themethodleaseEncryptedSlot().

6.6.8 Summary

SecureClient andSecureSlotProvider togetherprovide a securecommu-nication over an insecurechannel. All the securitychecksanduseddatastructuresaretransparentto the tier which builds on this tier. Currently, they only have to callthe methodssealObject() andunsealObject(). In the next versionof thisarchitecture,i.e. if all the security is doneon socket level, sealObject() andunsealObject() areimplicitly called,sothat thesecurecommunicationis totallytransparentto thetier above.

6.7 CommonSecure Classes

Commonsecureclassesprovide a securecommunicationchannelandcanbe usedinmultiple domains.They usetheSecureClient andtheSecureSlotProviderto establishasecurecommunicationlink.

6.7.1 Refreshable

TheJava permissionsaregrantedin a policy file which canbealteredduringtherun-time of a programthat readthe policy file at start time. If the changesshouldtakeeffect, theremustbe a possibility to updatethe stateby rereadingthe file or do an-otherappropriateaction.Therefore,aninterfacehasto beintroducedwhichprovidesamethodthatcando theupdate:

interface Refreshable extends Serializable{void refresh();

}

interface RemoteRefreshable extends Remote{void refresh(SealedCookieMacObject);

}

52

Page 54: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

Thefirst interfacecanbeimplementedby a serviceproxyor a regularlocal object,whereasthesecondinterfaceis intendedto be implementedby a servicebackend. Inthatcasetheserviceproxyhasto doencryptionof theparametersandcallstheservicebackendmethod.

Sincerefresh() hasno parameters,null hasto be usedasparameter. It isimportant to do it that way, becausethereare many things donetransparently, e.g.sendingthecookieandthetoken.

6.7.2 Register

Very often a serviceusesotherservicesasclient to perform its task. To do so, theclientshouldregisterandunregisteritself, sothattheservicecancreateor removecon-text informationabouttheclient. In this architecture,thecontext informationat leastconsistsof thesecretkey, thetokenamongotherthings.TheJini philosophypretendsthat all resourcesshouldbe leased.Context informationareresources,becausetheyusememorywhich canbeexhausted.To registerandunregisteronly two methodsareneeded:

interface Register extends Serializable{void register();void unregister();

}

interface RemoteRegister extends Remote{SealedMacObject register(PublicKey);void unregister(SealedCookieMac);

}

The first interfaceis intendedto be implementedby a serviceproxy. The twomethodshave to call the methodsof the secondinterfacethathasto be implementedby aservicebackend.Onproxyside,bothmethodshavenoarguments,sothey havetoretrieve theinformationby themselvesto call theassociatedmethodsof thebackend.

ThePublicKey is thepublic DH key which is neededby theservicebackendtocompletetheDH key agreementalgorithm,thereforetheproxy hasto do theDH keyagreementfirst. A publickey from andsignedby theservicebackendhasalreadybeenput into theproxy. Sincetheverificationof thesignedcodeis doneby theJVM, onlythedynamicdatahasto becheckedexplicitly.

SignedRegisterData

ThePublicKey andtheDomainName which is usedto lookupthepublic verifica-tion key in thekey storearebundledin oneinterface:

interface SignedRegisterData extends Serializable{DomainName getDomainName();PublicKey getPublicKey();

}

An implementationof it canbe put into a SignedObject which alsocontainsthesignatureof theSignedRegisterData.

53

Page 55: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

RegisterMethods

The proxy hasto call getDomainName() to retrieve the DomainName which itusesasthealiasto lookupthepublicverificationkey in thekey store.Thisverificationkey canbe usedto verify the signatureof theSignedRegisterData that canbestoredtogetherin aSignedObject. Only if theverificationsucceeds,thepublicDHkey canbeusedto performtheDH key agreementin theproxy, otherwiseanexceptionshouldbethrown.

Theverificationhasto bedoneif register() hasbeencalledontheproxy. Aftertheverificationhasbeensucceeded,theproxy generatesits own pair of thepublic andprivateDH keys to performthe DH key agreementat its side. Using its public key,it hasto call theregister() methodof theservicebackend. Theservicebackenddoesnotneedto performaintegrity check,becauseevery interestedpartyis allowedtoconnectto theservicebackend.

Theregister() methodon this sidealsohasto do theDH key agreementwiththegivenpublic DH key of theproxy andits own storedprivateDH key. Thecontextinformationhasto bestoredin a secureslot provider. The returnvalueof the leasingrequestcanbereturneddirectly to theclient. It is aSealedMacObject containingaSlotRes which includesthecookie,tokenandtheleasewhichareusedby theproxy,to identify theslot, theright to accesstheslotandto renew or cancelthelease,whereastherenewing of leasescaneasilybedoneby aLeaseRenewalManager.

Theunregister() methodof theproxy only hasto call theunregister()methodof the servicebackendusingnull asargument,sinceno argumentsarere-quired,but theunderlayingsealingtier isexpectinganargument.Theunregister()methodonbackendsideshouldreleasetheresourcethatstoresthecontext information.If theserviceproxydoesnot,or maybecouldnotcall unregister(), this hasto bedoneimplicitly if the leaseexpires.Thatmeanscalling theunregister() methodandtheexpirationof theassociatedleaseareequivalent.

6.8 Objects for Authentication

Thissectiondescribestheobjectswhich haveto beexchangedbetweenclient sideandservicesideto exchangeauthenticationdata.

6.8.1 User

Thegoalis to log on auser. Thatmeanstheuserhasto bedefinedby aninterface:

interface User extends Serializable{boolean equals (Object);int hashcode();String toString();

}

Therefore,a User hasthe sameinterfacedefinition like a CookieToken, butanothersemanticis associated.Theequals() methodis usedto comparetwo users.Only if theotherobjectrepresentsthe sameuser, equals() hasto returntrue,oth-erwisefalse.For anefficient storageof users,hashcode() shouldreturna collisionfree hashcode. ThetoString() methodshouldonly be usedfor a humanread-ablerepresentationof theobject.All comparisonsshouldbedonevia equals() andhashcode().

54

Page 56: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

6.8.2 Password

A commonlogin procedureis to usea user-namepassword dialog. Therefore,thepassword hasto bemodeledusinganinterface,too:

interface Password extends Serializable{boolean equals (Object);int hashcode();String toString();void clearPassword();char[] getPassword();

}

The first threemethods:equals(), hashcode() andtoString() have tobeimplementedthesamewaydescribedabove. Sinceapassword is verysensitive,therepresentationin thememoryshouldbeclearedby callingclearPassword().

Currently, the methodgetPassword() is only provided to supportthe JAASPasswordCallback class.Thenext versionshoulduseanownPasswordCallback,so thatgetPassword() is neededno longer. The role of getPassword() is toreturn the password as a char array representation,which is also the recommendedimplementation,becauseit is verysimpleto cleara chararray.

6.8.3 Challenge-Response

Anothercommonlogin procedureis to usea challenge-responseprocedure.Thereforethechallengeandtheresponsehasto beintroducedasinterfacedefinition:

interface Challenge extends Serializable{boolean equals (Object);int hashcode();String toString();byte[] toByteArray();

}

interface Response extends Serializable{boolean equals (Object);int hashcode();String toString();byte[] toByteArray();

}

The methodsequals(), hashcode() andtoString() have to be imple-mentedasUser suggestsit.

The methodtoByteArray() hasto returnthe byte arrayrepresentationof theChallenge or the response.This methodis neededby theJava CardApi thatonlyallows to exchangebyte[]. That meansexecutinga challenge-responseprocedureon a Java Cardenableddevice demandstheChallenge in bytearrayrepresentationandtheresponsehasto beretrievedfrom abytearray.

55

Page 57: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

6.8.4 DomainName

Assumingthat one Java Card enableddevice shouldbe usedin different domains,wherebyevery domainrequiresanothervariantof the challenge-responseprocedure,thedomainsandthereforethedifferentchallenge-responseprocedureshave to bedis-tinguished.This leadsto thefollowing interface:

interface DomainName extends Serializable{boolean equals (Object);int hashcode();String toString();byte[] toByteArray();

}

Thesemanticof all fourmethodsis thesameasexplainedabove.Notice:DomainNamedoesnotdealwith DNSor othernamingschemes.It only is therepresentationof differ-entlogin domains.It is upto everydomainto chooseitsDomainName representation.Thestringrepresentationof theDomainName is alsousedto determinethealiasnameonclientsideto retrievetheassociatedcertificateandthepublicverifyingkey in it. Twootherusesof theDomainName will beshown lateron.

6.8.5 DefaultUser

Thisconceptis verycrucialto thearchitecture.Oneaspectto determinedifferentloginschemescandependon wherethe client is executed.A possibleprocedurecould beto usethe IP numbersof the client host. In general,it is not a gooddecisionto useIP numbersfor thepurposeof authentication,becausethereexistsseveralwaysto faketheIP number.

Therefore,the conceptof a default user is utilized, which provides this featureamongotherthings,without extendingthearchitecturewith a new concept.A defaultuserdoesnot representa reallife person,but thelocationfrom wheretheuserslog in.

Example

At first, default usersoundsa bit confusing,becausea client host is meantandnot auser, asthenamesuggests.But defaultuseris not only usedto determinethelocation,whereauserwantsto log on. It is alsousedthatausercanlog onanonymously, sothatnoauthenticationis needed.Thisalsosoundsa little bit confusing,but anexamplecaneasilymotivatetheuse:theTV servicein achild’sbedroom,canbeturnedonbetween2pm and5pm without any authenticationif the remotecontrol in this room is used.After 5pm only persons,who have the permissionto watchTV, e.g. the parents,areallowed to usethe TV service. In the last caseauthenticationis needed.Thatmeansbetween2pmand5pmtheremotecontrol logson asa default userto theTV service.That meansthe TV servicedoesnot know, who is watchingTV, it only knows thatsomeoneis watchingTV, who usedthe remotecontrol in the child’s bedroom.Thatmeanstheremotecontrolis thedefault,becauseno otheruserinformationis needed.

ResponseTime

Anotherbenefitcanbetheresponsetime. For every log onrequestasessionkey hastobegeneratedthatcurrentlytakes3 secondson a SunUltra 5. This respondtime is too

56

Page 58: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

long,e.g. if thelight shouldbeturnedon. Sothelight switchlogson thelight serviceasdefault user. Only at thefirst time, thesessionkey hasto becalculated.Afterwards,everyonecanturn on or turn off the light asdefault userof that light switch servicewithoutany delay.

Interface Definition

The interfaceof theDefaultUser is very simplebecauseit builds on the existingconcepts:

interface DefaultUser extends User{}

That meansa DefaultUser is a normaluserandthe interfaceis only usedfortypesafety.

DefaultUser fulfills two purposes:it definesthelocation,from wheretheuserlogson andcanbeusedif theusercanbeanonymous,becausethe decisiononly de-pendsfrom wheretheuserswantsto usetheservice.Thelocationis notaphysical,buta logical location.Thatmeanson oneclient hostwith a multi userenvironment,therecanbeoneaccountonly for adefaultuser. All otheraccountshavenodefaultuser. Forexample:theVCR serviceshouldbeusedat theofficewithoutauthentication,becauseif theuserhasloggedonhisaccount,hehasalreadybeenauthenticated.Therefore,theusercanput adefaultuserin his homedirectorywhich will beusedto log on theVCRservice,whereasthecolleagues,which canalsolog on thesamehost,have their ownhomedirectoryon thatclient,but they do not have thedefaultuser.

Theuseof thedefaultuseris notobligatory. It is upto thelogin policy if thedefaultusershouldbeused,andwhich permissionsaregrantedto adefaultuser. In general,ifaclienthostcannotprovidethedefaultuser, themostrestrictivepolicy shouldbeused.

Handling the DefaultUser

Currently, thereis no notionhow thedefault usercanberetrievedon client side. TheDomainName hasto beusedin thatsituation,too. A client hostaccountcanbeusedto log ondifferentdomains,sotheDomainName is aparameterto retrievethecorrectdefaultuser. Theauthenticationof thedefaultusercanbedoneby achallenge-responseprocedure.How this worksis up to theimplementation,e.g. thedefault useris serial-izedandwritten to

file:/${user.home}/.jiniauth/{domainName}/defaultuser.ser.

Also theobjectneededfor thechallengecanbewritten to:

file:/${user.home}/.jiniauth/{domainName}/challresp.ser.

6.9 RemoteCallback

In general,to authenticatea user, the servicebackend, i.e. the login infrastructurehasto requestdatafrom the user, e.g. user-nameandpassword. So, theremustbe acommunicationbackto client side.

57

Page 59: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

LoginModule RemoteCal lbackHandler

SecureClientSecureClient

RemoteCallbck

B

RemoteCallbck

Ahandle() Handler

AHandler

B

result User

Password

Chal lngeRespnse

LoginToken

bio-metrical

Figure6.8: RemoteCallbackHandler

6.9.1 Interface Definition

Therefore,a remotecallbackhandleris used:

interface RemoteCallbackHandler extends Remote{SealedCookieMacObject handle(SealedCookieMacObject)

}

TheRemoteCallbackHandler hastobeaRemote object,sincethehandle()methodis calledremotelyfrom serviceside. Therefore,the communicationbetweenthe serviceside and the RemoteCallbackhandler hasto be securedusing theSecureClient onbothsides.

Theremotecallbackis aoneto onecommunication,whereastheservicesideis theactive part,becauseit is calling themethodandtheRemoteCallbackHandler isthepassivepart,becauseit actsasaservice,but with nocontext information.

Returnvalueaswell asparameterareSealedCookieMacObject, althoughnocookiesarerequired.This hasto bedone,becausetwo SecureClients communi-cate.In bothcasesthecookieargumentshouldsetto null, resp.it shouldbeignored.

Thisalsomeansthatno key generationis needed,becausea secretkey hasalreadybeencreatedthatcanbeusedfor theremotecallbackcommunication,too (figure6.8).

6.9.2 RemoteCallbackHandlerParam

Theobjectbehindthesealedparameteris:

interface RemoteCallbackHandlerParam extends Serializable{RemoteCallback[] getRemoteCallbacks();

}

6.9.3 RemoteCallback

Thus,RemoteCallbackHandlerParam only isacontainerfor anarrayof RemoteCallbacks:

interface RemoteCallback extends Callback, Serializable{}

SinceRemoteCallback definesno methods,it is only usedas marker, likeCallback, aninterfaceof JAAS, is used.Theextensionof Callback is not oblig-atory. It shouldexpressthataRemoteCallback is a specialkind of Callback. IftheJAAS packageis not used,Callback canberemovedsilently.

58

Page 60: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

Everyauthenticationtechnologywhichneedsremotecallbacksmustextendor im-plementtheRemoteCallback interface.

6.9.4 Common Callbacks

A few commonremotecallbacksarealreadydefinedin this architecture.

user-namePassword Callback

To performauser-namepassword dialog,threeinterfacesareprovided:

interface RemoteNameCallback extends RemoteCallback{String getPrompt();

}

interface RemotePasswordCallback extends RemoteCallback{String getPrompt();boolean isEchoOn();

}

interface RemoteNamePasswordCallback extends RemoteCallback{RemoteNameCallback getRemoteNameCallback();RemotePasswordCallback getPasswordCallback();

}

If a RemoteCallbackHandler hasto handlea RemoteNameCallback, ithasto print thepromptandit hasto returnaUser object.

If aRemotePasswordCallback is called,it hasto print thepromptandit hasto displaytheenteredpassword in clearor notaccordingtoisEchoOn(). Thereturnvalueis aPassword, whereasthepassword hasto beclearedon client side.

TheRemoteCallbackHandler canusethe consoleto promptfor user-nameandpassword. It canalsousea GUI. A betterapproachis to usea GUI which resideson client sideandcanberetrieved,e.g.:

file:/${user.home}/.jiniauth/userpassdialog.ser.

Thereare several benefitsusing that approach:every applianceknows for itselfwhich GUI fits perfectlyandfirms canfit out their appliance,e.g. roompanels,withtheir corporateidentity styleddialogs.

In general,thereturnvalueof theRemoteCallbackHandler hasto beasealedObject arraythatcorrespondsto theRemoteCallback array.

For reasonsof performance,thebothremotecallbacksarebundledto aRemoteNamePasswordCallbackwhich shouldreturnanAuthData objectthatextendsUserData:

interface UserData extends Serializable{User getUser();

}

interface AuthData extends UserData{Object getSecretData();

}

59

Page 61: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

Thesemanticof both interfacesis straightforward. UserData is a containerforanUser which canberetrievedby callinggetUser().

AuthData extendsthecontainerby addingadataobjectwhichshouldbehandledsecretly. This objectcanberetrievedby callinggetSecretData(). In this case,itis aPassword.

Challenge-ResponseCallback

Thisarchitecturealsoprovidesbuilt-in supportfor challenge-responseprocedures.There-fore it defines:

interface RemoteChallengeCallback extends RemoteCallback{Challenge getChallenge();

}

If theRemoteCallbackHandler receivesthiscallback,it shouldstartachallenge-responseprocedureandit shouldreturnits result:theResponse.

In general,therearetwo cases,achallenge-responseprocedureis needed.As men-tionedabove to checkif theDefaultUser canauthenticatehimself andin combi-nationwith the Java CardAPI. To determinewhich challenge-responseprocedureismeant,RemoteChallengeCallback shouldbeextendedby marker interfaces.

To check the authenticationof the DefaultUser, an object that containsthekey neededfor thechallenge-responseprocedure,canbedeserializedandtherefore,aprocedurecanbeexecuted.

If a challenge-responseprocedureis desired,e.g.a challenge-responseJini servicecan be contactedwhich itself contactsanotherJini serviceswhich provide the JavaCardAPI of asmartcardor a JavaRing.

Thereturnvalueof achallenge-responseprocedureis aChallengeData:

interface ChallengeData extends UserData{Challenge getChallenge();Response getResponse();

}

It extendsUserData andprovidestheChallenge andtheResponse, whereastheResponse only hasto be set,theChallenge is setlateron by anotherentity,otherwiseanold challengeandresponsecouldbeused.

Login Token Callback

TheRemoteCallbackHandler canalsobeusedto putor retrievea login tokenonclient side.Thatcanalsobestoredtogetherwith a cookieanda leaseasSlotRes asserializedobjectin the

file:/${user.home}/.jiniauth/{domainname}.

This is usefulfor multiple loginswith only oneauthentication,e.g.thelogin tokenis valid for ten minutesafter the userhasauthenticatedhimself correctly. Then, theusercallsanotherservicesin thesamedomainwhich - dependingon thepolicy - cancheckif at client sideexists a valid login token. If a valid login token exists andthelogin policy of thefirst serviceimpliesthelogin policy of thesecondservice,theuserwill beloggedon without furtherinteraction.

60

Page 62: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

6.9.5 Remarks

Thegivenconceptis extremelyflexible, sothatany possibleauthenticationschemecanbemodeledwith it. A big benefitis thatthelogin policy at servicesidedecideswhichof thegiventechniquesshouldbeused.Thatmeansa malicioususercannotgetmorerightsby fakingthesystemat client side.

It is alsoimaginablethatbiometricauthenticationschemeswill beusedby imple-mentingnew RemoteCallbacks.

6.10 Infrastructur eServices

ThearchitectureenfoldsseveralJini serviceswhich have alreadybeenmentioned.AservicenamedSubjectAuthenticator doesthe login procedureby contactingsomeotherservices:

1 LoginPolicy servicewhich decides,how to logon

1 RemoteCallbackHandler which returnstheauthenticationdata

1 UserDB servicewhich verifiesthereturneddata

In addition,to supportJavaRingauthenticationby processingachallenge-responseprocedure,two moreservicesarenecessary:

1 BlueDot servicewhich providesthefunctionalityof a Blue Dot Receptor(theJavaRing reader)

1 RingAuthenticationwhichcontactstheBlueDotservice,to runachallenge-responseprocedure

TheUserDB service,theLoginPolicy serviceandtheSubjectAuthenticatorservicecouldalsobe combinedin oneservice.But all threeservicesarevery modu-lar andprovide a well-definedAPI, with a well-definedsemantic,so it is gooddesigndecision,to separatethem.

Next, all servicesaredescribedin depth.

6.10.1 Login Policy DB Service

Thegeneraltaskof a login serviceis to determinedependingon oneor moreparame-ters,whatlogin policy shouldbeusedto log ona user.

Interface Definition

So,theinterfaceis verysimple:

interface LoginPolicyDB extends Refreshable, Register, Pingable{public final static int FIRSTATTEMPT = 1;LoginPolicy getLoginPolicy(LoginData);

}

61

Page 63: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

The interfacesRefreshable, Register andPingable have alreadybeenintroduced. Another servicehasto register with the LoginPolicy to establishasecurecommunicationlink. Refreshable is usedto refreshtheLoginPolicysstateandPingable is usedto determineif theLoginPolicyDB serviceis still alive.

The intrinsic serviceonly hasonemethod:getLoginPolicy() which getsaLoginData to determinewhich LoginPolicy shouldbe returned. The generalapproachis that this methodencryptsthe data,calls the backendserviceanddecryptits result,but first a look at theLoginData.

LoginData

interface LoginData extends Serializable{int getAttempt();String getService();DefaultUser getDefaultUser();...

}

TheLoginPolicyDB serviceonly usesthegiventhreemethodsof LoginData,theremainingareusedby otherservicesandthereforedescribed,whenneeded(figure6.9).

Login Policy Parameters

Login policiesthereforedependon threeparameters.As explainedabove, theDefaultUser canbe interpretedlogically astheclient

location,or theidentity of theclienthost.This informationcanberetrievedby callinggetDefaultUser().

Thesecondparameteris the serviceused. Its String representationis returnedby getService(). Thenamingschemeis an implementationfact,but a goodandsimpleapproachis to usethegetClass().getName() methodof the servicetoretrieve theclassname.

The useof countingthe attemptsshouldbe motivatedfirst. For examplethe TVservicein the childs bedroom:the first attemptis to log on asdefault user, becausebetween3pm and5pm exits no accessrestriction. That meansafter 5pm the defaultusercouldnot log on. Therefore,a secondattempthasto bestarted,e.g. to log on arealuserusinga user-namepassword dialog.

It is only up to the login policy servicewhich login policy shouldbe usedby agivencombinationof attempt,serviceandDefaultUser. It canbevery restrictive,for exampleonly Java Ring authenticationis allowed,or it canbemoreuserfriendly:log on asDefaultUser or to log on with aexisting login token.

LoginPolicy

TheLoginPolicy which is returnedcontainsonly two methods:

interface LoginPolicyDB extends Serializable{String getName();boolean implies(LoginPolicy);

}

62

Page 64: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

LoginPol icyDB Backend

LoginPol icyDBProxy

Attempt, DefaultUser, Service

LoginPolicy

Database of Login Policies

Figure6.9: Login Policy DB Service

TheLoginPolicy doesnotreturnalogin policy, but thenameof thelogin policywhich canbeusedto lookuptheauthenticationtechnology, e.g. in adatabase.

Theimplies() methodis very importantfor a login tokenauthentication,other-wisethelogin policy strengthcouldbeweakenby serviceswhichneedaweakauthen-ticationandgive out thelogin token. A servicethatneedsstrongerauthentication,butalsoacceptslogin tokens,couldbeused,without thestrongauthentication.

A login policy A shouldimply login policy B if theauthenticationstrengthof thelogin policy A is strongerthanor equalto the login policy B, whereasno semanticof the strengthis given in this architecture.It is up to the login policy administratorto decideaboutit. Theimply() methodshouldreturntrueat leastif thesameloginpolicy is given.Theimplementationalsohasto ensurethatnoendlessrecursionoccurs.

First attempt

Theinterfacealsodefinesaconstantthathasto beusedto determinethenumberof thefirst attempt.Two intuitivepossibilitiesareto useoneor zero.Thisarchitecturedefinesonethatcorrespondsto ”first attempt”.

RemoteInterface

If the LoginPolicyDB is implementedas Jini serviceor at leastas RMI ServerObject,theLoginPolicyDB is a serviceproxy andhasto do only the sealingandunsealingof thedataandit calls theappropriatemethodof thebackend,wherebythebackendhasto do thework describedabove.

interface RemoteLoginPolicyDB extends RemoteRegister,RemoteRefreshable, RemotePingable{SealedMacObject getLoginPolicy(SealedCookieMacObject);

}

6.10.2 UserDB Service

Thetaskof theUserDB serviceis to verify theresultsof theRemoteCallbackHandler.That means,it hasto authenticatethe userby the given extra data,e.g. password orchallengeandresponse.

Interface Definition

Therefore,it currentlyprovidestwo methods:

63

Page 65: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

UserDB Backend

UserDB Proxy

AuthData, e.g. user name &password or chal lenge & password

SubjectData

Database of AuthData

Figure6.10:UserDB Service

interface UserDB extends Refreshable, Register, Pingable{SubjectData authenticate(AuthData);SubjectData authenticate(ChallengeData);

}

Asexplainedabove,AuthData couldbetheresultof auser-namepassworddialogandChallengeData is theresultof a challenge-responseprocedure.

In general,AuthData could be usedin differentways,e.g. it could containanaudiofile insteadof the password, to verify the userby a voice recognitionsystem.Therefore,theseboth methodsspana wide rangeof possibleauthenticationmethodsfor verifying.

The semanticof Refreshable, Register andPingable which UserDBextendsis thesameasin LonginPolicyDB.

Bothauthenticate() methodsshouldcheckif theuserhasauthenticatedhim-selfcorrectly. In thatcase,aSubjectData shouldbereturnedwhichcontainsall theinformationto build aSubject (figure6.10).If theauthenticationfails,anexceptionshouldbethrown. Thesemanticis thatin general,only authenticatableuserstry to logon andthey give theright informationto log on. Every othercaseis anexceptionandhasto behandledlikeanexception.

SubjectAuthResult

SubjectAuthResult is definedas:

interface SubjectAuthResult extends Serializable{Set getPrincipals();Set getPrivateCredentials();Set getPublicCredentials();

}

The setsof Principals, privateand public credentialshave alreadybeenex-plainedabove. They areusedto build aSubject object,on which theauthorizationdecisionscanbemade.

RemoteInterface

The mostcommonway is that thesetwo authenticationmethodsdo the sealingandunsealingandthat they call themethodof a backendwhich implementsthefollowinginterface:

64

Page 66: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

interface RemoteUserDB extends RemoteRegister,RemoteRefreshable, RemotePingable{SealedMacObject authenticate(SealedCookieMacObject);

}

Sincethedatahasto besealed,thebackendonly hasto provideonemethodwhichhasto dispatchaccordinglyto theunsealeddatawhich authenticationverificationhasto beperformed.

6.10.3 SubjectAuthenticator Service

This is thecentralentity of thewholearchitecture.It contactstheLoginPolicyDB,theRemoteCallbackHandler andtheUserDB to handletheauthenticationpro-cess.

Interface Definitions

interface SubjectAuthenticator extends Register, Refreshable,Pingable{SubjectAuthResult login(LoginData, RemoteCallbackHandler);void logout(SlotRes);

}

TheRemoteSubjectAuthenticator is definedaccordinglyas:

interface RemoteSubjectAuthenticator{SealedMacObject login(SealedCookieMacObject,RemoteCallbackhandler);void logout(SealedCookieMacObject);

}

The SubjectAuthenticator interfacehasto be implementedby a serviceproxy andtheRemoteSubjectAuthenticator mustbe implementedby a ser-vicebackend.

Again, the serviceproxy has to do the sealingand unsealingof the data. TheRemoteCallbackHandler which implementsRemoteRef cannotbeencrypted,becausetheserializationanddeserializationprocess,which hasto bedoneby theen-cryption, resp. decryptionwould leadto a wrong reference,so that the RemoteCall-backHandlercouldnotbecontacted.SincethecommunicationbetweentheSubjectAuthenticatorandtheRemoteCallbackHandler is secure,no securityproblemsarises.

Thelogin()methodgetstheLoginData andaRemoteCallbackHandlerandhasto returnaSubjectAuthResult. First,it hastocontacttheLoginPolicyDBusingtheLoginData asparameter. Dependingon theLoginPolicy, it hasto in-voke the appropriateRemoteCallbacks, resp. checkif the given login token isvalid andimpliestheLoginPolicy (figure6.11).

LoginData

interface LoginData extends Serializable{...SecretKey getSecretKey();

65

Page 67: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

LoginPol icy DB

Proxy

User DBProxy

RemoteCal lbackHandler

SubjectAuthenticatorBackend

SubjectAuthenticator

Proxy

(1) LoginData, RemoteCallbackHandler

(8) SubjectAuthData

Database of LoginToken

(2) LoginData(3) LoginPolicy

(4) Callback

(5) Answer

(6) AuthData

(7) SubjectData

Figure6.11:SubjectAuthenticatorService

SlotRes getSlotRes();}

Therefore,two othermethodsof LoginData areneeded.To securethecommu-nicationwith theRemoteCallbackhandler, thegetSecretKey() methodre-trievesthesecretkey usedto encryptanddecryptthedata.If theLoginPolicy spec-ifies thata login tokencouldbeused,getSlotRes() returnstheslot resultthatcon-tainsthecookieandthetokenthatidentifiestheslotandtheright of theuserto retrievetheinformation.Therefore,afterasuccessfulauthentication,theSubjectAuthenticatorhasto storethe dataneededin a separateslot provider. Sincethe datastoredin thatslotneednoextrasecurecommunication,becausethedatais sentto andreceivedfromsecurechannels,anonsecureslotprovider is theright choice:

SlotProvider

interface SlotProvider extends AbstractSlotProvider{leaseSlot(Object);

}

Theonly methodhasto do a few things:

1 generateToken, Cookie andLease

1 storeToken, Cookie, Lease, expirationtimeandthegivenobjectin theslot,e.g.usingaSlotData

1 returnaSlotRes, containingtheToken, Cookie andtheLease

66

Page 68: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

JassSlotResult

In thatcase,thedatathathasto bestored,is well-defined:

interface JaasSlotResult extends Serializable{LoginPolicy getLoginPolicy();Subject getSubject();

}

First, theLoginPolicy itself hasto be stored,therewith the implication checkcanbedone.If thechecksucceeds,thestoredSubject canbeusedto built thereturnvalueof thelogin() method.

If no login token exists, the login token is not valid or it shouldnot be used,thereturnof theRemoteCallbackHandler mustbecheckedby calling theUserDBauthenticate() methods.They returnaSubjectData object,which is usedtobuild the Subjectobject,asmentionedabove. This Subject andthecorrespondingLoginPolicy shouldbestoredin a nonsecureslotprovider.

SubjectAuthResult

Both, theSubject andtheSlotRes, which is returnedfrom theslot provider, arereturnedto thecallerasaSubjectAuthResult:

interface SubjectAuthResult extends Serializable{SlotRes getSlotResult();Subject getSubject();

}

6.10.4 BlueDotService

TheBlueDot serviceis namedthatway, becausetheJava Ring readeris calledBlueDot Receptor“.Its taskis to dispatchmultiple requestfor theBlue Dot Receptorandstartthecommunicationthatis neededfrom theoutsideto communicatewith theJavaRing, resp.theJava CardAPI.

Java Card API

First a few wordsaboutthe Java CardAPI andthe classesprovidedby DallasSemi-conductor- themanufacturerof theJava Ring - to accesstheRing.

Onsmartcardsor on JavaRingsthatimplementtheJavaCardAPI, runsa reducedJVM thatonly containsthefollowing classes:

1 Applet,AID

1 APDU

1 ISO

1 Util

1 severalPIN classes

1 severalExceptionsclasses

67

Page 69: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

Host(running on

a workstation)

SmartCard Readere.g. Blue Dot

Receptor

inst

all

liste

ner

callb

ack

APDU

Smart Card,e.g. Java Ring

insert

cont

ains

AppletApplet(running on

the smart card)

ResponseAPDU

Figure6.12:JavaCardInteraction

D eventuallycryptoclasses,e.g.DES3_Key

D eventuallyseveralFile classes

Even,a very commonclassString is missingin thatlisting. Thebasicprincipleis that the Java CardAPI executesextendedApplets, whereasthe communicationbetweenanoutsideapplicationandanApplet is achievedby usinganAPDU objectwhich canonly exchangebytearrays.Thatmeansit is not possibleto exchangeJavaobjects.But evenif it would beallowed,it couldnot work, becausetheJava CardAPIprovidesno classloader.

Applets have to be loadedon the smartcardor the Java Ring via a proprietaryprotocol.If they areon thering, they run in apassivemodeuntil they aredeleted.Theappletsarewaiting for anincomingrequest.Thenthey processtherequestandreturntheresult,whereasrequestandresultarebytearraysencapsulatedin anAPDU (figure6.12).

The classISO containssomeconstantsandUtil somemethodsfor byte arraycopying. ThePIN classesareusedto protectthesmartcardor anapplication.

Two extensionpackagesprovide cryptographysupportwhich the Java Ring in-cludes. So the Java Ring can be usedto sign data,calculatehashcodesand it canasymmetricallyandsymmetricallydecryptandencryptdata.

Anotherextensionpackage,which is not includedin theJava Ring,definesseveralmessagesfor File handling.

But theJavaRingcontainssomeproprietaryextensionsby DallasSemiconductors:Clock andCoproccesor that provide accessto a clock and fast computationofasymmetricoperations.

68

Page 70: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

BlueDot Backend

BlueDotProxy

RingApplet

Object (return valueof Java Ring Applet)

SmartCard Readere.g. Blue Dot

Receptor

Applet A

installl istener

cal lback Host CHost BHost A

Figure6.13:Blue Dot Service

Interface Definitions

Now, theBlueDot servicehasto runoutsideRingAppletsthatselecttheAppletneededontheJavaRingandreturntheresultof theApplet asObject (figure6.13):

interface BlueDot extends Pingable{Object runApplet(RingApplet);

}

interface RemoteBlueDot extends RemotePingable{Object runApplet(RingApplet);

}

interface RingApplet extends Serializable{RingData getRingData();Object getData();void run(JibMultiFactory, String);

}

TheRingApplet providesthreemethodswhich arecalledby theBlueDot im-plementation.

First, if a Java Ring is inserted,getRingData() hasto becalledto retrieve theinformationaboutthe appletandhow it canbe selected.Then, the run() methodis calledusing the proprietaryJibMultiFactory which providesthe connectionto the Java Ring andat leastgetData() hasto return the datawhich is the resultof theexecutionof theApplet. TheStringargumentshouldbeprintedout after theexecutionhasbeencompleted.

At last,theRingData interface:

interface RingData extends Serializable{String getAppletName();String getMessage();String getPassword();URL getURL();

69

Page 71: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

RingAuthent icat ion Backend

RingAuthentication

Proxy

Chal lenge, DomainName

Chal lengeData

BlueDotProxy

Chal lengeResponse

Applet(Host)

load

Response

Figure6.14:RingAuthenticationService

}

RingData is just anotherdatacontainer. getAppletName() is usedto selectthe right Applet on thering. getPassword() returnstheoverall Ring passwordwhich is neededto accessthe ring. URL specifiesthe file which containsproprietaryinformationof how to accesstheApplet which hasto be downloadedfirst by theBlueDot implementation. getMessage() shouldreturn a messagethat can beprintedout,sothattheuserknowswhatappletis running.

TheBlueDot interfacehasto be implementedby theserviceproxy, whereastheRemoteBlueDot interfacehasto beimplementedby theservicebackend.Themostimportantdifferenceis that the remoteinterfaceextendsindirectly Remote, whereasthe local oneextendsindirectly Serializable. The communicationbetweentheproxyandthebackendhasnotto besecured,sincenocritical datahasto beexchanged,otherwisetheservicecouldbe extendedeasilyto provide a securecommunicationasmentionedabove.

6.10.5 RingAuthenticaton Service

The RingAuthentication hasa very simple interfacelike the most other ser-vicesconsistingof only onemethodthatgetsaChallenge andaDomainName andshouldreturnaChallengeData which containstheResponse:

interface RingAuthentication extends Pingable{ChallengeData challengeResponse(Challenge, DomainName);

}

interface RemoteRingAuthentication extends RemotePingable{ChallengeData challengeResponse(Challenge, DomainName);

}

Theserviceproxy, which implementsRingAuthentication, callsthemethodof theservicebackendwhich implementsRemoteRingAuthentication.

To do a Java Ring authentication,theservicebackendhasto find aBlueDot ser-viceandhasto call itsrunApplet()methodwith anappropriateRingApplet thatcommunicateswith thechallenge-responseappleton theJavaRing (figure6.14).

6.11 Service

Onegoal is to simplify the developmentof new services,so that the underlayingau-thenticationis astransparentaspossible. In general,therearetwo differentwaystoachievethis:

70

Page 72: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

D provideaclasswhich canbeextended

D provideaclasswhich canbeusedasa field

The advantageof the first approachis that morework canbe doneby the superclass.SinceJavadoesnotsupportmultiple inheritage,theclasshierarchyis verystatic,whereasthis is exactly theadvantageof thesecondapproach.But thesecondapproachlacksof not having thatmuchwork bedoneby theclass.

This architectureprovidesbothon bothsides:a classthatencapsulatesthewholeauthenticationfunctionalityandalsoclassesthatcanbeextendedandactaswrapper.

6.11.1 Interface Definitions

Consequently, the serviceproxy containsa classthat encapsulatesthe authenticationfunctionality. Its interfacedescriptionconsistsof two parts:

interface Authenticable extends Serializable{void login();void logout();

}

interface Authenticator extends Authenticable{SecureClient getSecureClient();SlotRes getSlotRes();

}

Theremotecounterpartof Authenticator isAuthenticatorBackendwhichalsoprovidessomemethodsneededfor anauthenticatedsession:

interface AuthenticatorBackend{SealedMacObject login(PublicKey, RemoteCallbackHandler,SealedCookieMacObject);void logout(SealedCookieMacObject);SecureSlotProvider getSessionSlotProvider();getSignedObject(String);

}

Sincethecommunicationhasto besecuredbetweentheserviceproxy andtheser-vicebackend,resultsandparametersaresealedobjects.AuthenticatorBackenddoesnot needto extendRemote or Serializable, becauseit is intendedto beafield in theservicebackend(figure6.15).

6.11.2 Proxy

The first interfaceonly describesin general,what a basic authenticationfunction-ality is: startingthe authenticationby calling login() andclosethe sessionwithlogout().

Thesecondinterfaceextendsthefirst andprovidestwo methods,in orderto accesstheunderlayingsecurecommunicationtier. Therole of getSecureClient() andgetSlotRes() is simple. They only have to returntheSecureClient andtheSlotReswhichcontainthecookie,tokenandthelease.Currently,getSecureClient()

71

Page 73: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

RemoteAuthenticator

ServiceBackend

ServiceProxy

AuthenticatorBackend

Authenticable

AuthenticatorSessionSlot

ProviderSecureClient

Figure6.15:ServiceBackendandServiceProxy

is needed,since the sealObject() and unsealObject() has to be usedbymethodson serviceproxysideto decryptresultsandto encryptparameters.

Theintentionof getSlotRes() is to provide the lease,sothat the leasecanbecanceledor renewedmanually. Thesecondinterfacecanberemovedin thenext ver-sion.Sealingandunsealingwill bedonetransparently. Cancelingtheleaseis doneim-plicitly bycallinglogout() andtherenewalcanbedonebyaLeaseRenewalManager.That meansthe whole interfacewould consistof two methods:login() and logout()which will bedescribednext. If getSecureClient() or getSlotResult() iscalled,without callinglogin() first, thelogin() methodhasto becalledimplic-itly. In general,every methodin the proxy that calls methodsof the servicebackendhasto ensurethat theproxy, resp.theuser, hasalreadybeenloggedon, otherwisethemethodhasto startthelog on processby callinglogin().

To logout,logout() hasto call thelogout()methodof theRemoteAuthenticatorwhichwill beimplementedby anobjectinsidetheservicebackend.If theserviceproxyhasnot beenloggedin, themethodshouldreturnsilently.

Themostimportantmethodof Authenicator is login() which handlesthewhole login processat client sideencapsulatedin the serviceproxy. If login() iscalled,anda login sessionalreadyexists,logout() shouldbe calledimplicitly, sothata secondlogin sessioncanbe started.An alternative would be to returnsilently,likelogout() it doesif nologin sessionexists,but this is not therecommendedway.

To beableto createa securecommunicationlink, thelogin() procedureof theserviceproxy hasto ensurethata cryptographicprovider is installedthatprovidesalltheusedalgorithms,if not, it hasto install anappropriateprovider.

SignedLoginData

The next step is to checkthe signatureof the dynamicdatathat the serviceproxycontains.Register andRemoteRegister usea SignedObject to exchangeSignedRegisterData. For thereasonsof log on,SignedRegisterData hasto be extendedto provide further information. It needsthe servicenamefrom theservicebackendto built theLoginData objectwhich is alsogivento thelogin policyserviceandit usesthenameto determinethelogin policy:

interface SignedLoginData extends SignedRegisterData{

72

Page 74: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

String getService();}

Having checkedthesignature,theDH key agreementcanbeexecuted,so that thesecretcommunicationkey is available. Thesecretkey andtheDomainName have tobeusedto instantiatetheRemoteCallbackHandler.

Two informationarestill neededto instantiatetheLoginData for thepurposeofcallingtheremotelogin()method.ThesearetheDefaultUser andtheLoginToken.Bothcanbenull if they do not exist at client side.

Theotherobjectsneededto instantiatetheLoginData are:theattemptcount,theservicenameandthesecretkey. Thesecretkey andtheservicenamearealsoavailableat client side,sothatit is alsopossibleto setthesebothvaluesin theservicebackend.If it is donethatway, SignedLoginData hasnot beused,becauseit only containstheservicename.

However, now, theremotelogin() methodcanbecalledwith thepublicDH key,theRemoteCallbackHandler andthesealedLoginData.

6.11.3 Backend

First, theservicebackendhasto generatethesecretkey usingthegivenpublicDH keyandits privateDH key. This is doneby thesecureslot provider, sothat theresultis aSlotRes. TheSlotRes containsthesecretkey which hasto beusedto unsealtheLoginData.

Having theLoginData andtheRemoteCallbackHandler, theSubjectAuthenticatorservicecanbecalled. Its login() methodreturnsaSubjectAuthResult if thelogin() succeeds.TheSubjectAuthResult, which containstheSubject, isstoredin thesecureslot provider.

LoginResult

Last,aLoginResult hasto becreated.It containsthe informationthat theserviceproxy needsfor the login session:the SlotRes to communicatewith the servicebackendandtheSlotRes which containstheleasedLoginToken:

interface LoginResult extends Serializable{SlotRes getLoginSlotResult();SlotRes getSlotResult();

}

This LoginResult hasto be sealedandreturnedasresultof the serviceproxylogin() invocation.

Theserviceproxy unsealstheresultandhasto storebothSlotRess. At least,ithasto settheCookie andToken, sothatits SecureClient cando thecommuni-cationwith theservicebackend.

Furthermore,it isupto theimplementationif theserviceproxywritestheLoginTokento diskor dosomeequivalentaction,sothattheLoginToken canberetrievedby an-otherlogin processfrom thesamedomain.Fromnow on,theuseris authenticatedandtheservicebackendcanusetheSubject to performauthorizatedactions.

ThegetSignedObject() hasto returntheSignedObject containingSignedLoginData,whereastheString argumentis theservicename.To signtheobject,theprivatesign-ing key hasto beretrievedfrom thekey store.TheDomainName is usedasalias.

73

Page 75: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

ThegetSessionSlotProvider()methodhasto returntheSessionSlotProvider,sothat thesealingandunsealingcanbedone.In thenext versionof this architecture,this shouldbedonetransparently, sothatthismethodis neededno longer.

6.11.4 RemoteInterface

The implementationof the interfacesabove canbeusedasfields in theserviceproxyandtheservicebackend.Theimplementationalsoprovidesabstractclasseswhich actaswrapperto call the appropriatemethodsof the fields. The servicebackendhastoimplementat leastthefollowing interface,wherebythemethodsonly have to actasawrapperto call theappropriatemethodsof theAuthenticatorBackend:

interface RemoteAuthenticator extends Remote{SealedMacObject login(PublicKey, RemoteCallbackHandler,SealedCookieMacObject);void logout(SealedCookieMacObject);

}

Theserviceproxydoesnotneedto implementsuchaninterface,becausetheclientis usingtheserviceproxy andthewholeprocessis transparentto theclient. Theloginprocessis startedimplicitly: if the client calls a methodon the serviceproxy thatrequiresa login session,themethodhasto checkif theuseris loggedon andif not, ithasto startthelogin process.

74

Page 76: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

Chapter 7

Implementation

This chapteronly providesimplementationfactsaboutthe referenceimplementation.All the conceptshave alreadybeenshown in the chaptersaboutthe architecture.Sothis chapteris especiallyfor those,who want to alteror expandthearchitecture.It isalsopossibleto extractsomeparts.A recommendationis to readthesourcecodelistingwhile studyingthis chapter.

7.1 PackageStructure and Conventions

Thewholearchitectureincludingthereferenceimplementationconsistsof 26packagesand145classes.Onehalf is theinterfacedefinitionandtheotherhalf is theimplemen-tation.Thenext sectionsgiveanoverview of thepackagestructureandtheconventionsused,providesomecommoninfrastructurethatcanbeusedanddescribethearchitec-turestartingfrom theclient side.

Anotherdistinction is madebetweensecurityandnon securitypackages,so thatthereare4 portionsof packages(”-” meansawholesubtree):

D nonsecurityinterfaces:schoch.jini.interfaces.-,dependsonnootherof thethreepackages,

D non securityimplementation:schoch.jini.reference.-,only dependson the nonsecurityinterfaces,

D securityinterfaces:schoch.jini.security.interfaces.-,only dependson thethenonsecurityinterfaces,

D securityimplementation:schoch.jini.security.reference.-,dependsonall thepack-ages.

7.1.1 Proxy Interface

Regularly, a servicehasto implementtwo interfaces.Theserviceproxy hasto imple-menttheinterfacethatspecifiestheprotocol,how a client talksto theservice.This isa local interface,becausetheserviceproxy is downloadedandthenexecutedlocally intheclient thread.

75

Page 77: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

7.1.2 RMI

Thecommunicationbetweentheserviceproxyandin general,its backendservicegoesover thenetwork. Themostcommonsolutionis to useJava’s built-in RemoteMethodInvocation(RMI).

RMI generatestransparentlytheappropriatestubsandskeletonclassesneededformarshallingandunmarshalling.SinceJDK1.2,skeletonsareneededno longer. To cre-atearemoteaccessableObject, themostcommonwayis to extendaUnicastRemoteObjector aActivation classandto instantiateit.

A client thatwantsto usetheremoteobject,needsaremotereferenceof theobjectwhich it obtainsfrom theRMI registry (not usedin this architecture),or directly asaregularobject:RemoteReference.

The interfacewhich the client usesasa protocolto the talk to the remoteobject,andwhich theclient stubandtheremoteservicemustsupport,hasto extendRemote.Remotesonly taskis to markthedefinedprotocolinterfaceasaremoteprotocol.Thatmeansa separateprogram,besidesthe java compiler (javac), the RemoteMethodInvocationCompiler(rmic), generatestheappropriatestubclassesfor thoseinterfaceswhich extendRemote.

7.1.3 Backend Interface

Back to the interfacesthata servicehasto implement. The serviceproxy hasto im-plementthelocalprotocolinterface,whereastheservicebackendimplementsaremoteinterface. If the local and remoteareequalexcept for the extensionof Remote, itis possibleto only useoneinterface. This alsoimplies that it is not possibleto hideRemoteExceptions,which arethrown by thestub,or theremoteobject.

In thisarchitecturetwo differentinterfacesareneeded,becausethecommunicationbetweenthe serviceproxy andthe servicebackendis encrypted.Whereasthe com-municationbetweenthe client andthe serviceproxy is not encrypted,becauseit is aregular local methodinvocation.This alsoshows that theencryptionis transparenttotheclient. A conventionis to nametheremoteinterface,like the local interface,withRemote asprefix, e.g. a local interfacenamedTV implies that the remoteinterfacehasto benamedRemoteTV.

7.2 Data containers

Many of the classesare just datacontainers.Their structureis to have public getterandprivatesettermethods.Theconstructoris public, too andit usestheprivatesettermethodsto setupthe fields. The namingconvention is to add the postfix Impl totheinterfacename,e.g. interfaceExampleimpliesclassExampleImpl.Thefollowingclassesareonly datacontainers:

D RingDataImpl

D LocalChallengeCallbackImpl

D LocalNamePasswordCallbackImpl

D RemoteChallengeCallbackImpl

D RemoteNameCallbackImpl

76

Page 78: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

D RemoteNamePasswordCallbackImpl

D RemotePasswordCallbackImpl

D UserDBCallbackImpl

D AuthDataImpl

D ChallengeDataImpl

D LoginDataImpl

D LoginResultImpl

D RemoteCallbackHandlerParamImpl

D SignedLoginDataImpl

D SignedRegisterDataImpl

D SubjectAuthResult

D SubjectDataImpl

D TokenDataImpl

D TransactionDataImpl

D UserDataImpl

D SlotResImpl

D JaasSlotResultImpl

7.2.1 ExtendedData Containers

SomedatacontainersalsodefinetoString(),hashCode() andequals()meth-ods:

D PrincipalImpl

D SlotDataImpl

D SecureSlotDataImpl

7.3 Cookie and Token

Thefour markerclasses

D LoginCookieImpl

D LoginTokenImpl

D ServiceCookieImpl

D ServiceTokenImpl

77

Page 79: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

have the commonsuperclassCookieTokenImpl. This classusesinternally a16 bytearray(128bit) to uniquelyrepresentacookieor token.

It is importantto usea goodrandomgenerator, becausethe token representstheright to acton behalfof a user. Soguessingtheright tokenshouldbevery hard. Thisimplementationusesthe SHA1PRNG algorithm from the Java Securityarchitecture.The16 randombytesaresetin thenoargumentconstructor.

7.4 ExchangeData

ChallengeDataImpl hasthesameimplementationasCookieTokenImpl. Onedifferenceis thatthetoByteArray() methodis public,sothatthebytearraycouldberead.

ResponseDataImpl needsnorandomgenerator, becausethebytearrayis givento theconstructor.

UserDataImpl usesa String to storethe user-name.DefaultUserImplonly is amarkerclassandextendsUserDataImpl.

PasswordImpl usesachararrayto storethepassword. TheclearPassword()methodoverridesthechararraywith spaces.It alsoprovidesafinalize() methodwhich only callsclearPassword().

TheDefaultLoginPolicy returnstheString ”Default” if getName() iscalled.It only impliesDefaultLoginPolicys.

7.5 Secure Communication

7.5.1 Encryption and Decryption

The constructorof SealedMacObject getsa SecretKey and an Object. ItserializestheObject into abytearrayusingaByteArrayOutputStream andanObjectOutputStream. On thatbyte arrayandwith the secretkey the MAC andtheencryptedversionarecalculatedandstoredinto two bytearrays.

getObject(SecretKey) doesthereverseoperation.It decryptsthestoredandencryptedbytearrayandcomparestheMAC of thatdecryptedbytearrayto thestoredMAC. If they arenotequal,anException will bethrown,otherwisetheoriginalob-jectwill bedeserializedwith aByteArrayInputStream andanObjectInputStream.

TheSealedCookieMacObject is just an extensionto SealedMacObjectwhich additionallystoresaCookie thatis givento theconstructor.

7.5.2 Slot Provider

A commonsuperclassfor secureandnonsecureslotprovidersisAbstractSlotProviderImpl.It storesthedurationwhichis neededto calculatetheexpiration,a landlordto call backandusesa LandlordLeaseFactory to generatenew Leases. Both argumentsaregivento theconstructor.

It usesaHashMap tostorethecontext information.getToken() andgetCookie()aredefinedabstract,becauseextensionsof this classdefinetheir own cookiesandto-kens.getData() andsetData mapthecookiesto thecontext information.

Thecancel() andrenew()methodsarealsodefined,but currentlydonothing.Thesemethodsshouldbecalledby thelandlordthatwasusedto build theleases.An-

78

Page 80: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

otherapproachis to make AbstractSlotProviderImpl anRemoteObject,sothatit canbeits own landlord.

SlotProviderImpl

SlotProviderImpl providesan implementationfor generateCookie() andgenerateToken(). Thesemethodsreturnanew LoginCookie orLoginToken.Themostimportantmethodis leaseSlot(). It generatesa new Token, Cookieanda Lease usingthe threegenerateXXX() methods,so that a SlotData canbeinstantiatedandbeput into theHashMap usingtheCookie askey.

SecureSlotProviderImpl

A moresophisticatedextensionof AbstractSlotProviderImpl isSecureSlotProviderImpl.How thepublicmethodswork, is describedabovemorein detail.Threeimportantpri-vate methodsarecompleteKeyGeneration(), getEncryptCipher() andkeyGeneration().

The last methodis called,whenthe objectis created.A KeyPairGeneratoris initialized with the key agreementalgorithm,specifiedin SecureClient andaDHParameterSpec, i.e. themoduloandthebase,alsoin SecureClient. Afterthekey pair is generated,theprivateandpublickey is storedseparately.

Thenext stepis to callcompleteKeyGeneration()with thepublickey of thesecureclient asargument. A KeyAgreement object is createdandinitialized withthatpublic key andtheown privatekey. In theend,thegeneratedSecretKey couldbereturned.

getEncryptCipher() is quite simple, it takesa SecretKey asargument,createsa new Cipher objectin encryptionmodeandreturnsit.

7.5.3 Secure Client

Thecounterpartof SecureSlotProviderImpl is SecureClient. The imple-mentationof thepublicmethodsdescribedin thearchitectureis straightforward.

It hasfieldstostoretheCookie,Token,SecretKey andthetransactionnumberneededto communicatewith aSecureSlotProvider. Anotherfield is typethatisusedto determineif theSecureClient is in activeor passivemode.

Oneof two importantprivatemethodsis checkTransactionNumber() thatchecksif thegivenandtheown transactionnumberareequalandincreasesthetrans-actionnumberin activemode.

The secondprivate methodis getEncryptCipher(). In that case,it needsno arguments,becauseit canaccessdirectly theSecretKey, so it canreturna newinstanceof Cipher in encryptionmodefor thesealObject() method.

7.6 Commonclasses

7.6.1 ServiceFinderImpl

ServiceFinderImpl is createdgiving aServiceTemplate to theconstructorwhich storesit in a field. The constructoralsocreatesa LookupDiscovery andaddsitself asDioscoveryListener. It usesaSet to keeptrackof thediscoveredlookupservices.Anotherfield storesa proxy thatfits to theServiceTemplate.

79

Page 81: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

If getProxy() is calledor a new lookupserviceis found,findService() iscalled.Thismethoditeratesthroughthesetof lookupservices,triesto getaproxyandregisterson thatproxy if it implementtheRegister interface. ThegetProxy()methodalsotriesto call ping() if theproxy implementsthePingable interface.

7.6.2 AbstractRingApplet

A commonsuperclassfor all hostprogramsthat communicatewith a Java Ring, isAbstractRingApplet. It hasonefield thatstorestheRingData, neededto com-municatewith theApplet on the ring andalsoprovidesthedecodeSW() methodthatreturnsthestatusword receivedfrom theRing,andreturnsaString describingthestatusword.

7.6.3 BasicUnicastService

BasicUnicastService is takenfrom Keith EdwardsCoreJini. This abstractsu-perclassdoesmostof thestandardinitialization with theJini infrastructure.A servicewhichextendsthisclasshasto implementtheabstractmethodgetProxy() which isusedby BasicUnicastService to registertheproxywith thelookupservice.

An instantiationof anextendedclassworkslike this: thefirst stepis to instantiatethesuperclass,thesecondstepis to call theinitialize() methodwhich doestheremaininginitialization andstartstheservice.

BasiscUnicastService extendsthe UnicastRemoteObject classandstoresits context, e.g.ServiceID persistentlyin a file.

7.6.4 RegisterImpl

An extensionto BasicUnicastService is RemoteRegisterImpl that pro-videstheadditionalability to registeronaserviceusingaproxythatextendsRegisterImpl.Registrationmeansto agreeon a commonsecretkey that is usedby theclient andtheserviceto encryptanddecryptthe communication.Thereareno restrictionson whodoestheregistration.

RegisterImpl, the proxy, hasa boolean field to indicate if the client hasregistered.It alsoprovidesa field to storean own instanceof SecureClient andtheresultof theSecureSlotProvider at serviceside:aSlotResult.

To communicatewith the backendservice,it hasa RemoteRegister field. ASignedObject field is used,to storetheSignedObject thattheservicescreatesandstoresit to thefield, beforeit registerstheproxy on lookupservices.

register() andunregister() have alreadybeenexplainedin the chapteraboutthearchitecture.TheprivatemethodscheckSignature() andinstallProvider()areworth to explain.

installProvider() is calledby register(). It createsa new instanceoftheSunJCE provider. If a provider with the nameof the instantiateddoesnot exist,theprovider is addedto theJVM.

The secondmethodcheckSignature() is calledby register(), too. Anew KeyStore usingtheSecureClient.KEYSTOREALG is createdandthe fileSecureClient.KEYSTORENAME in the usershomedirectoryis usedto build theKeyStore. The public verification key is retrieved from the KeyStore by theDomainName andcalling getPublicKey() on the returnedCertificate. Averificationenginewhich is initialized with theSecureClient.SIGALG and the

80

Page 82: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

PublicKey aregiven to the storedSignedObject methodverify() asargu-ments.If thecheckis positive thedatainsidetheSignedObject arereturned,oth-erwiseanException is thrown.

7.6.5 RemoteRegisterImpl

The counterpartof RegisterImpl is RemoteRegisterImpl with threefieldsand one constant. SERVICE_DURATION is the constantthat storesthe maximumdurationof theleasesthatareusedby theServiceSlotProvider thatis storedinoneof the threefields. TheDomainName anda PrivateKey, the signingkey aretheremainingtwo fields.

Thetwo cancel() methodsandthetwo renew() methodsonly call thecorre-spondingmethodsof theSecureSlotProvider.

Twomethodsareexplainedmorein detail:getSignedObject() andloadSigningKey().loadSigningKey() is calledby the constructorwith the privatesigningkey

accesspasswordasargument.As describedabove,aKeyStore is createdfrom afile.KeyStore.getKey() returnstheprivatesigningkey, wherebytheDomainNameandthepasswordareusedto accesstheprivatesigningkey.

getSignedObject() is called, when the proxy is createdwhich storesthatSignedObject. Thereforea new SignedRegisterDataImpl is createdandput togetherwith theprivatesigningkey anda signingengineinto theconstructorof aSignedObject which is returned.

7.7 Callback

Most of theclasses,i.e. theCallbacks itself areonly datacontainersandthereforenot worth to explainmorein detail,whereastheLocalCallbackHandler andtheRemoteCallbackHandler areworth to mention.

7.7.1 RemoteCallbackHandler

TheRemoteCallbackHandler hasfieldstostoretheDomainName, aSecureClientfor thecommunicationandaServiceFinder tofindaRingAuthenticationService.

TheSecureClient is createdin theconstructorin passivemodewith theSecretKeythatis usedby theserviceproxy andtheservicebackend.

Themostimportantmethodishandle(). It getsaSealedCookieMacObjectthat containsan array of RemoteCallbacks. Dependingon the type, which ischecked by instanceof, differentauthenticationschemescanbe processed.ThisimplementationsupportstwoRemoteCallbacks:RemoteNamePassordCallbackandRemoteChallengeCallback.

Theimplementationof bothschemesisstraightforward:fromtheRemoteNamePasswordCallbacksareextractedtheRemoteNameCallback andtheRemotePasswordCallback.Both messagesare promptedto the user. The Username and the Password arestoredin anAuthData object.After sealingthereturnvalue,thepassword is cleared.TheimplementationignorestheisEchoOn() value.readPassword() is asimplemethodthatreadsa chararrayfrom theconsole.

Theprocessingof theRemoteChallengeCallback isevensimpler. TheRingAuthenticationfinderis usedto geta proxy. On thatproxychallengeResponse() is calledwith

81

Page 83: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

theChallenge of theRemoteChallengeCallback andthestoredDomainName.Thereturnvalueis aChallengeData objectwhich is returnedsealed.

Theimplementationcurrentlydoesnot fulfill thespecification.Becauseit doesnotreturnansealedarrayof objects.It only returnsthefirst result.This mustbealteredina futurerelease.

7.7.2 LocalCallbackHandler

TheLocalCallbackHandler isanimplementationof JAAS’ CallbackHandlerinterface. It storesa UserDB proxy which canbe requestedby a LoginModule, aSecureClient to securethecommunicationandaRemoteCallbackHandlerwhich is describedabove.

The LocalCallbackHandler is invoked by a LoginModule. Dependingon the LocalCallback, a LocalNamePassword, a UserDBCallback or aLocalChallengeCallback canberequested.

UserDBCallback only hasto return the storedUserDB. The two remainingLocalCallbacksareprocessedbycallingthehandle()methodof theRemoteCallbackHandlerwith thecorrespondingRemoteCallbacks.ThatmeanstheLocalCallbackHandleractsasawrapperfor theRemoteCallbackHandler.

7.8 Authentication classes

Thefour classesgivenherearethefoundationof all serviceswhichneedauthenticationandauthorization.

A serviceproxyextendsAbstractProxywhichusesanAuthenticatorImpl.WhereastheservicebackendextendsAbstractBackendwhichusesanAuthenticatorBackendImplto provide theauthenticationfunctionality.

Bothclasses,i.e.AuthenticatorImpl andAuthenticatorBackendImpl,canbeuseddirectly, so that is not mandatoryto extendfrom thegivenclassesthat isthe moreflexible conceptif extensionis not possible.Whereasthe mosteasiestwayis to extendthe both classes.Theseboth classesonly act asa wrapper. That meansAbstractProxy calls thecorrespondingmethodsof AuthenticatorImpl andAbstractBackend callsthecorrespondingmethodsof AuthenticatorBackendImpl.

7.8.1 AbstractProxy

Therefore,anAbstractProxy providestwo methods:login() andlogout()that calls the appropriatemethodson Authenticator that is storedin the fieldauthenticator.

7.8.2 AbstractBackend

AbstractBackend is a little bit morecomplex thanAbstractProxy. It imple-mentstheLandlord interfaceandcallstheappropriatemethodsof theAuthenticatorBackendthatis storedasa field. RemoteAuthenticator is implementedby this class,too.

Thereforethelogin() andlogout()methodscall themethodsof theAuthenticatorBackend.getAuthenticator() andgetSignedObject() aretwo protectedmeth-

ods. The first returnsthe own field, whereasthe secondonereturnsthe resultof thecorrespondingmethodof theAuthenticatorBackend.

82

Page 84: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

Asexplainedabove,AuthenticatorImpl andAuthenticatorBackendImplareverycrucialfor theserviceitself.

In away, theseclassesaresimilartoRegisterImpl andRemoteRegisterImpl.Themaindifferenceis thatregistrationneedsnoauthentication,whereasauthenticationis neededby log onsessions.

loggedIn is aboolean field thatstoresthestateof thesession.Two fieldsareusedto storetheslot results.slotRes storestheresultthatis neededto communicatewith theSubjectAuthenticator service,whereasthe secondoneis neededtoreloginwith aLoginToken which theloginSlotResult contains.

TheSecureClient hasgot the object that encapsulatesthe securecommuni-cation. A SignedObject with the public DH key amongotherthingsis storedinthefield signedObject. Thelastfield remoteCallbackHandler holdsa ref-erencefor aRemoteCallbackHandler.

Theconstructorssetsthegivenvaluesfor signedObject andremoteAuthenticator.A new SecureClient is createdhere.

TheprivatemethodscheckSignature() andinstallProvider() aremostlyequalto themethodsdescribedin RegisterImpl. ThemethodsgetCallbackToken()andgetDefaultUser() still haveto beimplemented.Currently, they returnnull.

Everymethodthatcallsmethodsof thebackend,checksif alreadyhavebeenloggedin. If not,login() is calledexplicitly, whereaslogin() callslogout() first iftheuserhasalreadybeenloggedin.

After thatcheck,installProvider() andcheckSignature() arecalledto ensurethat the communicationcan be trusted. Then, the public DH key storedinside the SignedLoginData is usedto generatethe secretDH key by callingSecureClient.keyGeneration(). Thatnewly createdsecretkey andtheDomainName,alsostoredin theSignedLoginData, aretheargumentsto theRemoteCallbackHandlerImpl.

After creationof a LoginData, the login() methodof the backendcan becalled,whereastheLoginData will be sealedandthe resultwill be unsealed.TheresultcontainsthebothSlotResultswhicharestoredin thebothfields. In theend,theToken andtheCookie for theSecureClient canbesetfor furthercommu-nication.Thevery laststepis to setloggedIn to true, sincetheauthenticationhasbeensucceeded.

7.8.3 AuthenticatorBackendImpl

Thebackendversionof AuthenticatorImpl isAuthenticatorBackendImplthatimplementstheAuthenticatorBackend interface.

ThisimplementationhasfourfieldstostoreaDomainName, asessionslotprovider,a signingkey anda field for aSubjectAuthenticator finder. A constantcalledSESSION_DURATION statesthedurationof aLoginToken.

TheconstructortakesaLandlord, aDomainName andapasswordaschararray.Thepasswordis usedin loadSigningKey() to restoretheprivatesigningkey fromits storedencryptedversion.Theconstructorcreatesanew ServiceFinder to findaSubjectAuthenticator. It alsocreatesa new SecureSlotProvider, usingtheLandlord andtheSESSION_DURATION asarguments.Finally, theverb—domainName—is setandloadSigningKey() is calledwith thepassword.

loadSigningKey() andgetSignedObject() arevery closeto the samemethodsin RemoteRegisterImpl. Onedifferenceis thatSignedLoginDataImplis usedinsteadof its superclassSignedRegisterDataImpl.

83

Page 85: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

login() usesthe parameterpublicKey to leasea slot. After retrieving theCookie from the SlotResult, the encryptedLoginData could be decrypted.Then,theLoginData andthe storedRemoteCallbackHandler is usedto callthelogin() methodof theSubjectAuthenticator service.

If theauthenticationsucceeds,theservicereturnsaSubjectAuthResultwhichis storedin the SecureSlotProvider with the Cookie as key. Finally, the en-cryptedandnewly createdLoginResult containingthebothSlotResults is re-turned.

7.9 BlueDot Service

7.9.1 Proxy

TheBlueDotProxy implementstheBlueDot interface.This implementationhasone field that is a referenceto the backend,a RemoteBlueDot and is set by theconstructor. ping() andrunApplet() only call thecorrespondingmethodsof thebackend.

7.9.2 Backend

BlueDotService which implementsRemoteBlueDot is moresophisticated.Ithasto provide a schedulingfor all incomingrequeststhatwant to run anApplet ontheRing.

The incomingrequestsarestoredin a List calledqueue. Thenumberof portsis storedin ports, wherebythenumberof freeportsis storedseparatelyin free. Amappingbetweenportsandrequeststo run on arestoredin theMap plan.

Therealsomustbeafield to storeareferenceto aJibMultiFactory. It is usedto communicateto theBlue Dot Receptorandthereforeto theJavaRing.

The constructorsetsfree andports to one. Therealso shouldbe a way todeterminethenumberof portsdynamically. A Vector is createdasqueue andanewHashMap is usedasplan. TheJibMultiFactory is createdwith anoargumentsconstructor. ThenaddJibListener() andstartPolling() have to becalled.SinceBlueDotService implementsJibMultiListener, it registersitself.

Oneof thetwo argumentsof theBlueDotService is thestoragelocationwhichis givenasargumentto thesuperclassBasicUnicastService. Theotherparame-ter is theString path which determines,whereto storethedownloadedfiles. Butthemain()methodonly takesoneargument,i.e. thepath.Thefilenameof thestoragelocationis theconstantFILENAME.

getProxy() returnsanew instanceof aBlueDotProxy asexpected.The requestschedulingis done by the four methodsiButtonInserted(),

iButtonRemoved(), runApplet() anddispatchSlots().The runApplet() methodcreatesa new BlueDotEntry which storesthe

callerThread, anexceptionif thrown while executionandtheRingApplet to run.After enqueuing,dispatchSlots() is called.Theexecutionof thecurrentThread

cannow be suspendedby calling suspend() on theBlueDotEntry’s Thread.Sincetheexecutiononly resumesif theApplet hasbeenexecuted,theexceptionin-sidetheBlueDotEntry canbechecked.If it isnull,ringApplet.getData()is returned,otherwisethegivenException will bethrown.

84

Page 86: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

dispatchSlots() searchesfor the first free slot if the amountof freeslotsismorethanzero. TheBlueDotEntry is removedfrom thequeue andput into theMap plan using the numberof the port askey. A message,which is storedin theRingData insidetheRingApplet, is printedto theconsole.

iButtonInserted() is calledautomaticallyif a Java Ring hasbeeninserted.UsingtheJibMultiEvent parameter, theslot canbedetermined,andthereforetheBlueDotEntry of theplancanberetrieved. If thereis noBlueDotEntry for thespecifiedport,anerrormessageis printed.OtherwisethesetSlot() methodof theJibMultiFactory is calledwith theslotasargument.

A Selector hasto be createdto run the specifiedApplet on the Java Ring.Thedatafor thatis storedin theRingApplet andtheRingData which areaccess-ableby theplan. After the invocationof theSelector’sselect() method,theRingApplet’srun() methodcouldbecalled.

Thecounterpartof iButtonInserted() is iButtonRemoved(). Depend-ing on theslot, thecorrespondingBlueDotEntry is retrievedfrom theplan. ThecallerThread is reactivatedby callingresume() onit. Theamountof freeslotswillincrement,theBlueDotEntrywill beremovedfromtheplan anddispatchSlots()is called,sincethecurrentslot canbedispatched.

The proprietarysoftware to selectand run an Applet on the Java Ring needsan external “jib file. Therefore,the jib file needsto be downloaded. The methodwriteJibFile(), which is called in runApplet(), usesthe URL inside theRingData to download the jib file with a InputStream. It is written using aFileOutputStream into thestoredpathwith its appletname.

7.10 RingAuthentication Service

Building ontheBlueDot service,theRingAuthentication serviceprovidestheability to runachallenge-responseApplet onaJavaRing. ThereforeaRingAppletis neededwhich canbegivenasanargumentto theBlueDot service.

7.10.1 RingAuthenticationApplet

RingAuthenticationApplet extendsAbstractRingApplet andcanexe-cutea challenge-responseApplet on theJava Ring.

Threefieldsareneeded:challenge storesthegivenChallenge,challengeDatareferencesthe ChallengeData that containsthe Response and a byte arraysend is usedto communicatewith theJava Ring.

Only byte arrayscanbeexchangedwith theApplet on theJava Ring,sothataprotocolneedsto bedefined.All therelevantinformationaregivento theconstructor,i.e. theRingData, theChallenge andtheDomainName.

The protocol for the challenge-responseinvocation is: length of Password +password + lengthof DomainName + DomainName + Challenge. Currently,in thissampleimplementationnopassword is required,sothefirst byte is zeroandisfollowedby thelengthof thedomain.

DomainName andChallenge provide the methodtoByteArray() whichreturnstherepresentationof theseobjectsasbyte arrays.Doing it thatway, thefieldssend andchallenge canbesetin theconstructor.

Therun() methodcalls theencryptDispatch() methodandprintsout theendmessage.encryptDispatch() is the centralpoint of that class. It usesthe

85

Page 87: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

JibMultiFactory that is given asparameter, to contactthe Java Ring AppletusingthesendAPDU message,wherebyit createsanew CommandAPDU andreceivesaResponseAPDU.

EveryResponseAPDU hasgotastatuswordthatcanbeaccessedbycallingsw()on it. Theresponsecontainsabyte arraythat is structuredthatway: lengthof User+ User + Response.

Bothobjectsarerestoredfromthebyte arrayrepresentationandanew ChallengeDatacanbecreatedwith botharguments,sothatgetData() canreturnit.

7.10.2 Proxy

TheRingAuthenticationProxy implementstheRingAuthentication in-terfaceandcontainsa referenceto aRemoteRingAuthentication objectwhichis contactedif ping() or challengeResponse() is called.

7.10.3 Backend

RingAuthenticationService extendsBasicUnicastService andimple-mentstheRemoteRingAuthentication interface.

It hasfor constants:APPLET_NAME is usedto accesstheApplet on the JavaRing.FILENAME is neededto storethecontext informationof thatservice.MESSAGEisusedby theBlueDotServiceto printsomeinformationfor theuserandatlastPASSWORDcurrentlyasa""-String, sincethis implementationdoesnot usea password to ac-cesstheJava RingApplet.

Theclassprovidestwo fieldsbesidestheconstants.blueDotFinder isaServiceFinderusedto contacttheBlueDotService, i.e. to invoketherunApplet() methodofit. Finally, it also storesa RingData object that containsthe accessinformationneededby theBlueDot service.

Themain() methodexpectsoneargument:the URL, wherethe jib file, neededby the BlueDot servicecan be downloaded. Using the constantFILENAME andthe URL, which is enhancedby theAPPLET_NAME andtheAPPLET_POSTIX, theconstructoris called.

Therealstartof theserviceis doneby calling theinitialize() method.Theconstructorcreatesa new RingDataImpl with the given informationandsetsthefield. It alsosearchesaBlueDot serviceby creatinga new ServiceFinder. Thereferenceis storedto theappropriatefield.

getProxy() returnsa new instanceof RingAuthenticationProxy asex-pectedthatonly takesthereferenceof theserviceasargument.

Themostimportantmethodof thisclass:challengeResponse() is veryshort.Using theRingData field andthe two parametersChallenge andDomainNamea new RingAuthenticationApplet is created. Then, the ServiceFinderis usedto retrieve a valid referenceof a BlueDot proxy. The resultof the invoca-tion of therunApplet() methodof theBlueDot serviceis returned,wherebytheargumentwastheRingAuthenticationApplet.

7.11 UserDBservice

TheUserDB serviceconsistsof two parts: the serviceitself and the correspondingproxy.

86

Page 88: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

7.11.1 Proxy

TheUserDBProxy extendstheRegisterImpl andimplementstheUserDB in-terface.

Its constructorhasto thesetthefieldremoteUserDB thatreferencesthebackendserviceandit is usedby themethodsauthenticate(),ping() andrefresh()to call theappropriatemethodsontheservicebackend.They alsocheckif alreadybeenregistered,otherwiseregister() is calledfirst.

7.11.2 Backend

Theservicebackend,i.e. UserDBService extendsRemoteRegisterImpl andimplementstheRemoteUserDB interface.

Currently, theUserDB only providestwo usersfor two authenticationschemes.Itdoesnot contactsomekind of underlayinguserdatabase.

For password authentication,the usersschochand krone with their passwordsthomasandoliver arehardcoded.For usewith anJava Ring, two DESede keys arecreatedandstoredinto awell-defineddirectoryif they doesnot alreadyexist there.

Therefore,a few constantsareneeded.PATH defineswherethe keys shouldbestored,i.e. from whereto restore.SEPARATOR defines,how theuserandthedomainnameareseparatedin a filenameandSYMTYP definesthe prefix of sucha filename:schoch-john.secretKey.

SYMALG specifieswhich algorithmshouldbeusedfor thechallenge-responsepro-cedure.Theoneusedin thisimplementationisDESede/ECB/NoPadding. SYMKEYTYPdefinesthekeys: DESede.

FILENAME andSERVICE_DURATION aretwo morefields that store,wheretostoretheservicescontext informationandthemaximumdurationof a lease.

passwordMap andsecretKey are two Maps that map the user-nameto thepassword, i.e. SecretKey.

Themain()methodexpectstwo arguments:theDomainName andthepasswordto accessthe key store. The first thing is to add a new SunJCE securityproviderto theJVM. Then,anew UserDBService canbecreatedusingtheFILENAME, theDomainName andthepasswordaschararray. Thelastthingis to call theinitialize()methodof thatobjectto starttheservice.

Inside the constructor, two HashMaps are createdand generateMaps() iscalled for the two fields. This methodsput the password thomasand oliver in thepasswordMap for theusersschochandkrone.

It also tries to retrieve the keys for the challenge-responseprocedurefrom file.ThereforegetFilename() buildstheappropriatefilenameconsistingof path,User,DomainName andSYMTYP. If thefile exists,getSecretKey() is calledwhichre-trievestheSecretKey byusinganObjectInputStream, otherwisewriteKey()is calledwhichgeneratesanew SecretKey, writesit to afile usingaObjectOutputStreamandreturnsthekey asresultof the invocation.Now, theSecretKey andtheUsercouldbeput into thesecretKeyMap.

Sincetheuserdatais static,refresh() doescurrentlynothing.getProxy()returnsa new instanceof UserDBProxy asexpected.

Theargumentsfor theconstructorareareferenceof theserviceitself andtheresultof getSignedObject(). The most importantmethodis authenticate(). ItunsealstheSealedCookieMacObject andcallstheappropriatedoAuthentication()

87

Page 89: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

methodswith theunsealedobjectasparameterif thetheunsealedobjectis aninstanceof AuthData or ChallengeData method.

The verificationof the password is doneby comparingthe storedpassword withtheonein AuthData, wherebytheuser-nameis thekey to retrieve thepassword. Ifthe password is incorrect,the password or the userdoesnot exist in the databaseanException will bethrown, otherwisethestoredsubjectData will bereturned.

The verificationof the challenge-responseis similar. TheSubjectData is re-trieved from the map using the user-name. Then, the SecretKey is taken fromthe SubjectData and the Response is calculatedfrom the challengeusing theSecretKey. If thecalculatedResponse equalsto theResponse in theChallengeDataparameterthe subjectData will be returned,otherwisean Exception will bethrown.

The calculationof the Response is doneby initializing an Cipher object inENCRYPT_MODE with the SecretKey. The Response is retrieved by callingdoFinal() on theChallenge.

7.12 LoginPolicyDB service

Thestructureof this serviceis verysimilar to theUserDB’sone.

7.12.1 Proxy

TheLoginPolicyDBProxy extendsRegisterImpl andimplementstheLoginPolicyDBinterface. The field remoteLoginPolicyDB storesa referenceto the backendwhichisusedin thethreemethodsping(),refresh() andgetLoginPolicy()to call thecorrespondingmethods.Everymethodschecksif theproxyhasalreadybeenregistered,otherwiseregister() will becalledfirst.

7.12.2 Backend

LoginPolicyDBService is thebackendfor theproxy, it extendsRemoteRegisterImplandit implementstheRemoteLoginPolicyDB interface.

Its only constantis FILENAME which determineswhereto storethecontext infor-mation.

Sincethis is a sampleimplementation,only oneLoginPolicy is returned,notdependingonthethreedimensions:DefaultUser, serviceandattempt.ThatmeansgetLoginPolicy() doesthesealingandunsealingof theparameter, i.e. theresultandusesdoLookup() to retrieve theLoginPolicy.

doLookup() returnsanew instanceof DefaultLoginPolicy.getProxy() returnsanew instanceof LoginPolicyDBProxy asexpected.refresh() doescurrentlynothing,sincethepolicy is hardcoded.

7.13 Jaasservice

TheJaas serviceusestheJAAS moduleto implementtheSubjectAuthenticatorservice.This implementationalsoincludestwo implementationsof aLoginModule.

88

Page 90: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

7.13.1 ConsolePasswordLoginModule

ConsolePasswordLoginModule is onetheseimplementations.The four fieldsthatstoresSubject, CallbackHandler, sharedState andoptions aresetby initialize()’sarguments.

Theboolean field commitSucceeded andsucceeded areusedto statethatthesephasesarecompletedsuccessfully. The third boolean variabledebug is re-trievedfrom options andit is usedto displayadditionaldebug information.

Finally, afield thatstoresSubjectData is required,sincethis referenceis setbylogin() andusedin commit().

The constructordoesnothing, sinceinitialize() doesthe mandatoryini-tialization. That meansit setsdebug, options, sharedState, subject andcallbackHandler.

login() createsa NameCallback and a PasswordCallback to createaLocalNamePasswordCallback. It also createsa UserDBCallback and in-vokestheCallbackHandler’shandle() methodswith theseCallbacks.

After that,aUser andaPassword objectcanbe instantiatedwith the informa-tion from theCallbacks. SincetheUserDBCallback returnsaUserDB proxy,the servicecanbe consultedusinga AuthDataImpl, consistingof the User andthe Password. The result of that invocation,a SubjectData is stored. If anException occursin login(), all theinformationwill bewipedoutandan|LoginException|willbethrown.

commit() usestheSubjectData to addthePrincipals,thepubliccreden-tials andthe privateCredentialsto theSubject field. logout() doesthe reverseoperation:it removesthedatafrom theSubject field andclearsall information,likeabort() doesit.

7.13.2 RingLoginModule

RingLoginModule is verysimilartoConsolePasswordLoginModule, sothatonly thedifferencesneedto bestated.

login() usestheLocalChallengeCallbackwith anew ChallengeImpl()to retrieve theUser andtheResponse. ThentheUserDB canbecontactedwith anew ChallengeDataImpl, consistingof theChallenge, theResponse andtheUser. Therestis thesameasdescribedabove.

7.13.3 Proxy

TheJaasProxy alsoextendsRegisterImpl andimplementsSubjectAuthenticator.ThefieldsremoteSubjectAuthenticator referencesthebackendservice.

Themethodslogin(), logout(), ping() andrefresh() areresponsibleto do thesealing,unsealingandcall themethodsof thebackend. If theproxy hasnotbeenregistered,register() is calledfirst.

7.13.4 Backend

TheJaasService is a little bit morecomplex thantheotherservices.TheserviceextendsRemoteRegisterImpl andimplementstheRemoteSubjectAuthenticatorinterface.

89

Page 91: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

FILENAME and LOGIN_DURATION are two constantsthat specifieswhere tostorethecontext informationandthedurationof aleasethatisgivenoutfor aJAASSlotResultImpl.For thatreasonthefield landlordLeaseFactory is usedto createnew Leases.

A SlotProvider asafield isalsoneeded,becauseit containstheJAASSlotResults.Sincethisserviceusestwootherservices,theServiceFinder fieldsloginPolicyDBFinderanduserDBFinder areneeded.

Themain()methodexpectstwo arguments:theDomainName andthepasswordto accessthekey store.But before,a new JaasService canbe instantiated,a newSunJCE securityprovider is addedto JVM.

Finally,initialize() is calledontheJaasServicewhichstartstheservice.Theconstructorsetsthefield for landlordLeaseFactory, theslotProviderandthetwo ServiceFinders.

getProxy() returnsanew instanceof JaasProxy asexpected.SinceJaasService givesout two differentkindsof leases,this implementation

overridesthefour landlordmethods.If thecookieis a instanceof LoginCookie, thecorrespondingmethodof theslotProvider is called,otherwisethesupermethodis called.

refresh() andlogout() arecurrentlynot implemented.Themostimportantmethodislogin(). It getsthetwo proxiesfromtheServiceFinder

fieldsandunsealstheLoginData. Using theLoginData, theLoginPolicyDBserviceis contactedandreturnsaLoginPolicy.

TocreateaJaasLoginContext, thenameof theLoginPolicy andaCallbackHandlerareneeded,wherebythelastoneis anew instanceof LocalCallbackHandler thattakestheSecretKey, theRemoteCallbackHandler andtheUserDB proxy asargumentsfor theconstructor.

After theinstantiationof theLoginContext, thelogin()methodcanbecalledand if no Exception has occurred,getSubject() is called. The Subjectand theLoginPolicy arebundledinto a JaasSlotResultImpl objectwhichis storedinto the SlotProvider by calling leaseSlot(). The result of theleaseSlot() invocationandtheSubject arebundledasSubjectAuthResultImplandreturnedsealed.

7.14 Challenge-ResponseApplet and Host for the JavaRing

7.14.1 Applet

TheChResp_Applet extendsAppletwhichisdefinedin thejavacard.frameworkpackage.Sincethecommunicationonly worksonbyte arraylevel, theApplet itselfandall themethodsmustbespecifiedby byte values.

Therefore,thefollowing constantsaredefinedasproposedby theDallasSemicon-ductorsIDE: CHRESP_CLA, CHRESP_INS_SET_PIN, CHRESP_INS_SET_KEY,CHRESP_INS_ENCRYPT,CHRESP_INS_SWITCH_PIN,SELECT_CLA,SELECT_INS.TheconstantMAX_SEND_LENGTH is definedto determinethelengthof aAPDU pack-age.

TheDomain, theUser arestoredasbyte arrays.Thekey isstoredasDES3_EncKey.ToprovideanappletPIN, thefieldsuse_pin,appletPIN,pinSize andlastPINCheckTimeareused.To storethedatainsidetheAPDU abyte arrayapduData is defined.

90

Page 92: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

The constructorof the Applet registersitself with the Java Card Environmentusingregister(). Thenuse_pin is setto true,pinSize is setto zeroandanewOwnerPIN is generated.CallingupdateAndUnblock() onthatPIN, setsthepin.install() just createsa new instanceof thatApplet.

Themethoddispatcheris process() which callsoneof thefour methods,spec-ified by the four constants.The most importantmethodis encryptDispatch().If use_pin is true checkPin() is called which first checksthe time if the JavaRing is blocked and unblocksit if the duration is more than three minutes. ThelastPINCheckTime is set to the currenttime and the pin is checked by callingcheckon theappletPIN.

Theformatof theincomingdatais lengthof PIN + PIN + lengthof DomainName+ DomainName + Challenge. TheDomain andChallenge areretrievedfromthatinformation.Firstthedomainiscompared.If it isnotequalaISO.SW_WRONG_DATAException is thrown. ThentheencryptECB() methodis calledon the key andstoredin ret which is sentbackin theendby callingsendByteArray(), whereasthemethodonly sendsthebyte arrayin piecesof MAX_SEND_LENGTH.

The methodset_keyDispatch() expectsthe byte array format: lengthofPIN + PIN + length of Domain + Domain + length of User + User + Key.domain anduser areretrieveddirectly from thebyte array, whereasfirst thekey isgeneratedasDES3_EncKey andis setusingthesetKey() methodwith thebytearray.

set_pinDispatch() expectsthebyte arrayformat: lengthof old PIN + oldPIN + new PIN. It justcallscheckPIN(), setspinSize andcallsupdateAndUnblock()with thenew PIN ontheappletPIN.switch_pinDispatch() expectsthebytearrayformat: PIN + boolean. Sofirst the methodcallscheckPin() andthenitsetsuse_pin by callingbooleanFromByteArray() which interpretsthebytevalueasboolean value.

7.14.2 Host

ThecorrespondinghostprogramiscalledChResp_Host andimplementsJibMultiListenerandRunnable. SincetheencryptionrequestisdonebyRingAuthenticationApplet,this hostprogramis only usedto loadthekeys. Themain() methodexpectsfour ar-guments:thejib file path,thekey file path,theDomainName andtheuser-name.

Theprogramis startedasThread. Therun()methodsonly callsThread.sleep,sothattheprogramcannotleave theJVM.

If iButtonInserted() is invoked,theApplet is selectedandset_keyDispatchis called. Themethodbuilds abyte arrayasdescribedabove andsendsit usingthesendAPDU() method. Sinceno responseis requested,”no responsereceived” isprinted.

91

Page 93: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

Chapter 8

CaseStudy

This chaptershows how a simpleservicecanbe implementedusing the authentica-tion andauthorizationarchitecture.The intentionis to show how the communicationbetweentheservicelayerandthesecuritylayerworks. Thatmeansthegivensampleservicedoesnot have to bevery sophisticated.Its only taskis to show two messages.Thefirst messageshouldbeshown afterthesuccessfulauthentication.Thesecondoneshouldonly beshown if theauthenticateduserhasthepermissionfor it.

8.1 Interfaces

Thecommunicationprotocolbetweenclientandserviceis definedby a Java interface.Sincetheclientdoesnot needto bechangedafterintegratingthesecurityarchitecture,the interfaceshouldalsostaythesame.Thatmeansthe interfacehasno notionaboutthesecurityarchitecture:

public interface Sample extends Serializable{String getMessage();String getAuthMessage();

}

It only definesthe two methodsgetMessage() and getAuthMessage()which returnaString.

The Sampleinterfaceshouldbe implementedby a SampleProxy, whereastheRemoteSample interface, which definesthe communicationbetweenthe serviceproxyandtheservicebackend,shouldbeimplementedby thebackend:

public interface RemoteSample extends RemoteAuthenticator{SealedMacObject getMessage(SealedCookieMacObject data);SealedMacObject getAuthMessage(SealedCookieMacObject data);

}

It has to extendRemoteAuthenticator, sincethe proxy hasto invoke thelogin() andlogout() methods.getMessage() andgetAuthMessage()areresponsibletosecuretheinsecurecommunicationchannel.Sothey usetheSealedMacObjectasreturnvaluesandSealedCookieMacObject asarguments.

92

Page 94: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

8.2 SampleAction

The authorizationcheckis doneby calling theSubject.doAs() methodswith aSubject and a PrivilegedAction as arguments. Therefore,the actionsthatneedauthorization,have to beencapsulatedin therun() methodof an implementa-tion of thePrivilegedAction interface:

public class SampleAction implements PrivilegedAction {Object run(){

return System.getProperty("user.home");}

}

Therun() methodis verysimple.It only returnsaString objectcontainingtheusershomedirectory.

8.3 SampleProxy

Mostof thework of theproxysidework is doneby thesuperclassAbstractProxy,so that the SampleProxy only hasto extend that classand hasto implementtheSample interface:

public class SampleProxy extends AbstractProxy implements Sample{RemoteSample remoteSample;SampleProxy(RemoteSample, SignedObject){};String getMessage(){};String getAuthMessage(){};

}

The constructorcalls the superconstructorwith the RemoteSample and theSignedObject andsetsits ownRemoteSample field.

ThegetMessage() is responsibleto sealtherequestandto unsealtheresponsefrom thebackendwhich is calledby usingtheRemoteSample field:

public String getMessage() throws Exception {SealedCookieMacObject param =

authenticator.getSecureClient().sealObject(null);SealedMacObject result =

remoteSample.getMessage(param);String ret = (String)authenticator.getSecureClient().

unsealObject(result);return ret;

}

SincegetMessage() needsno parameters,only null hasto be sealed,usingthesealObject() methodof a secureclient which canbe retrieved by the superclassfield authenticator. With thatsealedobject,theappropriatemethodof theservicebackendcanbecalled. In theend,theresultof theremotemethodinvocationhasto beunsealedusingtheunseal() methodof thesecureclient.

getAuthMessage() doesexactly the same,except the invocationof anothermethodon thebackend.

Theoverallpatternis:

93

Page 95: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

D sealingtheparameters

D calling thebackendmethod

D unsealingtheresult

If thesealingandunsealingis donein thesecuresocket layer, thebackendmethodcanbecalleddirectly, becausethesealingandunsealingis doneimplicitly in thesecuresocket layer.

8.4 SampleService

Thecounterpartof the serviceproxy is the servicebackend. TheSampleServicehasto extendtheAbstractBackendwhichdoesthesealingamongotherthingsandit hasto implementtheRemoteSample interface. It alsoneedsa main() methodto starttheserviceandan implementationof getProxy() to returntheappropriateserviceproxy:

class SampleService extends AbstractBackend implementsRemoteSample{

final static String FILENAME = "SampleService.dat";SampleService(String, DomainName, char[]);main(String[]);Object getProxy();SealedMacObject getMessage(SealedCookieMacObject data){};SealedMacObject getAuthMessage(SealedCookieMacObject data){};

}

The constructorcalls the superconstructorwith the location of the servicecon-text data,theDomainName andthe password to accessthe key storeentrywhich isretrievedusingtheDomainName.

Tostarttheservice,themain()methodexpectstwoparameters,theDomainNameandthe password for the key store. The third parameterwhich is neededto instanti-ate theSampleService: the locationof the context datais storedin the constantFILENAME. After creationof SampleService, the initialize() methodiscalled:

...SampleService sampleService = new SampleService (FILENAME,

new DomainNameImpl(args[0]), args[1].toCharArray());sampleService.initialize();...

getProxy() returnsan instanceof theSampleProxy. Thereforeit calls theconstructorwith a referenceof itself andtheclassnameof itself:

return new SampleProxy(this, getSignedObject(this.getClass().getName()));

getMessage() shouldreturnaString containingthetwo words:”Hello World”.Therefore,getMessage() first hasto unseal,hasto checkimplicitly theparameterandhasto sealtheString:

94

Page 96: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

SecureSlotProvider sessionSlotProvider =authenticatorBackend.getSessionSlotProvider();

sessionSlotProvider.unsealObject(data);return

sessionSlotProvider.sealObject(data.getCookie(), "Hello World!");

ThesealingandunsealingisdonebyasecureslotproviderwhichneedstheCookiestoredin theparameterto retrieve thecontext information.

Theoverallpatternis:

D unsealtheparameter

D performtheactions

D sealtheresult

If thesealingandunsealingis doneby thesecuresocketlayer, only theactionshaveto beperformed.

ThedifferencebetweengetMessage() andgetAuthMessage() is thatgetAuthMessage()usesSubject.doAs() to performanactionthatneedsauthorization:

SecureSlotProvider sessionSlotProvider =authenticatorBackend.getSessionSlotProvider();

sessionSlotProvider.unsealObject(data); Cookie cookie =

data.getCookie();SubjectAuthResult subjectAuthResult =

(SubjectAuthResult)sessionSlotProvider.getData(cookie);String ret = (String)Subject.doAs(subjectAuthResult.

getSubject(), new SampleAction());return sessionSlotProvider.sealObject(cookie, ret);

Therefore,it retrievestheSubject from thecontext informationstoredby these-cureslot provider. It alsocreatesa new SampleAction thatrun() methodreturnsthe currentusershomedirectory. The restis unsealingthe parameterandsealingtheresult.

8.5 SampleClient

Finally, aSampleClient isneededthatusestheSampleService. TheSampleClientis a regularJini client thatusesaServiceTemplate to specify, whatJini serviceisneeded.Thewholesecurityarchitectureis transparentto the client, so that the clientonly hasto call thebothmethodson theproxy:

JOptionPane.showMessageDialog(null, "It’s message is:\n" +((Sample) o).getMessage(), "SampleClient",JOptionPane.PLAIN_MESSAGE);JOptionPane.showMessageDialog(null,"It’s ’auth’ message is:\n" + ((Sample) o).getAuthMessage(),"SampleClient", JOptionPane.PLAIN_MESSAGE);

95

Page 97: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

8.6 Setupthe policy files

Thesetupof thepolicy files is very crucial in thewholesecurityarchitecture,becausewrongentriescouldallow attacks.Thepolicy file at client sidehasto ensurethatonlyserviceproxiesthataresignedby trustedpartiesareexecuted,whereasthepolicy fileat servicebackendsideis usedto checkif the currentuseris authorizatedto executethe code. Theauthenticationservicealsoneedssomeinformationof how to performtheauthenticationprocess.

8.6.1 Client

The client only needsonepolicy file that only grantsthe appropriatepermissionstosignedand trustedcode. Currently, the SocketPermission must be grantedtounsignedcode,otherwisetheClassLoader cannotbe instantiated.The key store,which containsthepublic verifying keys,couldalsobespecified:

keystore "file:/${user.home}/.keystore", "JKS";

grant signedBy "john"{permission java.security.AllPermission "", "";

};

grant{permission java.net.SocketPermission "*:1024-","connect,accept";

};

8.6.2 Service

Thesampleserviceneedstwo differentpolicy files. OneJDK1.2stylepolicefile thatgrantsall local archivestheAllPermission, except the archivesthat containtheclasseswhich needauthorization.The permissionsfor theseclassesaregrantedin aseparatepolicy file. Thefirst policy file lookslike:

grant codebase "file:/H:/project/jaas1_0/lib/jaas.jar"{permission java.security.AllPermission;

};

...

grant codebase "file:/H:/project/jini1_0_1/lib/sun-util.jar"{permission java.security.AllPermission;

};

grant {permission java.net.SocketPermission "*:1024-","connect,accept";

};

Thesecondpolicy file grantspermissionto authorizationrelevantclasses:

96

Page 98: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

grant codebase"file:/H:/project/jaaa/sampleservice/schoch-sample-action.jar",

Principal schoch.jini.security.reference.auth.PrincipalImpl"schoch" {

permission java.util.PropertyPermission "user.home", "read";};

ThatentrygrantsthePropertyPermission to all classesinsidethejar archive,which are executedby a Subject that containsthe Principal schoch,to readtheuser.home systemproperty.

8.6.3 Authentication Service

The Authenticationserviceitself usesa regular policy file. This SampleServiceusesan authenticationservice,which usesJAAS, so that alsoa configurationfile forthelogin policiesis needed.Theconfigurationfile usedin thatexampleonly providesoneentryDefault which specifiesa consolelogin assufficient anda ring login asrequiredif thefirst fails:

Default{schoch.jini.security.reference.service.jaas.

ConsolePasswordLoginModule sufficient debug=true;schoch.jini.security.reference.service.jaas.

RingLoginModule required debug=true;};

8.7 Key Managementand Signing

A few jar archives,including the downloadableServiceProxy have to be signed.First, the private signing key and the public verifying key must be generated.TheDomainName is usedasalias to accessthe key store. In the given examplea usercalledJohnSmithwill becreated.His aliasandthereforetheDomainName is john:

> keytool -genkey -alias john -keypass 123456

Thepassword to accesstheprivatesigningkey is 123456.Theprivatesigningkeyis usedto signthedynamicDH key andthestaticcodeamongotherthings.

All jar archivesthatareusedby theSampleClient includingthedownloadablecode,have to besigned:

D jce1_2_1.jar

D sunjce_provider.jar

D jaas.jar

D jini-core.jar

D jini-ext.jar

D sun-util.jar

97

Page 99: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

D schoch-sample-client.jar

D schoch-common-int.jar

D schoch-common-impl.jar

D schoch-security-int.jar

D schoch-security-impl.jar

D schoch-signed-dl.jar

Another approachis to sign only the downloadablecodeand to grant the localclassestherequiredpermissions.

8.8 Setupthe envir onment

Theeasiestwayto runtheexampleis to installthewholeprojectin D:\project\jaaaunderWindow NT 4.0or Windows2000. If anotheroperatingsystemor anotherpathis usedthefile jaaa/template/environment.template needsto beupdated.Especiallythe pathsandvariablenameshave to be updated.If therearechangestoenviroment.template, generate-files.bat mustbecalledto updatethebatchfiles which areusedto run all theJava programs.If anotheroperatingsystemisused,all files in thetemplatesubdirectoryhave to beupdated.If anotherpathis used,all policy files in all subdirectoriesmustbeupdated.

8.9 Loading the key onto the Java Ring

If theUserDBService is started,it triesto readthedirectory.jiniauth/challrespin theusershomedirectory. If thedirectorydoesnotexist, theuserhasto createthedi-rectoryfirst,otherwisetheUserDBService cannotworkcorrectly. TheUserDBServicetriesto readtwoTripleDESkeysfrom thefiles[DomainName]-schoch.secretKeyand[DomainName]-krone.secretKey. If the keys do not exist, they will begeneratedautomatically.

To loadaJavaRingwith theuserschoch,loadkey1.bat in theringauthenticationsubdirectoryhasto be launched.If the programis up, theJava Ring mustbe pushedontothebluedot receptorandhasto bereleased.After theprogramreportsthat thereis no responsefrom the Java Ring, becauseit is only an upload,andthereforeno re-sponseis expected,theRing canbereleased.To loada Java Ring with theuserkrone,loadkey2.bat hasto belaunchedin thesamemanner.

8.10 Starting the example

Theexamplecanbestartedif thestepsdescribedabovehavebeendone:

D environment.template hasbeenupdatedandgenerate-files.bathasbeencalledif necessary

D .jiniauth/challresp hasbeencreatedin the usershomedirectoryandtheUserDB.bathasbeenstartedonceto createthekeys

98

Page 100: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

D thekeyshavebeenloadedontotheJava Rings

Thefirst thing is to starttheJini infrastructurein thejiniinfra subdirectory:

D deltmp.bat, deletethepersistentrmid andlus log directories

D lus-http.bat, thehttpserver for thelus

D rmid.bat, thermi activationdaemon

D lus.bat, thelus

Next, a httpserver for theproxiesandtheserviceshave to bestarted:

D common-dl/common-http.bat

D bluedot/bluedot.bat

D ringauthentication/ringauthentication.bat

D userdb/userdb.bat

D loginpolicydb.bat

D jaas/jass.bat

D sampleservice/[samplesigned]service.bat—

D sampleclient/sampleclient.bat

It is possibleto startsampleservice.bat or signedservice.bat. Thedifferenceis that sampleservice.bat startsa servicewhich downloadsa notsignedSampleProxy, sothattheexecutionfails.

First, theuseris promptedfor a user-nameandpassword,afterall servicesandtheclient is up. The password for the userschochis thomas.The password for the userkroneis oliver. If the user-name-password-dialogfails, the Java Ring authenticationstartsand promptsthe userto pushthe Java Ring onto the blue dot receptor. Onlythe userschochhasthe permissionto readthe authorizatedmessage.Both userscanretrieve the non authorizatedmessageafter authentication.If nothingenteredat theuser-name-passworddialog,a null pointerexceptionwill bethrown in thatversion.IftheRing authenticationshouldbeused,somethingmustbeenteredat theuser-name-password-dialog.

99

Page 101: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

Chapter 9

Conclusionand Futur eWork

First,ashortoverview aboutJini relatedprojectsis given.Then,conclusionsandfuturework aresubjectto thefollowing two sections.

9.1 Jini and Friends

In the field of standardizationtheseprotocols,all mayorplayersin the computerandhomeentertainmentbusinessareinvolved. They aretrying to build an infrastructurefor servicediscoveryandwell-definedprotocolsof how to communicate.

Microsoft and28 industrypartnersinitiated the UniversalPlug andPlay (UPnP)initiative in 1999.TheUPnPlayerprovidesdiscovery, descriptionandusageof homeapplications,but thereis currentlyno implementationavailable.

SunMicrosytemsprovidesanarchitecturecalledJini insteadwhichis alreadyavail-able.Thecoreconceptsof Jini, whichhavealreadybeenexplainedin detailabove,arediscovery, lookup, leasing,remoteeventsandtransactionsfor services.SunandEkoSystemsannouncedin April 2000oneof thefirst broad-scaledimplementationsof Jinitechnologyin healthcare.In February2000,MotorolaandSunannouncedthatthey willcollaborateon thedevelopmentof anext-generationarchitectureto supportdistributedCommand,Control,Communication,ComputerandIntelligence(C41)operationsfortheUS Army.

An approachof Sunis to make Jini’s underlayingcomputerlanguageJava thelin-guafrancafor every digital device. Java cameon the market in 1995andwasorigi-nally intendedfor embeddedsystems,but it washeavily usedastheInternetcomputerlanguage,becauseoneof thefeaturesis platformindependence:”Write once,runany-where”. At the momentit seemsthatJava returnsto its root: theembeddedsystems.EmbeddedJava, PersonalJava and the K Virtual Machineare productsthat fit intoenvironmentswith lessresources.So every small device is ableto understandJava.Microsoftgoesthesamewaypushingits operatingsystemWindowsCEin everysmalldevice. EspeciallypalmcomputersarerunningWindowsCE.

Sunjoinedsomeotherinitiativesin thatsegment,andput Java supportin it:

D HAVi: theHomeAudio andVideoInitiative (HAVi) is a ConsumerElectronics(CE)industrystandardthatwill ensureinteroperabilitybetweendigital audioandvideodevicesfrom differentvendorsandbrandsthatareconnectedvia anetworkin theconsumer’shome,

100

Page 102: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

D GSM: themobilephonestandard,

D DVB: thedigital televisionstandard,

D OSGi: the OpenServiceGateway Initiative (OSGi) definesa setof APIs andprovidesa sampleimplementationof a servicegateway architecture.A servicegateway is a focal point, which connectsthe local network containingthe ser-vices,to theInternet.

In January2000SunandCiscoformedanallianceto developanopenarchitecturefor anInternethomegateway. Ciscoprovidesa next-generationprototypeof a HomeGateway Server, runningSun’s Java EmbeddedServer on it. Sun’s EmbeddedServeritself canprovideJini servicesamongotherthings.Two otherimportantcollaberationsin thisfield, is thedevelopmentof a .comHomeenvironmentin Europewith TeliaandtheConnectedFamily environmentwith GTEandCisco.

At CES2000, the ConsumerElectronicsShow 2000,Sunpresenteda refrigera-tor with web panelasa part of the .comHomewhich alreadyusesthe Java andJinitechnology.

9.2 Conclusion

This thesisshowedthat it is possibleto providea secureauthenticationandauthoriza-tion architecturefor Jini services,only usingpresentJava technologies,althoughtherearea few thingsto do to completethearchitectureandtheprototype.

Currently, Jini doesnot provide any securityfeatures,sinceSunsgoal wasto bethefirst on themarket,sotherewasnot enoughtime to includeawholesecurityarchi-tecture.Sunreachedits goalto bethefirst andstill theonly one,who providesa verygeneralservicebrokerage.Therearealsoefforts to put securityinto Jini. Thatmeansto provide a secureRMI with integrity andconfidentiality: RMI SecurityExtension.This extensionalsobuildson JAAS to provideauthenticationandauthorization,but ina very generalway. So,thearchitectureshown in this thesisprovidesa very easyplugandplay approachfor servicedevelopersto includeauthenticationandauthorizationright now.

Thetransparency for theclient is worth a discussion.Theauthorsthink that it is agooddesigndecisionto provide transparency for theclient for variousreasons.First,the client shouldnot be ableto weakthe securitystrength,so that the decisionis upto the service. Second,existing clientsdoesnot needto be changedand third, it ismuchsimplerif only theservicesideis involved.Anotherapproachis thattheclient isawareof thesecurityissuesandis ableto specifythelevel of securityor bothsidescannegotiateaboutthelevel of security. Sincetheclientscanreceiveeventsandtheeventsaresecuredin someway, theclienthasto dealwith securityissues.

9.3 Futur e Work

Currently, the sealingandthe unsealingof datais doneat applicationlevel, i.e. themethodsthereforehave to becalledexplicitly. If thesealingis movedto socket level,then the sealingis doneimplicitly, so that the architectureis almost transparenttoserviceside. If the sealingis doneat applicationlevel, thereis a potentiallysecurityholein thedeserialisationprocess,sincetheserialisationstreamcouldbealteredduring

101

Page 103: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

thetransmission.Althoughthis potentialsecurityholeexists,thereis no concretebadscenarioknown by theauthors.

Anotherimportantpoint is to securetheleases.Theimplementationgivenby Sunis of coursenot secure,so an own implementationusing the securecommunicationclassesmustbeprovided.Also, theadministrationof leasesmustbecompleted,sothata leasecanberenewedor cancelled.Currently, leasesarecreated,but not really main-tained,sincethis astandardtaskandthereforenot thatimportantto this architecture.

Also,eventsshouldbesecuredusingasecurecommunicationchannel,sincereplayor deletionof eventson thewire is a heavy attack.

TheJini infrastructureitself wasnotsubjectto this architecture,sincetheauthenti-cationprocessis build on topof theJini interfaces.It is alsoimaginableto putsecurityin thecoreJini interfaces,but then,theproblemof standardizationarises.

Sincethe referenceimplementationis only madeto show, how and if the archi-tectureworksin smallexamples,someservices,especiallytheLoginPolicyDB serviceandtheUserDBservicehave to beexpanded,e.g. they couldcontactdatabasesusingtheJDBCinterface.

However, sincethis is thefirst trial of building a securearchitecture,therearestillremainmany pointswhich canbedonebetterat secondglance.Interestedpartiesarewelcometo continuethework on this architectureandthey maycontacttheauthorforthatpurpose.

9.4 Acknowledgements

Therearemany peopleI have to thankfor supportingmeto work on my diplomathe-sis. First, thereis Prof. Matternfrom ETH Zurich,who is responsiblefor my diplomathesis.Healsostartedtheprocedurethatmadeit possiblefor meto stayat theInterna-tional ComputerScienceInstitutein Berkeley, California,by contactingOliver Kronefrom SwissCom,whostill worksattheInstitutefor oneyearin all. OliverKronelookedafterthis diplomathesisandworkedwith mein thatfield. Healsoestablishedthecon-tactto SunMicrosystemsin Cubertino.At theinstitute,JoachimBeer, theleaderof theNSA GroupandLila Finhill, theadministrativemanager, helpedmein theadministra-tivefield. I hadmany discussionswith HannesFederrathfrom TU Dresden,a securityexpert at the Institute, aboutsecurityin generaland in my architecture.Also, BobScheiflerfrom SunMicrosystemsgave meanimportantfeedbackon this architecture.SandraFaul,acolleaguein giving privatelessonsfor pupils,at leastcorrectedthemostwrong partsof the Englishgrammar. And last but not least,I want to thankall thepeopleat theInstitutefor thatgreattime I hadfrom Februaryuntil May 2000.

102

Page 104: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

Bibliography

[1] W. KeithEdwards.CoreJini. PrenticeHall, 1999.

[2] George Coulouris, JeanDollimore, Tim Kindberg. Distributed Systems.Con-ceptsandDesign.SecondEdition.Chapter16 Security, page477-516.Addison-Wesley, 1998.

[3] JayMiller, Kelby Zorgdrager. The Jiro TechnologyOn-Line Tutorial. SeriesI:Part III. WhatareManagementComponents?SunMicrosystems.2000.

[4] Felix Baessler, JosBonnet,PascalBrisset,Ciara Byrne, Claudio Lobo, RogerKehr, PeterKeller, Oliver Krone, SusannaMakinen,JoachimPosegga,RolandSchmitz,TelmoSilva, Edwin Wiedmer, PeterWindirsch,FredericoVieira, PeteYoung.Eurescom.Jini & Friends@ Work: towardssecuredserviceaccess,Ver-sion0.9.May 2000.

[5] TishWilliams. JavaRingsAre A Girl’sBestFriend.UpsideToday. 1998-03-25.

[6] Bill Day. TheJavaPlatformScalesTo Fit SmallSpaces.JavaWorld. 1998-03-26.

[7] BethDickey, N’Gai Croal,ThomasHayden.RunRingsAroundYour FriendsinCyperscope.Newsweek.1999-05-24

[8] Casey Cameron,Bill Day. KnuckletopComputing:TheJavaRing.SunMicrosys-tems.1999-11-15.

[9] David Fiedler. Lord Of TheRings.WebDeveloper. 1998-03-25.

[10] WarrenWebb. Electronicstampslick interest.EDN Access.1998-08-03.

[11] RinaldoDi Giorgio. iButtons: Thefirst ready-to-buy 2.0 Java CardAPI devices.JavaWorld. April 1998.

[12] StevenMeloan.InsideTheJavaRing Event.SunMicrosystems.1999-11-15

[13] SteveLockwood,JoeDuhamel.TheJewel in theJavaRing.1998-04-03.

[14] Chuck McManis. Ring fever: A first-handlook at Java-poweredjewelry. JavaWorld. April 1998.

[15] StephenM. Curry. An introductionto theJavaRing.Java World. April 1998.

[16] DallasSemiconductors.javadocdocumentationof JavaRingpackages.

[17] JakobNielsen.TheJava Ring: A WearableComputer. useit.com.1998-01-05.

103

Page 105: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

[18] DallasSemiconducttors.iButtonwith JavaCommandProcessor. 1999-06-11.

[19] DallasSemiconductors.APDUSender.

[20] ChuckMcManis.My ENIGMAtic JavaRing.Java World. August1998.

[21] SunMicrosystems.Java Card2.0ApplicationProgrammingInterfaces.Revision1.0Final.1997-10-13.

[22] JonByous.JavaTechnology:An Early History. SunMicrosystems.2000-02-07.

[23] OpenCardCosortium.OpenCardFramework 1.2 – Programmer’s Guide.FourthEdition.December1999.

[24] ThomasSchack,RinaldoDi Giorgio. How to write OpenCardservicesfor JavaCardapplets.JavaWorld. October1998.

[25] Mike Wendler, StephanBreidenreich,Rinaldo Di Giorgio. How to write aCardTerminalclassfor simpleandcomplex readersin anOpenCardenvironment.JavaWorld. January1999.

[26] RinaldoDi Giorgio, MikeMontgomery. Write OpenCardservicesfor download-ing JavaCardapps.Java World. February1999.

[27] OpenCardConsortium.OpenCardFramework (OCF): FrequentlyAsked Ques-tions.1998-07-14.

[28] OpenCardConsortium.OpenCardFramework – GeneralinformationWebDocu-ment.October1998.

[29] SunMicrosystems.Java Naming& DirectoryInterface.

[30] SunMicrosystems.CreatingaCustomSocketType.1999.

[31] SunMicrosystems.CreatingaCustomRMI SocketFactory. 1999.

[32] Hewlett-PackardCompany. CoolTown Vision.2000.

[33] Tim Kindberg,JohnBarton,Jeff Morgan,GeneBecker, DebbieCaswell,PhilippeDebaty, Gita Gopal,MarcosFrid, Venky Krishnan,HowardMorris, JohnSchet-tino, Bill Serra.People,Places,Things: Web Presencefor the Real World.Hewlett-PackardCompany

[34] Rinaldo Di Giorgio. An introductionto the URL programminginterface.JavaWorld. September1999.

[35] Microsoft.UniversalPlugandPlay. 1999-11-02

[36] SunMicrosystems.MotorolaAnd SunCollaborateTo Dot-ComNext-GenerationC4I Systems.2000-02-10

[37] SunMicrosystems.SunMicrosystemsAnd Eko SystemsAnnounceOneOf TheFirst Broad-ScaleImplementationsOf Jini TechnologyIn Healthcare.2000-04-10.

[38] SunMicrosystems.K Virtual Machine(KVM). 2000.

104

Page 106: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

[39] RobertD. Hof, RogerCrockett. A Java In Every Pot?BusinessWeek.1998-07-16.

[40] JohnRommel.TheJava-enabledwirelessworld. Java World. March2000.

[41] SunMicrosystems.Standardsat Work. 2000.

[42] Sun Microsystems.Java TechnologyAdopted As The StandardFor A WideRangeOf ConsumerDevicesAcrossMultiple Markets.2000-01-06.

[43] OpenServicesGateway Initiative (OSGi).FrequentlyAskedQuestions.

[44] HomeAudio VideoInteroperability(HAVi). FrequentlyAskedQuestions.

[45] SunMicrosystems.HomeGatewayEnablesHomeServices.2000.

[46] SunMicrosystems.SunMicrosystemsAnd CiscoSystemsFormAllianceTo De-velopOpenArchitectureFor InternetHomeGateway. 2000-01-06.

[47] SunMicrosystems.SunMicrosystemsAnd Telia To DevelopA .ComHomeEn-vironmentIn Europe.2000-01-06.

[48] SunMicrosystems.SunMicrosystems,GTE And CiscoSystemsCreate”Con-nectedFamily” Internet-EnabledProductsAnd Technologies.2000-01-06.

[49] SunMicrosystems.The.ComHome.2000.

[50] Sun Microsystems.Sun Microsystems’Scott McNealy IntroducesThe .ComHomeOf TheFutureAt TheConsumerElectronicsShow. 2000-01-06.

[51] SunMicrosystems.Sony andSunJoin ForcesTo Link Digital ConsumerElec-tronicsAppliancesDirectly To InternetContentAnd Services.1999-11-10.

[52] RogerKehr, JoachimPosegga,HaraldVogt. PCA: Jini-basedPersonalCardAs-sistant.

[53] MichaelRohs,RogerKehr, HaraldVogt. Slides:Jini-enabledSmartcardTermi-nal.

[54] RinaldoDi Giorgio, MikeMontgomery. Write OpenCardservicesfor download-ing JavaCardapps.February1999.

[55] RogerKehr, MichaelRohs,HaraldVogt.Mobile CodeAs An EnablingTechnol-ogy for Smartcard-Middleware.

[56] Zhiquin Chen,Rinaldo Di Giorgio. UnderstandingJava Card 2.0. Java World.March1998.

[57] ProSystSoftwareAG. mBeddedServer. Whitepaper. 2000

[58] Eric Freeman,SusanneHupfer. Make room for JavaSpaces,Part 1. Java World.November1999.

[59] Eric Freeman.Makeroomfor JavaSpaces,Part 2. JavaWorld. January2000.

[60] SusanneHupfer. Makeroomfor JavaSpaces,Part3. Java World. March2000.

105

Page 107: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

[61] RogerKehr, AndreasZeidler, HaraldVogt. Towardsa GenericProxy ExecutiveServicefor SmallDevices.FuseNetDEWorkshopPositionPaper. October1999.

[62] PascalBriset.RealGeniesLive in Lightbulls: The Casefor a Lightweight JiniRegistrationProtocol.February2000.

[63] GerdAschemann,RogerKehr, AndreasZeidler. A Jini-basedGatewayArchitec-turefor Mobile Devices.JIT ’99. SpringerVerlag,1999.

[64] GerdAschemann,SvetlanaDomnitcheva, PeerHasselmeyer, RogerKehr, An-dreasZeidler. A Framework for the Integration of Legacy Devices into a JiniManagementFederation.DSCOM’99. Springer-Verlag,1999.

[65] GerdAschemann,RogerKehr, AndreasZeidler. Slides:Jini Shortcomings.2.JiniWorkshop,Zrich. 1999-11-22.

[66] VerlagHeise.Jini im Flachmann.heiseonlinenews.2000-02-25.

[67] Bill Venners.How to attachauserinterfaceto aJini service.JavaWorld. October1999.

[68] HannesFederrath.Slides:MathematischeGrundlagenasymmetrischerSysteme.Draft. 2000.

[69] CRYPTOCard.Homepage.1999.

[70] DenisBoder. pamcryptgPAM module.

[71] Bob Bosen.Positive UserAuthenticationwith Challenge/ResponseSuper-SmartCards.SecureComputingCorporation.1996.

[72] SecureComputingCorporation.WhitePaper:Virtual SmartCardSolution.2000.

[73] StevenE. Czerwinski,BenY. Zhao,ToddD. Hodes,Anthony D. Joseph,RandyH. Katz. An Architecturefor a SecureServiceDiscovery Service.Mobicom’99Seatle.ACM, 1999.

[74] Bob Bosen.InternetEncryption,NodeAuthentication,andUserAuthentication.SecureComputingCorporation.1996.

[75] SunMicrosystems.Java AuthenticationandAuthorizationService(JAAS) 1.0.Developer’sGuide.2000-01-14.

[76] SunMicrosystems.Java AuthenticationandAuthorizationService(JAAS) 1.0.LoginModuleDeveloper’sGuide.2000-01-12.

[77] SunMicrosystems.Java AuthenticationandAuthorizationService(JAAS) 1.0.FrequentlyAskedQuestions.2000-01-12.

[78] CharlieLai, Li Gong,Larry Koved, Anthony Nadalin,RolandSchemers.UserAuthenticationandAuthorizationin theJavaPlatform.Publishedin theProceed-ings of the 15th Annual ComputerSecurityApplication Conference,Phoenix,AZ, December1999.

[79] Vipin Samar, CharlieLai. MakingLogin ServicesIndependentof AuthenticationTechnologies.SunMicrosystems.

106

Page 108: An Authentication and Authorization Architecture for Jini ... · Jini, a technology from Sun Microsystems, is one of several approaches to provide a middleware for service discovery

[80] SunMicrosystems.Java CryptographyExtension1.2.1API Specification& Ref-erence.2000-02-03.

[81] SunMicrosystems.keytool - Key andCertificateManagementTool.

[82] SunMicrosystems.Java CryptographyArchitectureAPI Specification& Refer-ence.1998-10-30.

[83] Li Gong.Java SecurityArchitecture(JDK1.2).Version1.0. SunMicrosystems.1998-10-02.

[84] SunMicrosytems.Java RemoteMethosInvocationSpecification.Revision 1.50,JDK 1.2,October1998.

[85] SunMicrosystems.Java ObjectSerializationSpecification.Revision 1.43,JDK1.2,1998-11-30.

[86] SunMicrosystems.DefaultPolicy ImplementationandPolicy File Syntax.1998-10-30.

[87] Sun Microsystems.Java RemoteMethod InvocationSecurityExtension.EarlyLook Draft 2. 1999-09-24.

[88] SunMicrosystems.How to Implementa Provider for theJava CryptographyAr-chitecture.1998-09-21.

[89] Sun Microsystems.X.509 Certificatesand CertificateRevocationList (CRLs).1998-05-20.

[90] SunMicrosystems.SecurityManagersandJDK 1.2.1998-10-19.

[91] SunMicrosystems.API for PrivilegedBlocks.1998-09-22.

[92] SunMicrosystems.Permissionsin theJava2 SDK. 1998-10-30.

107