修复密码没有加密的问题
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
$ErrorActionPreference = "Stop"
|
$ErrorActionPreference = "Stop"
|
||||||
|
|
||||||
$VERSION = "1.0"
|
$VERSION = "1.1"
|
||||||
|
|
||||||
$IMAGE = "docker.bbitcn.net/bbit_invoice/server"
|
$IMAGE = "docker.bbitcn.net/bbit_invoice/server"
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import com.bbit.ticket.service.system.PasswordService
|
|||||||
import com.bbit.ticket.utils.ApiKeyUtil
|
import com.bbit.ticket.utils.ApiKeyUtil
|
||||||
import com.bbit.ticket.utils.CurrentUser
|
import com.bbit.ticket.utils.CurrentUser
|
||||||
import com.bbit.ticket.utils.net.PTApi
|
import com.bbit.ticket.utils.net.PTApi
|
||||||
|
import com.bbit.ticket.utils.net.SecurityUtil
|
||||||
import com.bbit.ticket.utils.parseUuid
|
import com.bbit.ticket.utils.parseUuid
|
||||||
import io.ktor.http.HttpStatusCode
|
import io.ktor.http.HttpStatusCode
|
||||||
import kotlin.uuid.Uuid
|
import kotlin.uuid.Uuid
|
||||||
@@ -72,8 +73,15 @@ object PTConfigService {
|
|||||||
): PageResult<DigitalAccountManageItem> = dbQuery {
|
): PageResult<DigitalAccountManageItem> = dbQuery {
|
||||||
when {
|
when {
|
||||||
user.isSuperAdmin || user.isEnterpriseAdmin -> {
|
user.isSuperAdmin || user.isEnterpriseAdmin -> {
|
||||||
EnterpriseManageDao.digitalAccountsForEnterprise(requireEnterpriseId(user), account, status, page, pageSize)
|
EnterpriseManageDao.digitalAccountsForEnterprise(
|
||||||
|
requireEnterpriseId(user),
|
||||||
|
account,
|
||||||
|
status,
|
||||||
|
page,
|
||||||
|
pageSize
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
user.isDigitalOperator -> {
|
user.isDigitalOperator -> {
|
||||||
val id = user.digitalAccountId
|
val id = user.digitalAccountId
|
||||||
?: throw BizException(ErrorCode.BAD_REQUEST.code, "当前账号未绑定数电账号")
|
?: throw BizException(ErrorCode.BAD_REQUEST.code, "当前账号未绑定数电账号")
|
||||||
@@ -83,15 +91,25 @@ object PTConfigService {
|
|||||||
?.takeIf { status.isNullOrBlank() || it.status == status.trim().uppercase() }
|
?.takeIf { status.isNullOrBlank() || it.status == status.trim().uppercase() }
|
||||||
PageResult(listOfNotNull(item), page, pageSize, if (item == null) 0 else 1)
|
PageResult(listOfNotNull(item), page, pageSize, if (item == null) 0 else 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> PageResult(emptyList(), page, pageSize, 0)
|
else -> PageResult(emptyList(), page, pageSize, 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun listDigitalAccountOptions(user: CurrentUser, account: String?, limit: Int): List<DigitalAccountManageItem> = dbQuery {
|
suspend fun listDigitalAccountOptions(
|
||||||
|
user: CurrentUser,
|
||||||
|
account: String?,
|
||||||
|
limit: Int
|
||||||
|
): List<DigitalAccountManageItem> = dbQuery {
|
||||||
when {
|
when {
|
||||||
user.isSuperAdmin || user.isEnterpriseAdmin -> {
|
user.isSuperAdmin || user.isEnterpriseAdmin -> {
|
||||||
EnterpriseManageDao.digitalAccountOptionsForEnterprise(requireEnterpriseId(user), account, limit.coerceIn(1, 200))
|
EnterpriseManageDao.digitalAccountOptionsForEnterprise(
|
||||||
|
requireEnterpriseId(user),
|
||||||
|
account,
|
||||||
|
limit.coerceIn(1, 200)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
user.isDigitalOperator -> {
|
user.isDigitalOperator -> {
|
||||||
val id = user.digitalAccountId
|
val id = user.digitalAccountId
|
||||||
?: throw BizException(ErrorCode.BAD_REQUEST.code, "当前账号未绑定数电账号")
|
?: throw BizException(ErrorCode.BAD_REQUEST.code, "当前账号未绑定数电账号")
|
||||||
@@ -101,6 +119,7 @@ object PTConfigService {
|
|||||||
?.let { listOf(it) }
|
?.let { listOf(it) }
|
||||||
?: emptyList()
|
?: emptyList()
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> emptyList()
|
else -> emptyList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -141,7 +160,7 @@ object PTConfigService {
|
|||||||
TaxRegister(
|
TaxRegister(
|
||||||
taxpayerNum = enterprise.taxpayerNum,
|
taxpayerNum = enterprise.taxpayerNum,
|
||||||
account = req.account,
|
account = req.account,
|
||||||
password = req.taxPassword,
|
password = SecurityUtil.encrypt3DES(req.taxPassword) ?: "",
|
||||||
phoneNum = req.phoneNum,
|
phoneNum = req.phoneNum,
|
||||||
name = req.name,
|
name = req.name,
|
||||||
identityType = req.identityType,
|
identityType = req.identityType,
|
||||||
@@ -170,7 +189,8 @@ object PTConfigService {
|
|||||||
apiKey = ApiKeyUtil.generate(),
|
apiKey = ApiKeyUtil.generate(),
|
||||||
)
|
)
|
||||||
EnterpriseManageDao.bindDigitalAccountUser(digitalAccountId, userId)
|
EnterpriseManageDao.bindDigitalAccountUser(digitalAccountId, userId)
|
||||||
EnterpriseManageDao.digitalAccount(digitalAccountId)!!.let { EnterpriseManageDao.run { it.toDigitalAccountItem() } }
|
EnterpriseManageDao.digitalAccount(digitalAccountId)!!
|
||||||
|
.let { EnterpriseManageDao.run { it.toDigitalAccountItem() } }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -251,31 +271,39 @@ object PTConfigService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
suspend fun openApiStatistics(user: CurrentUser): List<OpenApiStatisticsItem> = dbQuery {
|
suspend fun openApiStatistics(user: CurrentUser): List<OpenApiStatisticsItem> = dbQuery {
|
||||||
EnterpriseManageDao.openApiStatistics(requireEnterpriseId(user), if (user.isDigitalOperator) user.digitalAccountId else null)
|
EnterpriseManageDao.openApiStatistics(
|
||||||
|
requireEnterpriseId(user),
|
||||||
|
if (user.isDigitalOperator) user.digitalAccountId else null
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun requireEnterpriseId(user: CurrentUser): Uuid =
|
fun requireEnterpriseId(user: CurrentUser): Uuid =
|
||||||
user.enterpriseId ?: throw BizException(ErrorCode.BAD_REQUEST.code, "当前账号未绑定企业")
|
user.enterpriseId ?: throw BizException(ErrorCode.BAD_REQUEST.code, "当前账号未绑定企业")
|
||||||
|
|
||||||
suspend fun requireDigitalAccountForAction(user: CurrentUser, digitalAccountId: String?): DigitalAccountManageItem = dbQuery {
|
suspend fun requireDigitalAccountForAction(user: CurrentUser, digitalAccountId: String?): DigitalAccountManageItem =
|
||||||
val targetId = when {
|
dbQuery {
|
||||||
user.isDigitalOperator -> user.digitalAccountId
|
val targetId = when {
|
||||||
!digitalAccountId.isNullOrBlank() -> parseUuid(digitalAccountId, "digitalAccountId")
|
user.isDigitalOperator -> user.digitalAccountId
|
||||||
else -> user.digitalAccountId
|
!digitalAccountId.isNullOrBlank() -> parseUuid(digitalAccountId, "digitalAccountId")
|
||||||
} ?: throw BizException(ErrorCode.BAD_REQUEST.code, "请选择数电账号")
|
else -> user.digitalAccountId
|
||||||
|
} ?: throw BizException(ErrorCode.BAD_REQUEST.code, "请选择数电账号")
|
||||||
|
|
||||||
val row = EnterpriseManageDao.digitalAccount(targetId)
|
val row = EnterpriseManageDao.digitalAccount(targetId)
|
||||||
?: throw BizException(ErrorCode.BAD_REQUEST.code, "数电账号不存在", HttpStatusCode.NotFound)
|
?: throw BizException(ErrorCode.BAD_REQUEST.code, "数电账号不存在", HttpStatusCode.NotFound)
|
||||||
if (!user.isSuperAdmin && row[PtDigitalAccountTable.enterpriseId] != requireEnterpriseId(user)) {
|
if (!user.isSuperAdmin && row[PtDigitalAccountTable.enterpriseId] != requireEnterpriseId(user)) {
|
||||||
throw BizException(ErrorCode.FORBIDDEN.code, "无权操作该数电账号", HttpStatusCode.Forbidden)
|
throw BizException(ErrorCode.FORBIDDEN.code, "无权操作该数电账号", HttpStatusCode.Forbidden)
|
||||||
|
}
|
||||||
|
if (row[PtDigitalAccountTable.status] != "ENABLED") {
|
||||||
|
throw BizException(ErrorCode.FORBIDDEN.code, "数电账号已禁用", HttpStatusCode.Forbidden)
|
||||||
|
}
|
||||||
|
EnterpriseManageDao.run { row.toDigitalAccountItem() }
|
||||||
}
|
}
|
||||||
if (row[PtDigitalAccountTable.status] != "ENABLED") {
|
|
||||||
throw BizException(ErrorCode.FORBIDDEN.code, "数电账号已禁用", HttpStatusCode.Forbidden)
|
|
||||||
}
|
|
||||||
EnterpriseManageDao.run { row.toDigitalAccountItem() }
|
|
||||||
}
|
|
||||||
|
|
||||||
suspend fun requireDigitalAccountForLogin(user: CurrentUser, taxpayerNum: String, account: String): DigitalAccountManageItem =
|
suspend fun requireDigitalAccountForLogin(
|
||||||
|
user: CurrentUser,
|
||||||
|
taxpayerNum: String,
|
||||||
|
account: String
|
||||||
|
): DigitalAccountManageItem =
|
||||||
dbQuery {
|
dbQuery {
|
||||||
val row = EnterpriseManageDao.digitalAccountByTaxpayerAndAccount(taxpayerNum.trim(), account.trim())
|
val row = EnterpriseManageDao.digitalAccountByTaxpayerAndAccount(taxpayerNum.trim(), account.trim())
|
||||||
?: throw BizException(ErrorCode.BAD_REQUEST.code, "数电账号不存在", HttpStatusCode.NotFound)
|
?: throw BizException(ErrorCode.BAD_REQUEST.code, "数电账号不存在", HttpStatusCode.NotFound)
|
||||||
|
|||||||
@@ -219,7 +219,7 @@ object PTClient {
|
|||||||
|
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun buildRequestData(content: String): String {
|
fun buildRequestData(content: String): String {
|
||||||
val reqContent: String = SecurityUtil.encrypt3DES(Global.ptPassword, content) ?: ""
|
val reqContent: String = SecurityUtil.encrypt3DES(content) ?: ""
|
||||||
val sdf = SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
|
val sdf = SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
|
||||||
val map = HashMap<String, String>()
|
val map = HashMap<String, String>()
|
||||||
map["platformCode"] = Global.ptPlatformCode
|
map["platformCode"] = Global.ptPlatformCode
|
||||||
@@ -262,7 +262,7 @@ object PTClient {
|
|||||||
?: throw IllegalStateException("content 为空")
|
?: throw IllegalStateException("content 为空")
|
||||||
|
|
||||||
val plainContent =
|
val plainContent =
|
||||||
SecurityUtil.decrypt3DES(Global.ptPassword, encryptedContent)
|
SecurityUtil.decrypt3DES( encryptedContent)
|
||||||
?.trim()
|
?.trim()
|
||||||
?.takeIf { it.isNotEmpty() }
|
?.takeIf { it.isNotEmpty() }
|
||||||
?: "{}"
|
?: "{}"
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.bbit.ticket.utils.net
|
package com.bbit.ticket.utils.net
|
||||||
|
|
||||||
|
import com.bbit.ticket.utils.bootstrap.Global
|
||||||
import java.nio.charset.Charset
|
import java.nio.charset.Charset
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import javax.crypto.Cipher
|
import javax.crypto.Cipher
|
||||||
@@ -15,9 +16,9 @@ object SecurityUtil {
|
|||||||
private const val ALGORITHM_3DES = "DESede"
|
private const val ALGORITHM_3DES = "DESede"
|
||||||
val DEFAULT_CHARSET: Charset = Charset.forName("UTF-8")
|
val DEFAULT_CHARSET: Charset = Charset.forName("UTF-8")
|
||||||
|
|
||||||
fun encrypt3DES(encryptPassword: String, encryptByte: ByteArray): ByteArray? {
|
fun encrypt3DES( encryptByte: ByteArray): ByteArray? {
|
||||||
try {
|
try {
|
||||||
val cipher = init3DES(encryptPassword, 1)
|
val cipher = init3DES(Global.ptPassword, 1)
|
||||||
val doFinal = cipher.doFinal(encryptByte)
|
val doFinal = cipher.doFinal(encryptByte)
|
||||||
return doFinal
|
return doFinal
|
||||||
} catch (var4: Exception) {
|
} catch (var4: Exception) {
|
||||||
@@ -25,9 +26,9 @@ object SecurityUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun encrypt3DES(encryptPassword: String, encryptStr: String): String? {
|
fun encrypt3DES( encryptStr: String): String? {
|
||||||
try {
|
try {
|
||||||
val cipher = init3DES(encryptPassword, 1)
|
val cipher = init3DES(Global.ptPassword, 1)
|
||||||
val enBytes = cipher.doFinal(encryptStr.toByteArray(DEFAULT_CHARSET))
|
val enBytes = cipher.doFinal(encryptStr.toByteArray(DEFAULT_CHARSET))
|
||||||
return Base64.getEncoder().encodeToString(enBytes)
|
return Base64.getEncoder().encodeToString(enBytes)
|
||||||
} catch (var4: Exception) {
|
} catch (var4: Exception) {
|
||||||
@@ -35,9 +36,9 @@ object SecurityUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun decrypt3DES(decryptPassword: String, decryptByte: ByteArray): ByteArray? {
|
fun decrypt3DES(decryptByte: ByteArray): ByteArray? {
|
||||||
try {
|
try {
|
||||||
val cipher = init3DES(decryptPassword, 2)
|
val cipher = init3DES(Global.ptPassword, 2)
|
||||||
val doFinal = cipher.doFinal(decryptByte)
|
val doFinal = cipher.doFinal(decryptByte)
|
||||||
return doFinal
|
return doFinal
|
||||||
} catch (var4: Exception) {
|
} catch (var4: Exception) {
|
||||||
@@ -45,9 +46,9 @@ object SecurityUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun decrypt3DES(decryptPassword: String, decryptString: String?): String? {
|
fun decrypt3DES(decryptString: String): String? {
|
||||||
try {
|
try {
|
||||||
val cipher = init3DES(decryptPassword, 2)
|
val cipher = init3DES(Global.ptPassword, 2)
|
||||||
val deBytes = cipher.doFinal(Base64.getDecoder().decode(decryptString))
|
val deBytes = cipher.doFinal(Base64.getDecoder().decode(decryptString))
|
||||||
return String(deBytes, DEFAULT_CHARSET)
|
return String(deBytes, DEFAULT_CHARSET)
|
||||||
} catch (var4: Exception) {
|
} catch (var4: Exception) {
|
||||||
|
|||||||
@@ -10,14 +10,14 @@ app:
|
|||||||
env: "local"
|
env: "local"
|
||||||
|
|
||||||
database:
|
database:
|
||||||
url: "jdbc:postgresql://localhost:5432/ticket"
|
url: "jdbc:postgresql://postgres:5432/ticket"
|
||||||
user: "ticket"
|
user: "ticket"
|
||||||
password: "ticket_password"
|
password: "ticket_password"
|
||||||
maximumPoolSize: 16
|
maximumPoolSize: 16
|
||||||
minimumIdle: 4
|
minimumIdle: 4
|
||||||
|
|
||||||
redis:
|
redis:
|
||||||
url: "redis://127.0.0.1:6379"
|
url: "redis://redis:6379"
|
||||||
password: "ticket_password"
|
password: "ticket_password"
|
||||||
|
|
||||||
security:
|
security:
|
||||||
|
|||||||
Reference in New Issue
Block a user