Showing posts with label Carbon. Show all posts
Showing posts with label Carbon. Show all posts

Thursday, July 9, 2015

Enable email login in WSO2 carbon products

To enable email address the below steps can be followed in any carbon product.

1. EnableEmailUserName in carbon.xml

<EnableEmailUserName>true</EnableEmailUserName>

2. Then provide the correct regex to allow email address in user store configuration in user-mgt.xml for JDBC user store
E.g.,

    <Property name="UsernameJavaRegEx">[a-
zA-Z0-9@._-|//]{3,30}$</Property>
3. Create admin user with email address in user in user-mgt.xml.

   <AdminUser>
                     <UserName>admin@wso2.com</UserName>
                     <Password>admin</Password>
  </AdminUser>
By the above configurations, it will enable email address.

If you want to give the both support, email address and username, you can include the below property in user store configuration.

4.  <Property name="
UsernameWithEmailJavaScriptRegEx">[a-zA-Z0-9@._-|//]{3,30}$</Property>
      
To know how to do this for a LDAP, refer this well explained blog post [1] done for Identity server which is applicable for other carbon products as well. This document also explains the properties [2]

Thursday, January 30, 2014

How to resolve WSO2 platform build failures come due to package does not exist

You can follow the steps on building Carbon by the link below :

http://docs.wso2.org/display/Carbon420/Building+from+Source

Following blog post is for the users who have fair knowledge in programming. Intended users will be Quality Assurance Engineers.

How to Isolate :

1. First of all, to isolate the problems you face, it is better to start building according to the modules defined in the pom.xml.

E.g.,

Open the pom.xml in ../platform/branches/turing/product-releases/chunk-07

You will see the modules defined like below.

             <modules>
                <module>dependencies</module>
                <module>service-stubs</module>
                <module>components</module>
                <module>platform-integration/test-automation-framework</module>
                <module>features</module>
                <module>products</module>
                <module>platform-integration/platform-automated-test-suite</module>
             </modules>

Build one by one by the following command.

mvn clean install --fail-at-end
fail-at-end will be used to continue the all modules bulding eventhough there is a build failure.


2. Imagine when you are building products you get an error like below.

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project sample-utils: Compilation failure: Compilation failure:
[ERROR] /home/ushani/Downloads/Automation_TC/24_Jan_2014/turing/products/bps/3.2.0/modules/samples/product/sample-utils/src/main/java/org/wso2/bps/samples/util/PasswordEncryptUtil.java:[23,31] package org.apache.axiom.om.util does not exist
[ERROR] /home/ushani/Downloads/Automation_TC/24_Jan_2014/turing/products/bps/3.2.0/modules/samples/product/sample-utils/src/main/java/org/wso2/bps/samples/util/PasswordEncryptUtil.java:[58,66] package org.bouncycastle.jce.provider does not exist
[ERROR] /home/ushani/Downloads/Automation_TC/24_Jan_2014/turing/products/bps/3.2.0/modules/samples/product/sample-utils/src/main/java/org/wso2/bps/samples/util/PasswordEncryptUtil.java:[84,35] cannot find symbol
[ERROR] symbol  : variable Base64
[ERROR] location: class org.wso2.bps.samples.util.PasswordEncryptUtil
[ERROR] -> [Help 1]
[ERROR] Failed to execute goal org.wso2.maven:carbon-p2-plugin:1.5.3:p2-repo-gen (3-p2-repo-generation) on project wso2-bps-profile-gen: Error occured when processing the Feature Artifact: org.wso2.bps:org.wso2.bps.samples.utils.feature:3.2.0: ERROR: Failure to find org.wso2.bps:org.wso2.bps.samples.utils.feature:zip:3.2.0 in http://maven.wso2.org/nexus/content/groups/wso2-public/ was cached in the local repository, resolution will not be reattempted until the update interval of wso2-nexus has elapsed or updates are forced
[ERROR]

Identify the error, the affected place and the reason :
3. If you look at it properly, you see the error is in PasswordEncryptUtil.java class.
4. So the best thing is open the project in idea. from sample-utils/src/main/java/org/wso2/bps/samples onwards.
5. you will see the class name with a red curly underline since there is an error in the class.
6. Go to the class and check what is wrong in it. As per the above error, issue was with the symbol
variable Base64
7. In the code the following line was in red, exposing it as an error.

  String encodedString = Base64.encode(encryptedText);
8. Also there was another curly line in red mentioning the following import hasnt been done correctly.
import org.apache.axiom.om.util.Base64;

Solutions :

Solution 1.
a. Either you can check in you .m2 , which is also known as the maven repository in your machine.
.m2 is a repository that is created in every one of your machine, if you have installed maven properly. Whenever you need  any dependencies, it will automatically download in to your maven repository.
You can see your maven repo at the following place :
/home/<username>/.m2

b. Go to .m2 and follow the import path correctly in the file location.
E.g.,
 You should have a folder called axiom in the following file location.

/home/ushani/.m2/repository/org/apache
c. if you don't have a folder that means the issue is because it hasn't been downloaded properly. You can get it from someone else's .m2 repo and replace you one or can check from which location it has been taken. Sometimes axiom folder can be refereed from a different location.
if so you will have to provide the dependency manually in you pom.xml located in the related module.
E.g., I had the issue in sample-utils. So I will refer the pom.xml in that module.

/home/ushani/Downloads/Automation_TC/24_Jan_2014/turing/products/bps/3.2.0/modules/samples/product/sample-utils/pom.xml.
According to this the correct axiom is inside,

path : /home/ushani/.m2/repository/org/apache/ws/commons/axiom

Add the following dependency according to the correct location.

<dependency>
            <groupId>org.apache.ws.
commons.axiom</groupId>
            <artifactId>axiom-api</
artifactId>
            <version>1.2.8</version>
        </dependency>    
<dependency>
            <groupId>org.apache.ws.
commons.axiom</groupId>
            <artifactId>axiom-impl</
artifactId>
            <version>1.2.8</version>
    </dependency>

Solution 2:
1. Go near the issue underlined in red colour and get the your curosr top of it and the help comes in the left corner of your code editor window.
It will give you suggestions.

If there is a missing maven dependency it will ask whether to add. You have to click that suggestion and provide the correct path which will come automatically.

By this it will solve the problem and that dependency will be added in to your pom.xml automatically.

Thursday, July 18, 2013

Why do we get "PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target" exception?

Most of the time we might get an issue which says the following while trying to subscribe to emails in carbon products,


 [2013-07-18 11:25:22,974] ERROR {org.apache.axis2.transport.mail.MailTransportSender} - Error creating mail message or sending it to the configured server
javax.mail.MessagingException: Can't send command to SMTP host;
  nested exception is:
        javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target


This issue is occurred when the server has got self verified certificates and client's trust store does not have it. But in gmail there is a certificate that is issued by a CA. So if you use JRE certificate store ($JREHOME/lib/security/cacerts) in the client side, this issue may not be occurred as it contains some CA's root certificates. But this certificates store can be changed by setting system property 'javax.net.ssl.trustStore'.
Sometimes this blog might help you to store this certificate.

Why do we get "Failed Sending Email org.apache.axis2.AxisFault: The system cannot infer the transport information from the mailto" issue?


Most of the time in WSO2 Carbon products, users may encounter exceptions as follow when subscribing for a particular mail response:


[2013-07-17 09:49:45,781] ERROR {org.apache.axis2.description.ClientUtils} - The system cannot infer the transport information from the mailto:<email> URL.
Failed Sending Email
org.apache.axis2.AxisFault: The system cannot infer the transport information from the mailto : <email>

 at org.apache.axis2.description.ClientUtils.inferOutTransport(ClientUtils.java:81)
        at org.apache.axis2.client.OperationClient.prepareMessageContext(OperationClient.java:288)
        at org.apache.axis2.description.OutOnlyAxisOperationClient.executeImpl(OutOnlyAxisOperation.java:249)
        at org.apache.axis2.client.OperationClient.execute(OperationClient.java:149)
        at org.apache.axis2.client.ServiceClient.fireAndForget(ServiceClient.java:511)
        at org.apache.axis2.client.ServiceClient.fireAndForget(ServiceClient.java:488)
        at org.wso2.carbon.email.verification.util.EmailSender.run(EmailSender.java:115)
[2013-07-17 09:49:46,079] DEBUG {org.wso2.carbon.user.core.authorization.JDBCAuthorizationManager} - Authorization cache entry is not found for username

The reason can be :

The reason for this issue is the AxisConfiguration which uses to send this message does not have the mail transport. In axis2.xml you have to define the transportSender as below.

<transportSender name="mailto" class="org.apache.axis2.transport.mail.MailTransportSender">
        <parameter name="mail.smtp.from">user@gmail.com</parameter>
        <parameter name="mail.smtp.user">user</parameter>
        <parameter name="mail.smtp.password">mailpassword</parameter>
        <parameter name="mail.smtp.host">smtp.gmail.com</parameter>
        <parameter name="mail.smtp.port">587</parameter>
        <parameter name="mail.smtp.starttls.enable">true</parameter>
        <parameter name="mail.smtp.auth">true</parameter>
</transportSender> 


Sometimes having an unnecessary space in between these values might also be a reason for this issue.