com.webbfontaine.valuewebb.josso.JossoUtils.java Source code

Java tutorial

Introduction

Here is the source code for com.webbfontaine.valuewebb.josso.JossoUtils.java

Source

package com.webbfontaine.valuewebb.josso;

import org.apache.commons.lang3.StringUtils;
import org.josso.gateway.Constants;

import javax.faces.context.FacesContext;
import javax.servlet.http.Cookie;
import java.util.Map;

/**
 * Copyrights 2002-2011 Webb Fontaine
 * This software is the proprietary information of Webb Fontaine.
 * Its use is subject to License terms.
 * User: nigiyan
 * Date: 10/4/11
 */

public class JossoUtils {

    private JossoUtils() {
    }

    public static boolean isJossoEnabled() {
        return getCookieMap().containsKey(Constants.JOSSO_SINGLE_SIGN_ON_COOKIE);
    }

    public static String getJossoSessionId() {
        return StringUtils.trimToNull(
                isJossoEnabled() ? ((Cookie) getCookieMap().get(Constants.JOSSO_SINGLE_SIGN_ON_COOKIE)).getValue()
                        : null);
    }

    public static String getJossoSessionName() {
        return isJossoEnabled() ? ((Cookie) getCookieMap().get(Constants.JOSSO_SINGLE_SIGN_ON_COOKIE)).getName()
                : null;
    }

    public static Map getCookieMap() {
        return FacesContext.getCurrentInstance().getExternalContext().getRequestCookieMap();
    }

}