TIBCO BW Tutorial How to Perform Password Strength Regular Expression Validations Using Custom Java Code

There are scenarios where we need to validate a password string in our TIBCO BW based services and such validations might be based on certain criteria which needs regular expressions to perform the validation of the complexity of the password. In this TIBCO BW Tutorial, I will explain how to perform password complexity or password strength validation checks in TIBCO BW process using Custom Java Code.

Password Strength or Complexity Check Using Java Code in TIBCO BW

For our example scenario we want to ensure that password string coming as an input to our process meets below criteria:

* Length of the Password should be minimum 8 and maximum 12 characters.

* Password should contain at-least one Upper case character.

* Password should contain at-least one lower case character.

* Password should contain at-least one special character.

We will use java.util.regex package provided by Java for pattern matching with regular expressions. We will utilize Pattern Class and Matcher Class from this Java package in order to validate password against our defined regular expression.

We create a simple process as below which takes a String password as input and then we will have a Java Code activity where we will take this password as input and validate it against below regular expression:

((?=.*[a-z])(?=.*\\d)(?=.*[A-Z])(?=.*[@#$%!]).{8,12})

Java Code Activity has one input Parameter with the name in_password and a boolean output parameter with the name isValid as shown below:

Below is the complete Code for Java Code Palette with regular expression logic written in the invoke method:

package Test.ValidatePassword;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class ValidatePasswordValidatetPassword{
private static final String PASSWORD_PATTERN = "((?=.*[a-z])(?=.*\\d)(?=.*[A-Z])(?=.*[@#$%!]).{8,12})";
private Pattern pattern;
private Matcher matcher;
 
/****** START SET/GET METHOD, DO NOT MODIFY *****/
protected String in_password = "";
protected boolean isValid = false;
public String getin_password() {
return in_password;
}
public void setin_password(String val) {
in_password = val;
}
public boolean getisValid() {
return isValid;
}
public void setisValid(boolean val) {
isValid = val;
}
/****** END SET/GET METHOD, DO NOT MODIFY *****/
public ValidatePasswordValidatetPassword() {
}
public void invoke() throws Exception {
/* Available Variables: DO NOT MODIFY
In : String in_password
Out : boolean isValid
* Available Variables: DO NOT MODIFY *****/
 
pattern = Pattern.compile(PASSWORD_PATTERN);
matcher = pattern.matcher(in_password);
isValid= matcher.matches();
}
}

Now if you test this process with inputs of different values you will get isValid as true only if your input meets the validation requirements specified in the regular expression.

Hope this post is helpful for you and feel free to comment below if you have any questions.

Ajmal Abbasi

Ajmal Hussain Abbasi is Integration Consultant By Profession with 13+ years experience in Integration domain mainly with TIBCO products. He has extensive practical knowledge of TIBCO Business Works, TIBCO Cloud, TIBCO Flogo, TIBCO Mashery, TIBCO Spotfire, EMS and TIBCO ActiveSpaces. He has worked on a number of highly critical integration projects in various sectors by using his skills in TIBCO Flogo, TIBCO API Management (Mashery), TCI, Tibco Designer, TIBCO Business Studio, Adapters, TIBCO EMS, RV, Administrator, TIBCO BE, TIBCO ActiveSpaces etc. Ajmal Abbasi has experience with MuleSoft ESB as well. Ajmal Abbasi is also experienced in the area of API Management particularly with WSO2 API management platforms. Ajmal Abbasi is also experienced in developing solutions using Core Java and J2EE Technologies. You can contact Ajmal Abbasi for Consultancy, Technical Assistance and Technical Discussions.

More Posts - Website - Facebook - LinkedIn - YouTube

Leave a Reply

Your email address will not be published. Required fields are marked *