Package edu.stanford.bmir.protege.web.client.rpc.data

Examples of edu.stanford.bmir.protege.web.client.rpc.data.UserData


     * null if open id attribute is not present in session
     * (non-Javadoc)
     * @see edu.stanford.bmir.protege.web.client.rpc.OpenIdService#isOpenIdInSession()
     */
    public UserData isOpenIdInSessForAddNewOpenId() {
        UserData userData = null;
        try {
            HttpServletRequest request = this.getThreadLocalRequest();
            HttpSession session = request.getSession();
            String openIdUrl = (String) session.getAttribute(OpenIdConstants.HTTPSESSION_OPENID_URL);

            if (openIdUrl != null) {
                Optional<UserId> userId = MetaProjectManager.getManager().getUserAssociatedWithOpenId(openIdUrl);
                if (userId.isPresent()) {
                    userData = new UserData(userId.get());
                    session.setAttribute(OpenIdConstants.HTTPSESSION_OPENID_URL, null);
                    session.setAttribute(OpenIdConstants.HTTPSESSION_OPENID_ID, null);
                    session.setAttribute(OpenIdConstants.HTTPSESSION_OPENID_PROVIDER, null);
                }
            }
View Full Code Here


    private boolean isAuthenticateWithOpenId() {
        return WebProtegeProperties.get().isOpenIdAuthenticationEnabled();
    }

    public UserData checkIfOpenIdInSessionForLogin() {
        UserData userData = null;
        if (isAuthenticateWithOpenId()) {
            try {
                HttpServletRequest request = this.getThreadLocalRequest();
                HttpSession session = request.getSession(false);
                if (session != null) {
                    String openIdUrl = (String) session.getAttribute(OpenIdConstants.HTTPSESSION_OPENID_URL);
                    if (openIdUrl != null) {
                        Optional<UserId> userId = MetaProjectManager.getManager().getUserAssociatedWithOpenId(openIdUrl);
                        if (userId.isPresent()) { //user is associated with openid
                            userData = new UserData(userId.get());
                            session.setAttribute(OpenIdConstants.HTTPSESSION_OPENID_URL, null);
                            session.setAttribute(OpenIdConstants.HTTPSESSION_OPENID_ID, null);
                            session.setAttribute(OpenIdConstants.HTTPSESSION_OPENID_PROVIDER, null);
                            SessionConstants.setAttribute(SessionConstants.USER_ID, userId.get(), session);
                        }
View Full Code Here

            Log.getLogger().log(Level.WARNING, "Error at clearCreateUserToAssocOpenIdSessData : ", e);
        }
    }

    public UserData checkIfUserCreatedToAssocOpenId() {
        UserData userCreated = null;
        try {
            HttpServletRequest request = this.getThreadLocalRequest();
            HttpSession session = request.getSession();
            userCreated = (UserData) session.getAttribute(OpenIdConstants.CREATED_USER_TO_ASSOC_OPEN_ID);
        } catch (Exception e) {
View Full Code Here

            Log.getLogger().log(Level.WARNING, "Error at clearAuthUserToAssocOpenIdSessData : ", e);
        }
    }

    public UserData checkIfUserAuthenticatedToAssocOpenId() {
        UserData userAuthenticated = null;
        try {
            HttpServletRequest request = this.getThreadLocalRequest();
            HttpSession session = request.getSession();
            userAuthenticated = (UserData) session.getAttribute(OpenIdConstants.AUTHENTICATED_USER_TO_ASSOC_OPEN_ID);
        } catch (Exception e) {
View Full Code Here

        String openIdAccName = (String) session.getAttribute(OpenIdConstants.HTTPSESSION_OPENID_ID);
        String openIdProvider = (String) session.getAttribute(OpenIdConstants.HTTPSESSION_OPENID_PROVIDER);
        String salt = (String) session.getAttribute(AuthenticationConstants.NEW_SALT);

        if (userOpenId == null && salt != null) {
            UserData userData = AuthenticationUtil.createUserData(UserId.getUserId(userName));
            userData.setProperty(OpenIdUtil.REGISTRATION_RESULT_PROP, OpenIdConstants.REGISTER_USER_ERROR);
            return userData;
        }

        User user = MetaProjectManager.getManager().getMetaProject().getUser(userName);
        if (user != null) {
            UserData userData = AuthenticationUtil.createUserData(UserId.getUserId(userName));
            userData.setProperty(OpenIdUtil.REGISTRATION_RESULT_PROP, OpenIdConstants.USER_ALREADY_EXISTS);
            return userData;
        }

        UserData userData = MetaProjectManager.getManager().registerUser(userName, emailId, "");

        user = MetaProjectManager.getManager().getMetaProject().getUser(userName);
        user.setEmail(emailId);
        user.setDigestedPassword(hashedPassword, salt);

        String openIdPropBase = OpenIdConstants.OPENID_PROPERTY_PREFIX;

        for (int index = 1;; index++) {
            String opnId = user.getPropertyValue(openIdPropBase + index + OpenIdConstants.OPENID_PROPERTY_URL_SUFFIX);
            if (opnId == null) {
                user.addPropertyValue(openIdPropBase + index + OpenIdConstants.OPENID_PROPERTY_URL_SUFFIX, userOpenId);
                user.addPropertyValue(openIdPropBase + index + OpenIdConstants.OPENID_PROPERTY_ID_SUFFIX, openIdAccName);
                user.addPropertyValue(openIdPropBase + index + OpenIdConstants.OPENID_PROPERTY_PROVIDER_SUFFIX, openIdProvider);
                break;
            }
        }

        Log.getLogger().info("User " + userName + " created at: " + new Date() + " with OpenId: " + userOpenId);

        session.setAttribute(OpenIdConstants.CREATED_USER_TO_ASSOC_OPEN_ID, userData);
        session.setAttribute(OpenIdConstants.HTTPSESSION_OPENID_URL, null);
        session.setAttribute(OpenIdConstants.HTTPSESSION_OPENID_ID, null);
        session.setAttribute(OpenIdConstants.HTTPSESSION_OPENID_PROVIDER, null);
        userData.setProperty(OpenIdUtil.REGISTRATION_RESULT_PROP, OpenIdConstants.REGISTER_USER_SUCCESS);

        return userData;
    }
View Full Code Here

        }
        return encoded;
    }

    public static UserData createUserData(UserId userId) {
        UserData userData = new UserData(userId);
//        fillInGoups(userData, userId);
        fillInEmail(userData);
        return userData;
    }
View Full Code Here

    //used only for https
    public UserData registerUser(String userName, String password, String email) {
        MetaProjectManager mpm = MetaProjectManager.getManager();
        throwUserRegistrationExceptionIfAccountCreationIsDisabled(mpm);
        UserData userData = mpm.registerUser(userName, email, password);
        OWLAPIMetaProjectStore.getStore().saveMetaProject(mpm);
        return userData;
    }
View Full Code Here

        HttpServletRequest request = this.getThreadLocalRequest();
        HttpSession session = request.getSession();
        String salt = (String) session.getAttribute(AuthenticationConstants.NEW_SALT);
        String emptyPassword = "";

        UserData userData = metaProjectManager.registerUser(name, emailId, emptyPassword);

        User user = metaProjectManager.getMetaProject().getUser(name);
        user.setDigestedPassword(hashedPassword, salt);
        user.setEmail(emailId);
View Full Code Here

        if (!MetaProjectManager.getManager().hasValidCredentials(name, password)) {
            SessionConstants.removeAttribute(SessionConstants.USER_ID, session);
            return null;
        }

        UserData userData = AuthenticationUtil.createUserData(userId);
        SessionConstants.setAttribute(SessionConstants.USER_ID, userId, session);
        return userData;
    }
View Full Code Here

            return null;
        }

        User user = MetaProjectManager.getManager().getMetaProject().getUser(userName);
        if (user != null) {
            UserData userData = AuthenticationUtil.createUserData(UserId.getUserId(userName));
            userData.setProperty(OpenIdUtil.REGISTRATION_RESULT_PROP, OpenIdConstants.USER_ALREADY_EXISTS);
            return userData;
        }

        UserData userData = MetaProjectManager.getManager().registerUser(userName, emailId, password);
        user = MetaProjectManager.getManager().getMetaProject().getUser(userName);
        user.setEmail(emailId);

        String openIdPropBase = OpenIdConstants.OPENID_PROPERTY_PREFIX;

        for (int index = 1;; index++) {
            String opnId = user.getPropertyValue(openIdPropBase + index + OpenIdConstants.OPENID_PROPERTY_URL_SUFFIX);
            if (opnId == null) {
                user.addPropertyValue(openIdPropBase + index + OpenIdConstants.OPENID_PROPERTY_URL_SUFFIX, userOpenId);
                user.addPropertyValue(openIdPropBase + index + OpenIdConstants.OPENID_PROPERTY_ID_SUFFIX, openIdAccName);
                user.addPropertyValue(openIdPropBase + index + OpenIdConstants.OPENID_PROPERTY_PROVIDER_SUFFIX, openIdProvider);
                break;
            }
        }

        Log.getLogger().info("User " + userName + " created at: " + new Date() + " with OpenId: " + userOpenId);

        session.setAttribute(OpenIdConstants.CREATED_USER_TO_ASSOC_OPEN_ID, userData);
        session.setAttribute(OpenIdConstants.HTTPSESSION_OPENID_URL, null);
        session.setAttribute(OpenIdConstants.HTTPSESSION_OPENID_ID, null);
        session.setAttribute(OpenIdConstants.HTTPSESSION_OPENID_PROVIDER, null);
        userData.setProperty(OpenIdUtil.REGISTRATION_RESULT_PROP, OpenIdConstants.REGISTER_USER_SUCCESS);

        SessionConstants.setAttribute(SessionConstants.USER_ID, UserId.getUserId(userName), session);

        return userData;
    }
View Full Code Here

TOP

Related Classes of edu.stanford.bmir.protege.web.client.rpc.data.UserData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.