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


Java ClientInfo类代码示例

本文整理汇总了Java中org.restlet.data.ClientInfo的典型用法代码示例。如果您正苦于以下问题:Java ClientInfo类的具体用法?Java ClientInfo怎么用?Java ClientInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: setDefaultHttpHeader

import org.restlet.data.ClientInfo; //导入依赖的package包/类
/**
 * 
 * 设置标准http header
 * @param request {@code void}
 * @since eSDK Cloud V100R003C50
 */
private void setDefaultHttpHeader(Request request)
{
    ClientInfo clientInfo = new ClientInfo();
    
    List<Preference<MediaType>> acceptedMediaTypes = new ArrayList<Preference<MediaType>>();
    Preference<MediaType> preferenceMediaType = new Preference<MediaType>();
    
    MediaType mediaType = MediaType.register("application/json;version=1.2;charset=UTF-8;", "");
    preferenceMediaType.setMetadata(mediaType);
    acceptedMediaTypes.add(preferenceMediaType);
    clientInfo.setAcceptedMediaTypes(acceptedMediaTypes);
    
    List<Preference<Language>> acceptedLanguages = new ArrayList<Preference<Language>>();
    
    Preference<Language> preferenceLanguage = new Preference<Language>();
    Language language = new Language("zh_CN", "");
    preferenceLanguage.setMetadata(language);
    acceptedLanguages.add(preferenceLanguage);
    
    clientInfo.setAcceptedLanguages(acceptedLanguages);
    request.setClientInfo(clientInfo);
}
 
开发者ID:eSDK,项目名称:esdk_cloud_fc_cli,代码行数:29,代码来源:RestletClient.java

示例2: setRequestClientInfo

import org.restlet.data.ClientInfo; //导入依赖的package包/类
private void setRequestClientInfo(Request request, String userId) {
    ClientInfo ci = request.getClientInfo();
    User user = new User();
    user.setIdentifier(userId);
    ci.setUser(user);
    request.setClientInfo(ci);
}
 
开发者ID:SAP,项目名称:cf-mta-deploy-service,代码行数:8,代码来源:CustomActivitiRestAuthenticator.java

示例3: setDefaultHttpHeader

import org.restlet.data.ClientInfo; //导入依赖的package包/类
/**
 * 设置标准http header
 * 
 * @param request {@code void}
 * @since eSDK Cloud V100R003C50
 */
private void setDefaultHttpHeader(Request request, String version)
{
	ClientInfo clientInfo = new ClientInfo();

	List<Preference<MediaType>> acceptedMediaTypes = new ArrayList<Preference<MediaType>>();
	Preference<MediaType> preferenceMediaType = new Preference<MediaType>();

	String acceptStr = "application/json;";
	if (null == version)
	{
		acceptStr += "charset=UTF-8;";
	}
	else
	{
		acceptStr += version + "charset=UTF-8;";
	}
	MediaType mediaType = MediaType.register(acceptStr, "");
	preferenceMediaType.setMetadata(mediaType);
	acceptedMediaTypes.add(preferenceMediaType);
	clientInfo.setAcceptedMediaTypes(acceptedMediaTypes);

	List<Preference<Language>> acceptedLanguages = new ArrayList<Preference<Language>>();

	Preference<Language> preferenceLanguage = new Preference<Language>();
	Language language = new Language("zh_CN", "");
	preferenceLanguage.setMetadata(language);
	acceptedLanguages.add(preferenceLanguage);

	clientInfo.setAcceptedLanguages(acceptedLanguages);
	request.setClientInfo(clientInfo);
}
 
开发者ID:Huawei,项目名称:eSDK_FC_SDK_Java,代码行数:38,代码来源:RestletClient.java

示例4: callAccessTokenServerResource

import org.restlet.data.ClientInfo; //导入依赖的package包/类
/**
 * 認可コードを渡してアクセストークンを取得する.
 * 
 * @param client クライアント
 * @param authCode 認可コード(TokenManager.sessionsに存在するキー値を設定する)
 * @param applicationName アプリケーション名
 * @return not null: アクセストークン / null: アクセストークン取得失敗
 */
private static String callAccessTokenServerResource(final Client client, final String authCode,
        final String applicationName) {

    Request request = new Request();
    ClientInfo clientInfo = new ClientInfo();
    org.restlet.security.User user = new org.restlet.security.User(client.getClientId());
    clientInfo.setUser(user);
    request.setClientInfo(clientInfo);

    Response response = new Response(request);
    AccessTokenServerResource.init(request, response);

    // 入力値(アプリケーション名はbase64エンコードする)
    String base64ApplicationName = Base64.encodeToString(applicationName.getBytes(), Base64.URL_SAFE|Base64.NO_WRAP);
    StringRepresentation input = new StringRepresentation("grant_type=authorization_code&code=" + authCode + "&"
            + AccessTokenServerResource.REDIR_URI + "=" + DUMMY_REDIRECT_URI + "&"
            + AccessTokenServerResource.APPLICATION_NAME + "=" + base64ApplicationName);
    try {
        ResultRepresentation resultRepresentation = (ResultRepresentation) AccessTokenServerResource
                .requestToken(input);
        if (resultRepresentation.getResult()) {
            return resultRepresentation.getText();
        }
    } catch (JSONException | OAuthException e) {
        e.printStackTrace();
    }
    return null;
}
 
