/** * Assigns home, root and read only attributes from KpwdPrincipal. */ @SuppressWarnings("null") @Override public void session(Set<Principal> authorizedPrincipals, Set<Object> attrib) throws AuthenticationException { KpwdPrincipal kpwd = getFirst(filter(authorizedPrincipals, KpwdPrincipal.class), null); checkAuthentication(kpwd != null, "no record found"); attrib.add(new HomeDirectory(kpwd.home)); attrib.add(new RootDirectory(kpwd.root)); if (kpwd.isReadOnly) { attrib.add(Restrictions.readOnly()); } } }
@Override public void session(Set<Principal> authorizedPrincipals, Set<Object> attrib) throws AuthenticationException { Principal principal = find(authorizedPrincipals, instanceOf(UserNamePrincipal.class), null); checkAuthentication(principal != null, "no username principal"); Collection<UserAuthzInformation> mappings = _map.getValuesForPredicatesMatching(principal.getName()); checkAuthentication(!mappings.isEmpty(), "no mapping found for " + principal); for (UserAuthzInformation mapping : mappings) { attrib.add(new HomeDirectory(mapping.getHome())); attrib.add(new RootDirectory(mapping.getRoot())); if (mapping.isReadOnly()) { attrib.add(Restrictions.readOnly()); } mapping.getMaxUpload().ifPresent(s -> { attrib.add(new MaxUploadSize(s)); }); } } }