Search in sources :

Example 16 with ProfileException

use of org.craftercms.profile.api.exceptions.ProfileException in project profile by craftercms.

the class TenantServiceImpl method updateAttributeDefinitions.

@Override
public Tenant updateAttributeDefinitions(final String tenantName, final Collection<AttributeDefinition> attributeDefinitions) throws ProfileException {
    Tenant tenant = updateTenant(tenantName, new UpdateCallback() {

        @Override
        public void doWithTenant(TenantUpdater tenantUpdater) throws ProfileException {
            tenantUpdater.updateAttributeDefinitions(attributeDefinitions);
        }
    });
    logger.debug(LOG_KEY_ATTRIBUTE_DEFINITIONS_UPDATED, attributeDefinitions, tenantName);
    return tenant;
}
Also used : Tenant(org.craftercms.profile.api.Tenant) TenantUpdater(org.craftercms.profile.utils.db.TenantUpdater) I10nProfileException(org.craftercms.profile.api.exceptions.I10nProfileException) ProfileException(org.craftercms.profile.api.exceptions.ProfileException)

Example 17 with ProfileException

use of org.craftercms.profile.api.exceptions.ProfileException in project profile by craftercms.

the class AbstractProfileRestClientBase method doPostForUpload.

protected <T> T doPostForUpload(String url, MultiValueMap<String, Object> request, Class<T> responseType, Object... uriVariables) throws ProfileException {
    try {
        HttpHeaders headers = new HttpHeaders();
        headers.setContentType(MediaType.MULTIPART_FORM_DATA);
        HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(request, headers);
        return restTemplate.exchange(url, HttpMethod.POST, requestEntity, responseType, uriVariables).getBody();
    } catch (RestServiceException e) {
        handleRestServiceException(e);
    } catch (Exception e) {
        handleException(e);
    }
    return null;
}
Also used : RestServiceException(org.craftercms.commons.rest.RestServiceException) ProfileRestServiceException(org.craftercms.profile.exceptions.ProfileRestServiceException) HttpHeaders(org.springframework.http.HttpHeaders) HttpEntity(org.springframework.http.HttpEntity) MultiValueMap(org.springframework.util.MultiValueMap) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) RestServiceException(org.craftercms.commons.rest.RestServiceException) ProfileException(org.craftercms.profile.api.exceptions.ProfileException) ProfileRestServiceException(org.craftercms.profile.exceptions.ProfileRestServiceException)

Example 18 with ProfileException

use of org.craftercms.profile.api.exceptions.ProfileException in project profile by craftercms.

the class RememberMeManagerImpl method updateRememberMe.

protected void updateRememberMe(String loginId, RequestContext context) throws RememberMeException {
    PersistentLogin login;
    try {
        login = authenticationService.refreshPersistentLoginToken(loginId);
    } catch (ProfileException e) {
        throw new RememberMeException("Unable to update persistent login '" + loginId + "'", e);
    }
    logger.debug("Persistent login updated: {}", login);
    addRememberMeCookie(serializeLogin(login), context.getResponse());
}
Also used : ProfileException(org.craftercms.profile.api.exceptions.ProfileException) PersistentLogin(org.craftercms.profile.api.PersistentLogin) RememberMeException(org.craftercms.security.exception.rememberme.RememberMeException)

Example 19 with ProfileException

use of org.craftercms.profile.api.exceptions.ProfileException in project profile by craftercms.

the class RememberMeManagerImpl method disableRememberMe.

protected void disableRememberMe(String loginId, RequestContext context) throws RememberMeException {
    deleteRememberMeCookie(context.getResponse());
    try {
        authenticationService.deletePersistentLogin(loginId);
    } catch (ProfileException e) {
        throw new RememberMeException("Error invalidating persistent login '" + loginId + "'");
    }
    logger.debug("Persistent login '{}' invalidated", loginId);
}
Also used : ProfileException(org.craftercms.profile.api.exceptions.ProfileException) RememberMeException(org.craftercms.security.exception.rememberme.RememberMeException)

Example 20 with ProfileException

use of org.craftercms.profile.api.exceptions.ProfileException in project engine by craftercms.

the class ProfileRememberMeServices method logout.

@Override
public void logout(final HttpServletRequest request, final HttpServletResponse response, final Authentication authentication) {
    super.logout(request, response, authentication);
    // Needed because the super class expects to work only with the username
    String cookie = extractRememberMeCookie(request);
    if (authentication != null && isNotEmpty(cookie)) {
        String persistentLoginId = decodeCookie(cookie)[0];
        try {
            authenticationService.deletePersistentLogin(persistentLoginId);
        } catch (ProfileException e) {
            throw new RememberMeAuthenticationException("Error deleting persistent login " + persistentLoginId, e);
        }
    }
}
Also used : RememberMeAuthenticationException(org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationException) ProfileException(org.craftercms.profile.api.exceptions.ProfileException)

Aggregations

ProfileException (org.craftercms.profile.api.exceptions.ProfileException)22 Tenant (org.craftercms.profile.api.Tenant)8 I10nProfileException (org.craftercms.profile.api.exceptions.I10nProfileException)8 TenantUpdater (org.craftercms.profile.utils.db.TenantUpdater)7 PersistentLogin (org.craftercms.profile.api.PersistentLogin)5 Profile (org.craftercms.profile.api.Profile)4 RememberMeException (org.craftercms.security.exception.rememberme.RememberMeException)4 ProfileRestServiceException (org.craftercms.profile.exceptions.ProfileRestServiceException)3 AuthenticationSystemException (org.craftercms.security.exception.AuthenticationSystemException)3 RememberMeAuthenticationException (org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationException)3 AttributeDefinition (org.craftercms.profile.api.AttributeDefinition)2 Ticket (org.craftercms.profile.api.Ticket)2 NoSuchProfileException (org.craftercms.profile.exceptions.NoSuchProfileException)2 DisabledUserException (org.craftercms.security.exception.DisabledUserException)2 ApiOperation (com.wordnik.swagger.annotations.ApiOperation)1 FileNotFoundException (java.io.FileNotFoundException)1 InputStream (java.io.InputStream)1 Collection (java.util.Collection)1 FileExistsException (org.apache.commons.io.FileExistsException)1 ObjectId (org.bson.types.ObjectId)1