mirror of https://gitee.com/topiam/eiam
♻️ CAS协议完善
parent
1d13877768
commit
c69094b86e
|
@ -218,7 +218,6 @@ public class CasStandardApplicationServiceImpl extends AbstractCasApplicationSer
|
||||||
}
|
}
|
||||||
|
|
||||||
private final AppCasStandardConfigConverter casStandardConfigConverter;
|
private final AppCasStandardConfigConverter casStandardConfigConverter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AppCasConfigRepository
|
* AppCasConfigRepository
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -17,12 +17,13 @@
|
||||||
*/
|
*/
|
||||||
package cn.topiam.employee.application.cas.pojo;
|
package cn.topiam.employee.application.cas.pojo;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 协议端点域
|
* 协议端点域
|
||||||
*
|
*
|
||||||
|
|
|
@ -20,9 +20,11 @@ package cn.topiam.employee.application.cas.pojo;
|
||||||
import cn.topiam.employee.common.enums.app.AuthorizationType;
|
import cn.topiam.employee.common.enums.app.AuthorizationType;
|
||||||
import cn.topiam.employee.common.enums.app.CasUserIdentityType;
|
import cn.topiam.employee.common.enums.app.CasUserIdentityType;
|
||||||
import cn.topiam.employee.common.enums.app.InitLoginType;
|
import cn.topiam.employee.common.enums.app.InitLoginType;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author TopIAM
|
* @author TopIAM
|
||||||
|
|
|
@ -17,14 +17,16 @@
|
||||||
*/
|
*/
|
||||||
package cn.topiam.employee.application.cas.pojo;
|
package cn.topiam.employee.application.cas.pojo;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
import cn.topiam.employee.common.enums.app.AuthorizationType;
|
import cn.topiam.employee.common.enums.app.AuthorizationType;
|
||||||
import cn.topiam.employee.common.enums.app.CasUserIdentityType;
|
import cn.topiam.employee.common.enums.app.CasUserIdentityType;
|
||||||
import cn.topiam.employee.common.enums.app.InitLoginType;
|
import cn.topiam.employee.common.enums.app.InitLoginType;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serial;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author TopIAM
|
* @author TopIAM
|
||||||
|
|
|
@ -26,7 +26,7 @@ import org.hibernate.annotations.TypeDef;
|
||||||
import com.vladmihalcea.hibernate.type.json.JsonStringType;
|
import com.vladmihalcea.hibernate.type.json.JsonStringType;
|
||||||
|
|
||||||
import cn.topiam.employee.common.enums.app.CasUserIdentityType;
|
import cn.topiam.employee.common.enums.app.CasUserIdentityType;
|
||||||
import cn.topiam.employee.support.repository.domain.BaseEntity;
|
import cn.topiam.employee.support.repository.domain.LogicDeleteEntity;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
@ -46,7 +46,7 @@ import lombok.experimental.Accessors;
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
@Table(name = "app_cas_config")
|
@Table(name = "app_cas_config")
|
||||||
@TypeDef(name = "json", typeClass = JsonStringType.class)
|
@TypeDef(name = "json", typeClass = JsonStringType.class)
|
||||||
public class AppCasConfigEntity extends BaseEntity<Long> {
|
public class AppCasConfigEntity extends LogicDeleteEntity<Long> {
|
||||||
/**
|
/**
|
||||||
* APP ID
|
* APP ID
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,128 +0,0 @@
|
||||||
/*
|
|
||||||
* eiam-common - Employee Identity and Access Management Program
|
|
||||||
* Copyright © 2020-2023 TopIAM (support@topiam.cn)
|
|
||||||
*
|
|
||||||
* This program 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.
|
|
||||||
*
|
|
||||||
* This program 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package cn.topiam.employee.common.entity.app;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.persistence.Column;
|
|
||||||
import javax.persistence.Entity;
|
|
||||||
import javax.persistence.Table;
|
|
||||||
|
|
||||||
import org.hibernate.annotations.*;
|
|
||||||
|
|
||||||
import com.vladmihalcea.hibernate.type.json.JsonStringType;
|
|
||||||
|
|
||||||
import cn.topiam.employee.support.repository.domain.LogicDeleteEntity;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
import lombok.ToString;
|
|
||||||
import lombok.experimental.Accessors;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import static cn.topiam.employee.support.repository.domain.LogicDeleteEntity.SOFT_DELETE_SET;
|
|
||||||
import static cn.topiam.employee.support.repository.domain.LogicDeleteEntity.SOFT_DELETE_WHERE;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* APP Form 配置
|
|
||||||
*
|
|
||||||
* @author TopIAM
|
|
||||||
* Created by support@topiam.cn on 2022/12/13 22:31
|
|
||||||
*/
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
@ToString
|
|
||||||
@Entity
|
|
||||||
@Accessors(chain = true)
|
|
||||||
@Table(name = "app_tsa_config")
|
|
||||||
@SQLDelete(sql = "update app_tsa_config set " + SOFT_DELETE_SET + " where id_ = ?")
|
|
||||||
@SQLDeleteAll(sql = "update app_tsa_config set " + SOFT_DELETE_SET + " where id_ = ?")
|
|
||||||
@TypeDef(name = "json", typeClass = JsonStringType.class)
|
|
||||||
@Where(clause = SOFT_DELETE_WHERE)
|
|
||||||
public class AppTsaConfigEntity extends LogicDeleteEntity<Long> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* APP ID
|
|
||||||
*/
|
|
||||||
@Column(name = "app_id")
|
|
||||||
private Long appId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 登录页面
|
|
||||||
*/
|
|
||||||
@Column(name = "login_page")
|
|
||||||
private String loginPage;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 自动登录步骤
|
|
||||||
*/
|
|
||||||
@Column(name = "auto_login_steps")
|
|
||||||
@Type(type = "json")
|
|
||||||
private List<AutoLoginStep> autoLoginSteps;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建账号步骤
|
|
||||||
*/
|
|
||||||
@Column(name = "create_account_steps")
|
|
||||||
@Type(type = "json")
|
|
||||||
private List<CreateAccountStep> createAccountSteps;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@Schema(description = "自动登录步骤")
|
|
||||||
public static class AutoLoginStep implements Serializable {
|
|
||||||
|
|
||||||
private String action;
|
|
||||||
|
|
||||||
private String target;
|
|
||||||
|
|
||||||
private String value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@Schema(description = "创建账号步骤")
|
|
||||||
public static class CreateAccountStep implements Serializable {
|
|
||||||
|
|
||||||
private String title;
|
|
||||||
|
|
||||||
private String titleI18n;
|
|
||||||
|
|
||||||
private FormItemProp formItemProps;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@Schema(description = "表单内容")
|
|
||||||
public static class FormItemProp implements Serializable {
|
|
||||||
|
|
||||||
private List<String> name;
|
|
||||||
|
|
||||||
private List<Rule> rules;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@Schema(description = "表单验证规则")
|
|
||||||
public static class Rule implements Serializable {
|
|
||||||
|
|
||||||
private Boolean required;
|
|
||||||
|
|
||||||
private String message;
|
|
||||||
|
|
||||||
private String messageI18n;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,74 +0,0 @@
|
||||||
/*
|
|
||||||
* eiam-common - Employee Identity and Access Management Program
|
|
||||||
* Copyright © 2020-2023 TopIAM (support@topiam.cn)
|
|
||||||
*
|
|
||||||
* This program 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.
|
|
||||||
*
|
|
||||||
* This program 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package cn.topiam.employee.common.entity.app.po;
|
|
||||||
|
|
||||||
import cn.topiam.employee.common.entity.app.AppTsaConfigEntity;
|
|
||||||
import cn.topiam.employee.common.enums.app.AuthorizationType;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author TopIAM
|
|
||||||
* Created by support@topiam.cn on 2022/01/14 10:45
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
public class AppTsaConfigPO extends AppTsaConfigEntity {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 应用编码
|
|
||||||
*/
|
|
||||||
private String appCode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 模版
|
|
||||||
*/
|
|
||||||
private String appTemplate;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 客户端ID
|
|
||||||
*/
|
|
||||||
private String clientId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 客户端秘钥
|
|
||||||
*/
|
|
||||||
private String clientSecret;
|
|
||||||
|
|
||||||
// /**
|
|
||||||
// * SSO 发起方
|
|
||||||
// */
|
|
||||||
// private InitLoginType initLoginType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* SSO 登录链接
|
|
||||||
*/
|
|
||||||
private String initLoginUrl;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 授权范围
|
|
||||||
*/
|
|
||||||
private AuthorizationType authorizationType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 应用是否启用
|
|
||||||
*/
|
|
||||||
private Boolean enabled;
|
|
||||||
}
|
|
|
@ -22,11 +22,11 @@ import java.util.Optional;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.springframework.cache.annotation.CacheConfig;
|
import org.springframework.cache.annotation.CacheConfig;
|
||||||
import org.springframework.cache.annotation.CacheEvict;
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
|
||||||
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
|
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import cn.topiam.employee.common.entity.app.AppCasConfigEntity;
|
import cn.topiam.employee.common.entity.app.AppCasConfigEntity;
|
||||||
|
import cn.topiam.employee.support.repository.LogicDeleteRepository;
|
||||||
import static cn.topiam.employee.common.constants.ProtocolConstants.CAS_CONFIG_CACHE_NAME;
|
import static cn.topiam.employee.common.constants.ProtocolConstants.CAS_CONFIG_CACHE_NAME;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,7 +37,7 @@ import static cn.topiam.employee.common.constants.ProtocolConstants.CAS_CONFIG_C
|
||||||
*/
|
*/
|
||||||
@Repository
|
@Repository
|
||||||
@CacheConfig(cacheNames = { CAS_CONFIG_CACHE_NAME })
|
@CacheConfig(cacheNames = { CAS_CONFIG_CACHE_NAME })
|
||||||
public interface AppCasConfigRepository extends JpaRepository<AppCasConfigEntity, Long>,
|
public interface AppCasConfigRepository extends LogicDeleteRepository<AppCasConfigEntity, Long>,
|
||||||
QuerydslPredicateExecutor<AppCasConfigEntity>,
|
QuerydslPredicateExecutor<AppCasConfigEntity>,
|
||||||
AppCasConfigRepositoryCustomized {
|
AppCasConfigRepositoryCustomized {
|
||||||
|
|
||||||
|
|
|
@ -1,85 +0,0 @@
|
||||||
/*
|
|
||||||
* eiam-common - Employee Identity and Access Management Program
|
|
||||||
* Copyright © 2020-2023 TopIAM (support@topiam.cn)
|
|
||||||
*
|
|
||||||
* This program 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.
|
|
||||||
*
|
|
||||||
* This program 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package cn.topiam.employee.common.repository.app;
|
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.springframework.cache.annotation.CacheConfig;
|
|
||||||
import org.springframework.cache.annotation.CacheEvict;
|
|
||||||
import org.springframework.data.jpa.repository.Modifying;
|
|
||||||
import org.springframework.data.jpa.repository.Query;
|
|
||||||
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
|
|
||||||
import org.springframework.data.repository.query.Param;
|
|
||||||
import org.springframework.stereotype.Repository;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import cn.topiam.employee.common.entity.app.AppTsaConfigEntity;
|
|
||||||
import cn.topiam.employee.support.repository.LogicDeleteRepository;
|
|
||||||
import static cn.topiam.employee.common.constants.ProtocolConstants.TSA_CONFIG_CACHE_NAME;
|
|
||||||
import static cn.topiam.employee.support.repository.domain.LogicDeleteEntity.SOFT_DELETE_SET;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author TopIAM
|
|
||||||
*/
|
|
||||||
@Repository
|
|
||||||
@CacheConfig(cacheNames = { TSA_CONFIG_CACHE_NAME })
|
|
||||||
public interface AppTsaConfigRepository extends LogicDeleteRepository<AppTsaConfigEntity, Long>,
|
|
||||||
QuerydslPredicateExecutor<AppTsaConfigEntity>,
|
|
||||||
AppTsaConfigRepositoryCustomized {
|
|
||||||
/**
|
|
||||||
* 按应用 ID 删除
|
|
||||||
*
|
|
||||||
* @param appId {@link Long}
|
|
||||||
*/
|
|
||||||
@CacheEvict(allEntries = true)
|
|
||||||
@Modifying
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
@Query(value = "UPDATE app_tsa_config SET " + SOFT_DELETE_SET
|
|
||||||
+ " WHERE app_id = :appId", nativeQuery = true)
|
|
||||||
void deleteByAppId(@Param("appId") Long appId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* delete
|
|
||||||
*
|
|
||||||
* @param id must not be {@literal null}.
|
|
||||||
*/
|
|
||||||
@CacheEvict(allEntries = true)
|
|
||||||
@Override
|
|
||||||
void deleteById(@NotNull Long id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* save
|
|
||||||
*
|
|
||||||
* @param entity must not be {@literal null}.
|
|
||||||
* @param <S> {@link S}
|
|
||||||
* @return {@link AppTsaConfigEntity}
|
|
||||||
*/
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
@CacheEvict(allEntries = true)
|
|
||||||
<S extends AppTsaConfigEntity> S save(@NotNull S entity);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据应用ID获取配置
|
|
||||||
*
|
|
||||||
* @param appId {@link Long}
|
|
||||||
* @return {@link AppTsaConfigEntity}
|
|
||||||
*/
|
|
||||||
Optional<AppTsaConfigEntity> findByAppId(Long appId);
|
|
||||||
}
|
|
|
@ -1,50 +0,0 @@
|
||||||
/*
|
|
||||||
* eiam-common - Employee Identity and Access Management Program
|
|
||||||
* Copyright © 2020-2023 TopIAM (support@topiam.cn)
|
|
||||||
*
|
|
||||||
* This program 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.
|
|
||||||
*
|
|
||||||
* This program 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package cn.topiam.employee.common.repository.app;
|
|
||||||
|
|
||||||
import cn.topiam.employee.common.entity.app.po.AppTsaConfigPO;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author TopIAM
|
|
||||||
* Created by support@topiam.cn on 2022/01/14 09:58
|
|
||||||
*/
|
|
||||||
public interface AppTsaConfigRepositoryCustomized {
|
|
||||||
/**
|
|
||||||
* 根据应用ID获取
|
|
||||||
*
|
|
||||||
* @param appId {@link Long}
|
|
||||||
* @return {@link AppTsaConfigPO}
|
|
||||||
*/
|
|
||||||
AppTsaConfigPO getByAppId(Long appId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据应用 Client 获取
|
|
||||||
*
|
|
||||||
* @param clientId {@link String}
|
|
||||||
* @return {@link AppTsaConfigPO}
|
|
||||||
*/
|
|
||||||
AppTsaConfigPO getByClientId(String clientId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据应用编码查询应用配置
|
|
||||||
*
|
|
||||||
* @param appCode {@link String}
|
|
||||||
* @return {@link AppTsaConfigPO}
|
|
||||||
*/
|
|
||||||
AppTsaConfigPO findByAppCode(String appCode);
|
|
||||||
}
|
|
|
@ -1,111 +0,0 @@
|
||||||
/*
|
|
||||||
* eiam-common - Employee Identity and Access Management Program
|
|
||||||
* Copyright © 2020-2023 TopIAM (support@topiam.cn)
|
|
||||||
*
|
|
||||||
* This program 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.
|
|
||||||
*
|
|
||||||
* This program 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package cn.topiam.employee.common.repository.app.impl;
|
|
||||||
|
|
||||||
import org.springframework.cache.annotation.CacheConfig;
|
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
|
||||||
import org.springframework.dao.EmptyResultDataAccessException;
|
|
||||||
import org.springframework.jdbc.core.JdbcTemplate;
|
|
||||||
import org.springframework.stereotype.Repository;
|
|
||||||
|
|
||||||
import cn.topiam.employee.common.entity.app.po.AppTsaConfigPO;
|
|
||||||
import cn.topiam.employee.common.repository.app.AppTsaConfigRepositoryCustomized;
|
|
||||||
import cn.topiam.employee.common.repository.app.impl.mapper.AppTsaConfigPoMapper;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import static cn.topiam.employee.common.constants.ProtocolConstants.TSA_CONFIG_CACHE_NAME;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author TopIAM
|
|
||||||
* Created by support@topiam.cn on 2022/01/14 10:58
|
|
||||||
*/
|
|
||||||
@Repository
|
|
||||||
@AllArgsConstructor
|
|
||||||
@CacheConfig(cacheNames = { TSA_CONFIG_CACHE_NAME })
|
|
||||||
public class AppTsaConfigRepositoryCustomizedImpl implements AppTsaConfigRepositoryCustomized {
|
|
||||||
private static final String SELECT_SQL = """
|
|
||||||
SELECT
|
|
||||||
afc.*,
|
|
||||||
app.init_login_url,
|
|
||||||
app.init_login_type,
|
|
||||||
app.authorization_type,
|
|
||||||
app.template_,
|
|
||||||
app.code_,
|
|
||||||
app.is_enabled,
|
|
||||||
app.client_id,
|
|
||||||
app.client_secret
|
|
||||||
FROM
|
|
||||||
app
|
|
||||||
LEFT JOIN app_tsa_config atc ON app.id_ = atc.app_id AND atc.is_deleted = '0'
|
|
||||||
WHERE
|
|
||||||
app.is_deleted = '0'
|
|
||||||
""";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据应用ID获取
|
|
||||||
*
|
|
||||||
* @param appId {@link Long}
|
|
||||||
* @return {@link AppTsaConfigPO}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@Cacheable(key = "#p0", unless = "#result==null")
|
|
||||||
public AppTsaConfigPO getByAppId(Long appId) {
|
|
||||||
//@formatter:off
|
|
||||||
String sql = SELECT_SQL + " AND app_id = " + appId;
|
|
||||||
//@formatter:on
|
|
||||||
return jdbcTemplate.queryForObject(sql, new AppTsaConfigPoMapper());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Cacheable(key = "#p0", unless = "#result==null")
|
|
||||||
public AppTsaConfigPO getByClientId(String clientId) {
|
|
||||||
//@formatter:off
|
|
||||||
try {
|
|
||||||
String sql = SELECT_SQL + " AND app.client_id = " + "'"+clientId+"'";
|
|
||||||
return jdbcTemplate.queryForObject(sql, new AppTsaConfigPoMapper());
|
|
||||||
} catch (EmptyResultDataAccessException e){
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
//@formatter:on
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据应用编码查询应用配置
|
|
||||||
*
|
|
||||||
* @param appCode {@link String}
|
|
||||||
* @return {@link AppTsaConfigPO}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@Cacheable(key = "#p0", unless = "#result==null")
|
|
||||||
public AppTsaConfigPO findByAppCode(String appCode) {
|
|
||||||
//@formatter:off
|
|
||||||
String sql = SELECT_SQL + " AND app.code_ = " + "'"+appCode+"'";
|
|
||||||
//@formatter:on
|
|
||||||
try {
|
|
||||||
return jdbcTemplate.queryForObject(sql, new AppTsaConfigPoMapper());
|
|
||||||
} catch (EmptyResultDataAccessException e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* JdbcTemplate
|
|
||||||
*/
|
|
||||||
private final JdbcTemplate jdbcTemplate;
|
|
||||||
}
|
|
|
@ -17,15 +17,16 @@
|
||||||
*/
|
*/
|
||||||
package cn.topiam.employee.common.repository.app.impl.mapper;
|
package cn.topiam.employee.common.repository.app.impl.mapper;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import org.springframework.jdbc.core.RowMapper;
|
||||||
|
|
||||||
import cn.topiam.employee.common.entity.app.po.AppCasConfigPO;
|
import cn.topiam.employee.common.entity.app.po.AppCasConfigPO;
|
||||||
import cn.topiam.employee.common.enums.app.AuthorizationType;
|
import cn.topiam.employee.common.enums.app.AuthorizationType;
|
||||||
import cn.topiam.employee.common.enums.app.CasUserIdentityType;
|
import cn.topiam.employee.common.enums.app.CasUserIdentityType;
|
||||||
import cn.topiam.employee.common.enums.app.InitLoginType;
|
import cn.topiam.employee.common.enums.app.InitLoginType;
|
||||||
import org.springframework.jdbc.core.RowMapper;
|
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AppCasConfigPOPOMapper
|
* AppCasConfigPOPOMapper
|
||||||
|
|
|
@ -1,80 +0,0 @@
|
||||||
/*
|
|
||||||
* eiam-common - Employee Identity and Access Management Program
|
|
||||||
* Copyright © 2020-2023 TopIAM (support@topiam.cn)
|
|
||||||
*
|
|
||||||
* This program 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.
|
|
||||||
*
|
|
||||||
* This program 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package cn.topiam.employee.common.repository.app.impl.mapper;
|
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
import org.springframework.jdbc.core.RowMapper;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson2.JSON;
|
|
||||||
|
|
||||||
import cn.topiam.employee.common.entity.app.AppTsaConfigEntity;
|
|
||||||
import cn.topiam.employee.common.entity.app.po.AppTsaConfigPO;
|
|
||||||
import cn.topiam.employee.common.enums.app.AuthorizationType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author TopIAM
|
|
||||||
* Created by support@topiam.cn on 2022/01/14 10:58
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("DuplicatedCode")
|
|
||||||
public class AppTsaConfigPoMapper implements RowMapper<AppTsaConfigPO> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Implementations must implement this method to map each row of data
|
|
||||||
* in the ResultSet. This method should not call {@code next()} on
|
|
||||||
* the ResultSet; it is only supposed to map values of the current row.
|
|
||||||
*
|
|
||||||
* @param rs the ResultSet to map (pre-initialized for the current row)
|
|
||||||
* @param rowNum the number of the current row
|
|
||||||
* @return the result object for the current row (may be {@code null})
|
|
||||||
* @throws SQLException if an SQLException is encountered getting
|
|
||||||
* column values (that is, there's no need to catch SQLException)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public AppTsaConfigPO mapRow(ResultSet rs, int rowNum) throws SQLException {
|
|
||||||
//@formatter:off
|
|
||||||
AppTsaConfigPO appForm = new AppTsaConfigPO();
|
|
||||||
appForm.setAppId(rs.getLong("app_id"));
|
|
||||||
//应用表相关
|
|
||||||
appForm.setAppCode(rs.getString("code_"));
|
|
||||||
appForm.setAppTemplate(rs.getString("template_"));
|
|
||||||
appForm.setEnabled(rs.getBoolean("is_enabled"));
|
|
||||||
appForm.setClientId(rs.getString("client_id"));
|
|
||||||
appForm.setClientSecret(rs.getString("client_secret"));
|
|
||||||
// appForm.setInitLoginType(InitLoginType.getType(rs.getString("init_login_type")));
|
|
||||||
appForm.setInitLoginUrl(rs.getString("init_login_url"));
|
|
||||||
appForm.setAuthorizationType(AuthorizationType.getType(rs.getString("authorization_type")));
|
|
||||||
//配置相关
|
|
||||||
appForm.setLoginPage(rs.getString("login_page"));
|
|
||||||
appForm.setAutoLoginSteps(JSON.parseArray(rs.getString("auto_login_steps"))
|
|
||||||
.toList(AppTsaConfigEntity.AutoLoginStep.class));
|
|
||||||
appForm.setCreateAccountSteps(JSON.parseArray(rs.getString("create_account_stepss"))
|
|
||||||
.toList(AppTsaConfigEntity.CreateAccountStep.class));
|
|
||||||
//创建修改相关
|
|
||||||
appForm.setCreateBy(rs.getString("create_by"));
|
|
||||||
appForm.setCreateTime(rs.getObject("create_time", LocalDateTime.class));
|
|
||||||
appForm.setUpdateBy(rs.getString("update_by"));
|
|
||||||
appForm.setCreateTime(rs.getObject("update_time", LocalDateTime.class));
|
|
||||||
appForm.setRemark(rs.getString("remark_"));
|
|
||||||
return appForm;
|
|
||||||
//@formatter:on
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue