CAS 6.5.5 Local address contains illegal character, sending email notification

17 views
Skip to first unread message

Benito José Cuesta Viera

unread,
Jul 13, 2022, 12:49:25 PM7/13/22
to CAS Community
Hi,

I'm using surrogate authentication and its ok, but I need send an email when an surrogate authentication occurs. My configuration is:

# Surrogate email settings
cas.authn.surrogate.mail.attribute-name=email
cas.authn.surrogate.mail.from=x...@myorg.com
cas.authn.surrogate.mail.subject=Prueba
cas.authn.surrogate.mail.text=Texto
cas.authn.surrogate.mail.validate-addresses=false
# Email Server
spring.mail.host=relay.myorg.com
spring.mail.port=25
spring.mail.testConnection=true
spring.mail.properties.mail.smtp.auth=false
spring.mail.properties.mail.smtp.starttls.enable=false

The test connection is ok, but when a surrogate authentication occurs, the email is not sended and the log is:

2022-07-13 08:38:34,898 ERROR [org.apereo.cas.notifications.DefaultCommunicationsManager] - <Local address contains illegal character>
javax.mail.internet.AddressException: Local address contains illegal character
        at javax.mail.internet.InternetAddress.checkAddress(InternetAddress.java:1346) ~[jakarta.mail-1.6.7.jar!/:1.6.7]
        at javax.mail.internet.InternetAddress.parse(InternetAddress.java:1191) ~[jakarta.mail-1.6.7.jar!/:1.6.7]
        at javax.mail.internet.InternetAddress.parse(InternetAddress.java:728) ~[jakarta.mail-1.6.7.jar!/:1.6.7]
        at javax.mail.internet.InternetAddress.parse(InternetAddress.java:705) ~[jakarta.mail-1.6.7.jar!/:1.6.7]
        at org.springframework.mail.javamail.MimeMessageHelper.parseAddress(MimeMessageHelper.java:735) ~[spring-context-support-5.3.19.jar!/:5.3.19]
        at org.springframework.mail.javamail.MimeMessageHelper.setTo(MimeMessageHelper.java:614) ~[spring-context-support-5.3.19.jar!/:5.3.19]
        at org.apereo.cas.notifications.DefaultCommunicationsManager.email(DefaultCommunicationsManager.java:87) ~[cas-server-core-notifications-6.5.5.jar!/:6.5.5]
        at org.apereo.cas.authentication.event.DefaultSurrogateAuthenticationEventListener.notify(DefaultSurrogateAuthenticationEventListener.java:68) ~[cas-server-support-surrogate-authentication-6.5.5.jar!/:6.5.5]
        at org.apereo.cas.authentication.event.DefaultSurrogateAuthenticationEventListener.handleSurrogateAuthenticationSuccessEvent(DefaultSurrogateAuthenticationEventListener.java:37) ~[cas-server-support-surrogate-authentication-6.5.5.jar!/:6.5.5]
        at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
        at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
        at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
        at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
        at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344) ~[spring-aop-5.3.19.jar!/:5.3.19]
        at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198) ~[spring-aop-5.3.19.jar!/:5.3.19]
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-5.3.19.jar!/:5.3.19]
        at org.springframework.aop.interceptor.AsyncExecutionInterceptor.lambda$invoke$0(AsyncExecutionInterceptor.java:115) ~[spring-aop-5.3.19.jar!/:5.3.19]
        at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[?:?]
        at java.lang.Thread.run(Thread.java:829) [?:?]


Analizing the problem, and activating de trace logging level, I see this log:

TRACE [org.apereo.cas.notifications.DefaultCommunicationsManager] - <Attempting to send email [Texto] to [[x...@myorg.com]]>


You can see that the email value is not "x...@myorg.com" but "[x...@myorg.com]" (with brackets). The brackets cause that the eclipse-ee4j mail library fails in the method "checkAddress", exactly in this line.

Then, the real problem is that CAS get the email parameter in this line, and convert to String sending the internal brackets. I saw that the brackets are in all attributes, and they are not send to the client except for multivaluated attributes, but the notification module is sending email value with brackets.

Am I the only one this happens to? Does anyone know how to fix it, or is it a bug?

Thanks!!
Reply all
Reply to author
Forward
0 new messages