开发者ID:DeviceConnect,项目名称:DeviceConnect-Android,代码行数:37,代码来源:LocalOAuth2Main.java

示例5: getClientInfo

import org.restlet.data.ClientInfo; //导入依赖的package包/类
/**
 * Returns the client-specific information. Creates a new instance if no one
 * has been set.
 * 
 * @return The client-specific information.
 */
public ClientInfo getClientInfo() {
    // Lazy initialization with double-check.
    ClientInfo c = this.clientInfo;
    if (c == null) {
        synchronized (this) {
            c = this.clientInfo;
            if (c == null) {
                this.clientInfo = c = new ClientInfo();
            }
        }
    }
    return c;
}
 
开发者ID:DeviceConnect,项目名称:DeviceConnect-Android,代码行数:20,代码来源:Request.java

示例6: setDefaultHttpHeader

import org.restlet.data.ClientInfo; //导入依赖的package包/类
/**
 * 
 * 设置标准http header
 * @param request {@code void}
 * @since eSDK Cloud V100R003C50
 */
private void setDefaultHttpHeader(Request request, String version)
{
    ClientInfo clientInfo = new ClientInfo();
    
    List<Preference<MediaType>> acceptedMediaTypes = new ArrayList<Preference<MediaType>>();
    Preference<MediaType> preferenceMediaType = new Preference<MediaType>();
    
    String acceptStr = "application/json;";
    if (null == version)
    {
        acceptStr += "charset=UTF-8;";
    }
    else
    {
        acceptStr += version + "charset=UTF-8;";
    }
    MediaType mediaType = MediaType.register(acceptStr, "");
    preferenceMediaType.setMetadata(mediaType);
    acceptedMediaTypes.add(preferenceMediaType);
    clientInfo.setAcceptedMediaTypes(acceptedMediaTypes);
    
    List<Preference<Language>> acceptedLanguages = new ArrayList<Preference<Language>>();
    
    Preference<Language> preferenceLanguage = new Preference<Language>();
    Language language = new Language("zh_CN", "");
    preferenceLanguage.setMetadata(language);
    acceptedLanguages.add(preferenceLanguage);
    
    clientInfo.setAcceptedLanguages(acceptedLanguages);
    request.setClientInfo(clientInfo);
}
 
开发者ID:eSDK,项目名称:esdk_cloud_fc_cli,代码行数:38,代码来源:RestletClient.java

示例7: setXForwardedForHeader

import org.restlet.data.ClientInfo; //导入依赖的package包/类
public static void setXForwardedForHeader(ContextResource contextResource, HttpRequest req) throws GadgetException {
    ClientInfo clientInfo = contextResource.getClientInfo();
    List<String> forwardedAddresses = clientInfo.getForwardedAddresses();
    String origValue = null;
    if (!forwardedAddresses.isEmpty()) {
        origValue = StringUtils.join(clientInfo.getForwardedAddresses(), ", ");
    }
    String forwardedFor = getXForwardedForHeader(origValue, clientInfo.getAddress());
    if (forwardedFor != null) {
        req.setHeader("X-Forwarded-For", forwardedFor);
    }
}
 
开发者ID:devacfr,项目名称:spring-restlet,代码行数:13,代码来源:ServletUtil.java

示例8: optionsRequestHandler

import org.restlet.data.ClientInfo; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Options
public void optionsRequestHandler(){
	ClientInfo c = getRequest().getClientInfo();
	String origin = c.getAddress();
	Series<Header> responseHeaders = (Series<Header>) getResponse().getAttributes().get("org.restlet.http.headers");
	if (responseHeaders == null) {
		responseHeaders = new Series<Header>(Header.class);
		getResponse().getAttributes().put("org.restlet.http.headers", responseHeaders);
	}
	responseHeaders.add(new Header("Access-Control-Allow-Origin", origin));
	responseHeaders.add(new Header("Access-Control-Allow-Methods", "GET,PUT,POST,DELETE"));

}
 
开发者ID:streamreasoning,项目名称:rsp-services-csparql,代码行数:15,代码来源:SingleStreamDataServer.java

示例9: enrole

import org.restlet.data.ClientInfo; //导入依赖的package包/类
public void enrole(ClientInfo clientInfo) {
	User user = null;
	try {
		user = User.loadByNameNoParams(clientInfo.getUser().getIdentifier());
	} catch (ConfigurationException e) {
		Util.throwConfigurationException(e);
	}
	if (user != null && user.isSuper()) {
		clientInfo.getRoles().add(Super);
	}

}
 
开发者ID:slipstream,项目名称:SlipStreamServer,代码行数:13,代码来源:SuperEnroler.java

示例10: beforeHandle

