Iterator peopleIterator = people.iterator();
return peopleIterator.hasNext() ? (Person)peopleIterator.next() : null;
}
private LoginModule loadLoginModule() throws AuthenticationException {
XPlannerProperties properties = new XPlannerProperties();
String loginModuleClassName = properties.getProperty(LOGIN_MODULE_KEY);
if (loginModuleClassName == null) {
throw new AuthenticationException("no login module specified.");
}
HashMap options = new HashMap();
Iterator propertyNames = properties.getPropertyNames();
while (propertyNames.hasNext()) {
String name = (String)propertyNames.next();
if (name.startsWith(LOGIN_OPTION_PREFIX)) {
options.put(name.substring(LOGIN_OPTION_PREFIX.length()),
properties.getProperty(name));
}
}
LoginModule loginModule = null;
try {
Class loginModuleClass = Class.forName(loginModuleClassName);
if (javax.security.auth.spi.LoginModule.class.isAssignableFrom(loginModuleClass)) {
javax.security.auth.spi.LoginModule jaasLoginModule =
(javax.security.auth.spi.LoginModule)loginModuleClass.newInstance();
String principalClassName = properties.getProperty(JAAS_USER_PRINCIPAL_KEY);
if (principalClassName == null) {
throw new AuthenticationException("principal class name is required for JAAS login modules");
}
Class jaasPrincipalClass = Class.forName(principalClassName);
loginModule = new JaasLoginModuleAdapter(jaasLoginModule, jaasPrincipalClass, options);