@@ -0,0 +1,1601 @@
+/*%0D%0A * oxCore is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text.%0D%0A *%0D%0A * Copyright (c) 2014, Gluu%0D%0A */package org.xdi.service.net;%0D%0A%0D%0Aimport java.io.Serializable;%0D%0A%0D%0Aimport javax.faces.context.FacesContext;%0D%0Aimport javax.servlet.http.HttpServletRequest;%0D%0A%0D%0Aimport org.jboss.seam.Component;%0D%0Aimport org.jboss.seam.annotations.Logger;%0D%0Aimport org.jboss.seam.log.Log;%0D%0Aimport org.xdi.util.StringHelper;%0D%0A%0D%0A/**%0D%0A * Network service%0D%0A *%0D%0A * @author Yuriy Movchan Date: 04/28/2016%0D%0A */%0D%0Apublic class NetworkService implements Serializable %7B%0D%0A%0D%0A%09private static final long serialVersionUID = -1393318600428448743L;%0D%0A%0D%0A%09@Logger%0D%0A%09private Log log;%0D%0A%0D%0A    public String getRemoteIp() %7B%0D%0A        try %7B%0D%0A            FacesContext facesContext = FacesContext.getCurrentInstance();%0D%0A            if (facesContext == null) %7B%0D%0A                return null;%0D%0A            %7D%0D%0A%0D%0A            final HttpServletRequest request = (HttpServletRequest) facesContext.getExternalContext().getRequest();%0D%0A%0D%0A            String remoteIp = request.getHeader(%22X-FORWARDED-FOR%22);%0D%0A            if (StringHelper.isEmpty(remoteIp)) %7B%0D%0A            %09remoteIp = request.getRemoteAddr();%0D%0A            %7D%0D%0A            %0D%0A            return remoteIp;%0D%0A        %7D catch (Exception ex) %7B%0D%0A            log.error(%22Failed to get remote IP%22, ex);%0D%0A        %7D%0D%0A        %0D%0A        return null;%0D%0A    %7D%0D%0A%0D%0A%09/**%0D%0A%09 * Get NetworkService instance%0D%0A%09 *%0D%0A%09 * @return NetworkService instance%0D%0A%09 */%0D%0A%09public static NetworkService instance() %7B%0D%0A%09%09return (NetworkService) Component.getInstance(NetworkService.class);%0D%0A%09%7D%0D%0A%0D%0A%7D%0D%0A

Add network service