1 package org.sapia.regis.remote; 2 3 public class Authenticator { 4 5 private String _username, _password; 6 7 Authenticator(String username, String password){ 8 _username = username; 9 _password = password; 10 } 11 12 void authenticate(String username, String password){ 13 if(_username == null || _password == null){ 14 return; 15 } 16 else{ 17 if(_username == null){ 18 throw new IllegalStateException ("Registry server username not set"); 19 } 20 if(username == null){ 21 throw new SecurityException ("Invalid access; username not specified"); 22 } 23 if(!_username.equals(username)){ 24 throw new SecurityException ("Invalid access; username invalid"); 25 } 26 if(_password != null){ 27 if(password == null){ 28 throw new SecurityException ("Invalid access; password not specified"); 29 } 30 if(!_password.equals(password)){ 31 throw new SecurityException ("Invalid access; password invalid"); 32 } 33 } 34 } 35 } 36 } 37 | Popular Tags |