@Override public GroupPrincipal lookupPrincipalByGroupName(String group) throws IOException { if (!supportsGroups) { throw new UserPrincipalNotFoundException(group); // required by spec } return createGroupPrincipal(group); }
@Override public GroupPrincipal lookupPrincipalByGroupName(String group) throws IOException { if (!supportsGroups) { throw new UserPrincipalNotFoundException(group); // required by spec } return createGroupPrincipal(group); }
@Override public SimplePrincipal lookupPrincipalByName( String name ) throws IOException { return users.getOrThrow( name, new UserPrincipalNotFoundException( "no such user: " + name ) ); }
@Override public SimplePrincipal lookupPrincipalByGroupName( String name ) throws IOException { return groups.getOrThrow( name, new UserPrincipalNotFoundException( "no such group: " + name ) ); }
@Override public UserPrincipal lookupPrincipalByName(String name) throws IOException { this.checker.check(); String key = this.stringTransformer.transform(name); UserPrincipal user = this.users.get(key); if (user != null) { return user; } else { throw new UserPrincipalNotFoundException(name); } }
@Override public GroupPrincipal lookupPrincipalByGroupName(String groupName) throws IOException { this.checker.check(); String key = this.stringTransformer.transform(groupName); GroupPrincipal group = this.groups.get(key); if (group != null) { return group; } else { throw new UserPrincipalNotFoundException(groupName); } }
protected UserPrincipal toUser(Path file, UserPrincipal name) throws IOException { String username = name.toString(); FileSystem fileSystem = file.getFileSystem(); UserPrincipalLookupService lookupService = fileSystem.getUserPrincipalLookupService(); try { if (lookupService == null) { throw new UserPrincipalNotFoundException(username); } return lookupService.lookupPrincipalByName(username); } catch (IOException e) { handleUserPrincipalLookupServiceException(UserPrincipal.class, username, e); return null; } }
protected GroupPrincipal toGroup(Path file, GroupPrincipal name) throws IOException { String groupName = name.toString(); FileSystem fileSystem = file.getFileSystem(); UserPrincipalLookupService lookupService = fileSystem.getUserPrincipalLookupService(); try { if (lookupService == null) { throw new UserPrincipalNotFoundException(groupName); } return lookupService.lookupPrincipalByGroupName(groupName); } catch (IOException e) { handleUserPrincipalLookupServiceException(GroupPrincipal.class, groupName, e); return null; } }
@Override public UserPrincipal lookupPrincipalByName( String user ) throws IOException { try { if ( getCommandRunner().execute( "id " + user ).getExitCode() == 0 ) { return new StandardUserPrincipal( user ); } else { throw new UserPrincipalNotFoundException( user + " does not exist" ); } } catch ( JSchException e ) { throw new IOException( e ); } }
@Override public GroupPrincipal lookupPrincipalByGroupName( String group ) throws IOException { try { // I don't like this, but don't have a better way right // now... // Should be pretty safe in most instances if ( getCommandRunner().execute( "egrep -i \"^" + group + "\" /etc/group" ).getExitCode() == 0 ) { return new StandardGroupPrincipal( group ); } else { throw new UserPrincipalNotFoundException( group + " does not exist" ); } } catch ( JSchException e ) { throw new IOException( e ); } } };