Last Updated on : 2024-11-22 02:19:32download
This topic describes how to manage a password.
API description
ILockPasswordManager # void getPasswordList(PasswordListParams params, IThingResultCallback<PasswordListResp> callback);
Parameters
Parameter | Description |
---|---|
params | The parameter bean for getting the list of passwords. |
params.groupId | The ID of the site to which the lock belongs. |
params.deviceId | The device ID. |
params.periodType | The search criteria, defaulting to null. |
pageNo | The requested page number. |
pageSize | The number of items returned per page. |
callback | The callback. |
Example
ThingOSLock.getPasswordManager().getPasswordList(params, new IThingResultCallback<PasswordListResp>() {
@Override
public void onSuccess(PasswordListResp result) {
// Got password list successfully
}
@Override
public void onError(String errorCode, String errorMessage) {
// Failed to get password list
}
});
API description
ILockPassword # void getPasswordDetail(IThingResultCallback<PasswordBean> callback);
Parameters
Parameter | Description |
---|---|
callback | The callback. |
Example
ThingOSLock.newPasswordInstance(siteId, deviceId, passwordId).getPasswordDetail(new IThingResultCallback<PasswordBean>() {
@Override
public void onSuccess(PasswordBean result) {
//Got password details successfully
}
@Override
public void onError(String errorCode, String errorMessage) {
//Failed to get password details
}
});
API description
ILockPasswordManager # void createOncePassword(OncePasswordCreateParams params, IThingResultCallback<PasswordResp> callback);
Parameters
Parameter | Description |
---|---|
params | The parameter bean for creating a one-time offline password. |
params.groupId | The ID of the site to which the lock belongs. |
params.deviceId | The device ID of the lock. |
params.passwordName | The username for the password. |
callback | The callback. |
Example
OncePasswordCreateParams oncePasswordCreateParams = new OncePasswordCreateParams();
oncePasswordCreateParams.passwordName = "once password name";
oncePasswordCreateParams.groupId = siteId;
oncePasswordCreateParams.deviceId = deviceId;
ThingOSLock.getPasswordManager().createOncePassword(oncePasswordCreateParams, new IThingResultCallback<PasswordResp>() {
@Override
public void onSuccess(PasswordResp result) {
//Created one-time offline password successfully
}
@Override
public void onError(String errorCode, String errorMessage) {
//Failed to create one-time offline password
}
});
API description
ILockPasswordManager # void createPermanentPassword(long siteId, String lockDevId, String password, String name, IThingResultCallback<PasswordResp> callback);
Parameters
Parameter | Description |
---|---|
siteId | The ID of the site to which the lock belongs. |
lockDevId | The device ID of the lock. |
password | The password. |
name | The username for the password. |
callback | The callback. |
Example
ThingOSLock.getPasswordManager().createPermanentPassword(siteId, deviceId, "123456", "Test Password", new IThingResultCallback<PasswordResp>() {
@Override
public void onSuccess(PasswordResp result) {
//Create permanent password successfully
}
@Override
public void onError(String errorCode, String errorMessage) {
//Failed to create permanent password
}
});
keyStatus
in the PasswordBean
object. If the result is CREATE_FAIL
, you can retry creating the password using retryCreateOnlinePassword
.API description
ILockPasswordManager # void createOfflinePassword(OfflinePasswordCreateParams params, IThingResultCallback<PasswordResp> callback);
Parameters
Parameter | Description |
---|---|
params | The parameter bean for creating a time-limited offline password. |
params.groupId | The ID of the site to which the lock belongs. |
params.deviceId | The device ID of the lock. |
params.passwordName | The username for the password. |
passwordType | The password type, always set to PasswordType.TIME_LIMIT_OFFLINE . |
params.effectiveTime | The timestamp when the password becomes active, in milliseconds. |
params.invalidTime | The timestamp when the password expires, in milliseconds. |
params.timeZoneId | The time zone. If no value is specified, the SDK will assign one. |
callback | The callback. |
Example
OfflinePasswordCreateParams params = new OfflinePasswordCreateParams();
params.groupId = siteId;
params.deviceId = deviceId;
params.passwordName = "Password Name";
params.effectiveTime = effectiveTime;
params.invalidTime = invalidTime;
params.passwordType = PasswordType.TIME_LIMIT_OFFLINE;
params.timeZoneId = ThingOSUser.getUserInstance().getUser().getTimezoneId();
ThingOSLock.getPasswordManager().createOfflinePassword(params, new IThingResultCallback<PasswordResp>() {
@Override
public void onSuccess(PasswordResp result) {
//Created time-limited offline passwordd successfully
}
@Override
public void onError(String errorCode, String errorMessage) {
//Failed to create time-limited offline password
}
});
API description
ILockPasswordManager # void createLimitOnlinePassword(long siteId, String lockDevId, String password, String name, long effectiveTime, long invalidTime,
String workingDay, String startMinuteFormat, String endMinuteFormat, IThingResultCallback<PasswordResp> callback);
Parameters
Parameter | Description |
---|---|
siteId | The ID of the site to which the lock belongs. |
lockDevId | The device ID of the lock. |
password | The password. |
name | The name of the password. |
effectiveTime | The timestamp when the password becomes active, in milliseconds. |
invalidTime | The timestamp when the password expires, in milliseconds. |
workingDay | The schedule, a 7-bit string, with each bit being either 0 or 1 . 0 indicates the schedule is off, while 1 indicates it is on. The bits from left to right represent Sunday through Saturday. |
startMinuteFormat | The start time for access, a string in the format of hh:mm . For example, 03:30 indicates the e-key becomes active at 03:30. |
endMinuteFormat | The end time for access, a string in the format of hh:mm . For example, 18:30 indicates the e-key becomes inactive at 18:30. |
callback | The callback. |
Example
ThingOSLock.getPasswordManager().createLimitOnlinePassword(siteId,lockDevId,"123456", "Password Name",
effectiveTime, invalidTime, getWorkingDay(),
"03:30",
"19:50", new IThingResultCallback<PasswordResp>() {
@Override
public void onSuccess(PasswordResp result) {
//Create time-limited online password successfully
}
@Override
public void onError(String errorCode, String errorMessage) {
//Failed to create time-limited online password
}
});
When creating a time-limited online password, the lock must be online.
The lock connected to a gateway creates a password asynchronously. You can check the result through the keyStatus
in the PasswordBean
object. If the result is CREATE_FAIL
, you can retry creating the password using retryCreateOnlinePassword
.
API description
ILockPasswordManager # void removeOnceOfflinePassword(long siteId,String deviceId, String passwordId, IThingResultCallback<Boolean> callback);
Parameters
Parameter | Description |
---|---|
siteId | The ID of the site to which the lock belongs. |
deviceId | The device ID of the lock. |
passwordId | The password ID. |
callback | The callback. |
Example
ThingOSLock.getPasswordManager().removeOnceOfflinePassword(siteId, deviceId, passwordId, new IThingResultCallback<Boolean>() {
@Override
public void onSuccess(Boolean result) {
//Removed one-time offline password successfully
}
@Override
public void onError(String errorCode, String errorMessage) {
//Failed to remove one-time offline password
}
});
API description
ILockDevice # void removeOnlinePassword(long siteId, String deviceId, String passwordId, String lockId, IThingResultCallback<Boolean> callback);
Parameters
Parameter | Description |
---|---|
siteId | The ID of the site to which the lock belongs. |
deviceId | The device ID of the lock. |
passwordId | The password ID. |
lockId | The virtual ID written to the lock device, which can be obtained from the password details. |
callback | The callback. |
Example
ThingOSLock.getPasswordManager().removeLimitOfflinePassword(siteId, deviceId, passwordId, passwordBean.lockId, new IThingResultCallback<Boolean>() {
@Override
public void onSuccess(Boolean result) {
//Removed permanent online password successfully
}
@Override
public void onError(String errorCode, String errorMessage) {
//Failed to remove permanent online password
}
});
API description
ILockPasswordManager # void removeLimitOfflinePassword(long siteId, String deviceId, String passwordId, IThingResultCallback<String> callback);
Parameters
Parameter | Description |
---|---|
siteId | The ID of the site to which the lock belongs. |
deviceId | The device ID of the lock. |
passwordId | The password ID. |
callback | The callback. It returns a string of clear code. Users must manually enter the clear code on the lock to delete the respective time-limited offline password. Otherwise, the password will remain active. |
Example
ThingOSLock.getPasswordManager().removeLimitOfflinePassword(siteId, deviceId, passwordId, new IThingResultCallback<String>() {
@Override
public void onSuccess(String result) {
//Removed time-limited offline password successfully
//A clearing code is returned. Enter the clearing code in lock device
}
@Override
public void onError(String errorCode, String errorMessage) {
//Failed to remove time-limited offline password
}
});
API description
ILockPasswordManager # void removeOnlinePassword(long siteId, String deviceId, String passwordId, String lockId, IThingResultCallback<Boolean> callback);
Parameters
Parameter | Description |
---|---|
siteId | The ID of the site to which the lock belongs. |
deviceId | The device ID of the lock. |
passwordId | The password ID. |
lockId | The virtual ID written to the lock device, which can be obtained from the password details. |
callback | The callback. |
Example
ThingOSLock.getPasswordManager().removeOnlinePassword(siteId, deviceId, passwordId, passwordBean.lockId, new IThingResultCallback<Boolean>() {
@Override
public void onSuccess(Boolean result) {
//Removed time-limited online password successfully
}
@Override
public void onError(String errorCode, String errorMessage) {
//Failed to remove time-limited online password
}
});
API description
ILockPassword # void modifyPassword(PasswordUpdateParams params, IThingResultCallback<Boolean> callback);
Parameters
Parameter | Description |
---|---|
params | The parameter bean for renaming a password. |
params.passwordId | The password ID. |
params.passwordName | The name of the password. |
params.deviceId | The device ID of the lock. |
params.groupId | The site ID. |
callback | The callback. |
Example
PasswordUpdateParams params = new PasswordUpdateParams();
params.deviceId = deviceId;
params.groupId = siteId;
params.passwordId = passwordId;
params.passwordName = "new name";
ThingOSLock.newPasswordInstance(siteId, deviceId, passwordId).modifyPassword(params, new IThingResultCallback<Boolean>() {
@Override
public void onSuccess(Boolean result) {
//Modified password successfully
}
@Override
public void onError(String errorCode, String errorMessage) {
//Failed to modify password
}
});
API description
ILockPasswordManager # void forceRemoveOnlinePassword(long siteId, String lockDevId, String passwordId, IThingResultCallback<Boolean> callback);
Parameters
Parameter | Description |
---|---|
siteId | The site ID. |
lockDevId | The device ID of the lock. |
passwordId | The password ID. |
callback | The callback. |
Example
ThingOSLock.getPasswordManager().forceRemoveOnlinePassword(siteId, deviceId, passwordId, new IThingResultCallback<Boolean>() {
@Override
public void onSuccess(Boolean result) {
//force remove online password successfully
}
@Override
public void onError(String errorCode, String errorMessage) {
//force remove online password failed
}
});
removeOnlinePassword
.API description
ILockPasswordManager # void clearAllPassword(long siteId, String lockDevId, IThingResultCallback<Boolean> callback);
Parameters
Parameter | Description |
---|---|
siteId | The site ID. |
lockDevId | The device ID of the lock. |
callback | The callback. |
Example
ThingOSLock.getPasswordManager().clearAllPassword(siteId, deviceId, new IThingResultCallback<Boolean>() {
@Override
public void onSuccess(Boolean result) {
//Clear online password succeed
}
@Override
public void onError(String errorCode, String errorMessage) {
//Clear online password failed
}
});
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback