You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "Brendle, Detlef" <de...@prospective.ch> on 2016/01/07 12:38:21 UTC
org.apache.camel.InvalidPayloadException after adding a
@PreAuthorized Annotation to service method
Hi all,
I am facing an issue that I dont know how to solve.
For Security Reasons I needed to secure a service method that is also
called from a camel route.
<route id="mail.standard.async">
<from uri="direct:sendMailStandardAsync"/>
<bean ref="mailService" method="prepareMailHeader"/>
<to uri="velocity://dummy"/>
<wireTap uri="direct:sendMailStandardSync"/>
<transform>
<constant>OK</constant>
</transform>
</route>
@PreAuthorize("hasRole('" + BerechtigungName.ROLE_USER + "')")
public void sendMailStandardAsync(*MailInfo* mailInfo) {
LOG.info("Sending email to [{}]", mailInfo.getTo());
template.sendBody("direct:sendMailStandardAsync", mailInfo);
}
But now If the route is called I get an Exception:
*No type converter available to convert from type:
ch.prospective.njc.integration.mail.service.MailInfo to the required
type: java.util.Map with value MailInfo*
If I remove the Annotation again, everything works fine. So I assume that
somehow the annotation becomes part of the camel treatment.
Does anybody know how to solve this issue ?
Thanks,
Detlef
Re: org.apache.camel.InvalidPayloadException after adding a
@PreAuthorized Annotation to service method
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
How do you call that bean method - sendMailStandardAsync ?
Do you call it from another route or some java bean?
And is there more in the stacktrace? I wonder what that Map contains? I can
only assume spring do some proxy stuff and change the method parameters or
something.
If you can setup a sample project on github, then I can use that to debug.
Maybe we can detect this spring proxy stuff and unwrap the parameter from
the map and call the method with the right parameters.
On Thu, Jan 7, 2016 at 12:46 PM, Brendle, Detlef <
detlef.brendle@prospective.ch> wrote:
> PreAuthorize is a security annotation from Spring.
>
> org.springframework.security.access.prepost.PreAuthorize
>
> @Target({ ElementType.METHOD, ElementType.TYPE })
> @Retention(RetentionPolicy.RUNTIME)
> @Inherited
> @Documented
> public @interface PreAuthorize {
> /**
> * @return the Spring-EL expression to be evaluated before invoking the protected
> * method
> */
> String value();
> }
>
>
>
> 2016-01-07 12:42 GMT+01:00 Claus Ibsen <cl...@gmail.com>:
>
>> Maybe the annotations creates some kind of proxy object that has a
>> method signature with a different type than the method itself.
>>
>> Where is that @PreAuthorize coming from?
>>
>> On Thu, Jan 7, 2016 at 12:38 PM, Brendle, Detlef
>> <de...@prospective.ch> wrote:
>> > Hi all,
>> >
>> > I am facing an issue that I dont know how to solve.
>> > For Security Reasons I needed to secure a service method that is also
>> > called from a camel route.
>> >
>> > <route id="mail.standard.async">
>> > <from uri="direct:sendMailStandardAsync"/>
>> > <bean ref="mailService" method="prepareMailHeader"/>
>> > <to uri="velocity://dummy"/>
>> > <wireTap uri="direct:sendMailStandardSync"/>
>> > <transform>
>> > <constant>OK</constant>
>> > </transform>
>> > </route>
>> >
>> >
>> >
>> > @PreAuthorize("hasRole('" + BerechtigungName.ROLE_USER + "')")
>> > public void sendMailStandardAsync(*MailInfo* mailInfo) {
>> > LOG.info("Sending email to [{}]", mailInfo.getTo());
>> > template.sendBody("direct:sendMailStandardAsync", mailInfo);
>> > }
>> >
>> > But now If the route is called I get an Exception:
>> >
>> > *No type converter available to convert from type:
>> > ch.prospective.njc.integration.mail.service.MailInfo to the required
>> > type: java.util.Map with value MailInfo*
>> >
>> >
>> > If I remove the Annotation again, everything works fine. So I assume
>> that
>> > somehow the annotation becomes part of the camel treatment.
>> >
>> > Does anybody know how to solve this issue ?
>> >
>> >
>> > Thanks,
>> > Detlef
>>
>>
>>
>> --
>> Claus Ibsen
>> -----------------
>> http://davsclaus.com @davsclaus
>> Camel in Action 2: https://www.manning.com/ibsen2
>>
>
>
>
> --
>
> Prospective Media Services
>
> Hofackerstrasse 32
>
> CH-8032 Zürich
>
>
>
> Phone +41 44 384 55 19
>
> detlef.brendle@prospective.ch <in...@prospective.ch>
>
> www.prospective.ch
>
> blog.prospective.ch
>
>
> [image: Inline-Bild 1] <http://blog.prospective.ch/> [image: Inline-Bild
> 8] <http://www.facebook.com/ProspectiveMedia> [image: Inline-Bild 7]
> <https://plus.google.com/b/110350987305707874053/?tab=XX#110350987305707874053/posts>
> [image: Inline-Bild 5] <http://twitter.com/ProspectiveAG> [image:
> Inline-Bild 3] <http://www.xing.com/companies/prospectivemediaservicesag>
> [image: Inline-Bild 4]
> <http://www.linkedin.com/company/prospective-media-services-ag> [image:
> Inline-Bild 6]
> <http://www.kununu.com/ch/zh/zuerich/me/prospective-media-services> [image:
> Inline-Bild 10] <http://www.youtube.com/prospectivemedia/> [image:
> Inline-Bild 9] <http://www.flickr.com/photos/prospectivemedia/> [image:
> Inline-Bild 2] <http://www.prospective.ch/news/rss/index.xml>
>
> PROSPECTIVE – FÜR UMFASSENDE RECRUITING-SOLUTIONS
>
--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2
Re: org.apache.camel.InvalidPayloadException after adding a
@PreAuthorized Annotation to service method
Posted by "Brendle, Detlef" <de...@prospective.ch>.
PreAuthorize is a security annotation from Spring.
org.springframework.security.access.prepost.PreAuthorize
@Target({ ElementType.METHOD, ElementType.TYPE })
@Retention(RetentionPolicy.RUNTIME)
@Inherited
@Documented
public @interface PreAuthorize {
/**
* @return the Spring-EL expression to be evaluated before invoking
the protected
* method
*/
String value();
}
2016-01-07 12:42 GMT+01:00 Claus Ibsen <cl...@gmail.com>:
> Maybe the annotations creates some kind of proxy object that has a
> method signature with a different type than the method itself.
>
> Where is that @PreAuthorize coming from?
>
> On Thu, Jan 7, 2016 at 12:38 PM, Brendle, Detlef
> <de...@prospective.ch> wrote:
> > Hi all,
> >
> > I am facing an issue that I dont know how to solve.
> > For Security Reasons I needed to secure a service method that is also
> > called from a camel route.
> >
> > <route id="mail.standard.async">
> > <from uri="direct:sendMailStandardAsync"/>
> > <bean ref="mailService" method="prepareMailHeader"/>
> > <to uri="velocity://dummy"/>
> > <wireTap uri="direct:sendMailStandardSync"/>
> > <transform>
> > <constant>OK</constant>
> > </transform>
> > </route>
> >
> >
> >
> > @PreAuthorize("hasRole('" + BerechtigungName.ROLE_USER + "')")
> > public void sendMailStandardAsync(*MailInfo* mailInfo) {
> > LOG.info("Sending email to [{}]", mailInfo.getTo());
> > template.sendBody("direct:sendMailStandardAsync", mailInfo);
> > }
> >
> > But now If the route is called I get an Exception:
> >
> > *No type converter available to convert from type:
> > ch.prospective.njc.integration.mail.service.MailInfo to the required
> > type: java.util.Map with value MailInfo*
> >
> >
> > If I remove the Annotation again, everything works fine. So I assume that
> > somehow the annotation becomes part of the camel treatment.
> >
> > Does anybody know how to solve this issue ?
> >
> >
> > Thanks,
> > Detlef
>
>
>
> --
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2
>
--
Prospective Media Services
Hofackerstrasse 32
CH-8032 Zürich
Phone +41 44 384 55 19
detlef.brendle@prospective.ch <in...@prospective.ch>
www.prospective.ch
blog.prospective.ch
[image: Inline-Bild 1] <http://blog.prospective.ch/> [image: Inline-Bild 8]
<http://www.facebook.com/ProspectiveMedia> [image: Inline-Bild 7]
<https://plus.google.com/b/110350987305707874053/?tab=XX#110350987305707874053/posts>
[image: Inline-Bild 5] <http://twitter.com/ProspectiveAG> [image:
Inline-Bild 3] <http://www.xing.com/companies/prospectivemediaservicesag>
[image:
Inline-Bild 4]
<http://www.linkedin.com/company/prospective-media-services-ag> [image:
Inline-Bild 6]
<http://www.kununu.com/ch/zh/zuerich/me/prospective-media-services> [image:
Inline-Bild 10] <http://www.youtube.com/prospectivemedia/> [image:
Inline-Bild 9] <http://www.flickr.com/photos/prospectivemedia/> [image:
Inline-Bild 2] <http://www.prospective.ch/news/rss/index.xml>
PROSPECTIVE – FÜR UMFASSENDE RECRUITING-SOLUTIONS
Re: org.apache.camel.InvalidPayloadException after adding a
@PreAuthorized Annotation to service method
Posted by Claus Ibsen <cl...@gmail.com>.
Maybe the annotations creates some kind of proxy object that has a
method signature with a different type than the method itself.
Where is that @PreAuthorize coming from?
On Thu, Jan 7, 2016 at 12:38 PM, Brendle, Detlef
<de...@prospective.ch> wrote:
> Hi all,
>
> I am facing an issue that I dont know how to solve.
> For Security Reasons I needed to secure a service method that is also
> called from a camel route.
>
> <route id="mail.standard.async">
> <from uri="direct:sendMailStandardAsync"/>
> <bean ref="mailService" method="prepareMailHeader"/>
> <to uri="velocity://dummy"/>
> <wireTap uri="direct:sendMailStandardSync"/>
> <transform>
> <constant>OK</constant>
> </transform>
> </route>
>
>
>
> @PreAuthorize("hasRole('" + BerechtigungName.ROLE_USER + "')")
> public void sendMailStandardAsync(*MailInfo* mailInfo) {
> LOG.info("Sending email to [{}]", mailInfo.getTo());
> template.sendBody("direct:sendMailStandardAsync", mailInfo);
> }
>
> But now If the route is called I get an Exception:
>
> *No type converter available to convert from type:
> ch.prospective.njc.integration.mail.service.MailInfo to the required
> type: java.util.Map with value MailInfo*
>
>
> If I remove the Annotation again, everything works fine. So I assume that
> somehow the annotation becomes part of the camel treatment.
>
> Does anybody know how to solve this issue ?
>
>
> Thanks,
> Detlef
--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2