Package com.openkm.sdk4j.impl
Class AuthImpl
- java.lang.Object
-
- com.openkm.sdk4j.impl.ClientImpl
-
- com.openkm.sdk4j.impl.AuthImpl
-
- All Implemented Interfaces:
BaseAuth,Serializable
public class AuthImpl extends ClientImpl implements BaseAuth, Serializable
AuthImpl- Author:
- jllort
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidassignRole(String userId, String roleId)Method to assign a rolevoidchangeSecurity(String uuid, ChangeSecurity changeSecurity)Change several security permissions in the same call.StringcreatePersonalAccessToken(String name, Calendar expiration)Create personal access tokenvoidcreateRole(String roleId, boolean active)Method to create a new rolevoidcreateUser(String userId, String password, String email, String name, boolean active)Method to create a new uservoiddeleteRole(String roleId)Method to create a delete a rolevoiddeleteUser(String userId)Method to delete a userStringdisable2FA()Disable 2FAStringgenerate2FASecret()Generate 2FA secretMap<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).GrantedUsersAndRolesItemgetGrantedUsersAndRoles(String uuid)Get granted users and rolesList<Profile>getProfiles(boolean filterByActive)Get all profilesprotected StringgetRefreshToken()List<String>getRoles(boolean showAll)Retrieves a list of repository roles.List<String>getRolesByUser(String userId)Retrieves a list of roles by user.StringgetSessionId()Get sessionInputStreamgetTwoFactorQR(String secret)Get 2FACommonUsergetUser(String userId)Retrieve information of a given userProfilegetUserProfile(String userId)Get user profileList<CommonUser>getUsers(boolean showAll)Retrieve information of a given userList<CommonUser>getUsersByRole(String roleId)Retrieves a list of users by role.List<Tenant>getUserTenants()Get a list of available tenants for a user.StringgetUserToken(String userId)Get user tokenvoidgrantRole(String uuid, String roleId, int permissions, boolean recursive)Grant role permissions for a node.voidgrantUser(String uuid, String userId, int permissions, boolean recursive)Add user permissions to a node.booleanisLoginLowercase()Is login lowercasebooleanisTwoFactorAuthentication()Is two factor authenticationprotected Stringlogin(String personalAccessToken)protected Stringlogin(String user, String password)protected Stringlogin(String user, String password, int expiration, boolean restrictIp)protected Stringlogin(String user, String password, int expiration, boolean restrictIp, String personalAccessToken)protected voidlogout()voidoverwriteSecurity(String uuid, ChangeSecurity changeSecurity)Change several security permissions in the same call.voidremoveRole(String userId, String roleId)Method to remove a rolevoidrevokeRole(String uuid, String roleId, int permissions, boolean recursive)Revoke role permissions from a node.voidrevokeUser(String uuid, String userId, int permissions, boolean recursive)Revoke user permissions from a node.protected voidsetAuthorizationToken(String authorizationToken)setAuthenticationTokenvoidsetRolePermissions(String uuid, String roleId, int permissions, boolean recursive)Set role permissions for a node.voidsetUserPermissions(String uuid, String userId, int permissions, boolean recursive)Set user permissions to a nodevoidsetUserProfile(String userId, long profileId)Set the user profilevoidsetUserTenant(long tenantId)Update user tenant.voidupdateRole(String roleId, boolean active)Update role informationvoidupdateUser(String userId, String password, String email, String name, boolean active)Update user informationStringvalidate2FAAndSaveSecret(String secret, int code)Validate 2FA and save secretStringverify2FACode(int code)Verify 2FA code-
Methods inherited from class com.openkm.sdk4j.impl.ClientImpl
getClient, getWebTarget, setAuthorizationHeader, setJsessionIdHeader
-
-
-
-
Constructor Detail
-
AuthImpl
public AuthImpl(String host)
AuthImpl
-
-
Method Detail
-
getSessionId
public String getSessionId()
Description copied from interface:BaseAuthGet session- Specified by:
getSessionIdin interfaceBaseAuth- Returns:
- String session id
-
setAuthorizationToken
protected void setAuthorizationToken(String authorizationToken)
setAuthenticationToken
-
login
protected String login(String personalAccessToken) throws UnknownException, WebserviceException, AuthenticationException
-
login
protected String login(String user, String password) throws UnknownException, WebserviceException, AuthenticationException
-
login
protected String login(String user, String password, int expiration, boolean restrictIp) throws UnknownException, WebserviceException, AuthenticationException
-
login
protected String login(String user, String password, int expiration, boolean restrictIp, String personalAccessToken) throws UnknownException, WebserviceException, AuthenticationException
-
logout
protected void logout() throws WebserviceException, UnknownException- Throws:
WebserviceExceptionUnknownException
-
getRefreshToken
protected String getRefreshToken() throws UnknownException, WebserviceException
- Throws:
UnknownExceptionWebserviceException
-
getGrantedUsersAndRoles
public GrantedUsersAndRolesItem getGrantedUsersAndRoles(String uuid) throws AccessDeniedException, RepositoryException, DatabaseException, PathNotFoundException, UnknownException, WebserviceException
Description copied from interface:BaseAuthGet granted users and roles- Specified by:
getGrantedUsersAndRolesin interfaceBaseAuth- Parameters:
uuid- Node uuid.- Returns:
- GrantedUsersAndRolesItem An object with list the users and roles
- Throws:
AccessDeniedException- the access denied exceptionRepositoryException- the repository exceptionDatabaseException- the database exceptionPathNotFoundException- the path not found exceptionUnknownException- the unknown exceptionWebserviceException- the webservice exception
-
getGrantedRoles
public Map<String,Integer> getGrantedRoles(String uuid) throws AccessDeniedException, RepositoryException, DatabaseException, PathNotFoundException, WebserviceException, UnknownException
Description copied from interface:BaseAuthGet roles permissions from am item (document or folder).- Specified by:
getGrantedRolesin interfaceBaseAuth- Parameters:
uuid- Node uuid.- Returns:
- Map
A hashmap with pairs of role / permissions. - Throws:
AccessDeniedException- the access denied exceptionRepositoryException- the repository exceptionDatabaseException- the database exceptionPathNotFoundException- the path not found exceptionWebserviceException- the webservice exceptionUnknownException- the unknown exception
-
getGrantedUsers
public Map<String,Integer> getGrantedUsers(String uuid) throws AccessDeniedException, RepositoryException, DatabaseException, PathNotFoundException, WebserviceException, UnknownException
Description copied from interface:BaseAuthGet user permissions from am item (document or folder).- Specified by:
getGrantedUsersin interfaceBaseAuth- Parameters:
uuid- Node uuid.- Returns:
- Map
A hashmap with pairs of user / permissions. - Throws:
AccessDeniedException- the access denied exceptionRepositoryException- the repository exceptionDatabaseException- the database exceptionPathNotFoundException- the path not found exceptionWebserviceException- the webservice exceptionUnknownException- the unknown exception
-
getRoles
public List<String> getRoles(boolean showAll) throws AccessDeniedException, RepositoryException, DatabaseException, AuthException, WebserviceException, UnknownException
Description copied from interface:BaseAuthRetrieves a list of repository roles.- Specified by:
getRolesin interfaceBaseAuth- Parameters:
showAll- If should only return active roles or all them- Returns:
- List
A collection of repository roles. - Throws:
AccessDeniedException- the access denied exceptionRepositoryException- the repository exceptionDatabaseException- the database exceptionAuthException- the principal adapter exceptionWebserviceException- the webservice exceptionUnknownException- the unknown exception
-
getRolesByUser
public List<String> getRolesByUser(String userId) throws AccessDeniedException, RepositoryException, DatabaseException, AuthException, WebserviceException, UnknownException
Description copied from interface:BaseAuthRetrieves a list of roles by user.- Specified by:
getRolesByUserin interfaceBaseAuth- Parameters:
userId- A user id.- Returns:
- List
A repository roles. - Throws:
AccessDeniedException- the access denied exceptionRepositoryException- the repository exceptionDatabaseException- the database exceptionAuthException- the principal adapter exceptionWebserviceException- the webservice exceptionUnknownException- the unknown exception
-
getUsers
public List<CommonUser> getUsers(boolean showAll) throws AccessDeniedException, RepositoryException, DatabaseException, AuthException, UnknownException, WebserviceException
Description copied from interface:BaseAuthRetrieve information of a given user- Specified by:
getUsersin interfaceBaseAuth- Parameters:
showAll- If should only return active users or all them- Returns:
- List
A collection of repository users. - Throws:
AccessDeniedException- the access denied exceptionRepositoryException- the repository exceptionDatabaseException- the database exceptionAuthException- the principal adapter exceptionUnknownException- the unknown exceptionWebserviceException- the webservice exception
-
getUser
public CommonUser getUser(String userId) throws AccessDeniedException, RepositoryException, DatabaseException, AuthException, UnknownException, WebserviceException
Description copied from interface:BaseAuthRetrieve information of a given user- Specified by:
getUserin interfaceBaseAuth- Parameters:
userId- A user id.- Returns:
- CommonUser The data user
- Throws:
AccessDeniedException- the access denied exceptionRepositoryException- the repository exceptionDatabaseException- the database exceptionAuthException- the principal adapter exceptionUnknownException- the unknown exceptionWebserviceException- the webservice exception
-
getUsersByRole
public List<CommonUser> getUsersByRole(String roleId) throws AccessDeniedException, RepositoryException, DatabaseException, AuthException, UnknownException, WebserviceException
Description copied from interface:BaseAuthRetrieves a list of users by role.- Specified by:
getUsersByRolein interfaceBaseAuth- Parameters:
roleId- A role id.- Returns:
- List
A repository users. - Throws:
AccessDeniedException- the access denied exceptionRepositoryException- the repository exceptionDatabaseException- the database exceptionAuthException- the principal adapter exceptionUnknownException- the unknown exceptionWebserviceException- the webservice exception
-
revokeRole
public void revokeRole(String uuid, String roleId, int permissions, boolean recursive) throws AccessDeniedException, RepositoryException, DatabaseException, PathNotFoundException, UnknownException, WebserviceException
Description copied from interface:BaseAuthRevoke role permissions from a node.- Specified by:
revokeRolein interfaceBaseAuth- Parameters:
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.- Throws:
AccessDeniedException- the access denied exceptionRepositoryException- the repository exceptionDatabaseException- the database exceptionPathNotFoundException- the path not found exceptionUnknownException- the unknown exceptionWebserviceException- the webservice exception
-
revokeUser
public void revokeUser(String uuid, String userId, int permissions, boolean recursive) throws AccessDeniedException, RepositoryException, DatabaseException, PathNotFoundException, UnknownException, WebserviceException
Description copied from interface:BaseAuthRevoke user permissions from a node.- Specified by:
revokeUserin interfaceBaseAuth- Parameters:
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.- Throws:
AccessDeniedException- the access denied exceptionRepositoryException- the repository exceptionDatabaseException- the database exceptionPathNotFoundException- the path not found exceptionUnknownException- the unknown exceptionWebserviceException- the webservice exception
-
grantRole
public void grantRole(String uuid, String roleId, int permissions, boolean recursive) throws AccessDeniedException, RepositoryException, DatabaseException, PathNotFoundException, UnknownException, WebserviceException
Description copied from interface:BaseAuthGrant role permissions for a node.- Specified by:
grantRolein interfaceBaseAuth- Parameters:
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.- Throws:
AccessDeniedException- the access denied exceptionRepositoryException- the repository exceptionDatabaseException- the database exceptionPathNotFoundException- the path not found exceptionUnknownException- the unknown exceptionWebserviceException- the webservice exception
-
grantUser
public void grantUser(String uuid, String userId, int permissions, boolean recursive) throws AccessDeniedException, RepositoryException, DatabaseException, PathNotFoundException, UnknownException, WebserviceException
Description copied from interface:BaseAuthAdd user permissions to a node.- Specified by:
grantUserin interfaceBaseAuth- Parameters:
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.- Throws:
AccessDeniedException- the access denied exceptionRepositoryException- the repository exceptionDatabaseException- the database exceptionPathNotFoundException- the path not found exceptionUnknownException- the unknown exceptionWebserviceException- the webservice exception
-
createUser
public void createUser(String userId, String password, String email, String name, boolean active) throws AuthException, UnknownException, WebserviceException
Description copied from interface:BaseAuthMethod to create a new user- Specified by:
createUserin interfaceBaseAuth- Parameters:
userId- A user id.password- the passwordemail- the emailname- the nameactive- the active- Throws:
AuthException- the principal adapter exceptionUnknownException- the unknown exceptionWebserviceException- the webservice exception
-
deleteUser
public void deleteUser(String userId) throws AuthException, UnknownException, WebserviceException
Description copied from interface:BaseAuthMethod to delete a user- Specified by:
deleteUserin interfaceBaseAuth- Parameters:
userId- A user id.- Throws:
AuthException- the principal adapter exceptionUnknownException- the unknown exceptionWebserviceException- the webservice exception
-
updateUser
public void updateUser(String userId, String password, String email, String name, boolean active) throws AuthException, UnknownException, WebserviceException
Description copied from interface:BaseAuthUpdate user information- Specified by:
updateUserin interfaceBaseAuth- Parameters:
userId- A user id.password- the passwordemail- the emailname- the nameactive- the active- Throws:
AuthException- the principal adapter exceptionUnknownException- the unknown exceptionWebserviceException- the webservice exception
-
createRole
public void createRole(String roleId, boolean active) throws AuthException, UnknownException, WebserviceException
Description copied from interface:BaseAuthMethod to create a new role- Specified by:
createRolein interfaceBaseAuth- Parameters:
roleId- A role id.active- the active- Throws:
AuthException- the principal adapter exceptionUnknownException- the unknown exceptionWebserviceException- the webservice exception
-
deleteRole
public void deleteRole(String roleId) throws AuthException, UnknownException, WebserviceException
Description copied from interface:BaseAuthMethod to create a delete a role- Specified by:
deleteRolein interfaceBaseAuth- Parameters:
roleId- A role id.- Throws:
AuthException- the principal adapter exceptionUnknownException- the unknown exceptionWebserviceException- the webservice exception
-
updateRole
public void updateRole(String roleId, boolean active) throws AuthException, UnknownException, WebserviceException
Description copied from interface:BaseAuthUpdate role information- Specified by:
updateRolein interfaceBaseAuth- Parameters:
roleId- A role idactive- the active- Throws:
AuthException- the principal adapter exceptionUnknownException- the unknown exceptionWebserviceException- the webservice exception
-
assignRole
public void assignRole(String userId, String roleId) throws AuthException, UnknownException, WebserviceException
Description copied from interface:BaseAuthMethod to assign a role- Specified by:
assignRolein interfaceBaseAuth- Parameters:
userId- A user id.roleId- A role id.- Throws:
AuthException- the principal adapter exceptionUnknownException- the unknown exceptionWebserviceException- the webservice exception
-
removeRole
public void removeRole(String userId, String roleId) throws AuthException, UnknownException, WebserviceException
Description copied from interface:BaseAuthMethod to remove a role- Specified by:
removeRolein interfaceBaseAuth- Parameters:
userId- A user id.roleId- A role id.- Throws:
AuthException- the principal adapter exceptionUnknownException- the unknown exceptionWebserviceException- the webservice exception
-
changeSecurity
public void changeSecurity(String uuid, ChangeSecurity changeSecurity) throws PathNotFoundException, AccessDeniedException, RepositoryException, DatabaseException, UnknownException, WebserviceException
Description copied from interface:BaseAuthChange several security permissions in the same call.- Specified by:
changeSecurityin interfaceBaseAuth- Parameters:
uuid- Node uuid.changeSecurity- the change security- Throws:
PathNotFoundException- the path not found exceptionAccessDeniedException- the access denied exceptionRepositoryException- the repository exceptionDatabaseException- the database exceptionUnknownException- the unknown exceptionWebserviceException- the webservice exception
-
overwriteSecurity
public void overwriteSecurity(String uuid, ChangeSecurity changeSecurity) throws PathNotFoundException, AccessDeniedException, RepositoryException, DatabaseException, UnknownException, WebserviceException
Description copied from interface:BaseAuthChange several security permissions in the same call.- Specified by:
overwriteSecurityin interfaceBaseAuth- Parameters:
uuid- Node uuid.changeSecurity- the change security- Throws:
PathNotFoundException- the path not found exceptionAccessDeniedException- the access denied exceptionRepositoryException- the repository exceptionDatabaseException- the database exceptionUnknownException- the unknown exceptionWebserviceException- the webservice exception
-
getProfiles
public List<Profile> getProfiles(boolean filterByActive) throws AuthException, WebserviceException, UnknownException
Description copied from interface:BaseAuthGet all profiles- Specified by:
getProfilesin interfaceBaseAuth- Parameters:
filterByActive- the filter by active- Returns:
- List
A list with all the registered profiles. - Throws:
AuthException- the principal adapter exceptionWebserviceException- the webservice exceptionUnknownException- the unknown exception
-
getUserProfile
public Profile getUserProfile(String userId) throws AuthException, WebserviceException, UnknownException
Description copied from interface:BaseAuthGet user profile- Specified by:
getUserProfilein interfaceBaseAuth- Parameters:
userId- A user id.- Returns:
- Profile Return the profile assigned to a user.
- Throws:
AuthException- the principal adapter exceptionWebserviceException- the webservice exceptionUnknownException- the unknown exception
-
setUserProfile
public void setUserProfile(String userId, long profileId) throws AuthException, WebserviceException, UnknownException
Description copied from interface:BaseAuthSet the user profile- Specified by:
setUserProfilein interfaceBaseAuth- Parameters:
userId- The user id.profileId- The profile to be assigned.- Throws:
AuthException- the principal adapter exceptionWebserviceException- the webservice exceptionUnknownException- the unknown exception
-
getUserToken
public String getUserToken(String userId) throws AuthException, WebserviceException, UnknownException
Description copied from interface:BaseAuthGet user token- Specified by:
getUserTokenin interfaceBaseAuth- Parameters:
userId- A user id.- Returns:
- String Return the token to a user.
- Throws:
AuthException- the principal adapter exceptionWebserviceException- the webservice exceptionUnknownException- the unknown exception
-
setUserPermissions
public void setUserPermissions(String uuid, String userId, int permissions, boolean recursive) throws AccessDeniedException, RepositoryException, DatabaseException, PathNotFoundException, UnknownException, WebserviceException
Description copied from interface:BaseAuthSet user permissions to a node- Specified by:
setUserPermissionsin interfaceBaseAuth- Parameters:
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.- Throws:
AccessDeniedException- the access denied exceptionRepositoryException- the repository exceptionDatabaseException- the database exceptionPathNotFoundException- the path not found exceptionUnknownException- the unknown exceptionWebserviceException- the webservice exception
-
setRolePermissions
public void setRolePermissions(String uuid, String roleId, int permissions, boolean recursive) throws AccessDeniedException, RepositoryException, DatabaseException, PathNotFoundException, UnknownException, WebserviceException
Description copied from interface:BaseAuthSet role permissions for a node.- Specified by:
setRolePermissionsin interfaceBaseAuth- Parameters:
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.- Throws:
AccessDeniedException- the access denied exceptionRepositoryException- the repository exceptionDatabaseException- the database exceptionPathNotFoundException- the path not found exceptionUnknownException- the unknown exceptionWebserviceException- the webservice exception
-
getUserTenants
public List<Tenant> getUserTenants() throws AccessDeniedException, RepositoryException, DatabaseException, PathNotFoundException, UnknownException, WebserviceException
Description copied from interface:BaseAuthGet a list of available tenants for a user.- Specified by:
getUserTenantsin interfaceBaseAuth- Returns:
- List
the list of tenants - Throws:
AccessDeniedException- the access denied exceptionRepositoryException- the repository exceptionDatabaseException- the database exceptionPathNotFoundException- the path not found exceptionUnknownException- the unknown exceptionWebserviceException- the webservice exception
-
setUserTenant
public void setUserTenant(long tenantId) throws AccessDeniedException, RepositoryException, DatabaseException, PathNotFoundException, UnknownException, WebserviceExceptionDescription copied from interface:BaseAuthUpdate user tenant.- Specified by:
setUserTenantin interfaceBaseAuth- Parameters:
tenantId- tenantId tenant id- Throws:
AccessDeniedException- the access denied exceptionRepositoryException- the repository exceptionDatabaseException- the database exceptionPathNotFoundException- the path not found exceptionUnknownException- the unknown exceptionWebserviceException- the webservice exception
-
isLoginLowercase
public boolean isLoginLowercase() throws UnknownException, WebserviceExceptionDescription copied from interface:BaseAuthIs login lowercase- Specified by:
isLoginLowercasein interfaceBaseAuth- Returns:
- boolean boolean
- Throws:
UnknownException- the unknown exceptionWebserviceException- the webservice exception
-
isTwoFactorAuthentication
public boolean isTwoFactorAuthentication() throws UnknownException, WebserviceExceptionDescription copied from interface:BaseAuthIs two factor authentication- Specified by:
isTwoFactorAuthenticationin interfaceBaseAuth- Returns:
- true active two factor autentication
- Throws:
UnknownException- the unknown exceptionWebserviceException- the webservice exception
-
getTwoFactorQR
public InputStream getTwoFactorQR(String secret) throws AuthException, UnknownException, WebserviceException
Description copied from interface:BaseAuthGet 2FA- Specified by:
getTwoFactorQRin interfaceBaseAuth- Parameters:
secret- the secret- Returns:
- stream with 2FA qr image
- Throws:
AuthException- the principal adapter exceptionUnknownException- the unknown exceptionWebserviceException- the webservice exception
-
generate2FASecret
public String generate2FASecret() throws AuthException, UnknownException, WebserviceException
Description copied from interface:BaseAuthGenerate 2FA secret- Specified by:
generate2FASecretin interfaceBaseAuth- Returns:
- String with 2FA secret
- Throws:
AuthException- the principal adapter exceptionUnknownException- the unknown exceptionWebserviceException- the webservice exception
-
validate2FAAndSaveSecret
public String validate2FAAndSaveSecret(String secret, int code) throws AuthException, UnknownException, WebserviceException
Description copied from interface:BaseAuthValidate 2FA and save secret- Specified by:
validate2FAAndSaveSecretin interfaceBaseAuth- Parameters:
secret- the secretcode- the code- Returns:
- String string
- Throws:
AuthException- the principal adapter exceptionUnknownException- the unknown exceptionWebserviceException- the webservice exception
-
disable2FA
public String disable2FA() throws AuthException, UnknownException, WebserviceException
Description copied from interface:BaseAuthDisable 2FA- Specified by:
disable2FAin interfaceBaseAuth- Returns:
- String string
- Throws:
AuthException- the principal adapter exceptionUnknownException- the unknown exceptionWebserviceException- the webservice exception
-
verify2FACode
public String verify2FACode(int code) throws AuthException, UnknownException, WebserviceException
Description copied from interface:BaseAuthVerify 2FA code- Specified by:
verify2FACodein interfaceBaseAuth- Parameters:
code- the code- Returns:
- int string
- Throws:
AuthException- the principal adapter exceptionUnknownException- the unknown exceptionWebserviceException- the webservice exception
-
createPersonalAccessToken
public String createPersonalAccessToken(String name, Calendar expiration) throws DatabaseException, UnknownException, WebserviceException
Description copied from interface:BaseAuthCreate personal access token- Specified by:
createPersonalAccessTokenin interfaceBaseAuth- Parameters:
name- the nameexpiration- the expiration- Returns:
- String string
- Throws:
DatabaseException- the database exceptionUnknownException- the unknown exceptionWebserviceException- the webservice exception
-
-