// Path: src/java/com/idega/openid/util/OpenIDUtil.java
// public class OpenIDUtil {
// 
// 	private static final String WWW = "www";
// 	private static final String HTTP_PROTOCOL = "http://";
// 	private static final String HTTPS_PROTOCOL = "https://";
// 
// 	public String getSubDomain(String serverName) {
// 		ICDomain domain = IWMainApplication.getDefaultIWApplicationContext().getDomain();
// 		if (domain.getServerName().equals(serverName)) {
// 			return null;
// 		}
// 
// 		String subdomain = null;
// 		if (serverName.indexOf(HTTPS_PROTOCOL) != -1) {
// 			serverName = serverName.substring(serverName.indexOf(HTTPS_PROTOCOL) + 8);
// 		}
// 		if (serverName.indexOf(HTTP_PROTOCOL) != -1) {
// 			serverName = serverName.substring(serverName.indexOf(HTTP_PROTOCOL) + 7);
// 		}
// 		if (serverName.indexOf(".") != -1 && serverName.indexOf(".") != serverName.lastIndexOf(".") && serverName.indexOf(WWW) == -1) {
// 			subdomain = serverName.substring(0, serverName.indexOf("."));
// 		}
// 		
// 		return subdomain;
// 	}
// }


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.idega.openid.util.OpenIDUtil;
import com.idega.servlet.filter.util.PagesRedirectHandler;
package com.idega.openid.server.filter;



public class OpenIDPagesRedirectHandler implements PagesRedirectHandler {

	@Override
	public boolean isForwardOnRootURIRequest(HttpServletRequest request, HttpServletResponse response) {
		String serverName = request.getServerName();
// Path: src/java/com/idega/openid/util/OpenIDUtil.java
// public class OpenIDUtil {
// 
// 	private static final String WWW = "www";
// 	private static final String HTTP_PROTOCOL = "http://";
// 	private static final String HTTPS_PROTOCOL = "https://";
// 
// 	public String getSubDomain(String serverName) {
// 		ICDomain domain = IWMainApplication.getDefaultIWApplicationContext().getDomain();
// 		if (domain.getServerName().equals(serverName)) {
// 			return null;
// 		}
// 
// 		String subdomain = null;
// 		if (serverName.indexOf(HTTPS_PROTOCOL) != -1) {
// 			serverName = serverName.substring(serverName.indexOf(HTTPS_PROTOCOL) + 8);
// 		}
// 		if (serverName.indexOf(HTTP_PROTOCOL) != -1) {
// 			serverName = serverName.substring(serverName.indexOf(HTTP_PROTOCOL) + 7);
// 		}
// 		if (serverName.indexOf(".") != -1 && serverName.indexOf(".") != serverName.lastIndexOf(".") && serverName.indexOf(WWW) == -1) {
// 			subdomain = serverName.substring(0, serverName.indexOf("."));
// 		}
// 		
// 		return subdomain;
// 	}
// }


// Path: src/java/com/idega/openid/server/filter/OpenIDPagesRedirectHandler.java
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.idega.openid.util.OpenIDUtil;
import com.idega.servlet.filter.util.PagesRedirectHandler;

package com.idega.openid.server.filter;



public class OpenIDPagesRedirectHandler implements PagesRedirectHandler {

	@Override
	public boolean isForwardOnRootURIRequest(HttpServletRequest request, HttpServletResponse response) {
		String serverName = request.getServerName();
		String subDomain = new OpenIDUtil().getSubDomain(serverName);