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
[email protected]
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 [[[email protected]]]>


You can see that the email value is not "[email protected]" but 
"[[email protected]]" (with brackets). The brackets cause that the eclipse-ee4j 
mail library fails in the method "checkAddress", exactly in this line 
<https://github.com/eclipse-ee4j/mail/blob/33c67452393344c7e761242a26fb8f04f993d830/mail/src/main/java/javax/mail/internet/InternetAddress.java#L1347>
.

Then, the real problem is that CAS get the email parameter in this line 
<https://github.com/apereo/cas/blob/b5ea9fdca0664300a5b85e59bb1f7d5e40a01368/core/cas-server-core-notifications/src/main/java/org/apereo/cas/notifications/DefaultCommunicationsManager.java#L87>,
 
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!!

-- 
- Website: https://apereo.github.io/cas
- Gitter Chatroom: https://gitter.im/apereo/cas
- List Guidelines: https://goo.gl/1VRrw7
- Contributions: https://goo.gl/mh7qDG
--- 
You received this message because you are subscribed to the Google Groups "CAS 
Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/a/apereo.org/d/msgid/cas-user/791daf0e-52f4-44ac-af5e-2bd2aaede053n%40apereo.org.

Reply via email to