public Principal buildPrincipal(String value) throws GplazmaParseMapFileException { try { if (GroupPrincipal.class.isAssignableFrom(groupType)) { List<String> parts = Splitter.on(',').splitToList(value); checkFormat(parts.size() < 3, "Too many commas in \"%s\" for %s", value, label); boolean isPrimary = parts.size() == 2 ? Boolean.parseBoolean(parts.get(1)) : false; return groupType.getConstructor(String.class, Boolean.TYPE) .newInstance(parts.get(0), isPrimary); } else { return groupType.getConstructor(String.class).newInstance(value); } } catch (NoSuchMethodException|IllegalAccessException|InstantiationException e) { throw new RuntimeException("Failed to create principal: " + e); } catch (InvocationTargetException e) { throw new GplazmaParseMapFileException("Failed to create " + label + " principal \"" + value + "\": " + Exceptions.messageOrClassName((Exception)e.getCause())); } }
public synchronized Map<PrincipalMatcher,Set<Principal>> mapping() throws AuthenticationException { if (!Instant.now().isBefore(nextStat)) { nextStat = Instant.now().plusMillis(100); try { Instant mtime = Files.readAttributes(file, BasicFileAttributes.class) .lastModifiedTime().toInstant(); if (!lastLoaded.equals(mtime)) { lastLoaded = mtime; map = parseMapFile(); } } catch (IOException e) { throw new AuthenticationException("failed to read " + file + ": " + Exceptions.messageOrClassName(e)); } } return map; }