wso2 / product-is

Welcome to the WSO2 Identity Server source code! For info on working with the WSO2 Identity Server repository and contributing code, click the link below.
http://wso2.github.io/
Apache License 2.0
746 stars 724 forks source link

A password containing special characters under the config output_adapter.email.password causes the server to fail with an exception #10455

Closed yasinmiran closed 3 years ago

yasinmiran commented 3 years ago

Describe the issue:

Server won't start after setting a custom password under the [output_adapter.email] configuration in deployment.toml file. It only occurs when the password contains the special character & (ASCII = 38).

Server Stack Trace

[2020-11-11 12:28:39,553] [] ERROR {org.wso2.carbon.event.output.adapter.core} - [SCR] Exception occurred while unbinding reference Reference[name = output.event.adapter.tracker.service, interface = org.wso2.carbon.event.output.adapter.core.OutputEventAdapterFactory, policy = dynamic, cardinality = 0..n, target = null, bind = setEventAdapterType, unbind = unSetEventAdapterType]
    Details:
    Problematic reference = Reference[name = output.event.adapter.tracker.service, interface = org.wso2.carbon.event.output.adapter.core.OutputEventAdapterFactory, policy = dynamic, cardinality = 0..n, target = null, bind = setEventAdapterType, unbind = unSetEventAdapterType]
    of service component = event.output.adapter.service
    component implementation class = org.wso2.carbon.event.output.adapter.core.internal.ds.OutputEventAdapterServiceDS
    located in bundle with symbolic name = org.wso2.carbon.event.output.adapter.core
    bundle location = reference:file:../plugins/org.wso2.carbon.event.output.adapter.core_5.2.27.jar java.lang.reflect.InvocationTargetException
    at sun.reflect.GeneratedMethodAccessor21.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.eclipse.equinox.internal.ds.model.ComponentReference.unbind(ComponentReference.java:476)
    at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.unbindReference(ServiceComponentProp.java:617)
    at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.unbind(ServiceComponentProp.java:262)
    at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.build(ServiceComponentProp.java:350)
    at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponent(InstanceProcess.java:620)
    at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:197)
    at org.eclipse.equinox.internal.ds.Resolver.buildNewlySatisfied(Resolver.java:473)
    at org.eclipse.equinox.internal.ds.Resolver.enableComponents(Resolver.java:217)
    at org.eclipse.equinox.internal.ds.SCRManager.performWork(SCRManager.java:816)
    at org.eclipse.equinox.internal.ds.SCRManager$QueuedJob.dispatch(SCRManager.java:783)
    at org.eclipse.equinox.internal.ds.WorkThread.run(WorkThread.java:89)
    at org.eclipse.equinox.internal.util.impl.tpt.threadpool.Executor.run(Executor.java:70)
Caused by: java.lang.NullPointerException
    at org.wso2.carbon.event.output.adapter.core.internal.ds.OutputEventAdapterServiceDS.unSetEventAdapterType(OutputEventAdapterServiceDS.java:111)
    ... 15 more

Logs After the Exception is Thrown Multiple Times

Server keeps on logging the following warning for a long time and never spin up the console.

[2020-11-11 13:42:25,711] []  WARN {org.wso2.carbon.core.init.CarbonServerManager} - Carbon initialization is delayed due to the following unsatisfied items:
[2020-11-11 13:42:25,712] []  WARN {org.wso2.carbon.core.init.CarbonServerManager} - Waiting for required OSGi Service: org.wso2.carbon.event.publisher.core.EventPublisherService
[2020-11-11 13:42:25,713] []  WARN {org.wso2.carbon.core.init.CarbonServerManager} - Waiting for required OSGi Service: org.wso2.carbon.humantask.core.HumanTaskEngineService

How to reproduce:

Add the following properties to the deployment.toml file in the IS_HOME/repository/conf folder to configure a custom email server and try to start the server.

[output_adapter.email]
from_address= "myusername@gmail.com"
username= "myusername"
password= "my_password_&" <-- add '&' character into a password
hostname= "smtp.gmail.com"

Expected behavior:

When setting up a password for the email client, the configuration should allow to include a password containing all the minimal special ASCII characters !@#$%^&*

Environment information:

somindatommy commented 3 years ago

The reason for this is, having special characters will create issues in the XML. Using CDATA will resolve the issue.

[output_adapter.email]
from_address= "wso2iamtest@gmail.com"
username= "wso2iamtest"
password= "<![CDATA[wso2_iam123_&]]>"
hostname= "smtp.gmail.com"