1 45 package org.exolab.jms.net.connector; 46 47 import java.security.Principal ; 48 49 50 57 public class TestAuthenticator implements Authenticator { 58 59 63 private Principal [] _principals; 64 65 66 70 public TestAuthenticator() { 71 } 72 73 79 public TestAuthenticator(Principal principal) { 80 if (principal != null) { 81 _principals = new Principal []{principal}; 82 } 83 } 84 85 91 public TestAuthenticator(Principal [] principals) { 92 _principals = principals; 93 } 94 95 102 public boolean authenticate(Principal principal) throws ResourceException { 103 boolean result = false; 104 if (_principals == null) { 105 if (principal == null) { 106 result = true; 107 } 108 } else { 109 for (int i = 0; i < _principals.length; ++i) { 110 Principal other = _principals[i]; 111 if ((other == null && principal == null) 112 || (other != null && other.equals(principal))) { 113 result = true; 114 break; 115 } 116 } 117 } 118 return result; 119 } 120 121 } 122 | Popular Tags |