Add base oauth2 classes (#2)

* Update build.gradle

* Add oauth2 types
This commit is contained in:
Guilherme Werner 2023-12-24 08:22:15 -03:00 committed by GitHub
parent 68f92bca97
commit 4ba26d707d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 109 additions and 4 deletions

View file

@ -1,6 +1,6 @@
// Copyright (c) Tribufu. All Rights Reserved.
package com.tribufu.sdk;
package com.tribufu;
import java.net.http.HttpClient;
import java.util.HashMap;

View file

@ -0,0 +1,20 @@
// Copyright (c) Tribufu. All Rights Reserved.
package com.tribufu.oauth2;
public class OAuth2AuthorizeRequest {
private final OAuth2ResponseType responseType;
private final String clientId;
private final String scope;
private final String redirectUri;
private final String state;
public OAuth2AuthorizeRequest(OAuth2ResponseType responseType, String clientId, String scope, String redirectUri,
String state) {
this.responseType = responseType;
this.clientId = clientId;
this.scope = scope;
this.redirectUri = redirectUri;
this.state = state;
}
}

View file

@ -0,0 +1,13 @@
// Copyright (c) Tribufu. All Rights Reserved.
package com.tribufu.oauth2;
public class OAuth2CodeResponse {
public final String code;
public final String state;
public OAuth2CodeResponse(String code, String state) {
this.code = code;
this.state = state;
}
}

View file

@ -0,0 +1,11 @@
// Copyright (c) Tribufu. All Rights Reserved.
package com.tribufu.oauth2;
public enum OAuth2GrantType {
AuthorizationCode,
RefreshToken,
Password,
ClientCredentials,
DeviceCode,
}

View file

@ -0,0 +1,8 @@
// Copyright (c) Tribufu. All Rights Reserved.
package com.tribufu.oauth2;
public enum OAuth2ResponseType {
Code,
Token,
}

View file

@ -0,0 +1,26 @@
// Copyright (c) Tribufu. All Rights Reserved.
package com.tribufu.oauth2;
public class OAuth2TokenRequest {
private final OAuth2GrantType grantType;
private final String code;
private final String refreshToken;
private final String username;
private final String password;
private final String clientId;
private final String clientSecret;
private final String redirectUri;
public OAuth2TokenRequest(OAuth2GrantType grantType, String code, String refreshToken, String username,
String password, String clientId, String clientSecret, String redirectUri) {
this.grantType = grantType;
this.code = code;
this.refreshToken = refreshToken;
this.username = username;
this.password = password;
this.clientId = clientId;
this.clientSecret = clientSecret;
this.redirectUri = redirectUri;
}
}

View file

@ -0,0 +1,20 @@
// Copyright (c) Tribufu. All Rights Reserved.
package com.tribufu.oauth2;
public class OAuth2TokenResponse {
private final OAuth2TokenType tokenType;
private final String accessToken;
private final String refreshToken;
private final String scope;
private final int expiresIn;
public OAuth2TokenResponse(OAuth2TokenType tokenType, String accessToken, String refreshToken, String scope,
int expiresIn) {
this.tokenType = tokenType;
this.accessToken = accessToken;
this.refreshToken = refreshToken;
this.scope = scope;
this.expiresIn = expiresIn;
}
}

View file

@ -0,0 +1,7 @@
// Copyright (c) Tribufu. All Rights Reserved.
package com.tribufu.oauth2;
public enum OAuth2TokenType {
Bearer,
}

View file

@ -1,6 +1,6 @@
// Copyright (c) TribuFu. All Rights Reserved
// Copyright (c) Tribufu. All Rights Reserved
package com.tribufu.sdk;
package com.tribufu;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;