Examples of WGUserProfile


Examples of de.innovationgate.webgate.api.WGUserProfile

        }

        // Try to retrieve previously stored user profile in session
        String wgpid = (String) session.getAttribute(SESSION_PROFILENAME_INDIVIDUALDB + database.getDbReference());
        if (wgpid != null) {
            WGUserProfile profile = persDB.getUserProfile(wgpid);
            if (profile != null) {
                TMLUserProfile tmlProfile = new TMLUserProfile(profile, getCore());
                request.setAttribute(WGACore.ATTRIB_PROFILE + database.getDbReference(), tmlProfile);
                return tmlProfile;
            }
        }

        // Fetch user profile using database's persmode. If not available we
        // take the default value for the option
        String persModeStr = (String) _core.readPublisherOptionOrDefault(database, WGACore.DBATTRIB_PERSMODE);
        Integer persMode;
        if (persModeStr != null) {
            persMode = Integer.valueOf(persModeStr);
        }
        // Backup for sure, which should not happen as the option is defined for
        // all databases
        else {
            persMode = Constants.PERSMODE_AUTO;
        }

        // If in Mode AUTO, the User Profile is retrieved automatically
        // (otherwise it is set in the login process)
        WGUserProfile userProfile = null;
        boolean created = false;
        if (persMode == Constants.PERSMODE_AUTO) {
            boolean secureMode = database.getBooleanAttribute(WGACore.DBATTRIB_SECURE_APP, false);
            String cookieName = COOKIE_WGPID;
            if (secureMode) {
                cookieName = COOKIE_SECURE_WGPID;
            }

            wgpid = this.findCookie(request.getCookies(), cookieName);
            if (wgpid != null) {
                userProfile = persDB.getUserProfile(wgpid);
            }

            if (userProfile == null) {
                userProfile = createUserProfile((String) request.getHeader("User-Agent"), persDB, wgpid, Constants.PERSMODE_AUTO);
                created = true;
            }

            if (userProfile != null && !userProfile.isDummy()) {
                Cookie wgpidCookie = new Cookie(cookieName, userProfile.getName());
                wgpidCookie.setPath("/");
                wgpidCookie.setSecure(secureMode);
                wgpidCookie.setMaxAge(60 * 60 * 24 * 365);
                response.addCookie(wgpidCookie);
            }
        }

        else if (persMode == Constants.PERSMODE_LOGIN) {
            if (database.getSessionContext().isAnonymous()) {
                // no profile for anonymous
                return null;
            }
            String userName = database.getSessionContext().getUser();
            userProfile = persDB.getUserProfile(userName);
            if (userProfile == null) {
                userProfile = createUserProfile((String) request.getHeader("User-Agent"), persDB, userName, Constants.PERSMODE_LOGIN);
                created =  true;
            }
        }

        // If valid user profile, set in session object and register new session
        if (userProfile != null && !userProfile.isDeleted()) {

            // Drop cache so we can be sure to be up-to-date with the backend
            // database
            // (Since backend changes - maybe from other cluster nodes - are not
            // registered for user profiles)
            userProfile.dropCache();

            session.setAttribute(SESSION_PROFILENAME_INDIVIDUALDB + database.getDbReference(), userProfile.getName());
            TMLUserProfile tmlProfile = new TMLUserProfile(userProfile, getCore());
            request.setAttribute(WGACore.ATTRIB_PROFILE + database.getDbReference(), tmlProfile);
            this.registerSession(userProfile, request, session, created);
            return tmlProfile;
        }
View Full Code Here

Examples of de.innovationgate.webgate.api.WGUserProfile

    }

    private WGUserProfile createUserProfile(String userAgent, WGDatabase persDB, String wgpid, int persMode) throws WGAPIException {

        WGUserProfile userProfile;
        UserAgentVerifier userAgentVerifier = getCore().getUserAgentVerifier();
        if (userAgentVerifier.isValidUserAgent(userAgent) == true) {
            userProfile = persDB.createUserProfile(wgpid, persMode);
        }
        else {
            userProfile = persDB.getDummyProfile(wgpid);
        }

        if (userProfile != null && !userProfile.isDummy()) {
            TMLUserProfile.prepareNewProfile(userProfile);
            userProfile.save();
        }

        return userProfile;
    }
View Full Code Here

Examples of de.innovationgate.webgate.api.WGUserProfile

    if (persMode.intValue() != Constants.PERSMODE_CUSTOM) {
      return TMLUserProfile.RC_WRONG_PERSMODE;
    }

    // Ensure, there is no profile yet with this name
    WGUserProfile profile = persDB.getUserProfile(name);
    if (profile != null) {
      return TMLUserProfile.RC_PROFILE_EXISTS;
    }

    // Try to create the profile
    try {
      profile = persDB.createUserProfile(name, Constants.PERSMODE_CUSTOM);
    }
    catch (WGException e) {
      this.addwarning("Exception creating user profile: " + e.getMessage(), true);
    }
    if (profile == null) {
      return TMLUserProfile.RC_NOT_CREATABLE;
    }
    TMLUserProfile.prepareNewProfile(profile);

    // Set password eventually
    if (password != null) {
      profile.setMetaData(WGUserProfile.META_PASSWORD, password);
    }

    try {
      profile.save();
    }
    catch (WGAPIException e) {
      this.addwarning("Unable to create user profile: " + e.getMessage(), true);
            return TMLUserProfile.RC_NOT_CREATABLE;
    }
View Full Code Here

Examples of de.innovationgate.webgate.api.WGUserProfile

    if (persMode.intValue() != Constants.PERSMODE_CUSTOM) {
      return TMLUserProfile.RC_WRONG_PERSMODE;
    }

    // Try to fetch profile
    WGUserProfile profile = persDB.getUserProfile(name);
    if (profile == null) {
      return TMLUserProfile.RC_NO_PROFILE;
    }

    // Test password
    if (!password.equals(profile.getPassword())) {
      return TMLUserProfile.RC_WRONG_PASSWORD;
    }

    // Attach to session & request and register hit
    attachProfileToUser(domain, profile);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.