org.restlet.data.ClientInfo Java Examples
The following examples show how to use
org.restlet.data.ClientInfo.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LocalOAuth2Main.java From DeviceConnect-Android with MIT License | 5 votes |
/** * 認可コードを渡してアクセストークンを取得する. * * @param client クライアント * @param authCode 認可コード(TokenManager.sessionsに存在するキー値を設定する) * @param applicationName アプリケーション名 * @return not null: アクセストークン / null: アクセストークン取得失敗 */ private 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; }
Example #2
Source File: Request.java From DeviceConnect-Android with MIT License | 5 votes |
/** * 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; }
Example #3
Source File: ContextResourceClientFactory.java From attic-polygene-java with Apache License 2.0 | 4 votes |
public ClientInfo getInfo() { return info; }
Example #4
Source File: OntopiaTestResource.java From ontopia with Apache License 2.0 | 4 votes |
public OntopiaTestResource(Method method, String url, MediaType preferredMime) { super(method, url); setNext(client); setClientInfo(new ClientInfo(preferredMime)); }
Example #5
Source File: Request.java From DeviceConnect-Android with MIT License | 2 votes |
/** * Sets the client-specific information. * * @param clientInfo * The client-specific information. */ public void setClientInfo(ClientInfo clientInfo) { this.clientInfo = clientInfo; }