Package edu.stanford.smi.protege.server.metaproject

Examples of edu.stanford.smi.protege.server.metaproject.User


        try {

            List<String> openIdList = new ArrayList<String>();
            List<String> openIdAccId = new ArrayList<String>();
            List<String> openIdProvider = new ArrayList<String>();
            User user = MetaProjectManager.getManager().getMetaProject().getUser(name);
            Collection<PropertyValue> propColl = user.getPropertyValues();
            for (Iterator<PropertyValue> iterator = propColl.iterator(); iterator.hasNext();) {
                PropertyValue propertyValue = iterator.next();
                if (propertyValue.getPropertyName().startsWith(OpenIdConstants.OPENID_PROPERTY_PREFIX)
                        && propertyValue.getPropertyName().endsWith(OpenIdConstants.OPENID_PROPERTY_URL_SUFFIX)) {
                    String openIdAccNamePropName = propertyValue.getPropertyName().replace(
                            OpenIdConstants.OPENID_PROPERTY_URL_SUFFIX, OpenIdConstants.OPENID_PROPERTY_ID_SUFFIX);
                    String openIdProvdNamePropName = propertyValue.getPropertyName()
                    .replace(OpenIdConstants.OPENID_PROPERTY_URL_SUFFIX,
                            OpenIdConstants.OPENID_PROPERTY_PROVIDER_SUFFIX);
                    String openIdAccNamePropValue = user.getPropertyValue(openIdAccNamePropName);
                    String openIdProvdNamePropValue = user.getPropertyValue(openIdProvdNamePropName);
                    openIdList.add(propertyValue.getPropertyValue());
                    openIdAccId.add(openIdAccNamePropValue);
                    openIdProvider.add(openIdProvdNamePropValue);
                }
            }
View Full Code Here


    @SuppressWarnings("finally")
    public OpenIdData removeAssocToOpenId(String name, String opnId) {
        OpenIdData openIdData = new OpenIdData();
        try {
            User user = MetaProjectManager.getManager().getMetaProject().getUser(name);
            Collection<PropertyValue> propColl = user.getPropertyValues();
            for (Iterator<PropertyValue> iterator = propColl.iterator(); iterator.hasNext();) {
                PropertyValue propertyValue = iterator.next();
                if (propertyValue.getPropertyName().startsWith(OpenIdConstants.OPENID_PROPERTY_PREFIX)
                        && propertyValue.getPropertyName().endsWith(OpenIdConstants.OPENID_PROPERTY_URL_SUFFIX)) {
                    String openIdAccNamePropName = propertyValue.getPropertyName().replace(
                            OpenIdConstants.OPENID_PROPERTY_URL_SUFFIX, OpenIdConstants.OPENID_PROPERTY_ID_SUFFIX);
                    String openIdProvdNamePropName = propertyValue.getPropertyName()
                    .replace(OpenIdConstants.OPENID_PROPERTY_URL_SUFFIX, OpenIdConstants.OPENID_PROPERTY_PROVIDER_SUFFIX);
                    String openIdAccNamePropValue = user.getPropertyValue(openIdAccNamePropName);
                    String openIdProvdNamePropValue = user.getPropertyValue(openIdProvdNamePropName);
                    if (propertyValue.getPropertyValue().trim().equalsIgnoreCase(opnId)) {

                        user.removePropertyValue(propertyValue.getPropertyName(), propertyValue.getPropertyValue());
                        user.removePropertyValue(openIdAccNamePropName, openIdAccNamePropValue);
                        user.removePropertyValue(openIdProvdNamePropName, openIdProvdNamePropValue);
                    }
                }
            }
        } catch (Exception e) {
            Log.getLogger().log(Level.WARNING, "Errors at removing Users Association to OpenId:", e);
View Full Code Here

            if (userOpenId == null) {
                return null;
            }

            User user = MetaProjectManager.getManager().getMetaProject().getUser(name);
            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);

                    session.setAttribute(OpenIdConstants.HTTPSESSION_OPENID_URL, null);
                    session.setAttribute(OpenIdConstants.HTTPSESSION_OPENID_ID, null);
                    session.setAttribute(OpenIdConstants.HTTPSESSION_OPENID_PROVIDER, null);
                    break;
View Full Code Here

            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);
View Full Code Here

        try {
            HttpServletRequest request = this.getThreadLocalRequest();
            HttpSession session = request.getSession();
            String challenge = (String) session.getAttribute(AuthenticationConstants.LOGIN_CHALLENGE);
            session.setAttribute(AuthenticationConstants.LOGIN_CHALLENGE, null);
            User user = MetaProjectManager.getManager().getMetaProject().getUser(userName);
            if (user == null) {
                return null;
            }
            String storedHashedPswd = user.getDigestedPassword();
            AuthenticationUtil authenticatinUtil = new AuthenticationUtil();

            if (!authenticatinUtil.verifyChallengedHash(storedHashedPswd, response, challenge)) {
                return null;
            }

            String userOpenId = (String) session.getAttribute(OpenIdConstants.HTTPSESSION_OPENID_URL);
            String openIdAccName = (String) session.getAttribute(OpenIdConstants.HTTPSESSION_OPENID_ID);
            String openIdProvider = (String) session.getAttribute(OpenIdConstants.HTTPSESSION_OPENID_PROVIDER);

            if (userOpenId == null) {
                return null;
            }

            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 + " logged in at: " + new Date() + " with OpenId: " + userOpenId);
View Full Code Here

            pw.println();
            pw.print("User: ");
            pw.println(userId.get().getUserName());
            final UserId id = userId.get();
            if(!id.isGuest()) {
                User user = MetaProjectManager.getManager().getMetaProject().getUser(id.getUserName());
                pw.println("email: " + user.getEmail());
                pw.println("groups: ");
                for(Group group : user.getGroups()) {
                    pw.println("        " + group.getName());
                }
            }
        }
        if(request.isPresent()) {
View Full Code Here

    private static final long serialVersionUID = 3242452355007002607L;

    public synchronized void setNotificationDelay(final String user, final NotificationType notificationType, final NotificationInterval notificationInterval) {
        //FIXME: everything on this path can be null
        final User userProperties = MetaProjectManager.getManager().getMetaProject().getUser(user);
        String currentUserPropertyValue = userProperties.getPropertyValue(notificationType.getValue());
        while (currentUserPropertyValue != null) {
            userProperties.removePropertyValue(notificationType.getValue(), currentUserPropertyValue);
            currentUserPropertyValue = userProperties.getPropertyValue(notificationType.getValue());
        }
        final NotificationTimestamp notificationTimestamp = NotificationTimestamp.fromType(notificationType);
        String currentUserTimestamp = userProperties.getPropertyValue(notificationTimestamp.getValue());
        if (currentUserTimestamp == null) {
            userProperties.addPropertyValue(notificationTimestamp.getValue(), Long.toString(new Date().getTime()));
        }
        userProperties.addPropertyValue(notificationType.getValue(), notificationInterval.getValue());
    }
View Full Code Here

    public static void fillInEmail(UserData userData) {
        final UserId userId = userData.getUserId();
        if (userId.isGuest()) {
            return;
        }
        User user = MetaProjectManager.getManager().getMetaProject().getUser(userId.getUserName());
        if (user == null) {
            return;
        }
        userData.setEmail(user.getEmail());
    }
View Full Code Here

        changePassword(userName, EmailConstants.RESET_PASSWORD);
        App.get().getMailManager().sendMail(email, EmailConstants.FORGOT_PASSWORD_SUBJECT, EmailConstants.FORGOT_PASSWORD_EMAIL_BODY);
    }

    public LoginChallengeData getUserSaltAndChallenge(String userNameOrEmail) {
      User user = MetaProjectManager.getManager().getUser(userNameOrEmail);
        if (user == null) {
            return null;
        }
        String userSalt = user.getSalt();
        if (userSalt == null) {
            return null;
        }
        String encodedChallenge = generateSalt();
        HttpServletRequest request = this.getThreadLocalRequest();
View Full Code Here

        HttpSession session = request.getSession();

        final String challenge = (String) session.getAttribute(AuthenticationConstants.LOGIN_CHALLENGE);
        session.setAttribute(AuthenticationConstants.LOGIN_CHALLENGE, null);

        User user = MetaProjectManager.getManager().getUser(userNameOrEmail);
        if (user == null) { //user not in metaproject
            return UserId.getGuest();
        }
        AuthenticationUtil authenticatinUtil = new AuthenticationUtil();
        boolean isverified = authenticatinUtil.verifyChallengedHash(user.getDigestedPassword(), response, challenge);
        if (isverified) {
            UserId userId = UserId.getUserId(user.getName());
            SessionConstants.setAttribute(SessionConstants.USER_ID, userId, session);
            return userId;
        }
        else {
            return UserId.getGuest();
View Full Code Here

TOP

Related Classes of edu.stanford.smi.protege.server.metaproject.User

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.