import org.restlet.data.ClientInfo; //导入依赖的package包/类
@Override
protected int beforeHandle(Request request, Response response) {

	ClientInfo clientInfo = request.getClientInfo();
	String agent = clientInfo.getAgent();

	for (String browserName : affectedBrowserNames) {
		if (agent != null && agent.contains(browserName)) {

			List<Preference<MediaType>> preferences;
			preferences = clientInfo.getAcceptedMediaTypes();

			LinkedList<Preference<MediaType>> trimmedPreferences;
			trimmedPreferences = new LinkedList<Preference<MediaType>>();

			for (Preference<MediaType> preference : preferences) {
				MediaType mediaType = preference.getMetadata();
				if (MediaType.TEXT_HTML.equals(mediaType)
						|| MediaType.APPLICATION_XHTML.equals(mediaType)) {
					trimmedPreferences.add(preference);
					clientInfo.setAcceptedMediaTypes(trimmedPreferences);
				}
			}

		}
	}
	return CONTINUE;
}
 
开发者ID:slipstream,项目名称:SlipStreamServer,代码行数:29,代码来源:TrimmedMediaTypesFilter.java

示例11: getInfo

import org.restlet.data.ClientInfo; //导入依赖的package包/类
public ClientInfo getInfo()
{
    return info;
}
 
开发者ID:apache,项目名称:polygene-java,代码行数:5,代码来源:ContextResourceClientFactory.java

示例12: OntopiaTestResource

import org.restlet.data.ClientInfo; //导入依赖的package包/类
public OntopiaTestResource(Method method, String url, MediaType preferredMime) {
	super(method, url);
	setNext(client);
	setClientInfo(new ClientInfo(preferredMime));
}
 
开发者ID:ontopia,项目名称:ontopia,代码行数:6,代码来源:OntopiaTestResource.java

示例13: AbstractLocator

import org.restlet.data.ClientInfo; //导入依赖的package包/类
/**
 * Abstractor locator matches a video path to a specific video instance
 * based on client parameters like device, resolution, etc
 * Further more conditional access is applied, a valid ticket need to be 
 * supplied in order to play out. 
 * 
 * @param abstractPath
 * @param queryForm
 * @param clientInfo
 */
public AbstractLocator(String abstractPath, Form queryForm, ClientInfo clientInfo) {
	this.abstractPath = abstractPath.endsWith("/") ? abstractPath.substring(0, abstractPath.length()-1) : abstractPath;
	this.queryString = URLDecoder.decode(queryForm.getQueryString());
	this.queryForm = queryForm;
	this.clientInfo = clientInfo;
	
	GlobalConfiguration conf = GlobalConfiguration.getInstance();
	this.abstractPath = conf.getProperty("server-basepath") + this.abstractPath;

	String ticket = queryForm.getFirstValue("ticket", true);
	LOG.debug("ticket = "+ticket);
	LOG.debug("abstract path = "+abstractPath);
	
	if (ticket == null) {
		//TODO: check with smithers if ticket is required for this video
		status = Status.CLIENT_ERROR_FORBIDDEN;
		return;
	} else {
		if (ticket.indexOf("?") > -1) {
			ticket = ticket.substring(0, ticket.indexOf("?"));
			LOG.debug("new ticket = "+ticket);
		}
		
		String wowzaUri = conf.getProperty("wowza-server-uri");

		Request request = new Request(Method.GET, wowzaUri+"/acl/ticket/"+ticket);
		Client client = new Client(Protocol.HTTP);
		Response response = client.handle(request);
		
		//TODO: add support for ip whitelisting instead of ticketing
		
		try {
			Document fsxml = DocumentHelper.parseText(response.getEntityAsText());
			String uri = fsxml.selectSingleNode("//properties/uri") == null ? null : fsxml.selectSingleNode("//properties/uri").getText();
			//String fsxmlStatus = fsxml.selectSingleNode("//properties/status") == null ? null : fsxml.selectSingleNode("//properties/status").getText();
			
			String domainPath = abstractPath.indexOf("/domain/") == -1 ? abstractPath : abstractPath.substring(abstractPath.indexOf("/domain/"));
			
			if (uri != null && uri.startsWith(domainPath)) {
				status = Status.REDIRECTION_SEE_OTHER;
				return;
			}
			status = Status.CLIENT_ERROR_FORBIDDEN;
			request.release();
			response.release();
			return;
		} catch (DocumentException e) {
			status = Status.SERVER_ERROR_INTERNAL;
			request.release();
			response.release();
			return;
		}
	}		
}
 
开发者ID:Noterik,项目名称:Rafael,代码行数:65,代码来源:AbstractLocator.java

示例14: getClientInfo

import org.restlet.data.ClientInfo; //导入依赖的package包/类
public ClientInfo getClientInfo() {
    return this.request.getClientInfo();
}
 
开发者ID:devacfr,项目名称:spring-restlet,代码行数:4,代码来源:ContextResource.java

示例15: setClientInfo

import org.restlet.data.ClientInfo; //导入依赖的package包/类
/**
 * Sets the client-specific information.
 * 
 * @param clientInfo
 *            The client-specific information.
 */
public void setClientInfo(ClientInfo clientInfo) {
    this.clientInfo = clientInfo;
}
 
开发者ID:DeviceConnect,项目名称:DeviceConnect-Android,代码行数:10,代码来源:Request.java


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