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