Skip to content

Commit

Permalink
Fix mobile grant issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
mpmadhavig committed Apr 25, 2024
1 parent 2d35c7a commit b7082d3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import org.wso2.carbon.utils.multitenancy.MultitenantUtils;

import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
* New grant type for Identity Server
Expand Down Expand Up @@ -158,22 +160,21 @@ public boolean validateScope(OAuthTokenReqMessageContext tokReqMsgCtx)


/**
* TODO
*
* You need to implement how to validate the mobile number
*
* @param mobileNumber
* @return
* @param mobileNumber Mobile number of the user.
* @return true if the mobile number is valid, otherwise false.
*/
private boolean isValidMobileNumber(String mobileNumber){

// just demo validation

if(mobileNumber.startsWith("033")){
return true;
}

return false;
// Regular expression to match 10 digits, with optional country code
String pattern = "^(\\+\\d{1,3})?\\d{10}$";
// Create a Pattern object
Pattern r = Pattern.compile(pattern);
// Create Matcher object
Matcher m = r.matcher(mobileNumber);
// Check if the pattern matches
return m.matches();
}

@Override
Expand Down
16 changes: 14 additions & 2 deletions sample-outbound-connector/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
<repository>
<id>wso2-nexus</id>
<name>WSO2 internal Repository</name>
<url>http://maven.wso2.org/nexus/content/groups/wso2-public/</url>
<url>https://maven.wso2.org/nexus/content/groups/wso2-public/</url>
<releases>
<enabled>true</enabled>
<updatePolicy>daily</updatePolicy>
Expand All @@ -142,13 +142,25 @@
<repository>
<id>wso2.releases</id>
<name>WSO2 internal Repository</name>
<url>http://maven.wso2.org/nexus/content/repositories/releases/</url>
<url>https://maven.wso2.org/nexus/content/repositories/releases/</url>
<releases>
<enabled>true</enabled>
<updatePolicy>daily</updatePolicy>
<checksumPolicy>ignore</checksumPolicy>
</releases>
</repository>
<repository>
<id>wso2.snapshots</id>
<name>Apache Snapshot Repository</name>
<url>https://maven.wso2.org/nexus/content/repositories/snapshots/</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>daily</updatePolicy>
</snapshots>
<releases>
<enabled>false</enabled>
</releases>
</repository>
</repositories>

<properties>
Expand Down

0 comments on commit b7082d3

Please sign in to comment.