All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jresearch.flexess.client.impl.UserManager Maven / Gradle / Ivy

The newest version!
package org.jresearch.flexess.client.impl;

import java.text.MessageFormat;

import org.jresearch.flexess.client.FlexessConnectException;
import org.jresearch.flexess.client.IUserManager;
import org.jresearch.flexess.client.UamClientException;
import org.jresearch.flexess.core.IUserService;
import org.jresearch.flexess.umi.api.AuthenticationException;
import org.jresearch.flexess.umi.api.IAuthenticationData;
import org.jresearch.flexess.umi.api.IResetAuthenticationData;
import org.jresearch.flexess.umi.api.ISignUpData;
import org.jresearch.flexess.umi.api.IUser;
import org.jresearch.flexess.umi.api.ResetAuthenticationException;
import org.jresearch.flexess.umi.api.SignUpException;
import org.jresearch.flexess.umi.api.UmiException;
import org.jresearch.flexess.umi.api.UnsupportedAuthenticationMethodException;
import org.springframework.remoting.RemoteAccessException;

/**
 * In case of local core the user service will ignore the application parameter.
 * There is only one application
 *
 * @author kot
 *
 */
public class UserManager implements IUserManager {

	private IUserService userService;

	public IUserService getUserService() {
		return userService;
	}

	public void setUserService(final IUserService userService) {
		this.userService = userService;
	}

	@Override
	public IUser getUser(final String userId) throws UamClientException {
		try {
			return userService.getUser(userId);
		} catch (final UmiException e) {
			throw new UamClientException(MessageFormat.format("Unable to find application: {0}.", e.getLocalizedMessage()), e); //$NON-NLS-1$
		} catch (final RemoteAccessException e) {
			throw new FlexessConnectException(MessageFormat.format("Can''t connect: {0}.", e.getLocalizedMessage()), e); //$NON-NLS-1$
		}
	}

	@Override
	public IUser authenticate(final IAuthenticationData authenticationData) throws AuthenticationException, UnsupportedAuthenticationMethodException {
		return userService.authenticate(authenticationData);
	}

	@Override
	public boolean isResetEnable() {
		try {
			return userService.isResetEnable();
		} catch (final UmiException e) {
			throw new UamClientException(MessageFormat.format("Some UNI problem: {0}.", e.getLocalizedMessage()), e); //$NON-NLS-1$
		}
	}

	@Override
	public void reset(final IResetAuthenticationData resetAuthData) throws ResetAuthenticationException, UnsupportedAuthenticationMethodException {
		try {
			userService.reset(resetAuthData);
		} catch (final UmiException e) {
			throw new UamClientException(MessageFormat.format("Some UMI problem: {0}.", e.getLocalizedMessage()), e); //$NON-NLS-1$
		}
	}

	@Override
	public boolean isSignUpEnable() {
		try {
			return userService.isSignUpEnable();
		} catch (final UmiException e) {
			throw new UamClientException(MessageFormat.format("Some UNI problem: {0}.", e.getLocalizedMessage()), e); //$NON-NLS-1$
		}
	}

	@Override
	public void signUp(final ISignUpData signUpData) throws SignUpException, UnsupportedAuthenticationMethodException {
		try {
			userService.signUp(signUpData);
		} catch (final UmiException e) {
			throw new SignUpException(e);
		}
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy