我有一台具有以下server.xml
的Websphere Liberty服务器:
<managedThreadFactory jndiName="concurrent/threadFactory" maxPriority="5" />
<openidConnectClient id="AppID"
inboundPropagation="required"
clientId="${APPID_CLIENT_ID}"
clientSecret="${APPID_CLIENT_SECRET}"
authorizationEndpointUrl="https://${APPID_HOST}/oauth/v4/${APPID_TENANT_ID}/authorization"
tokenEndpointUrl="https://${APPID_HOST}/oauth/v4/${APPID_TENANT_ID}/token"
jwkEndpointUrl="https://${APPID_HOST}/oauth/v4/${APPID_TENANT_ID}/publickeys"
issuerIdentifier="https://${APPID_HOST}/oauth/v4/${APPID_TENANT_ID}"
tokenEndpointAuthMethod="basic"
signatureAlgorithm="none"
trustAliasName="${APPID_HOST}"
trustStoreRef="appidtruststore"
audiences="${APPID_CLIENT_ID}" />
是否可以从Java应用程序代码中以编程方式读取
clientSecret="${APPID_CLIENT_SECRET}"
的解密值? 最佳答案
这取决于值的编码方式。如果将其加密,那么根据定义,就无法轻松对其进行解密(否则将破坏加密的目的)。
如果您只是在进行可逆编码(例如XOR或AES),则可以使用Liberty功能对其进行解密。
首先,请确保在server.xml中启用了以下功能:
<feature>passwordUtilities-1.0</feature>
然后,您可以使用
com.ibm.websphere.crypto.PasswordUtil
API对其进行解码,如下所示:String rawValue = // get from System properties or env var
String decodedValue = PasswordUtil.decode(rawValue);
关于java - 以编程方式从server.xml读取解密的值,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/58219079/