[ 
https://issues.apache.org/jira/browse/CAMEL-27035?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18146060#comment-18146060
 ] 

Karol Krawczyk commented on CAMEL-27035:
----------------------------------------

I would like to take this. All five points hold on main (8e904a3bb0f7).

1. {{OpenApiClientSupport.resolveString}} reads the header with 
{{getHeader(name, String.class)}}, so a Map reaches 
{{encodePlaintextForEncrypt}} as its {{toString()}} and is encrypted in UTF-8, 
while the same value in the body fails with an {{InvalidPayloadException}} 
since CAMEL-26258 and the 4.24 upgrade guide promises exactly that.
2. {{ObjectConverter.toInteger(String)}} is a bare {{Integer.valueOf(value)}}, 
so {{""}} and {{"abc"}} throw a NumberFormatException wrapped in a 
{{TypeConversionException}}, and {{createClientConfigurations}} resolves all 
six names for every exchange, which fails {{encrypt}} and {{decrypt}} as well.
3. The {{required = true}} of {{region}} contradicts its own description. 
{{KMSUtils.createClient}} already throws "Region or endpoint is required", so 
only the metadata and the generated catalog are wrong.
4. The catalog lists six headers and {{CamelAlibabaKmsOperation}} is not among 
them, although the producer reads it. PR 
https://github.com/apache/camel/pull/30048 for camel-alibaba-mns is the 
template.
5. {{KMSProperties}} carries seven {{@Metadata}} texts that the build never 
reads, since only {{headersClass = KMSHeaders}} is read. Inverting the two 
classes as {{MNSProperties}} now does removes them.

h3. What I am doing

* The plaintext of the header or the exchange property is rejected only when 
the text the converter gives is the {{toString()}} of the object 
({{BodyFacts.kindOf(value) != PAYLOAD && text.equals(value.toString())}}), 
which is what {{ToStringTypeConverter}}, the fallback that is never promoted, 
returns for an object no other converter reads as text. The message names the 
class and never the value, which is the plaintext. 
{{IllegalArgumentException}}, not {{InvalidPayloadException}}, since that 
exception is about the message body.
* {{numberOfBytes}} is resolved only for {{generateDataKey}}, an empty value 
counts as unset, and a value that is not a number fails with a message that 
names the header. The shared {{OpenApiClientSupport.resolveInteger}} is 
untouched: camel-alibaba-mns has the same trap in {{delaySeconds}} and 
{{priority}}, which is another component and another ticket.
* Points 4 and 5 follow https://github.com/apache/camel/pull/30048, with the 
catalog, the component page and the endpoint DSL regenerated.
* 9 tests in a new {{KMSInputTest}}, on the Mockito client of 
{{EncryptPlaintextTest}}, so no credentials are needed. With the old resolution 
restored, 5 of them fail.
* An upgrade-guide entry for 4.24: the plaintext header, the number of bytes, 
and the required marker of {{region}}.

Could you assign it to me?

_Reported by Claude Code on behalf of Karol Krawczyk_

> camel-alibaba-kms: a Map or POJO in the plaintext header is encrypted as its 
> toString(), and an invalid numberOfBytes header fails every operation
> --------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-27035
>                 URL: https://issues.apache.org/jira/browse/CAMEL-27035
>             Project: Camel
>          Issue Type: Bug
>    Affects Versions: 4.23.0
>            Reporter: Saravanakumar Selvaraj
>            Priority: Minor
>
> Follow-up to the review of https://github.com/apache/camel/pull/30139.
> 1. A Map or a POJO in the CamelAlibabaKmsPlaintext header or exchange 
> property is encrypted as its toString(), because 
> OpenApiClientSupport.resolveString reads the value as a String. The same 
> value as the message body fails with an InvalidPayloadException since 
> CAMEL-26258, and the 4.24 upgrade guide says that a toString() is no longer 
> encrypted.
> 2. An empty or non-numeric String in the CamelAlibabaKmsNumberOfBytes header 
> or exchange property fails every exchange with a TypeConversionException, 
> also for encrypt and decrypt, which do not use the value. 
> OpenApiClientSupport.resolveInteger lets only null through, and 
> KMSUtils.createClientConfigurations resolves all six names for each exchange.
> 3. region has @Metadata(required = true), but the code needs region or 
> endpoint, and neither when kmsClient is set or autowired.
> 4. KMSHeaders has no constant for CamelAlibabaKmsOperation, which the 
> producer reads like the other input headers. Only KMSProperties declares it, 
> so the header is missing from the header list of the component JSON, the 
> endpoint DSL and the doc page. https://github.com/apache/camel/pull/30048 
> closed the same gap for camel-alibaba-mns.
> 5. KMSProperties has @Metadata with texts of its own on its seven header 
> names, but the build reads only the headers class KMSHeaders. So these texts 
> are not used.
> _Claude Code on behalf of saravanakumar1987_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to