Package org.eclipse.hono.auth
Class Device
- java.lang.Object
-
- org.eclipse.hono.auth.Device
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static String
asAddress(String tenantId, String deviceId)
Gets the device id in an address structure.static String
asAddress(Device device)
Gets the device id in an address structure.protected Boolean
checkAuthorization(String authority)
Checks if this device has a particular authority.String
getDeviceId()
Gets this device's identifier.String
getName()
String
getTenantId()
Gets the identifier of the tenant this device belongs to.io.vertx.core.json.JsonObject
principal()
Get the underlying principal of the device.String
toString()
-
-
-
Constructor Detail
-
Device
public Device(io.jsonwebtoken.Jws<io.jsonwebtoken.Claims> token)
Creates a new device for a token.The token is expected to contain the device identifier in the sub claim and the tenant identifier in the ten claim.
- Parameters:
token
- The token asserting the device's identity.- Throws:
NullPointerException
- if the token does not contain a tenant and device identifier.
-
Device
public Device(String tenantId, String deviceId)
Creates a new device for a tenant and device identifier.- Parameters:
tenantId
- The tenant.deviceId
- The device identifier.- Throws:
NullPointerException
- if any of the params isnull
.
-
-
Method Detail
-
checkAuthorization
protected final Boolean checkAuthorization(String authority)
Checks if this device has a particular authority.In order for the check to succeed, the JWT must
- not be expired
- contain the given authorities in its aut claim
- Parameters:
authority
- The authority to check for.- Returns:
true
if the device has the given authority,false
otherwise.
-
principal
public final io.vertx.core.json.JsonObject principal()
Get the underlying principal of the device.- Returns:
- JSON representation of the Principal.
-
getTenantId
public final String getTenantId()
Gets the identifier of the tenant this device belongs to.- Returns:
- The identifier.
-
getDeviceId
public final String getDeviceId()
Gets this device's identifier.- Returns:
- The identifier.
-
getName
public final String getName()
Returns the device identifier.
-
toString
public final String toString()
-
asAddress
public static final String asAddress(String tenantId, String deviceId)
Gets the device id in an address structure.- Parameters:
tenantId
- The id of the tenant.deviceId
- The id of the device.- Returns:
- tenantId and deviceId as an address.
- Throws:
NullPointerException
- if any of the parameters arenull
.
-
asAddress
public static final String asAddress(Device device)
Gets the device id in an address structure.- Parameters:
device
- The device.- Returns:
- tenantId and deviceId as an address.
- Throws:
NullPointerException
- if device isnull
.
-
-