All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.imunity.furms.unity.client.oauth.UnityOauthAccessTokenRepository Maven / Gradle / Ivy

There is a newer version: 4.3.1
Show newest version
/*
 * Copyright (c) 2021 Bixbit s.c. All rights reserved.
 *  See LICENSE file for licensing information.
 */

package io.imunity.furms.unity.client.oauth;

import io.imunity.furms.spi.tokens.AccessTokenRepository;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.web.util.UriComponentsBuilder;

import java.net.URI;

@Component
class UnityOauthAccessTokenRepository implements AccessTokenRepository {
	private final UnityOauthClient unityClient;
	private final UnityOauthProperties unityOauthProperties;

	UnityOauthAccessTokenRepository(UnityOauthClient unityClient, UnityOauthProperties unityOauthProperties) {
		this.unityClient = unityClient;
		this.unityOauthProperties = unityOauthProperties;
	}

	@Override
	public void revoke(String accessToken, String clientId) {
		URI uri = UriComponentsBuilder.fromUriString(unityOauthProperties.getRevoke())
			.queryParam("token", accessToken)
			.queryParam("client_id", clientId)
			.queryParam("token_type_hint", "access_token")
			.queryParam("logout", "true")
			.build()
			.toUri();

		unityClient.post(uri, MediaType.APPLICATION_FORM_URLENCODED);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy