Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Protected Ctors](https://developer.android.com/reference/java/nio/file/attribute/UserPrincipalLookupService#proctors) \| [Methods](https://developer.android.com/reference/java/nio/file/attribute/UserPrincipalLookupService#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/java/nio/file/attribute/UserPrincipalLookupService#inhmethods)

# UserPrincipalLookupService

` public abstract class UserPrincipalLookupService `   
` extends https://developer.android.com/reference/java/lang/Object ` ` `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | java.nio.file.attribute.UserPrincipalLookupService |

<br />

*** ** * ** ***

An object to lookup user and group principals by name. A `https://developer.android.com/reference/java/nio/file/attribute/UserPrincipal` represents an identity that may be used to determine access rights to objects in a file system. A `https://developer.android.com/reference/java/nio/file/attribute/GroupPrincipal` represents a *group identity* . A `UserPrincipalLookupService` defines methods to lookup identities by name or group name (which are typically user or account names). Whether names and group names are case sensitive or not depends on the implementation. The exact definition of a group is implementation specific but typically a group represents an identity created for administrative purposes so as to determine the access rights for the members of the group. In particular it is implementation specific if the *namespace* for names and groups is the same or is distinct. To ensure consistent and correct behavior across platforms it is recommended that this API be used as if the namespaces are distinct. In other words, the `https://developer.android.com/reference/java/nio/file/attribute/UserPrincipalLookupService#lookupPrincipalByName(java.lang.String)` should be used to lookup users, and `https://developer.android.com/reference/java/nio/file/attribute/UserPrincipalLookupService#lookupPrincipalByGroupName(java.lang.String)` should be used to lookup groups.
**See also:**

- `https://developer.android.com/reference/java/nio/file/FileSystem#getUserPrincipalLookupService()`

## Summary

| ### Protected constructors ||
|---|---|
| ` https://developer.android.com/reference/java/nio/file/attribute/UserPrincipalLookupService#UserPrincipalLookupService()() ` Initializes a new instance of this class. |

| ### Public methods ||
|---|---|
| ` abstract https://developer.android.com/reference/java/nio/file/attribute/GroupPrincipal` | ` https://developer.android.com/reference/java/nio/file/attribute/UserPrincipalLookupService#lookupPrincipalByGroupName(java.lang.String)(https://developer.android.com/reference/java/lang/String group) ` Lookup a group principal by group name. |
| ` abstract https://developer.android.com/reference/java/nio/file/attribute/UserPrincipal` | ` https://developer.android.com/reference/java/nio/file/attribute/UserPrincipalLookupService#lookupPrincipalByName(java.lang.String)(https://developer.android.com/reference/java/lang/String name) ` Lookup a user principal by name. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.

## Protected constructors

### UserPrincipalLookupService

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
protected UserPrincipalLookupService ()
```

Initializes a new instance of this class.

<br />

## Public methods

### lookupPrincipalByGroupName

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract GroupPrincipal lookupPrincipalByGroupName (String group)
```

Lookup a group principal by group name.

Where an implementation does not support any notion of group then this method always throws `https://developer.android.com/reference/java/nio/file/attribute/UserPrincipalNotFoundException`. Where the namespace for user accounts and groups is the same, then this method is identical to invoking `https://developer.android.com/reference/java/nio/file/attribute/UserPrincipalLookupService#lookupPrincipalByName(java.lang.String)`.

<br />

| Parameters ||
|---|---|
| `group` | `String`: the string representation of the group to lookup <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/nio/file/attribute/GroupPrincipal` | a group principal <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/IOException` | if an I/O error occurs |
| `https://developer.android.com/reference/java/lang/SecurityException` | In the case of the default provider, and a security manager is installed, it checks `https://developer.android.com/reference/java/lang/RuntimePermission``("lookupUserInformation")` |
| `https://developer.android.com/reference/java/nio/file/attribute/UserPrincipalNotFoundException` | the principal does not exist or is not a group |

### lookupPrincipalByName

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract UserPrincipal lookupPrincipalByName (String name)
```

Lookup a user principal by name.

<br />

| Parameters ||
|---|---|
| `name` | `String`: the string representation of the user principal to lookup <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/nio/file/attribute/UserPrincipal` | a user principal <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/IOException` | if an I/O error occurs |
| `https://developer.android.com/reference/java/lang/SecurityException` | In the case of the default provider, and a security manager is installed, it checks `https://developer.android.com/reference/java/lang/RuntimePermission``("lookupUserInformation")` |
| `https://developer.android.com/reference/java/nio/file/attribute/UserPrincipalNotFoundException` | the principal does not exist |