/** * If this {@link SecurityRealm} supports a look up of {@link GroupDetails} by their names, override this method * to provide the look up. * * <p> * This information, when available, can be used by {@link AuthorizationStrategy}s to improve the UI and * error diagnostics for the user. */ public GroupDetails loadGroupByGroupname(String groupname) throws UsernameNotFoundException, DataAccessException { throw new UserMayOrMayNotExistException(groupname); }
/** * Gets the cached UserDetails for the given username. * Similar to {@link #loadUserByUsername(String)} except it doesn't perform the actual lookup if there is a cache miss. * * @param idOrFullName the username * * @return {@code null} if the cache doesn't contain any data for the key or the user details cached for the key. * @throws UsernameNotFoundException if a previous lookup resulted in the same */ @CheckForNull public UserDetails getCached(String idOrFullName) throws UsernameNotFoundException { Boolean exists = existenceCache.getIfPresent(idOrFullName); if (exists != null && !exists) { throw new UserMayOrMayNotExistException(String.format("\"%s\" does not exist", idOrFullName)); } else { return detailsCache.getIfPresent(idOrFullName); } }
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException { UserDetailsService uds = delegate; // fix the reference for concurrency support if(uds ==null) throw new UserMayOrMayNotExistException(Messages.UserDetailsServiceProxy_UnableToQuery(username)); return uds.loadUserByUsername(username); }
/** * If this {@link SecurityRealm} supports a look up of {@link GroupDetails} by their names, override this method * to provide the look up. * * <p> * This information, when available, can be used by {@link AuthorizationStrategy}s to improve the UI and * error diagnostics for the user. */ public GroupDetails loadGroupByGroupname(String groupname) throws UsernameNotFoundException, DataAccessException { throw new UserMayOrMayNotExistException(groupname); }
/** * If this {@link SecurityRealm} supports a look up of {@link GroupDetails} by their names, override this method * to provide the look up. * <p/> * <p/> * This information, when available, can be used by {@link AuthorizationStrategy}s to improve the UI and * error diagnostics for the user. */ public GroupDetails loadGroupByGroupname(String groupname) throws UsernameNotFoundException, DataAccessException { throw new UserMayOrMayNotExistException(groupname); }
/** * If this {@link SecurityRealm} supports a look up of {@link GroupDetails} by their names, override this method * to provide the look up. * <p/> * <p/> * This information, when available, can be used by {@link AuthorizationStrategy}s to improve the UI and * error diagnostics for the user. */ public GroupDetails loadGroupByGroupname(String groupname) throws UsernameNotFoundException, DataAccessException { throw new UserMayOrMayNotExistException(groupname); }
/** * If this {@link SecurityRealm} supports a look up of {@link GroupDetails} by their names, override this method * to provide the look up. * <p/> * <p/> * This information, when available, can be used by {@link AuthorizationStrategy}s to improve the UI and * error diagnostics for the user. */ public GroupDetails loadGroupByGroupname(String groupname) throws UsernameNotFoundException, DataAccessException { throw new UserMayOrMayNotExistException(groupname); }
/** * If this {@link SecurityRealm} supports a look up of {@link GroupDetails} * by their names, override this method to provide the look up. * <p/> * < * p/> * This information, when available, can be used by * {@link AuthorizationStrategy}s to improve the UI and error diagnostics * for the user. */ public GroupDetails loadGroupByGroupname(String groupname) throws UsernameNotFoundException, DataAccessException { throw new UserMayOrMayNotExistException(groupname); }
/** * Gets the cached UserDetails for the given username. * Similar to {@link #loadUserByUsername(String)} except it doesn't perform the actual lookup if there is a cache miss. * * @param idOrFullName the username * * @return {@code null} if the cache doesn't contain any data for the key or the user details cached for the key. * @throws UsernameNotFoundException if a previous lookup resulted in the same */ @CheckForNull public UserDetails getCached(String idOrFullName) throws UsernameNotFoundException { Boolean exists = existenceCache.getIfPresent(idOrFullName); if (exists != null && !exists) { throw new UserMayOrMayNotExistException(String.format("\"%s\" does not exist", idOrFullName)); } else { return detailsCache.getIfPresent(idOrFullName); } }
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException { UserDetailsService uds = delegate; // fix the reference for concurrency support if(uds ==null) throw new UserMayOrMayNotExistException(Messages.UserDetailsServiceProxy_UnableToQuery(username)); return uds.loadUserByUsername(username); }
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException { UserDetailsService uds = delegate; // fix the reference for concurrency support if (uds == null) { throw new UserMayOrMayNotExistException(Messages.UserDetailsServiceProxy_UnableToQuery(username)); } return uds.loadUserByUsername(username); }
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException { UserDetailsService uds = delegate; // fix the reference for concurrency support if(uds ==null) throw new UserMayOrMayNotExistException(Messages.UserDetailsServiceProxy_UnableToQuery(username)); return uds.loadUserByUsername(username); }
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException { UserDetailsService uds = delegate; // fix the reference for concurrency support if(uds ==null) throw new UserMayOrMayNotExistException(Messages.UserDetailsServiceProxy_UnableToQuery(username)); return uds.loadUserByUsername(username); }
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException { UserDetailsService uds = delegate; // fix the reference for concurrency support if(uds ==null) throw new UserMayOrMayNotExistException(Messages.UserDetailsServiceProxy_UnableToQuery(username)); return uds.loadUserByUsername(username); }
public ActiveDirectoryGroupDetails call() throws NamingException { for (ActiveDirectoryDomain domain : domains) { if (domain==null) { throw new UserMayOrMayNotExistException("Unable to retrieve group information without bind DN/password configured"); throw new UserMayOrMayNotExistException(groupname);
public ActiveDirectoryGroupDetails call() throws Exception { ComObjectCollector col = new ComObjectCollector(); COM4J.addListener(col); try { // First get the distinguishedName String dn = getDnOfUserOrGroup(groupname); IADsOpenDSObject dso = COM4J.getObject(IADsOpenDSObject.class, "LDAP:", null); IADsGroup group = dso.openDSObject(dnToLdapUrl(dn), null, null, ADS_READONLY_SERVER) .queryInterface(IADsGroup.class); // If not a group will throw UserMayOrMayNotExistException if (group == null) { throw new UserMayOrMayNotExistException(groupname); } return new ActiveDirectoryGroupDetails(groupname); } catch (UsernameNotFoundException e) { // failed to convert group name to DN throw new UsernameNotFoundException("Failed to get the DN of the group " + groupname); } catch (ComException e) { // recover gracefully since AD might behave in a way we haven't anticipated LOGGER.log(Level.WARNING, String.format("Failed to figure out details of AD group: %s", groupname), e); throw new UserMayOrMayNotExistException(groupname); } finally { col.disposeAll(); COM4J.removeListener(col); } } });
throw new UserMayOrMayNotExistException("Unable to retrieve the user information without bind DN/password configured"); throw e; throw new UserMayOrMayNotExistException("Unable to retrieve the user information without bind DN/password configured"); throw new UserMayOrMayNotExistException(msg);
public LdapUserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException { try { LdapUserDetails ldapUser = ldapSearch.searchForUser(username); // LdapUserSearch does not populate granted authorities (group search). // Add those, as done in LdapAuthenticationProvider.createUserDetails(). if (ldapUser != null) { LdapUserDetailsImpl.Essence user = new LdapUserDetailsImpl.Essence(ldapUser); // intern attributes Attributes v = ldapUser.getAttributes(); if (v instanceof BasicAttributes) {// BasicAttributes.equals is what makes the interning possible Attributes vv = (Attributes)attributesCache.get(v); if (vv==null) attributesCache.put(v,vv=v); user.setAttributes(vv); } GrantedAuthority[] extraAuthorities = authoritiesPopulator.getGrantedAuthorities(ldapUser); for (GrantedAuthority extraAuthority : extraAuthorities) { user.addAuthority(extraAuthority); } ldapUser = user.createUserDetails(); } return ldapUser; } catch (LdapDataAccessException e) { LOGGER.log(Level.WARNING, "Failed to search LDAP for username="+username,e); throw new UserMayOrMayNotExistException(e.getMessage(),e); } } }
public LdapUserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException { try { LdapUserDetails ldapUser = ldapSearch.searchForUser(username); // LdapUserSearch does not populate granted authorities (group search). // Add those, as done in LdapAuthenticationProvider.createUserDetails(). if (ldapUser != null) { LdapUserDetailsImpl.Essence user = new LdapUserDetailsImpl.Essence(ldapUser); // intern attributes Attributes v = ldapUser.getAttributes(); if (v instanceof BasicAttributes) {// BasicAttributes.equals is what makes the interning possible Attributes vv = (Attributes)attributesCache.get(v); if (vv==null) attributesCache.put(v,vv=v); user.setAttributes(vv); } GrantedAuthority[] extraAuthorities = authoritiesPopulator.getGrantedAuthorities(ldapUser); for (GrantedAuthority extraAuthority : extraAuthorities) { user.addAuthority(extraAuthority); } ldapUser = user.createUserDetails(); } return ldapUser; } catch (LdapDataAccessException e) { LOGGER.log(Level.WARNING, "Failed to search LDAP for username="+username,e); throw new UserMayOrMayNotExistException(e.getMessage(),e); } } }