当前位置: 首页>>代码示例>>Java>>正文


Java VaadinRequest.getHeader方法代码示例

本文整理汇总了Java中com.vaadin.server.VaadinRequest.getHeader方法的典型用法代码示例。如果您正苦于以下问题:Java VaadinRequest.getHeader方法的具体用法?Java VaadinRequest.getHeader怎么用?Java VaadinRequest.getHeader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.vaadin.server.VaadinRequest的用法示例。


在下文中一共展示了VaadinRequest.getHeader方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getUserRemoteAddress

import com.vaadin.server.VaadinRequest; //导入方法依赖的package包/类
@Nullable
protected String getUserRemoteAddress() {
    VaadinRequest currentRequest = VaadinService.getCurrentRequest();

    String userRemoteAddress = null;

    if (currentRequest != null) {
        String xForwardedFor = currentRequest.getHeader("X_FORWARDED_FOR");
        if (StringUtils.isNotBlank(xForwardedFor)) {
            String[] strings = xForwardedFor.split(",");
            String userAddressFromHeader = StringUtils.trimToEmpty(strings[strings.length - 1]);

            if (StringUtils.isNotEmpty(userAddressFromHeader)) {
                userRemoteAddress = userAddressFromHeader;
            } else {
                userRemoteAddress = currentRequest.getRemoteAddr();
            }
        } else {
            userRemoteAddress = currentRequest.getRemoteAddr();
        }
    }

    return userRemoteAddress;
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:25,代码来源:ConnectionImpl.java

示例2: negotiate

import com.vaadin.server.VaadinRequest; //导入方法依赖的package包/类
@Override
public Locale negotiate(List<Locale> supportedLocales,
        VaadinRequest vaadinRequest) {
    String languages = vaadinRequest.getHeader("Accept-Language");
    try {
        // Use reflection here, so the code compiles with jdk 1.7
        Class<?> languageRange = Class
                .forName("java.util.Locale$LanguageRange");
        Method parse = languageRange.getMethod("parse", String.class);
        Object priorityList = parse.invoke(null, languages);
        Method lookup = Locale.class.getMethod("lookup", List.class,
                Collection.class);
        return (Locale) lookup.invoke(null, priorityList, supportedLocales);
    } catch (ClassNotFoundException | IllegalAccessException | IllegalArgumentException | NoSuchMethodException | SecurityException | InvocationTargetException e) {
        throw new RuntimeException(
                "Java8LocaleNegotiontionStrategy need java 1.8 or newer.",
                e);
    }

}
 
开发者ID:viritin,项目名称:viritin,代码行数:21,代码来源:Java8LocaleNegotiationStrategy.java

示例3: getClientIpAddr

import com.vaadin.server.VaadinRequest; //导入方法依赖的package包/类
private String getClientIpAddr(VaadinRequest request) {
    String ip = request.getHeader("X-Forwarded-For");
    if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
        ip = request.getHeader("Proxy-Client-IP");
    }
    if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
        ip = request.getHeader("WL-Proxy-Client-IP");
    }
    if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
        ip = request.getHeader("HTTP_CLIENT_IP");
    }
    if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
        ip = request.getHeader("HTTP_X_FORWARDED_FOR");
    }
    if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
        ip = request.getRemoteAddr();
    }
    return ip;
}
 
开发者ID:AKSW,项目名称:RDFUnit,代码行数:20,代码来源:RDFUnitDemo.java

示例4: UiAccessControl

import com.vaadin.server.VaadinRequest; //导入方法依赖的package包/类
public UiAccessControl(VaadinRequest request) {
	sessionId = request.getWrappedSession().getId();
	
	if (!isUserSignedIn()) {
		// try auto login
		String host = request.getHeader("Host");
		VirtualHost vHost = MApi.lookup(CherryApi.class).findVirtualHost(host);
		AaaContext context = vHost.doLogin(new VaadinRequestWrapper(request), null);
		if (context != null) {
			IProperties session = MApi.lookup(InternalCherryApi.class).getCherrySession(sessionId);
			session.put(InternalCherryApi.SESSION_ACCESS_NAME, context);
		}
	}
}
 
开发者ID:mhus,项目名称:cherry-web,代码行数:15,代码来源:UiAccessControl.java

示例5: negotiate

import com.vaadin.server.VaadinRequest; //导入方法依赖的package包/类
@Override
public Locale negotiate(final List<Locale> supportedLocales,
        VaadinRequest vaadinRequest) {
    String languages = vaadinRequest.getHeader("Accept-Language");
    ArrayList<Locale> preferredArray = new ArrayList<>(
            supportedLocales);
    if (languages != null) {
        final String[] priorityList = languages.split(",");

        Collections.sort(preferredArray, new Comparator<Locale>() {

            @Override
            public int compare(Locale o1, Locale o2) {
                int pos1 = supportedLocales.size(), pos2 = supportedLocales
                        .size();
                for (int i = 0; i < priorityList.length; i++) {
                    String lang = priorityList[i].split("[_;-]")[0].trim();
                    if (lang.equals(o1.getLanguage())) {
                        pos1 = i;
                    }
                    if (lang.equals(o2.getLanguage())) {
                        pos2 = i;
                    }
                }
                return pos1 - pos2;
            }
        });
    }
    return preferredArray.get(0);
}
 
开发者ID:viritin,项目名称:viritin,代码行数:31,代码来源:Java7LocaleNegotiationStrategy.java

示例6: DefaultUserAgentInspector

import com.vaadin.server.VaadinRequest; //导入方法依赖的package包/类
/**
 * Constructor using {@link VaadinRequest}
 * @param request Vaadin Request
 */
public DefaultUserAgentInspector(VaadinRequest request) {
	this(request.getHeader("user-agent"), request.getHeader("accept"));
}
 
开发者ID:holon-platform,项目名称:holon-vaadin7,代码行数:8,代码来源:DefaultUserAgentInspector.java


注:本文中的com.vaadin.server.VaadinRequest.getHeader方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。