Class PrincipalResource
java.lang.Object
ch.tocco.nice2.rest.core.spi.AbstractRestResource
ch.tocco.nice2.rest.principal.impl.resources.PrincipalResource
- All Implemented Interfaces:
RestResource
@Path("/principals/{usernameOrPk: (?!.*(businessunits))[^/]+}")
public class PrincipalResource
extends AbstractRestResource
-
Field Summary
Fields inherited from class ch.tocco.nice2.rest.core.spi.AbstractRestResource
uriInfo
-
Constructor Summary
ConstructorDescriptionPrincipalResource
(PasswordUpdateService passwordUpdateService, RequestNewPasswordService requestNewPasswordService, Context context, TextResources textResources, org.slf4j.Logger log, SecurityManager securityManager, BusinessUnitManager businessUnitManager, RecaptchaVerificationService recaptchaVerificationService, PrincipalManager principalManager) -
Method Summary
Modifier and TypeMethodDescriptionvoid
activateTwoFactorAuthentication
(String usernameOrPk, TwoFactorActivateBean twoFactorActivateBean) void
changeBusinessUnit
(String usernameOrPk, BusinessUnitChangeBean businessUnitBean) generateTwoFactorAuthenticationSecret
(String usernameOrPk) getPasswordRules
(String username) Returns the password validation rulesjakarta.ws.rs.core.Response
resetPassword
(String usernameOrPk) Resets the password of a principalvoid
setPrivilegedRoles
(List<String> privilegedRoles) jakarta.ws.rs.core.Response
updatePassword
(String usernameOrPk, UpdatePasswordBean passwordBean) Updates the password of a principalvalidatePassword
(String usernameOrPk, UpdatePasswordBean passwordBean) Validates the new password of a certain principal against the password policyMethods inherited from class ch.tocco.nice2.rest.core.spi.AbstractRestResource
getPathParameter, setUriInfo, tryGetInt
-
Constructor Details
-
PrincipalResource
public PrincipalResource(PasswordUpdateService passwordUpdateService, RequestNewPasswordService requestNewPasswordService, Context context, TextResources textResources, org.slf4j.Logger log, SecurityManager securityManager, BusinessUnitManager businessUnitManager, RecaptchaVerificationService recaptchaVerificationService, PrincipalManager principalManager)
-
-
Method Details
-
setPrivilegedRoles
-
validatePassword
@POST @Path("/password-validation") @Produces("application/json") @Consumes("application/json") public ValidationResultBean validatePassword(@PathParam("usernameOrPk") String usernameOrPk, UpdatePasswordBean passwordBean) Validates the new password of a certain principal against the password policy- Parameters:
usernameOrPk
- username or primary key of the principal whose password will be validatedpasswordBean
- bean which contains the password to be validated. If the user is not authenticated currently, the bean must contain the current password (= old password) for authentication.- Returns:
- the validation result
-
updatePassword
@POST @Path("/password-update") @Consumes("application/json") public jakarta.ws.rs.core.Response updatePassword(@PathParam("usernameOrPk") String usernameOrPk, UpdatePasswordBean passwordBean) Updates the password of a principal- Parameters:
usernameOrPk
- username or primary key of the principal whose password will be changedpasswordBean
- bean which contains the new and old (optional for usermanager) passwords. If the user is not authenticated currently, the bean must contain the current password (= old password) for authentication.- Returns:
- Status 200 on success
-
resetPassword
@POST @Path("/password-reset") public jakarta.ws.rs.core.Response resetPassword(@PathParam("usernameOrPk") String usernameOrPk) Resets the password of a principal- Parameters:
usernameOrPk
- username of the principal whose password will be reset- Returns:
- Status 200 on success (else 400 - regardless of the actual error)
-
getPasswordRules
@GET @Path("/password-rules") @Produces("application/json") public PasswordRulesBean getPasswordRules(@PathParam("usernameOrPk") String username) Returns the password validation rules- Parameters:
username
- username of the principal to get the validation rules for- Returns:
- the current password policy for the given principal
-
changeBusinessUnit
@PUT @Path("/businessunit") @Consumes("application/json") public void changeBusinessUnit(@PathParam("usernameOrPk") String usernameOrPk, BusinessUnitChangeBean businessUnitBean) -
generateTwoFactorAuthenticationSecret
@GET @Path("/two-factor") @Produces("application/json") public TwoFactorBean generateTwoFactorAuthenticationSecret(@PathParam("usernameOrPk") String usernameOrPk) -
activateTwoFactorAuthentication
@POST @Path("/two-factor") @Consumes("application/json") public void activateTwoFactorAuthentication(@PathParam("usernameOrPk") String usernameOrPk, TwoFactorActivateBean twoFactorActivateBean)
-