/** * The instance method checks if for the given user the password is correct. The test itself is * done with * * @param _name name of the person name to check * @param _passwd password of the person to check * @see #checkLogin */ protected boolean checkLogin(final String _name, final String _passwd) { boolean ret = false; try { LoginContext login = new LoginContext(this.application, new LoginCallBackHandler(_name, _passwd)); login.login(); Person person = null; for (JAASSystem system : JAASSystem.getAllJAASSystems()) { Set users = login.getSubject().getPrincipals(system.getPersonJAASPrincipleClass()); System.out.println("---------------------->users=" + users); for (Object persObj : users) { try { String persKey = (String) system.getPersonMethodKey().invoke(persObj, null); Person foundPerson = Person.getWithJAASKey(system, persKey); if (foundPerson == null) { // TODO: JAASKey for person must be added!!! } else if (person == null) { person = foundPerson; } else if (person.getId() != foundPerson.getId()) { LOG.error( "For JAAS system " + system.getName() + " " + "person with key '" + persKey + "' is not unique!" + "Have found person '" + person.getName() + "' " + "(id = " + person.getId() + ") and person " + "'" + foundPerson.getName() + "' " + "(id = " + foundPerson.getId() + ")."); // TODO: throw exception!! } } catch (IllegalAccessException e) { LOG.error("could not execute person key method for system " + system.getName(), e); // TODO: throw exception!! } catch (IllegalArgumentException e) { LOG.error("could not execute person key method for system " + system.getName(), e); // TODO: throw exception!! } catch (InvocationTargetException e) { LOG.error("could not execute person key method for system " + system.getName(), e); // TODO: throw exception!! } } } if (person == null) { for (JAASSystem system : JAASSystem.getAllJAASSystems()) { Set users = login.getSubject().getPrincipals(system.getPersonJAASPrincipleClass()); for (Object persObj : users) { try { String persKey = (String) system.getPersonMethodKey().invoke(persObj, null); if (person == null) { person = Person.createPerson(system, persKey, persKey); } else { person.assignToJAASSystem(system, persKey); } } catch (IllegalAccessException e) { LOG.error("could not execute person key method for system " + system.getName(), e); // TODO: throw exception!! } catch (IllegalArgumentException e) { LOG.error("could not execute person key method for system " + system.getName(), e); // TODO: throw exception!! } catch (InvocationTargetException e) { LOG.error("could not execute person key method for system " + system.getName(), e); // TODO: throw exception!! } } } } person.cleanUp(); for (JAASSystem system : JAASSystem.getAllJAASSystems()) { if (system.getRoleJAASPrincipleClass() != null) { Set rolesJaas = login.getSubject().getPrincipals(system.getRoleJAASPrincipleClass()); Set<Role> rolesEfaps = new HashSet<Role>(); for (Object roleObj : rolesJaas) { try { String roleKey = (String) system.getRoleMethodKey().invoke(roleObj, null); Role roleEfaps = Role.getWithJAASKey(system, roleKey); if (roleEfaps != null) { rolesEfaps.add(roleEfaps); } } catch (IllegalAccessException e) { LOG.error("could not execute role key method for system " + system.getName(), e); } catch (IllegalArgumentException e) { LOG.error("could not execute role key method for system " + system.getName(), e); } catch (InvocationTargetException e) { LOG.error("could not execute role key method for system " + system.getName(), e); } } person.setRoles(system, rolesEfaps); } } ret = true; } catch (EFapsException e) { e.printStackTrace(); LOG.error("login failed for '" + _name + "'", e); } catch (LoginException e) { e.printStackTrace(); LOG.error("login failed for '" + _name + "'", e); } return ret; }