cn.herodotus.stirrup.oauth2.client.domain.OidcClientRegistration Maven / Gradle / Ivy
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2020-2030 郑庚伟 ZHENGGENGWEI (码匠君), Licensed under the AGPL License
*
* This file is part of Herodotus Cloud.
*
* Herodotus Cloud is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Herodotus Cloud is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
package cn.herodotus.stirrup.oauth2.client.domain;
import cn.herodotus.stirrup.core.definition.constants.BaseConstants;
import cn.herodotus.stirrup.core.foundation.json.jackson2.deserializer.ArrayOrStringToListDeserializer;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.google.common.base.MoreObjects;
import java.io.Serializable;
import java.time.Instant;
import java.util.List;
/**
* Description: 客户端注册请求及返回实体
*
* 数据类型转换,参考 org.springframework.security.oauth2.server.authorization.oidc.http.converter.OidcClientRegistrationHttpMessageConverter
*
* @author : gengwei.zheng
* @date : 2023/5/20 14:31
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class OidcClientRegistration implements Serializable {
/**
* 自定义属性,用于 IOT 设备识别
*/
@JsonProperty(BaseConstants.PRODUCT_ID)
private String productId;
@JsonProperty(OidcClientMetadataClaimNames.CLIENT_ID)
private String clientId;
@JsonProperty(OidcClientMetadataClaimNames.CLIENT_ID_ISSUED_AT)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", locale = "GMT+8", timezone = "GMT+8", shape = JsonFormat.Shape.NUMBER_INT)
private Instant clientIdIssuedAt;
@JsonProperty(OidcClientMetadataClaimNames.CLIENT_SECRET)
private String clientSecret;
@JsonProperty(OidcClientMetadataClaimNames.CLIENT_SECRET_EXPIRES_AT)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", locale = "GMT+8", timezone = "GMT+8", shape = JsonFormat.Shape.NUMBER_INT)
private Instant clientSecretExpiresAt;
@JsonProperty(OidcClientMetadataClaimNames.CLIENT_NAME)
private String clientName;
@JsonProperty(OidcClientMetadataClaimNames.REDIRECT_URIS)
@JsonDeserialize(using = ArrayOrStringToListDeserializer.class)
private List redirectUris;
@JsonProperty(OidcClientMetadataClaimNames.POST_LOGOUT_REDIRECT_URIS)
@JsonDeserialize(using = ArrayOrStringToListDeserializer.class)
private List postLogoutRedirectUris;
@JsonProperty(OidcClientMetadataClaimNames.TOKEN_ENDPOINT_AUTH_METHOD)
private String tokenEndpointAuthenticationMethod;
@JsonProperty(OidcClientMetadataClaimNames.TOKEN_ENDPOINT_AUTH_SIGNING_ALG)
private String tokenEndpointAuthenticationSigningAlgorithm;
@JsonProperty(OidcClientMetadataClaimNames.GRANT_TYPES)
@JsonDeserialize(using = ArrayOrStringToListDeserializer.class)
public List grantTypes;
@JsonProperty(OidcClientMetadataClaimNames.RESPONSE_TYPES)
@JsonDeserialize(using = ArrayOrStringToListDeserializer.class)
public List responseTypes;
/**
* 这里 Scope 的格式只能是以空格分隔的字符串。否则存储的时候会出问题。
*
* 参见:org.springframework.security.oauth2.server.authorization.oidc.http.converter.OidcClientRegistrationHttpMessageConverter
* 其中静态类MapOidcClientRegistrationConverter
的convertScope
方法
*/
@JsonProperty(OidcClientMetadataClaimNames.SCOPE)
private String scope;
@JsonProperty(OidcClientMetadataClaimNames.JWKS_URI)
private String jwksUri;
@JsonProperty(OidcClientMetadataClaimNames.ID_TOKEN_SIGNED_RESPONSE_ALG)
public String idTokenSignedResponseAlgorithm;
@JsonProperty(OidcClientMetadataClaimNames.REGISTRATION_ACCESS_TOKEN)
public String registrationAccessToken;
@JsonProperty(OidcClientMetadataClaimNames.REGISTRATION_CLIENT_URI)
public String registrationClientUri;
public String getProductId() {
return productId;
}
public void setProductId(String productId) {
this.productId = productId;
}
public String getClientId() {
return clientId;
}
public void setClientId(String clientId) {
this.clientId = clientId;
}
public Instant getClientIdIssuedAt() {
return clientIdIssuedAt;
}
public void setClientIdIssuedAt(Instant clientIdIssuedAt) {
this.clientIdIssuedAt = clientIdIssuedAt;
}
public String getClientSecret() {
return clientSecret;
}
public void setClientSecret(String clientSecret) {
this.clientSecret = clientSecret;
}
public Instant getClientSecretExpiresAt() {
return clientSecretExpiresAt;
}
public void setClientSecretExpiresAt(Instant clientSecretExpiresAt) {
this.clientSecretExpiresAt = clientSecretExpiresAt;
}
public String getClientName() {
return clientName;
}
public void setClientName(String clientName) {
this.clientName = clientName;
}
public List getRedirectUris() {
return redirectUris;
}
public void setRedirectUris(List redirectUris) {
this.redirectUris = redirectUris;
}
public List getPostLogoutRedirectUris() {
return postLogoutRedirectUris;
}
public void setPostLogoutRedirectUris(List postLogoutRedirectUris) {
this.postLogoutRedirectUris = postLogoutRedirectUris;
}
public String getTokenEndpointAuthenticationMethod() {
return tokenEndpointAuthenticationMethod;
}
public void setTokenEndpointAuthenticationMethod(String tokenEndpointAuthenticationMethod) {
this.tokenEndpointAuthenticationMethod = tokenEndpointAuthenticationMethod;
}
public String getTokenEndpointAuthenticationSigningAlgorithm() {
return tokenEndpointAuthenticationSigningAlgorithm;
}
public void setTokenEndpointAuthenticationSigningAlgorithm(String tokenEndpointAuthenticationSigningAlgorithm) {
this.tokenEndpointAuthenticationSigningAlgorithm = tokenEndpointAuthenticationSigningAlgorithm;
}
public List getGrantTypes() {
return grantTypes;
}
public void setGrantTypes(List grantTypes) {
this.grantTypes = grantTypes;
}
public List getResponseTypes() {
return responseTypes;
}
public void setResponseTypes(List responseTypes) {
this.responseTypes = responseTypes;
}
public String getScope() {
return scope;
}
public void setScope(String scope) {
this.scope = scope;
}
public String getJwksUri() {
return jwksUri;
}
public void setJwksUri(String jwksUri) {
this.jwksUri = jwksUri;
}
public String getIdTokenSignedResponseAlgorithm() {
return idTokenSignedResponseAlgorithm;
}
public void setIdTokenSignedResponseAlgorithm(String idTokenSignedResponseAlgorithm) {
this.idTokenSignedResponseAlgorithm = idTokenSignedResponseAlgorithm;
}
public String getRegistrationAccessToken() {
return registrationAccessToken;
}
public void setRegistrationAccessToken(String registrationAccessToken) {
this.registrationAccessToken = registrationAccessToken;
}
public String getRegistrationClientUri() {
return registrationClientUri;
}
public void setRegistrationClientUri(String registrationClientUri) {
this.registrationClientUri = registrationClientUri;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("productId", productId)
.add("clientId", clientId)
.add("clientIdIssuedAt", clientIdIssuedAt)
.add("clientSecret", clientSecret)
.add("clientSecretExpiresAt", clientSecretExpiresAt)
.add("clientName", clientName)
.add("redirectUris", redirectUris)
.add("postLogoutRedirectUris", postLogoutRedirectUris)
.add("tokenEndpointAuthenticationMethod", tokenEndpointAuthenticationMethod)
.add("tokenEndpointAuthenticationSigningAlgorithm", tokenEndpointAuthenticationSigningAlgorithm)
.add("grantTypes", grantTypes)
.add("responseTypes", responseTypes)
.add("scope", scope)
.add("jwksUri", jwksUri)
.add("idTokenSignedResponseAlgorithm", idTokenSignedResponseAlgorithm)
.add("registrationAccessToken", registrationAccessToken)
.add("registrationClientUri", registrationClientUri)
.toString();
}
}