public class AuthImpl extends ClientImpl implements BaseAuth, Serializable
Modifier and Type | Method and Description |
---|---|
void |
assignRole(String userId,
String roleId)
Method to assign a role
|
void |
changeSecurity(String uuid,
ChangeSecurity changeSecurity)
Change several security permissions in the same call.
|
void |
createRole(String roleId,
boolean active)
Method to create a new role
|
void |
createUser(String userId,
String password,
String email,
String name,
boolean active)
Method to create a new user
|
void |
deleteRole(String roleId)
Method to create a delete a role
|
void |
deleteUser(String userId)
Method to delete a user
|
String |
disable2FA()
Disable 2FA
|
String |
generate2FASecret()
Generate 2FA secret
|
Map<String,Integer> |
getGrantedRoles(String uuid)
Get roles permissions from am item (document or folder).
|
Map<String,Integer> |
getGrantedUsers(String uuid)
Get user permissions from am item (document or folder).
|
GrantedUsersAndRolesItem |
getGrantedUsersAndRoles(String uuid)
Get granted users and roles
|
List<Profile> |
getProfiles(boolean filterByActive)
Get all profiles
|
String |
getRefreshToken() |
List<String> |
getRoles(boolean showAll)
Retrieves a list of repository roles.
|
List<String> |
getRolesByUser(String userId)
Retrieves a list of roles by user.
|
String |
getSessionId()
Get session
|
InputStream |
getTwoFactorQR(String secret)
Get 2FA
|
CommonUser |
getUser(String userId)
Retrieve information of a given user
|
Profile |
getUserProfile(String userId)
Get user profile
|
List<CommonUser> |
getUsers(boolean showAll)
Retrieve information of a given user
|
List<CommonUser> |
getUsersByRole(String roleId)
Retrieves a list of users by role.
|
List<Tenant> |
getUserTenants()
Get a list of available tenants for a user.
|
void |
grantRole(String uuid,
String roleId,
int permissions,
boolean recursive)
Grant role permissions for a node.
|
void |
grantUser(String uuid,
String userId,
int permissions,
boolean recursive)
Add user permissions to a node.
|
boolean |
hasSecurityRecursive()
Has security recursive
|
boolean |
isAdmin()
Is admin
|
boolean |
isLoginLowercase()
Is login lowercase
|
boolean |
isPasswordExpired()
Check the password of the user expiration
|
boolean |
isTwoFactorAuthentication()
Is two factor authentication
|
protected String |
login(String user,
String password) |
protected String |
login(String user,
String password,
int expiration,
boolean restrictIp) |
protected void |
logout() |
void |
removeRole(String userId,
String roleId)
Method to remove a role
|
void |
revokeRole(String uuid,
String roleId,
int permissions,
boolean recursive)
Revoke role permissions from a node.
|
void |
revokeUser(String uuid,
String userId,
int permissions,
boolean recursive)
Revoke user permissions from a node.
|
void |
setAuthorizationToken(String authorizationToken)
setAuthenticationToken
|
void |
setRolePermissions(String uuid,
String roleId,
int permissions,
boolean recursive)
Set role permissions for a node.
|
void |
setUserPermissions(String uuid,
String userId,
int permissions,
boolean recursive)
Set user permissions to a node
|
void |
setUserProfile(String userId,
long profileId)
Set the user profile
|
void |
setUserTenant(long tenantId)
Update user tenant.
|
void |
updateRole(String roleId,
boolean active)
Update role information
|
void |
updateUser(String userId,
String password,
String email,
String name,
boolean active)
Update user information
|
String |
validate2FAAndSaveSecret(String secret,
int code)
Validate 2FA and save secret
|
String |
verify2FACode(int code)
Verify 2FA code
|
getClient, resource, resource
public AuthImpl(String host)
public void setAuthorizationToken(String authorizationToken)
setAuthorizationToken
in interface BaseAuth
authorizationToken
- the authorization tokenprotected String login(String user, String password) throws UnknownException, WebserviceException, AuthenticationException
protected String login(String user, String password, int expiration, boolean restrictIp) throws UnknownException, WebserviceException, AuthenticationException
protected void logout() throws UnknownException, WebserviceException
UnknownException
WebserviceException
public String getSessionId() throws UnknownException, WebserviceException
BaseAuth
getSessionId
in interface BaseAuth
UnknownException
- the unknown exceptionWebserviceException
- the webservice exceptionpublic String getRefreshToken() throws UnknownException, WebserviceException
UnknownException
WebserviceException
public GrantedUsersAndRolesItem getGrantedUsersAndRoles(String uuid) throws AccessDeniedException, RepositoryException, DatabaseException, PathNotFoundException, UnknownException, WebserviceException
BaseAuth
getGrantedUsersAndRoles
in interface BaseAuth
uuid
- Node uuid.AccessDeniedException
- the access denied exceptionRepositoryException
- the repository exceptionDatabaseException
- the database exceptionPathNotFoundException
- the path not found exceptionUnknownException
- the unknown exceptionWebserviceException
- the webservice exceptionpublic Map<String,Integer> getGrantedRoles(String uuid) throws AccessDeniedException, RepositoryException, DatabaseException, PathNotFoundException, WebserviceException, UnknownException
BaseAuth
getGrantedRoles
in interface BaseAuth
uuid
- Node uuid.AccessDeniedException
- the access denied exceptionRepositoryException
- the repository exceptionDatabaseException
- the database exceptionPathNotFoundException
- the path not found exceptionWebserviceException
- the webservice exceptionUnknownException
- the unknown exceptionpublic Map<String,Integer> getGrantedUsers(String uuid) throws AccessDeniedException, RepositoryException, DatabaseException, PathNotFoundException, WebserviceException, UnknownException
BaseAuth
getGrantedUsers
in interface BaseAuth
uuid
- Node uuid.AccessDeniedException
- the access denied exceptionRepositoryException
- the repository exceptionDatabaseException
- the database exceptionPathNotFoundException
- the path not found exceptionWebserviceException
- the webservice exceptionUnknownException
- the unknown exceptionpublic List<String> getRoles(boolean showAll) throws AccessDeniedException, RepositoryException, DatabaseException, PrincipalAdapterException, WebserviceException, UnknownException
BaseAuth
getRoles
in interface BaseAuth
showAll
- If should only return active roles or all themAccessDeniedException
- the access denied exceptionRepositoryException
- the repository exceptionDatabaseException
- the database exceptionPrincipalAdapterException
- the principal adapter exceptionWebserviceException
- the webservice exceptionUnknownException
- the unknown exceptionpublic List<String> getRolesByUser(String userId) throws AccessDeniedException, RepositoryException, DatabaseException, PrincipalAdapterException, WebserviceException, UnknownException
BaseAuth
getRolesByUser
in interface BaseAuth
userId
- A user id.AccessDeniedException
- the access denied exceptionRepositoryException
- the repository exceptionDatabaseException
- the database exceptionPrincipalAdapterException
- the principal adapter exceptionWebserviceException
- the webservice exceptionUnknownException
- the unknown exceptionpublic List<CommonUser> getUsers(boolean showAll) throws AccessDeniedException, RepositoryException, DatabaseException, PrincipalAdapterException, UnknownException, WebserviceException
BaseAuth
getUsers
in interface BaseAuth
showAll
- If should only return active users or all themAccessDeniedException
- the access denied exceptionRepositoryException
- the repository exceptionDatabaseException
- the database exceptionPrincipalAdapterException
- the principal adapter exceptionUnknownException
- the unknown exceptionWebserviceException
- the webservice exceptionpublic CommonUser getUser(String userId) throws AccessDeniedException, RepositoryException, DatabaseException, PrincipalAdapterException, UnknownException, WebserviceException
BaseAuth
getUser
in interface BaseAuth
userId
- A user id.AccessDeniedException
- the access denied exceptionRepositoryException
- the repository exceptionDatabaseException
- the database exceptionPrincipalAdapterException
- the principal adapter exceptionUnknownException
- the unknown exceptionWebserviceException
- the webservice exceptionpublic List<CommonUser> getUsersByRole(String roleId) throws AccessDeniedException, RepositoryException, DatabaseException, PrincipalAdapterException, UnknownException, WebserviceException
BaseAuth
getUsersByRole
in interface BaseAuth
roleId
- A role id.AccessDeniedException
- the access denied exceptionRepositoryException
- the repository exceptionDatabaseException
- the database exceptionPrincipalAdapterException
- the principal adapter exceptionUnknownException
- the unknown exceptionWebserviceException
- the webservice exceptionpublic void revokeRole(String uuid, String roleId, int permissions, boolean recursive) throws AccessDeniedException, RepositoryException, DatabaseException, PathNotFoundException, UnknownException, WebserviceException
BaseAuth
revokeRole
in interface BaseAuth
uuid
- Node uuid.roleId
- Role name which permissions are changed.permissions
- A mask with the permissions to be removed.recursive
- If the nodePath indicates a folder, the permissions can be applied recursively.AccessDeniedException
- the access denied exceptionRepositoryException
- the repository exceptionDatabaseException
- the database exceptionPathNotFoundException
- the path not found exceptionUnknownException
- the unknown exceptionWebserviceException
- the webservice exceptionpublic void revokeUser(String uuid, String userId, int permissions, boolean recursive) throws AccessDeniedException, RepositoryException, DatabaseException, PathNotFoundException, UnknownException, WebserviceException
BaseAuth
revokeUser
in interface BaseAuth
uuid
- Node uuid.userId
- User name which permissions are changed.permissions
- A mask with the permissions to be removed.recursive
- If the nodePath indicates a folder, the permissions can be revoked recursively.AccessDeniedException
- the access denied exceptionRepositoryException
- the repository exceptionDatabaseException
- the database exceptionPathNotFoundException
- the path not found exceptionUnknownException
- the unknown exceptionWebserviceException
- the webservice exceptionpublic void grantRole(String uuid, String roleId, int permissions, boolean recursive) throws AccessDeniedException, RepositoryException, DatabaseException, PathNotFoundException, UnknownException, WebserviceException
BaseAuth
grantRole
in interface BaseAuth
uuid
- Node uuid.roleId
- Role name which permissions are changed.permissions
- A mask with the permissions to be removed.recursive
- If the nodePath indicates a folder, the permissions can be applied recursively.AccessDeniedException
- the access denied exceptionRepositoryException
- the repository exceptionDatabaseException
- the database exceptionPathNotFoundException
- the path not found exceptionUnknownException
- the unknown exceptionWebserviceException
- the webservice exceptionpublic void grantUser(String uuid, String userId, int permissions, boolean recursive) throws AccessDeniedException, RepositoryException, DatabaseException, PathNotFoundException, UnknownException, WebserviceException
BaseAuth
grantUser
in interface BaseAuth
uuid
- Node uuid.userId
- User name which permissions are changed.permissions
- A mask with the permissions to be added.recursive
- If the nodePath indicated a folder, the permissions can be applied recursively.AccessDeniedException
- the access denied exceptionRepositoryException
- the repository exceptionDatabaseException
- the database exceptionPathNotFoundException
- the path not found exceptionUnknownException
- the unknown exceptionWebserviceException
- the webservice exceptionpublic void createUser(String userId, String password, String email, String name, boolean active) throws PrincipalAdapterException, UnknownException, WebserviceException
BaseAuth
createUser
in interface BaseAuth
userId
- A user id.password
- the passwordemail
- the emailname
- the nameactive
- the activePrincipalAdapterException
- the principal adapter exceptionUnknownException
- the unknown exceptionWebserviceException
- the webservice exceptionpublic void deleteUser(String userId) throws PrincipalAdapterException, UnknownException, WebserviceException
BaseAuth
deleteUser
in interface BaseAuth
userId
- A user id.PrincipalAdapterException
- the principal adapter exceptionUnknownException
- the unknown exceptionWebserviceException
- the webservice exceptionpublic void updateUser(String userId, String password, String email, String name, boolean active) throws PrincipalAdapterException, UnknownException, WebserviceException
BaseAuth
updateUser
in interface BaseAuth
userId
- A user id.password
- the passwordemail
- the emailname
- the nameactive
- the activePrincipalAdapterException
- the principal adapter exceptionUnknownException
- the unknown exceptionWebserviceException
- the webservice exceptionpublic void createRole(String roleId, boolean active) throws PrincipalAdapterException, UnknownException, WebserviceException
BaseAuth
createRole
in interface BaseAuth
roleId
- A role id.active
- the activePrincipalAdapterException
- the principal adapter exceptionUnknownException
- the unknown exceptionWebserviceException
- the webservice exceptionpublic void deleteRole(String roleId) throws PrincipalAdapterException, UnknownException, WebserviceException
BaseAuth
deleteRole
in interface BaseAuth
roleId
- A role id.PrincipalAdapterException
- the principal adapter exceptionUnknownException
- the unknown exceptionWebserviceException
- the webservice exceptionpublic void updateRole(String roleId, boolean active) throws PrincipalAdapterException, UnknownException, WebserviceException
BaseAuth
updateRole
in interface BaseAuth
roleId
- A role idactive
- the activePrincipalAdapterException
- the principal adapter exceptionUnknownException
- the unknown exceptionWebserviceException
- the webservice exceptionpublic void assignRole(String userId, String roleId) throws PrincipalAdapterException, UnknownException, WebserviceException
BaseAuth
assignRole
in interface BaseAuth
userId
- A user id.roleId
- A role id.PrincipalAdapterException
- the principal adapter exceptionUnknownException
- the unknown exceptionWebserviceException
- the webservice exceptionpublic void removeRole(String userId, String roleId) throws PrincipalAdapterException, UnknownException, WebserviceException
BaseAuth
removeRole
in interface BaseAuth
userId
- A user id.roleId
- A role id.PrincipalAdapterException
- the principal adapter exceptionUnknownException
- the unknown exceptionWebserviceException
- the webservice exceptionpublic void changeSecurity(String uuid, ChangeSecurity changeSecurity) throws PathNotFoundException, AccessDeniedException, RepositoryException, DatabaseException, UnknownException, WebserviceException
BaseAuth
changeSecurity
in interface BaseAuth
uuid
- Node uuid.changeSecurity
- the change securityPathNotFoundException
- the path not found exceptionAccessDeniedException
- the access denied exceptionRepositoryException
- the repository exceptionDatabaseException
- the database exceptionUnknownException
- the unknown exceptionWebserviceException
- the webservice exceptionpublic List<Profile> getProfiles(boolean filterByActive) throws PrincipalAdapterException, WebserviceException, UnknownException
BaseAuth
getProfiles
in interface BaseAuth
filterByActive
- the filter by activePrincipalAdapterException
- the principal adapter exceptionWebserviceException
- the webservice exceptionUnknownException
- the unknown exceptionpublic Profile getUserProfile(String userId) throws PrincipalAdapterException, WebserviceException, UnknownException
BaseAuth
getUserProfile
in interface BaseAuth
userId
- A user id.PrincipalAdapterException
- the principal adapter exceptionWebserviceException
- the webservice exceptionUnknownException
- the unknown exceptionpublic void setUserProfile(String userId, long profileId) throws PrincipalAdapterException, WebserviceException, UnknownException
BaseAuth
setUserProfile
in interface BaseAuth
userId
- The user id.profileId
- The profile to be assigned.PrincipalAdapterException
- the principal adapter exceptionWebserviceException
- the webservice exceptionUnknownException
- the unknown exceptionpublic void setUserPermissions(String uuid, String userId, int permissions, boolean recursive) throws AccessDeniedException, RepositoryException, DatabaseException, PathNotFoundException, UnknownException, WebserviceException
BaseAuth
setUserPermissions
in interface BaseAuth
uuid
- Node uuid.userId
- User name which permissions are set.permissions
- User name which permissions are set.recursive
- recursive – If the nodePath indicated a folder, the permissions can be applied recursively.AccessDeniedException
- the access denied exceptionRepositoryException
- the repository exceptionDatabaseException
- the database exceptionPathNotFoundException
- the path not found exceptionUnknownException
- the unknown exceptionWebserviceException
- the webservice exceptionpublic void setRolePermissions(String uuid, String roleId, int permissions, boolean recursive) throws AccessDeniedException, RepositoryException, DatabaseException, PathNotFoundException, UnknownException, WebserviceException
BaseAuth
setRolePermissions
in interface BaseAuth
uuid
- Node uuid.roleId
- Role name which permissions are set.permissions
- A mask with the permissions to be set.recursive
- If the nodePath indicates a folder, the permissions can be applied recursively.AccessDeniedException
- the access denied exceptionRepositoryException
- the repository exceptionDatabaseException
- the database exceptionPathNotFoundException
- the path not found exceptionUnknownException
- the unknown exceptionWebserviceException
- the webservice exceptionpublic List<Tenant> getUserTenants() throws AccessDeniedException, RepositoryException, DatabaseException, PathNotFoundException, UnknownException, WebserviceException
BaseAuth
getUserTenants
in interface BaseAuth
AccessDeniedException
- the access denied exceptionRepositoryException
- the repository exceptionDatabaseException
- the database exceptionPathNotFoundException
- the path not found exceptionUnknownException
- the unknown exceptionWebserviceException
- the webservice exceptionpublic void setUserTenant(long tenantId) throws AccessDeniedException, RepositoryException, DatabaseException, PathNotFoundException, UnknownException, WebserviceException
BaseAuth
setUserTenant
in interface BaseAuth
tenantId
- tenantId tenant idAccessDeniedException
- the access denied exceptionRepositoryException
- the repository exceptionDatabaseException
- the database exceptionPathNotFoundException
- the path not found exceptionUnknownException
- the unknown exceptionWebserviceException
- the webservice exceptionpublic boolean isAdmin() throws PrincipalAdapterException, UnknownException, WebserviceException
BaseAuth
isAdmin
in interface BaseAuth
PrincipalAdapterException
- the principal adapter exceptionUnknownException
- the unknown exceptionWebserviceException
- the webservice exceptionpublic boolean hasSecurityRecursive() throws UnknownException, WebserviceException
BaseAuth
hasSecurityRecursive
in interface BaseAuth
UnknownException
- the unknown exceptionWebserviceException
- the webservice exceptionpublic boolean isLoginLowercase() throws UnknownException, WebserviceException
BaseAuth
isLoginLowercase
in interface BaseAuth
UnknownException
- the unknown exceptionWebserviceException
- the webservice exceptionpublic boolean isPasswordExpired() throws UnknownException, WebserviceException
BaseAuth
isPasswordExpired
in interface BaseAuth
UnknownException
- the unknown exceptionWebserviceException
- the webservice exceptionpublic boolean isTwoFactorAuthentication() throws UnknownException, WebserviceException
BaseAuth
isTwoFactorAuthentication
in interface BaseAuth
UnknownException
- the unknown exceptionWebserviceException
- the webservice exceptionpublic InputStream getTwoFactorQR(String secret) throws PrincipalAdapterException, UnknownException, WebserviceException
BaseAuth
getTwoFactorQR
in interface BaseAuth
secret
- the secretPrincipalAdapterException
- the principal adapter exceptionUnknownException
- the unknown exceptionWebserviceException
- the webservice exceptionpublic String generate2FASecret() throws PrincipalAdapterException, UnknownException, WebserviceException
BaseAuth
generate2FASecret
in interface BaseAuth
PrincipalAdapterException
- the principal adapter exceptionUnknownException
- the unknown exceptionWebserviceException
- the webservice exceptionpublic String validate2FAAndSaveSecret(String secret, int code) throws PrincipalAdapterException, UnknownException, WebserviceException
BaseAuth
validate2FAAndSaveSecret
in interface BaseAuth
secret
- the secretcode
- the codePrincipalAdapterException
- the principal adapter exceptionUnknownException
- the unknown exceptionWebserviceException
- the webservice exceptionpublic String disable2FA() throws PrincipalAdapterException, UnknownException, WebserviceException
BaseAuth
disable2FA
in interface BaseAuth
PrincipalAdapterException
- the principal adapter exceptionUnknownException
- the unknown exceptionWebserviceException
- the webservice exceptionpublic String verify2FACode(int code) throws PrincipalAdapterException, UnknownException, WebserviceException
BaseAuth
verify2FACode
in interface BaseAuth
code
- the codePrincipalAdapterException
- the principal adapter exceptionUnknownException
- the unknown exceptionWebserviceException
- the webservice exceptionCopyright © 2021 Open Knowledge Management System S.L.. All Rights Reserved.