Files
Stirling-PDF/src/main/java/stirling/software/SPDF/model/provider/Provider.java

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

75 lines
2.2 KiB
Java
Raw Normal View History

2025-01-22 15:14:06 +00:00
package stirling.software.SPDF.model.provider;
2025-01-24 18:14:15 +00:00
import static stirling.software.SPDF.utils.validation.Validator.isStringEmpty;
import java.util.ArrayList;
2025-01-22 15:14:06 +00:00
import java.util.Arrays;
import java.util.Collection;
import java.util.stream.Collectors;
2025-01-24 18:14:15 +00:00
import lombok.Data;
2025-01-22 15:14:06 +00:00
import lombok.NoArgsConstructor;
2025-01-24 18:14:15 +00:00
@Data
2025-01-22 15:14:06 +00:00
@NoArgsConstructor
2025-01-24 18:14:15 +00:00
public class Provider {
2025-01-22 15:14:06 +00:00
private String issuer;
private String name;
private String clientName;
private String clientId;
private String clientSecret;
private Collection<String> scopes;
private String useAsUsername;
2025-01-24 18:14:15 +00:00
private String authorizationUri;
private String tokenUri;
private String userInfoUri;
2025-01-22 15:14:06 +00:00
public Provider(
String issuer,
String name,
String clientName,
String clientId,
String clientSecret,
Collection<String> scopes,
2025-01-24 18:14:15 +00:00
String useAsUsername,
String authorizationUri,
String tokenUri,
String userInfoUri) {
2025-01-22 15:14:06 +00:00
this.issuer = issuer;
this.name = name;
this.clientName = clientName;
this.clientId = clientId;
this.clientSecret = clientSecret;
2025-01-24 18:14:15 +00:00
this.scopes = scopes == null ? new ArrayList<>() : scopes;
this.useAsUsername = isStringEmpty(useAsUsername) ? "email" : useAsUsername;
this.authorizationUri = authorizationUri;
this.tokenUri = tokenUri;
this.userInfoUri = userInfoUri;
2025-01-22 15:14:06 +00:00
}
public void setScopes(String scopes) {
2025-01-24 18:14:15 +00:00
if (scopes != null && !scopes.isBlank()) {
this.scopes =
Arrays.stream(scopes.split(",")).map(String::trim).collect(Collectors.toList());
}
2025-01-22 15:14:06 +00:00
}
2025-01-24 18:14:15 +00:00
@Override
public String toString() {
return "Provider [name="
+ getName()
+ ", clientName="
+ getClientName()
+ ", clientId="
+ getClientId()
+ ", clientSecret="
+ (getClientSecret() != null && !getClientSecret().isEmpty() ? "*****" : "NULL")
+ ", scopes="
+ getScopes()
+ ", useAsUsername="
+ getUseAsUsername()
+ "]";
2025-01-22 15:14:06 +00:00
}
}