diff --git a/.gitignore b/.gitignore index 9901bfb1a..00b99da36 100644 --- a/.gitignore +++ b/.gitignore @@ -25,4 +25,6 @@ target *pom.xml.next *pom.xml.tag *release.properties -*.DS_STORE \ No newline at end of file +*.DS_STORE + +dependency-reduced-pom.xml diff --git a/components/api-invocation-handler/pom.xml b/components/api-invocation-handler/pom.xml index 464beae82..391a8147c 100644 --- a/components/api-invocation-handler/pom.xml +++ b/components/api-invocation-handler/pom.xml @@ -4,7 +4,7 @@ com.wso2telco.dep component-dep - 3.0.2-SNAPSHOT + 3.0.4-SNAPSHOT ../../pom.xml diff --git a/components/apim-loghandler/pom.xml b/components/apim-loghandler/pom.xml index 454487ad3..6e96e8d6a 100644 --- a/components/apim-loghandler/pom.xml +++ b/components/apim-loghandler/pom.xml @@ -4,7 +4,7 @@ com.wso2telco.dep component-dep - 3.0.2-SNAPSHOT + 3.0.4-SNAPSHOT ../../pom.xml diff --git a/components/billing/billing-extension/pom.xml b/components/billing/billing-extension/pom.xml index ef2169de8..1366154e9 100644 --- a/components/billing/billing-extension/pom.xml +++ b/components/billing/billing-extension/pom.xml @@ -4,7 +4,7 @@ com.wso2telco.dep component-dep - 3.0.2-SNAPSHOT + 3.0.4-SNAPSHOT ../../../pom.xml diff --git a/components/billing/billing-service/pom.xml b/components/billing/billing-service/pom.xml index fdf973aea..ae62135ca 100644 --- a/components/billing/billing-service/pom.xml +++ b/components/billing/billing-service/pom.xml @@ -4,7 +4,7 @@ com.wso2telco.dep component-dep - 3.0.2-SNAPSHOT + 3.0.4-SNAPSHOT ../../../pom.xml diff --git a/components/ipvalidate-handler/pom.xml b/components/ipvalidate-handler/pom.xml new file mode 100644 index 000000000..ccf8e89f6 --- /dev/null +++ b/components/ipvalidate-handler/pom.xml @@ -0,0 +1,102 @@ + + + + 4.0.0 + + com.wso2telco.dep + component-dep + 3.0.4-SNAPSHOT + ../../pom.xml + + + ipvalidate-handler + bundle + ipvalidate-handler + 3.0.4-SNAPSHOT + http://maven.apache.org + + UTF-8 + + + + org.apache.synapse + synapse-core + + + org.wso2.carbon.apimgt + org.wso2.carbon.apimgt.gateway + + + org.wso2.carbon.apimgt + org.wso2.carbon.apimgt.gateway + + + com.wso2telco.core + dbutils + + + javax.cache + cache-api + 1.0.0 + + + + junit + junit + 3.8.1 + test + + + + + + + + org.apache.felix + maven-scr-plugin + 1.7.2 + + + generate-scr-scrdescriptor + + scr + + + + + + org.apache.felix + maven-bundle-plugin + true + 2.3.5 + + NONE + + ${project.groupId}.${project.artifactId} + ${project.artifactId} + + com.wso2telco.dep.ipvalidate.handler.* + + + *;resolution:=optional + + + scribe;scope=compile|runtime;inline=false; + + * + UIBundle + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 8 + 8 + + + + + diff --git a/components/ipvalidate-handler/src/main/java/com/wso2telco/dep/ipvalidate/handler/IPValidateHandler.java b/components/ipvalidate-handler/src/main/java/com/wso2telco/dep/ipvalidate/handler/IPValidateHandler.java new file mode 100644 index 000000000..b97a0d480 --- /dev/null +++ b/components/ipvalidate-handler/src/main/java/com/wso2telco/dep/ipvalidate/handler/IPValidateHandler.java @@ -0,0 +1,176 @@ +package com.wso2telco.dep.ipvalidate.handler; + +import java.util.Map; + +import org.apache.axis2.AxisFault; +import org.apache.axis2.Constants; +import org.apache.commons.httpclient.HttpStatus; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.http.HttpHeaders; +import org.apache.synapse.Mediator; +import org.apache.synapse.MessageContext; +import org.apache.synapse.SynapseConstants; +import org.apache.synapse.core.axis2.Axis2MessageContext; +import org.apache.synapse.transport.passthru.PassThroughConstants; +import org.apache.synapse.transport.passthru.util.RelayUtils; +import org.wso2.carbon.apimgt.gateway.handlers.security.APIAuthenticationHandler; +import org.wso2.carbon.apimgt.gateway.handlers.security.APISecurityConstants; +import org.wso2.carbon.apimgt.gateway.handlers.security.APISecurityException; + +import com.wso2telco.dep.ipvalidate.handler.validation.ClientValidator; +import com.wso2telco.dep.ipvalidate.handler.validation.configuration.IPValidationProperties; +import com.wso2telco.dep.ipvalidate.handler.validation.dto.RequestData; +import com.wso2telco.dep.ipvalidate.handler.validation.impl.ClientValidatorImpl; +import com.wso2telco.dep.ipvalidate.handler.validation.service.ValidationCacheService; + +public class IPValidateHandler extends APIAuthenticationHandler { + + private static final Log log = LogFactory.getLog(IPValidateHandler.class); + private ClientValidator clientvalidator = null; + + public boolean handleRequest(MessageContext messageContext) { + log.debug("Request received : " + messageContext); + + try { + + Map headers = getTransportHeaders(messageContext); + log.debug("headers : " + headers); + RequestData requestData = new RequestData(); + + requestData.setClientkey(getClientKey(messageContext)); + requestData.setHostip(getHostIP(headers)); + + if (IPValidationProperties.isCustomValidationEnabled()) { + clientvalidator = new ClientValidatorImpl(); + if (clientvalidator.validateRequest(requestData)) { + ValidationCacheService validationCacheService = new ValidationCacheService(); + String clientToken = validationCacheService.getTokenfromCache(requestData.getClientkey()); + if (clientToken != null) { + setTokentoContext(messageContext, clientToken); + } else { + throw new APISecurityException(IPValidationProperties.getValidationFalidErrCode(), + IPValidationProperties.getValidationFalidErrMsg()); + } + } else { + throw new APISecurityException(IPValidationProperties.getInvalidHostErrCode(), + IPValidationProperties.getInvalidHostErrMsg()); + } + } + return super.handleRequest(messageContext); + } catch (APISecurityException e) { + log.error("Error : " + e); + handleIPValidateFailure(messageContext, e); + return false; + } + } + + private Map getTransportHeaders(MessageContext messageContext) { + return (Map) ((Axis2MessageContext) messageContext).getAxis2MessageContext() + .getProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS); + } + + private String getHostIP(Map headers) { + String hostIp = null; + + if (headers.get(IPValidationProperties.getIpHeaderName()) != null) { + hostIp = String.valueOf(headers.get(IPValidationProperties.getIpHeaderName())).split(",")[0]; + } else if (headers.get(IPValidationProperties.getHostHeaderName()) != null) { + hostIp = String.valueOf(headers.get(IPValidationProperties.getHostHeaderName())).split(":")[0]; + } + return hostIp; + } + + private String getClientKey(MessageContext messageContext) throws APISecurityException + { + String clientKey = null; + + try + { + String urlPath = messageContext.getTo().toString().split("[?]")[1]; + String keyParam = urlPath.split("=")[0]; + if(keyParam.equalsIgnoreCase(IPValidationProperties.getClientKeyParamName())) + { + clientKey = urlPath.split("=")[1]; + } else + { + log.error("Invalid query parameter "); + throw new APISecurityException(IPValidationProperties.getValidationFalidErrCode(), + IPValidationProperties.getValidationFalidErrMsg()); + } + } + catch(Exception e) + { + log.error("Error occurred while geting client key " + e); + throw new APISecurityException(IPValidationProperties.getValidationFalidErrCode(), + IPValidationProperties.getValidationFalidErrMsg()); + } + return clientKey; + } + + private void handleIPValidateFailure(MessageContext messageContext, APISecurityException e) { + messageContext.setProperty(SynapseConstants.ERROR_CODE, e.getErrorCode()); + messageContext.setProperty(SynapseConstants.ERROR_MESSAGE, + APISecurityConstants.getAuthenticationFailureMessage(e.getErrorCode())); + messageContext.setProperty(SynapseConstants.ERROR_EXCEPTION, e); + + Mediator sequence = messageContext.getSequence(APISecurityConstants.API_AUTH_FAILURE_HANDLER); + // Invoke the custom error handler specified by the user + if (sequence != null && !sequence.mediate(messageContext)) { + // If needed user should be able to prevent the rest of the fault handling + // logic from getting executed + return; + } + // By default we send a 401 response back + org.apache.axis2.context.MessageContext axis2MC = ((Axis2MessageContext) messageContext). + getAxis2MessageContext(); + // This property need to be set to avoid sending the content in pass-through pipe (request message) + // as the response. + axis2MC.setProperty(PassThroughConstants.MESSAGE_BUILDER_INVOKED, Boolean.TRUE); + try { + RelayUtils.consumeAndDiscardMessage(axis2MC); + } catch (AxisFault axisFault) { + //In case of an error it is logged and the process is continued because we're setting a fault message in the payload. + log.error("Error occurred while consuming and discarding the message", axisFault); + } + axis2MC.setProperty(Constants.Configuration.MESSAGE_TYPE, "application/soap+xml"); + int status; + if (e.getErrorCode() == APISecurityConstants.API_AUTH_GENERAL_ERROR) { + status = HttpStatus.SC_INTERNAL_SERVER_ERROR; + } else if (e.getErrorCode() == APISecurityConstants.API_AUTH_INCORRECT_API_RESOURCE || + e.getErrorCode() == APISecurityConstants.API_AUTH_FORBIDDEN || + e.getErrorCode() == APISecurityConstants.INVALID_SCOPE) { + status = HttpStatus.SC_FORBIDDEN; + } else { + status = HttpStatus.SC_UNAUTHORIZED; + Map headers = + (Map) axis2MC.getProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS); + if (headers != null) { + headers.put(HttpHeaders.WWW_AUTHENTICATE, getAuthenticator().getChallengeString() + + ", error=\"invalid token\"" + + ", error_description=\"The access token expired\""); + axis2MC.setProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS, headers); + } + } + + if (messageContext.isDoingPOX() || messageContext.isDoingGET()) { + setFaultPayload(messageContext, e); + } else { + setSOAPFault(messageContext, e); + } + sendFault(messageContext, status); + } + + + private void setTokentoContext(MessageContext messageContext, String token) { + Map headers = getTransportHeaders(messageContext); + Axis2MessageContext axis2smc = (Axis2MessageContext) messageContext; + org.apache.axis2.context.MessageContext axis2MessageCtx = axis2smc.getAxis2MessageContext(); + + if (headers != null && headers instanceof Map) { + Map headersMap = (Map) headers; + headersMap.put("Authorization", "Bearer " + token); + axis2MessageCtx.setProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS, headersMap); + } + } +} diff --git a/components/ipvalidate-handler/src/main/java/com/wso2telco/dep/ipvalidate/handler/validation/ClientValidator.java b/components/ipvalidate-handler/src/main/java/com/wso2telco/dep/ipvalidate/handler/validation/ClientValidator.java new file mode 100644 index 000000000..5bf642b0c --- /dev/null +++ b/components/ipvalidate-handler/src/main/java/com/wso2telco/dep/ipvalidate/handler/validation/ClientValidator.java @@ -0,0 +1,11 @@ +package com.wso2telco.dep.ipvalidate.handler.validation; + +import org.wso2.carbon.apimgt.gateway.handlers.security.APISecurityException; + +import com.wso2telco.dep.ipvalidate.handler.validation.dto.RequestData; + +public interface ClientValidator { + + public boolean validateRequest(RequestData requestdata) throws APISecurityException ; + +} diff --git a/components/ipvalidate-handler/src/main/java/com/wso2telco/dep/ipvalidate/handler/validation/CustomValidator.java b/components/ipvalidate-handler/src/main/java/com/wso2telco/dep/ipvalidate/handler/validation/CustomValidator.java new file mode 100644 index 000000000..fa586a149 --- /dev/null +++ b/components/ipvalidate-handler/src/main/java/com/wso2telco/dep/ipvalidate/handler/validation/CustomValidator.java @@ -0,0 +1,17 @@ +package com.wso2telco.dep.ipvalidate.handler.validation; + +import org.wso2.carbon.apimgt.gateway.handlers.security.APISecurityException; + +import com.wso2telco.dep.ipvalidate.handler.validation.dto.RequestData; + +public abstract class CustomValidator { + + protected CustomValidator nextValidator; + + public void setNextValidator(CustomValidator nextValidator) { + this.nextValidator = nextValidator; + } + + public abstract boolean doValidation(RequestData requestData) throws APISecurityException; + +} diff --git a/components/ipvalidate-handler/src/main/java/com/wso2telco/dep/ipvalidate/handler/validation/configuration/IPValidationProperties.java b/components/ipvalidate-handler/src/main/java/com/wso2telco/dep/ipvalidate/handler/validation/configuration/IPValidationProperties.java new file mode 100644 index 000000000..e720bb303 --- /dev/null +++ b/components/ipvalidate-handler/src/main/java/com/wso2telco/dep/ipvalidate/handler/validation/configuration/IPValidationProperties.java @@ -0,0 +1,112 @@ +package com.wso2telco.dep.ipvalidate.handler.validation.configuration; + +import java.util.Properties; + +import com.wso2telco.core.dbutils.fileutils.PropertyFileReader; +import com.wso2telco.dep.ipvalidate.handler.validation.utils.IPValidationUtil; + +public class IPValidationProperties { + + static { + loadValidationProperties(); + } + + private static boolean isCustomValidationEnabled; + private static String validatorClasses; + private static Long cacheModExpiretime; + private static Long cacheAccessExpiretime; + private static int invalidClientErrCode; + private static int invalidHostErrCode; + private static int validationFalidErrCode; + private static String invalidClientErrMsg; + private static String invalidHostErrMsg; + private static String validationFalidErrMsg; + private static String ipHeaderName; + private static String hostHeaderName; + private static String clientKeyParamName; + + + private static void loadValidationProperties() + { + Properties props = PropertyFileReader.getFileReader().getProperties(IPValidationUtil.IP_VALIDATION_PROPERTIES_FILE); + + isCustomValidationEnabled = Boolean.valueOf(props.getProperty(IPValidationUtil.IS_IP_VALIDATION_ENABLED)); + validatorClasses = props.getProperty(IPValidationUtil.IP_VALIDATION_CLASSES); + cacheModExpiretime = Long.parseLong(props.getProperty(IPValidationUtil.IP_VALIDATION_CACHE_MOD_EXPIRE)); + cacheAccessExpiretime = Long.parseLong(props.getProperty(IPValidationUtil.IP_VALIDATION_CACHE_ACCESS_EXPIRE)); + + invalidClientErrCode = Integer.parseInt(props.getProperty(IPValidationUtil.IP_VALIDATION_ERROR_CODE_INVALID_CLIENT)); + invalidHostErrCode = Integer.parseInt(props.getProperty(IPValidationUtil.IP_VALIDATION_ERROR_CODE_INVALID_HOST)); + validationFalidErrCode = Integer.parseInt(props.getProperty(IPValidationUtil.IP_VALIDATION_ERROR_CODE_VALIDATION_FAILURE)); + + invalidClientErrMsg = props.getProperty(IPValidationUtil.IP_VALIDATION_ERROR_MSG_INVALID_CLIENT); + invalidHostErrMsg = props.getProperty(IPValidationUtil.IP_VALIDATION_ERROR_MSG_INVALID_HOST); + validationFalidErrMsg = props.getProperty(IPValidationUtil.IP_VALIDATION_ERROR_MSG_VALIDATION_FAILURE); + ipHeaderName = props.getProperty(IPValidationUtil.IP_VALIDATION_HEADER_NAME); + hostHeaderName = props.getProperty(IPValidationUtil.IP_VALIDATION_HOST_HEADER_NAME); + clientKeyParamName = props.getProperty(IPValidationUtil.IP_VALIDATION_KEY_PARAM_NAME); + } + + + public static boolean isCustomValidationEnabled() { + return isCustomValidationEnabled; + } + + + public static String getValidatorClasses() { + return validatorClasses; + } + + + public static Long getCacheModExpiretime() { + return cacheModExpiretime; + } + + + public static Long getCacheAccessExpiretime() { + return cacheAccessExpiretime; + } + + + public static int getInvalidClientErrCode() { + return invalidClientErrCode; + } + + + public static int getInvalidHostErrCode() { + return invalidHostErrCode; + } + + + public static int getValidationFalidErrCode() { + return validationFalidErrCode; + } + + + public static String getInvalidClientErrMsg() { + return invalidClientErrMsg; + } + + + public static String getInvalidHostErrMsg() { + return invalidHostErrMsg; + } + + + public static String getValidationFalidErrMsg() { + return validationFalidErrMsg; + } + + public static String getIpHeaderName() { + return ipHeaderName; + } + + + public static String getClientKeyParamName() { + return clientKeyParamName; + } + + public static String getHostHeaderName() { + return hostHeaderName; + } +} diff --git a/components/ipvalidate-handler/src/main/java/com/wso2telco/dep/ipvalidate/handler/validation/dao/IPValidationDao.java b/components/ipvalidate-handler/src/main/java/com/wso2telco/dep/ipvalidate/handler/validation/dao/IPValidationDao.java new file mode 100644 index 000000000..70379ae59 --- /dev/null +++ b/components/ipvalidate-handler/src/main/java/com/wso2telco/dep/ipvalidate/handler/validation/dao/IPValidationDao.java @@ -0,0 +1,164 @@ +package com.wso2telco.dep.ipvalidate.handler.validation.dao; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.apimgt.impl.utils.APIMgtDBUtil; + +import com.wso2telco.core.dbutils.DbUtils; +import com.wso2telco.core.dbutils.util.DataSourceNames; +import com.wso2telco.dep.ipvalidate.handler.validation.dto.ClientIPPool; +import com.wso2telco.dep.ipvalidate.handler.validation.dto.ClientIPRange; +import com.wso2telco.dep.ipvalidate.handler.validation.dto.ClientIDSummary; + +public class IPValidationDao { + + private static final Log log = LogFactory.getLog(IPValidationDao.class); + + public ArrayList getClientKeyList() throws Exception { + log.debug("Get Client id list "); + Connection conn = null; + PreparedStatement ps = null; + ResultSet results = null; + ArrayList clientKeyList = new ArrayList(); + + String sql = "select distinct client_key from client_id_summary"; + try { + conn = DbUtils.getDbConnection(DataSourceNames.WSO2TELCO_DEP_DB); + ps = conn.prepareStatement(sql); + results = ps.executeQuery(); + + while (results.next()) { + clientKeyList.add(results.getString("client_key")); + } + } catch (Exception e) { + log.error("Error while getting id list " + e); + throw e; + } finally { + APIMgtDBUtil.closeAllConnections(ps, conn, results); + } + return clientKeyList; + } + + public List getSumaryListForClient(String clientKey) throws Exception { + log.debug("Get summary ID list for client : " + clientKey); + Connection conn = null; + PreparedStatement ps = null; + ResultSet results = null; + List clientIPSummaryList = new ArrayList(); + String sql = "select * from client_id_summary where client_key = ?"; + try { + conn = DbUtils.getDbConnection(DataSourceNames.WSO2TELCO_DEP_DB); + ps = conn.prepareStatement(sql); + ps.setString(1, clientKey); + results = ps.executeQuery(); + + while (results.next()) { + ClientIDSummary clientIpSummary = new ClientIDSummary(); + + clientIpSummary.setClientId(results.getString("client_id")); + clientIpSummary.setSummaryId(results.getInt("ID")); + clientIpSummary.setClientKey(results.getString("client_key")); + clientIpSummary.setValidationEnabled(results.getBoolean("ip_validation_enabled")); + + clientIPSummaryList.add(clientIpSummary); + } + } catch (Exception e) { + log.error("Error while getting summary ID list for client " + e); + throw e; + } finally { + APIMgtDBUtil.closeAllConnections(ps, conn, results); + } + return clientIPSummaryList; + } + + public String getClientToken(String clientId) throws Exception { + log.debug("get Client Token " + clientId); + Connection conn = null; + PreparedStatement ps = null; + ResultSet results = null; + String clientIdToken = null; + + String sql = "select ACCESS_TOKEN from idn_oauth2_access_token where CONSUMER_KEY_ID = ? and TOKEN_STATE = 'ACTIVE';"; + try { + conn = DbUtils.getDbConnection(DataSourceNames.WSO2AM_DB); + ps = conn.prepareStatement(sql); + ps.setString(1, clientId); + results = ps.executeQuery(); + + while (results.next()) { + clientIdToken = results.getString("ACCESS_TOKEN"); + } + } catch (Exception e) { + log.error("Error while getting summary ID list for client " + e); + throw e; + } finally { + APIMgtDBUtil.closeAllConnections(ps, conn, results); + } + return clientIdToken; + } + + public ClientIPPool getPoolIPListBySummaryId(int summaryId) throws Exception { + log.debug("Get get pool IP list for summary id : " + summaryId); + Connection conn = null; + PreparedStatement ps = null; + ResultSet results = null; + ClientIPPool clientIPPool = new ClientIPPool(); + clientIPPool.setSummaryId(summaryId); + + String sql = "select ip from client_ip_pool_mapping m, ip_pool p where m.ip_pool_id = p.ip_pool_id and m.summary_id = ?"; + try { + ArrayList poolIPList = new ArrayList(); + conn = DbUtils.getDbConnection(DataSourceNames.WSO2TELCO_DEP_DB); + ps = conn.prepareStatement(sql); + ps.setInt(1, summaryId); + results = ps.executeQuery(); + while (results.next()) { + poolIPList.add(results.getString("ip")); + } + clientIPPool.setIp(poolIPList); + } catch (Exception e) { + log.error("Error while getting pool IP list for summary id " + e); + throw e; + } finally { + APIMgtDBUtil.closeAllConnections(ps, conn, results); + } + return clientIPPool; + } + + public List getRangeIPListBySummaryId(int summaryId) throws Exception { + log.debug("Get get range IP list for summary id : " + summaryId); + Connection conn = null; + PreparedStatement ps = null; + ResultSet results = null; + List clientIPRangeList = new ArrayList(); + + String sql = "select start_ip,end_ip from client_ip_range_mapping m, ip_range p where m.ip_range_id = p.ip_range_id and m.summary_id = ?"; + try { + conn = DbUtils.getDbConnection(DataSourceNames.WSO2TELCO_DEP_DB); + ps = conn.prepareStatement(sql); + ps.setInt(1, summaryId); + results = ps.executeQuery(); + while (results.next()) { + ClientIPRange clientIPRange = new ClientIPRange(); + clientIPRange.setSummaryId(summaryId); + clientIPRange.setStartIP(results.getString("start_ip")); + clientIPRange.setEndIP(results.getString("end_ip")); + + clientIPRangeList.add(clientIPRange); + } + } catch (Exception e) { + log.error("Error while getting range IP list for summary id " + e); + throw e; + } finally { + APIMgtDBUtil.closeAllConnections(ps, conn, results); + } + return clientIPRangeList; + } + +} diff --git a/components/ipvalidate-handler/src/main/java/com/wso2telco/dep/ipvalidate/handler/validation/dto/ClientIDSummary.java b/components/ipvalidate-handler/src/main/java/com/wso2telco/dep/ipvalidate/handler/validation/dto/ClientIDSummary.java new file mode 100644 index 000000000..2454d8323 --- /dev/null +++ b/components/ipvalidate-handler/src/main/java/com/wso2telco/dep/ipvalidate/handler/validation/dto/ClientIDSummary.java @@ -0,0 +1,48 @@ +package com.wso2telco.dep.ipvalidate.handler.validation.dto; + +public class ClientIDSummary { + + private int summaryId = 0; + private String clientId = null; + private String clientKey = null; + private boolean isValidationEnabled = false; + + public int getSummaryId() { + return summaryId; + } + + public void setSummaryId(int summaryId) { + this.summaryId = summaryId; + } + + public String getClientId() { + return clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getClientKey() { + return clientKey; + } + + public void setClientKey(String clientKey) { + this.clientKey = clientKey; + } + + public boolean isValidationEnabled() { + return isValidationEnabled; + } + + public void setValidationEnabled(boolean isValidationEnabled) { + this.isValidationEnabled = isValidationEnabled; + } + + @Override + public String toString() { + return "ClientIDSummary [summaryId=" + summaryId + ", clientId=" + clientId + ", clientKey=" + clientKey + + ", isValidationEnabled=" + isValidationEnabled + "]"; + } + +} diff --git a/components/ipvalidate-handler/src/main/java/com/wso2telco/dep/ipvalidate/handler/validation/dto/ClientIPPool.java b/components/ipvalidate-handler/src/main/java/com/wso2telco/dep/ipvalidate/handler/validation/dto/ClientIPPool.java new file mode 100644 index 000000000..c5421b00f --- /dev/null +++ b/components/ipvalidate-handler/src/main/java/com/wso2telco/dep/ipvalidate/handler/validation/dto/ClientIPPool.java @@ -0,0 +1,31 @@ +package com.wso2telco.dep.ipvalidate.handler.validation.dto; + +import java.util.ArrayList; + +public class ClientIPPool { + + private int summaryId = 0; + private ArrayList ip = null; + + public int getSummaryId() { + return summaryId; + } + + public void setSummaryId(int summaryId) { + this.summaryId = summaryId; + } + + public ArrayList getIp() { + return ip; + } + + public void setIp(ArrayList ip) { + this.ip = ip; + } + + @Override + public String toString() { + return "ClientIPPool [summaryId=" + summaryId + ", ip=" + ip + "]"; + } + +} diff --git a/components/ipvalidate-handler/src/main/java/com/wso2telco/dep/ipvalidate/handler/validation/dto/ClientIPRange.java b/components/ipvalidate-handler/src/main/java/com/wso2telco/dep/ipvalidate/handler/validation/dto/ClientIPRange.java new file mode 100644 index 000000000..85dc0a628 --- /dev/null +++ b/components/ipvalidate-handler/src/main/java/com/wso2telco/dep/ipvalidate/handler/validation/dto/ClientIPRange.java @@ -0,0 +1,39 @@ +package com.wso2telco.dep.ipvalidate.handler.validation.dto; + +public class ClientIPRange { + + private int summaryId = 0; + private String startIP = null; + private String endIP = null; + + public int getSummaryId() { + return summaryId; + } + + public void setSummaryId(int summaryId) { + this.summaryId = summaryId; + } + + public String getStartIP() { + return startIP; + } + + public void setStartIP(String startIP) { + this.startIP = startIP; + } + + public String getEndIP() { + return endIP; + } + + public void setEndIP(String endIP) { + this.endIP = endIP; + } + + @Override + public String toString() { + return "ClientIPRange [summaryId=" + summaryId + ", startIP=" + startIP + ", endIP=" + endIP + "]"; + } + + +} diff --git a/components/ipvalidate-handler/src/main/java/com/wso2telco/dep/ipvalidate/handler/validation/dto/ClientKeyIPData.java b/components/ipvalidate-handler/src/main/java/com/wso2telco/dep/ipvalidate/handler/validation/dto/ClientKeyIPData.java new file mode 100644 index 000000000..40407da80 --- /dev/null +++ b/components/ipvalidate-handler/src/main/java/com/wso2telco/dep/ipvalidate/handler/validation/dto/ClientKeyIPData.java @@ -0,0 +1,69 @@ +package com.wso2telco.dep.ipvalidate.handler.validation.dto; + +import java.util.List; + +public class ClientKeyIPData { + + private int summaryId = 0; + private String clientId = null; + private String clientToken = null; + private ClientIPPool poolIpList = null; + private List rangeIpList = null; + private boolean isValidationEnabled = false; + + public int getSummaryId() { + return summaryId; + } + + public void setSummaryId(int summaryId) { + this.summaryId = summaryId; + } + + public String getClientId() { + return clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + public ClientIPPool getPoolIpList() { + return poolIpList; + } + + public void setPoolIpList(ClientIPPool poolIpList) { + this.poolIpList = poolIpList; + } + + public List getRangeIpList() { + return rangeIpList; + } + + public void setRangeIpList(List rangeIpList) { + this.rangeIpList = rangeIpList; + } + + public boolean isValidationEnabled() { + return isValidationEnabled; + } + + public void setValidationEnabled(boolean isValidationEnabled) { + this.isValidationEnabled = isValidationEnabled; + } + + @Override + public String toString() { + return "ClientKeyIPData [summaryId=" + summaryId + ", clientId=" + clientId + ", clientToken=" + clientToken + + ", poolIpList=" + poolIpList + ", rangeIpList=" + rangeIpList + ", isValidationEnabled=" + + isValidationEnabled + "]"; + } + +} diff --git a/components/ipvalidate-handler/src/main/java/com/wso2telco/dep/ipvalidate/handler/validation/dto/IPPool.java b/components/ipvalidate-handler/src/main/java/com/wso2telco/dep/ipvalidate/handler/validation/dto/IPPool.java new file mode 100644 index 000000000..23204c481 --- /dev/null +++ b/components/ipvalidate-handler/src/main/java/com/wso2telco/dep/ipvalidate/handler/validation/dto/IPPool.java @@ -0,0 +1,29 @@ +package com.wso2telco.dep.ipvalidate.handler.validation.dto; + +public class IPPool { + + private int poolId = 0; + private String ip = null; + + public int getPoolId() { + return poolId; + } + + public void setPoolId(int poolId) { + this.poolId = poolId; + } + + public String getIp() { + return ip; + } + + public void setIp(String ip) { + this.ip = ip; + } + + @Override + public String toString() { + return "IPPool [poolId=" + poolId + ", ip=" + ip + "]"; + } + +} diff --git a/components/ipvalidate-handler/src/main/java/com/wso2telco/dep/ipvalidate/handler/validation/dto/IPRange.java b/components/ipvalidate-handler/src/main/java/com/wso2telco/dep/ipvalidate/handler/validation/dto/IPRange.java new file mode 100644 index 000000000..ca6ab135e --- /dev/null +++ b/components/ipvalidate-handler/src/main/java/com/wso2telco/dep/ipvalidate/handler/validation/dto/IPRange.java @@ -0,0 +1,39 @@ +package com.wso2telco.dep.ipvalidate.handler.validation.dto; + +public class IPRange { + + private int rangeId = 0; + private String startIP = null; + private String endIP = null; + + public int getRangeId() { + return rangeId; + } + + public void setRangeId(int rangeId) { + this.rangeId = rangeId; + } + + public String getStartIP() { + return startIP; + } + + public void setStartIP(String startIP) { + this.startIP = startIP; + } + + public String getEndIP() { + return endIP; + } + + public void setEndIP(String endIP) { + this.endIP = endIP; + } + + @Override + public String toString() { + return "IPRange [rangeId=" + rangeId + ", startIP=" + startIP + ", endIP=" + endIP + "]"; + } + + +} diff --git a/components/ipvalidate-handler/src/main/java/com/wso2telco/dep/ipvalidate/handler/validation/dto/RequestData.java b/components/ipvalidate-handler/src/main/java/com/wso2telco/dep/ipvalidate/handler/validation/dto/RequestData.java new file mode 100644 index 000000000..400330a9c --- /dev/null +++ b/components/ipvalidate-handler/src/main/java/com/wso2telco/dep/ipvalidate/handler/validation/dto/RequestData.java @@ -0,0 +1,40 @@ +package com.wso2telco.dep.ipvalidate.handler.validation.dto; + +public class RequestData { + + private String hostip = null; + private String clientkey = null; + private String clienttoken = null; + + public String getHostip() { + return hostip; + } + + public void setHostip(String hostip) { + this.hostip = hostip; + } + + public String getClientkey() { + return clientkey; + } + + public void setClientkey(String clientkey) { + this.clientkey = clientkey; + } + + public String getClienttoken() { + return clienttoken; + } + + public void setClienttoken(String clienttoken) { + this.clienttoken = clienttoken; + } + + @Override + public String toString() { + return "RequestData [hostip=" + hostip + ", clientkey=" + clientkey + ", clienttoken=" + clienttoken + "]"; + } + + + +} diff --git a/components/ipvalidate-handler/src/main/java/com/wso2telco/dep/ipvalidate/handler/validation/impl/ClientKeyValidation.java b/components/ipvalidate-handler/src/main/java/com/wso2telco/dep/ipvalidate/handler/validation/impl/ClientKeyValidation.java new file mode 100644 index 000000000..f658dcaaf --- /dev/null +++ b/components/ipvalidate-handler/src/main/java/com/wso2telco/dep/ipvalidate/handler/validation/impl/ClientKeyValidation.java @@ -0,0 +1,40 @@ +package com.wso2telco.dep.ipvalidate.handler.validation.impl; + +import java.util.List; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.apimgt.gateway.handlers.security.APISecurityConstants; +import org.wso2.carbon.apimgt.gateway.handlers.security.APISecurityException; + +import com.wso2telco.dep.ipvalidate.handler.validation.CustomValidator; +import com.wso2telco.dep.ipvalidate.handler.validation.configuration.IPValidationProperties; +import com.wso2telco.dep.ipvalidate.handler.validation.dto.ClientKeyIPData; +import com.wso2telco.dep.ipvalidate.handler.validation.dto.RequestData; +import com.wso2telco.dep.ipvalidate.handler.validation.service.ValidationCacheService; + +public class ClientKeyValidation extends CustomValidator { + + private static final Log log = LogFactory.getLog(ClientKeyValidation.class); + + @Override + public boolean doValidation(RequestData requestData) throws APISecurityException { + log.debug("Client key validation : " + requestData); + log.info("Client key validation : " + requestData.getClientkey()); + boolean status = false; + + List clientIpSummaryList = ValidationCacheService.getCache().get(requestData.getClientkey()); + + if (clientIpSummaryList != null) { + status = true; + } + + if (status && nextValidator != null) { + nextValidator.doValidation(requestData); + } + + log.info("Client key validation status : " + status); + return status; + } + +} diff --git a/components/ipvalidate-handler/src/main/java/com/wso2telco/dep/ipvalidate/handler/validation/impl/ClientValidatorImpl.java b/components/ipvalidate-handler/src/main/java/com/wso2telco/dep/ipvalidate/handler/validation/impl/ClientValidatorImpl.java new file mode 100644 index 000000000..605a3a7d0 --- /dev/null +++ b/components/ipvalidate-handler/src/main/java/com/wso2telco/dep/ipvalidate/handler/validation/impl/ClientValidatorImpl.java @@ -0,0 +1,62 @@ +package com.wso2telco.dep.ipvalidate.handler.validation.impl; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.apimgt.gateway.handlers.security.APISecurityException; + +import com.wso2telco.dep.ipvalidate.handler.validation.ClientValidator; +import com.wso2telco.dep.ipvalidate.handler.validation.CustomValidator; +import com.wso2telco.dep.ipvalidate.handler.validation.configuration.IPValidationProperties; +import com.wso2telco.dep.ipvalidate.handler.validation.dto.RequestData; + +public class ClientValidatorImpl implements ClientValidator { + + private static final Log log = LogFactory.getLog(ClientValidatorImpl.class); + + @Override + public boolean validateRequest(RequestData requestData) throws APISecurityException { + + boolean status = false; + + try { + log.debug("Start validate request : " + requestData); + log.info("Validate client : " + requestData.getClientkey()); + + String validationclasses = IPValidationProperties.getValidatorClasses(); + String[] strValidationClassList = validationclasses.split(","); + CustomValidator previousValidation = null; + for (String strvalidationclass : strValidationClassList) { + log.debug("Validate class " + strvalidationclass); + CustomValidator nextValidation = (CustomValidator) Class.forName(strvalidationclass).newInstance(); + if (previousValidation != null) { + previousValidation.setNextValidator(nextValidation); + } + previousValidation = nextValidation; + status = previousValidation.doValidation(requestData); + log.debug("Validate class " + strvalidationclass + " response : " + status); + if(!status) + { + break; + } + } + } catch (APISecurityException e) { + log.error(e); + throw e; + } catch (InstantiationException e) { + log.error(e); + throw new APISecurityException(IPValidationProperties.getValidationFalidErrCode(), + IPValidationProperties.getValidationFalidErrMsg()); + } catch (IllegalAccessException e) { + log.error(e); + throw new APISecurityException(IPValidationProperties.getValidationFalidErrCode(), + IPValidationProperties.getValidationFalidErrMsg()); + } catch (ClassNotFoundException e) { + log.error(e); + throw new APISecurityException(IPValidationProperties.getValidationFalidErrCode(), + IPValidationProperties.getValidationFalidErrMsg()); + } + log.info("responce for validation : " + status); + return status; + } + +} diff --git a/components/ipvalidate-handler/src/main/java/com/wso2telco/dep/ipvalidate/handler/validation/impl/HostIpValidation.java b/components/ipvalidate-handler/src/main/java/com/wso2telco/dep/ipvalidate/handler/validation/impl/HostIpValidation.java new file mode 100644 index 000000000..e32124cf0 --- /dev/null +++ b/components/ipvalidate-handler/src/main/java/com/wso2telco/dep/ipvalidate/handler/validation/impl/HostIpValidation.java @@ -0,0 +1,114 @@ +package com.wso2telco.dep.ipvalidate.handler.validation.impl; + +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.util.ArrayList; +import java.util.List; + +import org.wso2.carbon.apimgt.gateway.handlers.security.APISecurityConstants; +import org.wso2.carbon.apimgt.gateway.handlers.security.APISecurityException; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import com.wso2telco.dep.ipvalidate.handler.validation.CustomValidator; +import com.wso2telco.dep.ipvalidate.handler.validation.configuration.IPValidationProperties; +import com.wso2telco.dep.ipvalidate.handler.validation.dto.ClientIPPool; +import com.wso2telco.dep.ipvalidate.handler.validation.dto.ClientIPRange; +import com.wso2telco.dep.ipvalidate.handler.validation.dto.ClientKeyIPData; +import com.wso2telco.dep.ipvalidate.handler.validation.dto.RequestData; +import com.wso2telco.dep.ipvalidate.handler.validation.service.ValidationCacheService; + +public class HostIpValidation extends CustomValidator { + + private static final Log log = LogFactory.getLog(HostIpValidation.class); + + @Override + public boolean doValidation(RequestData requestData) throws APISecurityException { + log.debug("Host IP validation : " + requestData); + log.info("Validate IP for client : " + requestData.getClientkey() + " IP : " + requestData.getHostip()); + boolean status = false; + + try { + List clientIpSummaryList = ValidationCacheService.getCache() + .get(requestData.getClientkey()); + + if (clientIpSummaryList == null) { + ValidationCacheService.loadCache(); + clientIpSummaryList = ValidationCacheService.getCache().get(requestData.getClientkey()); + } + + for (ClientKeyIPData clientIpSummary : clientIpSummaryList) { + ClientIPPool clientIPPool = clientIpSummary.getPoolIpList(); + + List clientIPRangeList = clientIpSummary.getRangeIpList(); + if (isValidPoolIP(clientIPPool.getIp(), requestData.getHostip())) { + status = true; + break; + } else if (isIPinValidRange(clientIPRangeList, requestData.getHostip())) { + status = true; + break; + } + } + + if (status && nextValidator != null) { + nextValidator.doValidation(requestData); + } + + } catch (APISecurityException e) { + throw e; + } catch (Exception e) { + log.error(e); + throw new APISecurityException(IPValidationProperties.getInvalidHostErrCode(), + IPValidationProperties.getInvalidHostErrMsg()); + } + log.info("responce for IP validation : " + status); + return status; + } + + public boolean isValidPoolIP(ArrayList strings, String searchString) { + log.debug("Check is valid pool IP :" + strings + " ; " + searchString); + boolean isIPValid = false; + if (strings.contains(searchString)) { + isIPValid = true; + } + return isIPValid; + } + + public boolean isIPinValidRange(List clientIPRangeList, String ip) { + log.debug("Check is isIPinValidRange :" + clientIPRangeList + " , " + ip + " ; "); + boolean isIPValid = false; + for (ClientIPRange clientIpRange : clientIPRangeList) { + log.info("Check clientIpRange :" + clientIpRange); + if (isValidRangeIP(clientIpRange.getStartIP(), clientIpRange.getEndIP(), ip)) { + isIPValid = true; + break; + } + } + return isIPValid; + } + + public static boolean isValidRangeIP(String ipStart, String ipEnd, String ipToCheck) { + + log.debug("Check is valid range IP :" + ipStart + " , " + ipEnd + " ; " + ipToCheck); + try { + long ipLo = ipToLong(InetAddress.getByName(ipStart)); + long ipHi = ipToLong(InetAddress.getByName(ipEnd)); + long ipToTest = ipToLong(InetAddress.getByName(ipToCheck)); + return (ipToTest >= ipLo && ipToTest <= ipHi); + } catch (UnknownHostException e) { + e.printStackTrace(); + return false; + } + } + + public static long ipToLong(InetAddress ip) { + byte[] octets = ip.getAddress(); + long result = 0; + for (byte octet : octets) { + result <<= 8; + result |= octet & 0xff; + } + return result; + } + +} diff --git a/components/ipvalidate-handler/src/main/java/com/wso2telco/dep/ipvalidate/handler/validation/service/ValidationCacheService.java b/components/ipvalidate-handler/src/main/java/com/wso2telco/dep/ipvalidate/handler/validation/service/ValidationCacheService.java new file mode 100644 index 000000000..98156bff0 --- /dev/null +++ b/components/ipvalidate-handler/src/main/java/com/wso2telco/dep/ipvalidate/handler/validation/service/ValidationCacheService.java @@ -0,0 +1,74 @@ +package com.wso2telco.dep.ipvalidate.handler.validation.service; + +import java.util.ArrayList; +import java.util.List; + +import javax.cache.Cache; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import com.wso2telco.dep.ipvalidate.handler.validation.dto.ClientIPPool; +import com.wso2telco.dep.ipvalidate.handler.validation.dto.ClientIPRange; +import com.wso2telco.dep.ipvalidate.handler.validation.dto.ClientKeyIPData; +import com.wso2telco.dep.ipvalidate.handler.validation.utils.CacheOperation; +import com.wso2telco.dep.ipvalidate.handler.validation.utils.IPValidationDBUtils; +import com.wso2telco.dep.ipvalidate.handler.validation.utils.IPValidationUtil; + +public class ValidationCacheService { + private static final Log log = LogFactory.getLog(ValidationCacheService.class); + + static { + log.debug("initialize IP validation cache"); + try { + CacheOperation.createIPKeyValidationCache(); + loadCache(); + } catch (Exception e) { + log.error("Error while initializing cache : " + e); + e.printStackTrace(); + } + } + + public static Cache> getCache() { + Cache> ipValidationCache = CacheOperation + .getCache(IPValidationUtil.IP_VALIDATION_CACHE_NAME); + try { + if (!ipValidationCache.iterator().hasNext()) { + loadCache(); + ipValidationCache = CacheOperation.getCache(IPValidationUtil.IP_VALIDATION_CACHE_NAME); + } + } catch (Exception ex) { + log.error("Error while initializing cache : " + ex); + ex.printStackTrace(); + } + + return ipValidationCache; + } + + public static void loadCache() throws Exception { + log.debug("load Cache"); + IPValidationDBUtils ipvalidationDBUtils = new IPValidationDBUtils(); + ArrayList clientKeyList = ipvalidationDBUtils.getClientKeyList(); + Cache> clienIPCache = CacheOperation + .getCache(IPValidationUtil.IP_VALIDATION_CACHE_NAME); + + for (String clientKey : clientKeyList) { + List clientIpSummaryList = ipvalidationDBUtils.getValidIPListForClient(clientKey); + clienIPCache.put(clientKey, clientIpSummaryList); + } + log.debug("clienIPCache : " + clienIPCache); + } + + public String getTokenfromCache(String clientKey) + { + String clientToken = null; + List clientIpSummaryList = ValidationCacheService.getCache() + .get(clientKey); + if(!clientIpSummaryList.isEmpty()) + { + clientToken = clientIpSummaryList.get(0).getClientToken(); + } + log.info("return Token from Cache " + clientKey + " ; " + clientToken); + return clientToken; + } +} diff --git a/components/ipvalidate-handler/src/main/java/com/wso2telco/dep/ipvalidate/handler/validation/utils/CacheOperation.java b/components/ipvalidate-handler/src/main/java/com/wso2telco/dep/ipvalidate/handler/validation/utils/CacheOperation.java new file mode 100644 index 000000000..4b1d1f910 --- /dev/null +++ b/components/ipvalidate-handler/src/main/java/com/wso2telco/dep/ipvalidate/handler/validation/utils/CacheOperation.java @@ -0,0 +1,24 @@ +package com.wso2telco.dep.ipvalidate.handler.validation.utils; + +import java.util.List; + +import javax.cache.Cache; +import javax.cache.Caching; + +import org.wso2.carbon.apimgt.impl.APIConstants; +import org.wso2.carbon.apimgt.impl.utils.APIUtil; + +import com.wso2telco.dep.ipvalidate.handler.validation.configuration.IPValidationProperties; +import com.wso2telco.dep.ipvalidate.handler.validation.dto.ClientKeyIPData; + +public class CacheOperation { + + public static Cache> getCache(final String cacheName) { + return Caching.getCacheManager(APIConstants.API_MANAGER_CACHE_MANAGER).getCache(cacheName); + } + + public static Cache createIPKeyValidationCache() { + return APIUtil.getCache(APIConstants.API_MANAGER_CACHE_MANAGER, IPValidationUtil.IP_VALIDATION_CACHE_NAME, + IPValidationProperties.getCacheModExpiretime(),IPValidationProperties.getCacheAccessExpiretime()); + } +} diff --git a/components/ipvalidate-handler/src/main/java/com/wso2telco/dep/ipvalidate/handler/validation/utils/IPValidationDBUtils.java b/components/ipvalidate-handler/src/main/java/com/wso2telco/dep/ipvalidate/handler/validation/utils/IPValidationDBUtils.java new file mode 100644 index 000000000..9f3c3ff35 --- /dev/null +++ b/components/ipvalidate-handler/src/main/java/com/wso2telco/dep/ipvalidate/handler/validation/utils/IPValidationDBUtils.java @@ -0,0 +1,62 @@ +package com.wso2telco.dep.ipvalidate.handler.validation.utils; + +import java.util.ArrayList; +import java.util.List; + +import com.wso2telco.dep.ipvalidate.handler.validation.dao.IPValidationDao; +import com.wso2telco.dep.ipvalidate.handler.validation.dto.ClientIDSummary; +import com.wso2telco.dep.ipvalidate.handler.validation.dto.ClientKeyIPData; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +public class IPValidationDBUtils { + + private static final Log log = LogFactory.getLog(IPValidationDBUtils.class); + + private IPValidationDao ipValidationdao; + + public IPValidationDBUtils() { + ipValidationdao = new IPValidationDao(); + } + + public ArrayList getClientKeyList() throws Exception { + log.debug("Get client key list"); + ArrayList clientKeyList = new ArrayList(); + try { + clientKeyList = ipValidationdao.getClientKeyList(); + } catch (Exception e) { + log.error("error while getting client key list " + e); + throw e; + } + return clientKeyList; + } + + public List getValidIPListForClient(String clientKey) throws Exception { + log.debug("Get valid IP list for client : " + clientKey); + List clientIPDataList = new ArrayList(); + try { + List summaryIdList = ipValidationdao.getSumaryListForClient(clientKey); + + for (ClientIDSummary clientIPSummary : summaryIdList) { + ClientKeyIPData clientKeyIPData = new ClientKeyIPData(); + + clientKeyIPData.setClientId(clientIPSummary.getClientId()); + clientKeyIPData.setSummaryId(clientIPSummary.getSummaryId()); + clientKeyIPData.setValidationEnabled(clientIPSummary.isValidationEnabled()); + clientKeyIPData.setClientToken(ipValidationdao.getClientToken(clientIPSummary.getClientId())); + clientKeyIPData.setPoolIpList(ipValidationdao.getPoolIPListBySummaryId(clientIPSummary.getSummaryId())); + clientKeyIPData + .setRangeIpList(ipValidationdao.getRangeIPListBySummaryId(clientIPSummary.getSummaryId())); + + clientIPDataList.add(clientKeyIPData); + } + } catch (Exception e) { + log.error("error while valid IP list for client " + e); + throw e; + } + + return clientIPDataList; + } + +} diff --git a/components/ipvalidate-handler/src/main/java/com/wso2telco/dep/ipvalidate/handler/validation/utils/IPValidationUtil.java b/components/ipvalidate-handler/src/main/java/com/wso2telco/dep/ipvalidate/handler/validation/utils/IPValidationUtil.java new file mode 100644 index 000000000..65c1b9b77 --- /dev/null +++ b/components/ipvalidate-handler/src/main/java/com/wso2telco/dep/ipvalidate/handler/validation/utils/IPValidationUtil.java @@ -0,0 +1,40 @@ +package com.wso2telco.dep.ipvalidate.handler.validation.utils; + +import java.util.Properties; + +import com.wso2telco.core.dbutils.fileutils.PropertyFileReader; + +public class IPValidationUtil { + + public static final String IP_VALIDATION_PROPERTIES_FILE = "ip-validation.properties"; + public static final String IS_IP_VALIDATION_ENABLED = "handler.ip.validation.enable"; + public static final String IP_VALIDATION_CLASSES = "handler.ip.validation.classes"; + public static final String IP_VALIDATION_INBUILD_TOKEN = "handler.ip.validation.token"; + public static final String IP_VALIDATION_CACHE_NAME = "IP_KEY_VALIDATION_CACHE"; + public static final String IP_VALIDATION_CACHE_MOD_EXPIRE = "handler.ip.validation.cache.modify.expire"; + public static final String IP_VALIDATION_CACHE_ACCESS_EXPIRE = "handler.ip.validation.cache.access.expire"; + + //Error messages + public static final String IP_VALIDATION_ERROR_CODE_INVALID_CLIENT = "ip.validation.error.code.invalid.client"; + public static final String IP_VALIDATION_ERROR_CODE_INVALID_HOST = "ip.validation.error.code.invalid.host"; + public static final String IP_VALIDATION_ERROR_CODE_VALIDATION_FAILURE = "ip.validation.error.code.validate.failed"; + public static final String IP_VALIDATION_ERROR_MSG_INVALID_CLIENT = "ip.validation.error.msg.invalid.client"; + public static final String IP_VALIDATION_ERROR_MSG_INVALID_HOST = "ip.validation.error.msg.invalid.host"; + public static final String IP_VALIDATION_ERROR_MSG_VALIDATION_FAILURE = "ip.validation.error.msg.validate.failed"; + public static final String IP_VALIDATION_HEADER_NAME = "ip.validation.header.name"; + public static final String IP_VALIDATION_HOST_HEADER_NAME = "ip.validation.host.header.name"; + public static final String IP_VALIDATION_KEY_PARAM_NAME = "ip.validation.client.key.param.name"; + private static Properties props = null; + + public static Properties loadUserMaskingProperties(){ + if (props == null) { + props = PropertyFileReader.getFileReader().getProperties(IP_VALIDATION_PROPERTIES_FILE); + } + return props; + } + + public static String getUserMaskingConfiguration(String property) { + loadUserMaskingProperties(); + return props.getProperty(property); + } +} diff --git a/components/ipvalidate-handler/src/test/java/com/wso2telco/dep/ipvalidate/handler/AppTest.java b/components/ipvalidate-handler/src/test/java/com/wso2telco/dep/ipvalidate/handler/AppTest.java new file mode 100644 index 000000000..3562afaee --- /dev/null +++ b/components/ipvalidate-handler/src/test/java/com/wso2telco/dep/ipvalidate/handler/AppTest.java @@ -0,0 +1,54 @@ +package com.wso2telco.dep.ipvalidate.handler; + +import com.wso2telco.dep.ipvalidate.handler.validation.utils.IPValidationDBUtils; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Unit test for simple App. + */ +public class AppTest + extends TestCase +{ + /** + * Create the test case + * + * @param testName name of the test case + */ + public AppTest( String testName ) + { + super( testName ); + } + + /** + * @return the suite of tests being tested + */ + public static Test suite() + { + return new TestSuite( AppTest.class ); + } + + /** + * Rigourous Test :-) + */ + public void testApp() + { + assertTrue( true ); + } + +// public void test() +// { +// IPValidationDBUtils ipvalidationDBUtils = new IPValidationDBUtils(); +// try { +// ipvalidationDBUtils.getClientKeyList(); +// assertTrue( false ); +// } catch (Exception e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// assertTrue( false ); +// } +// +// } +} diff --git a/components/jaggery-apps/admin/pom.xml b/components/jaggery-apps/admin/pom.xml index 468b04bf7..0a1fd8077 100644 --- a/components/jaggery-apps/admin/pom.xml +++ b/components/jaggery-apps/admin/pom.xml @@ -23,7 +23,7 @@ com.wso2telco.dep component-dep - 3.0.2-SNAPSHOT + 3.0.4-SNAPSHOT ../../../pom.xml diff --git a/components/jaggery-apps/admin/src/main/admin/site/conf/locales/jaggery/locale_default.json b/components/jaggery-apps/admin/src/main/admin/site/conf/locales/jaggery/locale_default.json index d4634c60f..689c5343e 100644 --- a/components/jaggery-apps/admin/src/main/admin/site/conf/locales/jaggery/locale_default.json +++ b/components/jaggery-apps/admin/src/main/admin/site/conf/locales/jaggery/locale_default.json @@ -1,35 +1,40 @@ { + "," : ", ", " for above roles.": " for above roles.", + "and" : " and ", "API Availability": "API Availability", "API Context": "API Context", "API Deployment Stats": "API Deployment Stats", "Abnormal API Usage": "Abnormal API Usage", "Abnormal Backend Time": "Abnormal Backend Time", - "Abnormal Renewal of Access Tokens": "Abnormal Renewal of Access Tokens", "Abnormal Request Count": "Abnormal Request Count", "Abnormal Resource Access Pattern": "Abnormal Resource Access Pattern", "Abnormal Response Time": "Abnormal Response Time", "AbnormalRefreshAlert": "Abnormal Access Token Renewal", - "AbnormalRefreshAlert_Desc": "This alert type should get triggered if there is a change in the pattern of renewing access tokens of an application by a user. These alerts could be treated as an indication of a stolen access token.", + "AbnormalRefreshAlert_Desc": "This alert gets triggered if there is a change in the pattern of renewing access tokens of an application by a user. These alerts could be treated as an indication of a stolen access token.", "AbnormalTierUsage": "Abnormal API Usage", - "AbnormalTierUsage_Desc": "This alert should get triggered if there is a drastic reduction in API usage for a given API for a given user. These types of alerts should be treated as an indication of a failure of the application using the altered API.", + "AbnormalTierUsage_Desc": "This alert gets triggered if there is a drastic reduction in API usage for a given API for a given user. These types of alerts should be treated as an indication of a failure of the application using the altered API.", "Access Token Errors": "Access Token Errors", "Actions": "Actions", "Activate": "Activate", "Active": "Active", "Add": "Add", + "ADD Label":"Add Label", "Add Advanced Throttle Policy": "Add Advanced Throttle Policy", "Add Application Level Policy": "Add Application Level Policy", + "Add Blacklist Policy" : "Add Blacklist Policy", "Add Conditional Group": "Add Conditional Group", "Add Custom Attribute": "Add Custom Attribute", - "Add Custom Rule": "Add Custom Rule", + "Add Custom Policy": "Add Custom Policy", + "Add Host":"Add Host", "Add Item": "Add Item", + "Add Microgateway":"Add Microgateway", "Add New Policy": "Add New Policy", "Add New Tier": "Add New Tier", - "Add Subscription Tier": "Add Subscription Tier", - "Add Tier": "Add Tier", + "Add Subscription Throttle Policy": "Add Subscription Throttle Policy", + "Add Policy": "Add Policy", "Admin Portal": "Admin Portal", - "Advanced Throttling": "Advanced Throttling", + "Advanced Policies": "Advanced Policies", "Advanced Throttling Policies": "Advanced Throttling Policies", "Alert Configurations": "Alert Configurations", "Alerts": "Alerts", @@ -42,7 +47,8 @@ "Application Creation": "Application Creation", "Application Errors": "Application Errors", "Application Registration": "Application Registration", - "Application Tiers": "Application Tiers", + "Application Policies": "Application Policies", + "Application Throttling Policies" : "Application Throttling Policies", "Apply Rule": "Apply Rule", "Approval Tasks": "Approval Tasks", "Approve": "Approve", @@ -51,7 +57,7 @@ "Bandwidth": "Bandwidth", "Bandwidth :": "Bandwidth :", "Billing Plan": "Billing Plan", - "Black List": "Black List", + "Black List Policies": "Black List Policies", "Blacklist": "Blacklist", "Blacklisted Items": "Blacklisted Items", "Blacklisted items are not defined": "Blacklisted items are not defined", @@ -74,13 +80,14 @@ "Configuration Name": "Configuration Name", "Created On": "Created On", "Custom Attributes": "Custom Attributes", - "Custom Rules": "Custom Rules", - "Custom Rules are not defined": "Custom Rules are not defined", + "Custom Policies": "Custom Policies", + "Custom Throttling Policies" : "Custom Throttling Policies", + "Custom Policies are not defined": "Custom policies are not defined", "Data Bandwidth": "Data Bandwidth", "Day(s)": "Day(s)", "Deactivate": "Deactivate", "Default Limits": "Default Limits", - "Define Rule": "Define Rule", + "Define Policy": "Define Policy", "Delete": "Delete", "Denied": "Denied", "Deny": "Deny", @@ -88,10 +95,11 @@ "Description of the throttle policy.": "Description of the throttle policy.", "Domains": "Domains", "Edit": "Edit", - "Edit Advanced Throttle Throttle Policy": "Edit Advanced Throttle Throttle Policy", + "Edit Advanced Throttle Policy": "Edit Advanced Throttle Policy", "Edit Configurations": "Edit Configurations", "Edit Custom Policy": "Edit Custom Policy", - "Edit Subscription Tier": "Edit Subscription Tier", + "Edit Microgateway":"Edit Microgateway", + "Edit Subscription Policy": "Edit Subscription Policy", "Edit Tier": "Edit Tier", "Eg ": "Eg ", "Eg : ": "Eg : ", @@ -101,17 +109,21 @@ "Error occurred while saving policy (Cause:": "Error occurred while saving policy (Cause:", "Error!": "Error!", "Execution Policy": "Execution Policy", - "Following query will allow 5 request per minute for Admin user": "Following query will allow 5 request per minute for Admin user", + "Following query will allow 5 request per minute for Admin user": "The following query allows 5 requests per minute for an Admin user", "Format : ": "Format : ", "Free": "Free", "FrequentTierHittingAlert": "Tier Crossing", - "FrequentTierHittingAlert_Desc": "This alert type should get triggered if at least one of the two cases below are satisfied; if a particular application gets throttled out for hitting the subscribed tier limit of that application, more than 10 times (by default) within a day (by default) or if a particular user of an application, gets throttled out for hitting the subscribed tier limit of a particular API, more than 10 times (by default) within a day (by default)", + "FrequentTierHittingAlert_Desc": "This alert gets triggered if at least one of the two cases below are satisfied; if a particular application gets throttled out for hitting the subscribed tier limit of that application more than 10 times (by default) within a day (by default) or if a particular user of an application gets throttled out for hitting the subscribed tier limit of a particular API more than 10 times (by default) within a day (by default)", + "Gateway Label": "Gateway Label", + "Gateway Hosts":"Gateway Hosts", + "Gateway Host":"Gateway Host", "GEO Location configurations": "GEO Location configurations", "General Details": "General Details", "Go Back": "Go Back", "Header Condition Policy ": "Header Condition Policy ", "Header Data": "Header Data", "Header Name:": "Header Name:", + "Health Availability": "Health Availability", "Hour(s)": "Hour(s)", "ID": "ID", "IP Address": "IP Address", @@ -129,7 +141,8 @@ "JWT Token": "JWT Token", "KB": "KB", "Key Template": "Key Template", - "Key Template Already Exists. Add a new Key Template": "Key Template Already Exists. Add a new Key Template", + "Key Template Already Exists. Add a new Key Template": "Key Template already exists. Add a new Key Template", + "Labels":"Labels", "Live Log Viewer": "Live Log Viewer", "Live log viewer": "Live log viewer", "Log Analyzer": "Log Analyzer", @@ -137,8 +150,12 @@ "Login Errors": "Login Errors", "Logout": "Logout", "MB": "MB", - "Manage Alert Types": "Manage Alert Types", + "Manage Alert Types": "Manage Alerts", "Manage Tiers": "Manage Tiers", + "Microgateway":"Microgateway", + "Microgateways":"Microgateways", + "Microgateway Host":"Microgateway Host", + "Microgateways are not defined":"Microgateways are not defined", "Minute(s)": "Minute(s)", "Modal title": "Modal title", "Month(s)": "Month(s)", @@ -149,10 +166,10 @@ "Name of the header.": "Name of the header.", "Name of the query param.": "Name of the query param.", "Name of the throttle policy.": "Name of the throttle policy.", - "No Configurations to be listed": "No Configurations to be listed", + "No Configurations to be listed": "No configurations to be listed", "No Custom Rules Found": "No Custom Rules Found", "No properties to configure.": "No properties to configure.", - "No tasks assigned to the login user or no connectivity with BPS engine.": "No tasks assigned to the login user or no connectivity with BPS engine.", + "No tasks assigned to the login user or no connectivity with BPS engine.": "No tasks assigned to the logged-in user or no connectivity with the BPS engine.", "No tasks assigned to the signed-in user or no connectivity with the BPS engine.": "No tasks assigned to the signed-in user or no connectivity with the BPS engine.", "Number of API Failures": "Number of API Failures", "Number of requests allowed.": "Number of requests allowed.", @@ -181,7 +198,7 @@ "Request/min": "Request/min", "Request/s": "Request/s", "RequestPatternChanged": "Abnormal Resource Access", - "RequestPatternChanged_Desc": "This alert type should get triggered if there is a change in the resource access pattern of a user of a particular Application. These alerts could be treated as an indication of a suspicious activity made by a user over your application.", + "RequestPatternChanged_Desc": "This alert gets triggered if there is a change in the resource access pattern of a user of a particular application. These alerts could be treated as an indication of a suspicious activity made by a user over your application.", "Required": "Required", "Reset": "Reset", "Roles": "Roles", @@ -204,21 +221,21 @@ "Start IP Address:": "Start IP Address:", "Status": "Status", "Stop On Quota Reach": "Stop On Quota Reach", - "Subscription Tier List": "Subscription Tier List", - "Subscription Tiers": "Subscription Tiers", + "Subscription Throttling Policies" : "Subscription Throttling Policies", + "Subscription Policies": "Subscription Policies", "Subscriptions Creation": "Subscriptions Creation", "Success!": "Success!", "Tasks": "Tasks", "Template Name": "Template Name", - "The theme should be a zip file containing css and images compliant with the API Manager theme format": "The theme should be a zip file containing css and images compliant with the API Manager theme format", + "The theme should be a zip file containing css and images compliant with the API Manager theme format": "The theme should be a zip file containing CSS and images that are compliant with the API Manager theme format", "Theme was uploaded successfully.": "Theme was uploaded successfully.", "This configuration is used to define JWT claims conditions": "This configuration is used to define JWT claims conditions", "This configuration is used to throttle based on Headers.": "This configuration is used to throttle based on Headers.", "This configuration is used to throttle by IP address.": "This configuration is used to throttle by IP address.", - "This configuration use to throttle based on query parameters.": "This configuration use to throttle based on query parameters.", + "This configuration use to throttle based on query parameters.": "This configuration is used to throttle based on query parameters.", "This tier is ": "This tier is ", "Throttle Based on bandwidth.": "Throttle Based on bandwidth.", - "Throttle Policies": "Throttle Policies", + "Throttle Policies": "Throttling Policies", "Throttle based on request count .": "Throttle based on request count .", "Throttling Tiers": "Throttling Tiers", "Tier Crossing": "Tier Crossing", @@ -230,7 +247,7 @@ "Unseen Source IP Address": "Unseen Source IP Address", "Unsubscribe": "Unsubscribe", "UnusualIPAccessAlert": "Unseen Source IP Access", - "UnusualIPAccessAlert_Desc": "This alert type should get triggered if there is either a change in the request source IP for a particular API of an application or if the request is from an IP used before a time period of 30 days (default). These alerts could be treated as an indication of a suspicious activity made by a user over an API of an application. ", + "UnusualIPAccessAlert_Desc": "This alert gets triggered if there is either a change in the request source IP for a particular API of an application or if the request is from an IP used before a time period of 30 days (default). These alerts could be treated as an indication of a suspicious activity made by a user over an API of an application. ", "Update": "Update", "Upload": "Upload", "Upload Tenant Theme": "Upload Tenant Theme", @@ -241,28 +258,28 @@ "Value of the JWT claim.": "Value of the JWT claim.", "Value of the header.": "Value of the header.", "Value of the query param.": "Value of the query param.", - "WSO2 API Manager": "WSO2 API Manager", + "WSO2 API Manager": "Apigate Internal Gateway", "Warning!": "Warning!", "Week(s)": "Week(s)", "Will be applicable to the whole API.": "Will be applicable to the whole API.", "Year(s)": "Year(s)", "_Desc": "_Desc", "abnormalBackendTime": "Abnormal Backend Time", - "abnormalBackendTime_Desc": "This alert type should get triggered if there is a sudden increase in the backend time corresponding to a particular API resource. These alerts could be treated as an indication of a slow backend. In technical terms, if the backend time of a particular API resource (eg: GET /calc/1.0/numbers) of a tenant lies outside the Xth percentile value, we will send an alert out. Default percentile value is 95%. Here, we safely assume that the corresponding backend time of an API resource follows a normal distribution. Percentile value gets calculated daily by default. ", + "abnormalBackendTime_Desc": "This alert gets triggered if there is a sudden increase in the backend time corresponding to a particular API resource. These alerts could be treated as an indication of a slow backend. In technical terms, if the backend time of a particular API resource (eg: GET /calc/1.0/numbers) of a tenant lies outside the Xth percentile value, we will send an alert out. Default percentile value is 95%. Here, we safely assume that the corresponding backend time of an API resource follows a normal distribution. Percentile value gets calculated daily by default. ", "abnormalRequestsPerMin": "Abnormal Request Count", - "abnormalRequestsPerMin_Desc": "This alert type should get triggered if there is a sudden spike or a drop in the request count within a period of one minute by default for a particular API resource. These alerts could be treated as an indication of a possible high traffic or suspicious act or possible malfunction of the client application etc.", + "abnormalRequestsPerMin_Desc": "This alert gets triggered if there is a sudden spike or a drop in the request count within a period of one minute by default for a particular API resource. These alerts could be treated as an indication of a possible high traffic, suspicious activity, possible malfunction of the client application, etc.", "abnormalResponseTime": "Abnormal Response Time", - "abnormalResponseTime_Desc": "This alert type should get triggered if there is a sudden increase in the response time of a particular API resource. These alerts could be treated as an indication of a slow WSO2 API Manager runtime or a slow backend. ", + "abnormalResponseTime_Desc": "This alert gets triggered if there is a sudden increase in the response time of a particular API resource. These alerts could be treated as an indication of a slow WSO2 API Manager runtime or a slow backend. ", "blocked": "BLOCKED", "common.button.edit": "common.button.edit", "controlled": "Restricted by tenants", "created": "CREATED", "deprecated": "DEPRECATED", "healthAvailabilityPerMin": "Health Availability", - "healthAvailabilityPerMin_Desc": "This alert type should get triggered if at least one of the three cases below are satisfied; Response time of an API > Response time upper percentile of that particular API or Request Count of an API per minute > Request count per minute lower percentile or Response status code >= 500 (By Default) AND Response status code < 600 (By Default)", - "isn't configured. If a policy configured with any of these conditions, it won't be applied.": "isn't configured. If a policy configured with any of these conditions, it won't be applied.", + "healthAvailabilityPerMin_Desc": "This alert gets triggered if at least one of the three cases below are satisfied; Response time of an API > Response time upper percentile of that particular API or Request count of an API per minute > Request count per minute lower percentile or Response status code >= 500 (By Default) AND Response status code < 600 (By Default)", + "isn't configured. If a policy configured with any of these conditions, it won't be applied.": "isn't configured. If a policy is configured with any of these conditions, it won't be applied.", "myTasks": "myTasks", - "private": "Visible to my domain", + "private": "Visible to my Domain", "public": "Public", "published": "PUBLISHED", "restricted": "Restricted by roles", @@ -272,6 +289,17 @@ "tasks": "tasks", "tenants": "Visible to Tenants", "keys should be separated by colon and each attribute should start with" : "keys should be separated by colon and each attribute should start with", - "Allowed keys" : "Allowed keys" + "Allowed keys" : "Allowed keys", + "Type an Email and press Enter":"Type an Email and press Enter", + "API State Approval" : "API State Change", + "Suspended" : "Suspended", + "Label contains spaces": "Label contains spaces", + "Label": "Label", + "Label contains one or more illegal characters": "Label contains one or more illegal characters ", + "Generate" : "Generate", + "Applications" : "Applications", + "Application Name" : "Application Name", + "Owner" : "Owner", + "Change Application Owner" : "Change Application Owner" } diff --git a/components/jaggery-apps/admin/src/main/admin/site/conf/locales/jaggery/locale_en.json b/components/jaggery-apps/admin/src/main/admin/site/conf/locales/jaggery/locale_en.json index 4ddd58636..083096e57 100644 --- a/components/jaggery-apps/admin/src/main/admin/site/conf/locales/jaggery/locale_en.json +++ b/components/jaggery-apps/admin/src/main/admin/site/conf/locales/jaggery/locale_en.json @@ -1,18 +1,19 @@ { + "," : ", ", " for above roles.": " for above roles.", + "and" : " and ", "API Availability": "API Availability", "API Context": "API Context", "API Deployment Stats": "API Deployment Stats", "Abnormal API Usage": "Abnormal API Usage", "Abnormal Backend Time": "Abnormal Backend Time", - "Abnormal Renewal of Access Tokens": "Abnormal Renewal of Access Tokens", "Abnormal Request Count": "Abnormal Request Count", "Abnormal Resource Access Pattern": "Abnormal Resource Access Pattern", "Abnormal Response Time": "Abnormal Response Time", "AbnormalRefreshAlert": "Abnormal Access Token Renewal", - "AbnormalRefreshAlert_Desc": "This alert type should get triggered if there is a change in the pattern of renewing access tokens of an application by a user. These alerts could be treated as an indication of a stolen access token.", + "AbnormalRefreshAlert_Desc": "This alert gets triggered if there is a change in the pattern of renewing access tokens of an application by a user. These alerts could be treated as an indication of a stolen access token.", "AbnormalTierUsage": "Abnormal API Usage", - "AbnormalTierUsage_Desc": "This alert should get triggered if there is a drastic reduction in API usage for a given API for a given user. These types of alerts should be treated as an indication of a failure of the application using the altered API.", + "AbnormalTierUsage_Desc": "This alert gets triggered if there is a drastic reduction in API usage for a given API for a given user. These types of alerts should be treated as an indication of a failure of the application using the altered API.", "Access Token Errors": "Access Token Errors", "Actions": "Actions", "Activate": "Activate", @@ -88,7 +89,7 @@ "Description of the throttle policy.": "Description of the throttle policy.", "Domains": "Domains", "Edit": "Edit", - "Edit Advanced Throttle Throttle Policy": "Edit Advanced Throttle Throttle Policy", + "Edit Advanced Throttle Policy": "Edit Advanced Throttle Policy", "Edit Configurations": "Edit Configurations", "Edit Custom Policy": "Edit Custom Policy", "Edit Subscription Tier": "Edit Subscription Tier", @@ -101,17 +102,18 @@ "Error occurred while saving policy (Cause:": "Error occurred while saving policy (Cause:", "Error!": "Error!", "Execution Policy": "Execution Policy", - "Following query will allow 5 request per minute for Admin user": "Following query will allow 5 request per minute for Admin user", + "Following query will allow 5 request per minute for Admin user": "The following query will allow 5 requests per minute for an Admin user", "Format : ": "Format : ", "Free": "Free", "FrequentTierHittingAlert": "Tier Crossing", - "FrequentTierHittingAlert_Desc": "This alert type should get triggered if at least one of the two cases below are satisfied; if a particular application gets throttled out for hitting the subscribed tier limit of that application, more than 10 times (by default) within a day (by default) or if a particular user of an application, gets throttled out for hitting the subscribed tier limit of a particular API, more than 10 times (by default) within a day (by default)", + "FrequentTierHittingAlert_Desc": "This alert gets triggered if at least one of the two cases below are satisfied; if a particular application gets throttled out for hitting the subscribed tier limit of that application, more than 10 times (by default) within a day (by default) or, if a particular user of an application gets throttled out for hitting the subscribed tier limit of a particular API, more than 10 times (by default) within a day (by default)", "GEO Location configurations": "GEO Location configurations", "General Details": "General Details", "Go Back": "Go Back", "Header Condition Policy ": "Header Condition Policy ", "Header Data": "Header Data", "Header Name:": "Header Name:", + "Health Availability": "Health Availability", "Hour(s)": "Hour(s)", "ID": "ID", "IP Address": "IP Address", @@ -129,7 +131,7 @@ "JWT Token": "JWT Token", "KB": "KB", "Key Template": "Key Template", - "Key Template Already Exists. Add a new Key Template": "Key Template Already Exists. Add a new Key Template", + "Key Template Already Exists. Add a new Key Template": "Key Template already exists. Add a new Key Template", "Live Log Viewer": "Live Log Viewer", "Live log viewer": "Live log viewer", "Log Analyzer": "Log Analyzer", @@ -137,7 +139,7 @@ "Login Errors": "Login Errors", "Logout": "Logout", "MB": "MB", - "Manage Alert Types": "Manage Alert Types", + "Manage Alert Types": "Manage Alerts", "Manage Tiers": "Manage Tiers", "Minute(s)": "Minute(s)", "Modal title": "Modal title", @@ -149,10 +151,10 @@ "Name of the header.": "Name of the header.", "Name of the query param.": "Name of the query param.", "Name of the throttle policy.": "Name of the throttle policy.", - "No Configurations to be listed": "No Configurations to be listed", + "No Configurations to be listed": "No configurations to be listed", "No Custom Rules Found": "No Custom Rules Found", "No properties to configure.": "No properties to configure.", - "No tasks assigned to the login user or no connectivity with BPS engine.": "No tasks assigned to the login user or no connectivity with BPS engine.", + "No tasks assigned to the login user or no connectivity with BPS engine.": "No tasks assigned to the logged-in user or no connectivity with the BPS engine.", "No tasks assigned to the signed-in user or no connectivity with the BPS engine.": "No tasks assigned to the signed-in user or no connectivity with the BPS engine.", "Number of API Failures": "Number of API Failures", "Number of requests allowed.": "Number of requests allowed.", @@ -181,7 +183,7 @@ "Request/min": "Request/min", "Request/s": "Request/s", "RequestPatternChanged": "Abnormal Resource Access", - "RequestPatternChanged_Desc": "This alert type should get triggered if there is a change in the resource access pattern of a user of a particular Application. These alerts could be treated as an indication of a suspicious activity made by a user over your application.", + "RequestPatternChanged_Desc": "This alert gets triggered if there is a change in the resource access pattern of a user of a particular application. These alerts could be treated as an indication of a suspicious activity made by a user over your application.", "Required": "Required", "Reset": "Reset", "Roles": "Roles", @@ -210,15 +212,15 @@ "Success!": "Success!", "Tasks": "Tasks", "Template Name": "Template Name", - "The theme should be a zip file containing css and images compliant with the API Manager theme format": "The theme should be a zip file containing css and images compliant with the API Manager theme format", - "Theme was uploaded successfully.": "Theme was uploaded successfully.", + "The theme should be a zip file containing css and images compliant with the API Manager theme format": "The theme should be a zip file containing CSS and images compliant with the API Manager theme format", + "Theme was uploaded successfully.": "The theme was uploaded successfully.", "This configuration is used to define JWT claims conditions": "This configuration is used to define JWT claims conditions", "This configuration is used to throttle based on Headers.": "This configuration is used to throttle based on Headers.", "This configuration is used to throttle by IP address.": "This configuration is used to throttle by IP address.", - "This configuration use to throttle based on query parameters.": "This configuration use to throttle based on query parameters.", + "This configuration use to throttle based on query parameters.": "This configuration is used to throttle based on query parameters.", "This tier is ": "This tier is ", "Throttle Based on bandwidth.": "Throttle Based on bandwidth.", - "Throttle Policies": "Throttle Policies", + "Throttle Policies": "Throttling Policies", "Throttle based on request count .": "Throttle based on request count .", "Throttling Tiers": "Throttling Tiers", "Tier Crossing": "Tier Crossing", @@ -230,7 +232,7 @@ "Unseen Source IP Address": "Unseen Source IP Address", "Unsubscribe": "Unsubscribe", "UnusualIPAccessAlert": "Unseen Source IP Access", - "UnusualIPAccessAlert_Desc": "This alert type should get triggered if there is either a change in the request source IP for a particular API of an application or if the request is from an IP used before a time period of 30 days (default). These alerts could be treated as an indication of a suspicious activity made by a user over an API of an application. ", + "UnusualIPAccessAlert_Desc": "This alert gets triggered if there is either a change in the request source IP for a particular API of an application or, if the request is from an IP used before a time period of 30 days (default). These alerts could be treated as an indication of a suspicious activity made by a user over an API of an application. ", "Update": "Update", "Upload": "Upload", "Upload Tenant Theme": "Upload Tenant Theme", @@ -241,25 +243,25 @@ "Value of the JWT claim.": "Value of the JWT claim.", "Value of the header.": "Value of the header.", "Value of the query param.": "Value of the query param.", - "WSO2 API Manager": "WSO2 API Manager", + "WSO2 API Manager": "Apigate Internal Gateway", "Warning!": "Warning!", "Week(s)": "Week(s)", "Will be applicable to the whole API.": "Will be applicable to the whole API.", "Year(s)": "Year(s)", "_Desc": "_Desc", "abnormalBackendTime": "Abnormal Backend Time", - "abnormalBackendTime_Desc": "This alert type should get triggered if there is a sudden increase in the backend time corresponding to a particular API resource. These alerts could be treated as an indication of a slow backend. In technical terms, if the backend time of a particular API resource (eg: GET /calc/1.0/numbers) of a tenant lies outside the Xth percentile value, we will send an alert out. Default percentile value is 95%. Here, we safely assume that the corresponding backend time of an API resource follows a normal distribution. Percentile value gets calculated daily by default. ", + "abnormalBackendTime_Desc": "This alert gets triggered if there is a sudden increase in the backend time corresponding to a particular API resource. These alerts could be treated as an indication of a slow backend. In technical terms, if the backend time of a particular API resource (eg: GET /calc/1.0/numbers) of a tenant lies outside the Xth percentile value, an alert is sent out. The default percentile value is 95%. Here, we safely assume that the corresponding backend time of an API resource follows a normal distribution. Percentile value gets calculated daily by default. ", "abnormalRequestsPerMin": "Abnormal Request Count", - "abnormalRequestsPerMin_Desc": "This alert type should get triggered if there is a sudden spike or a drop in the request count within a period of one minute by default for a particular API resource. These alerts could be treated as an indication of a possible high traffic or suspicious act or possible malfunction of the client application etc.", + "abnormalRequestsPerMin_Desc": "This alert gets triggered if there is a sudden spike or drop in the request count within a period of one minute, by default, for a particular API resource. These alerts could be treated as an indication of possible high traffic, suspicious activity, possible malfunction of the client application, etc.", "abnormalResponseTime": "Abnormal Response Time", - "abnormalResponseTime_Desc": "This alert type should get triggered if there is a sudden increase in the response time of a particular API resource. These alerts could be treated as an indication of a slow WSO2 API Manager runtime or a slow backend. ", + "abnormalResponseTime_Desc": "This alert gets triggered if there is a sudden increase in the response time of a particular API resource. These alerts could be treated as an indication of a slow WSO2 API Manager runtime or a slow backend. ", "blocked": "BLOCKED", "common.button.edit": "common.button.edit", "controlled": "Restricted by tenants", "created": "CREATED", "deprecated": "DEPRECATED", "healthAvailabilityPerMin": "Health Availability", - "healthAvailabilityPerMin_Desc": "This alert type should get triggered if at least one of the three cases below are satisfied; Response time of an API > Response time upper percentile of that particular API or Request Count of an API per minute > Request count per minute lower percentile or Response status code >= 500 (By Default) AND Response status code < 600 (By Default)", + "healthAvailabilityPerMin_Desc": "This alert gets triggered if at least one of the three cases below are satisfied; Response time of an API > Response time upper percentile of that particular API or Request count of an API per minute > Request count per minute lower percentile or Response status code >= 500 (By Default) AND Response status code < 600 (By Default)", "isn't configured. If a policy configured with any of these conditions, it won't be applied.": "isn't configured. If a policy configured with any of these conditions, it won't be applied.", "myTasks": "myTasks", "private": "Visible to my domain", @@ -267,8 +269,17 @@ "published": "PUBLISHED", "restricted": "Restricted by roles", "retired": "RETIRED", - "roles": "Visible to Roles", + "roles": "Visible to roles", "settings": "settings", "tasks": "tasks", - "tenants": "Visible to Tenants" -} \ No newline at end of file + "tenants": "Visible to tenants", + "Type an Email and press Enter":"Type an email address and press Enter", + "Label contains spaces": "Label contains spaces", + "Label": "Label", + "Label contains one or more illegal characters": "Label contains one or more illegal characters ", + "Generate" : "Generate", + "Applications" : "Applications", + "Application Name" : "Application Name", + "Owner" : "Owner", + "Change Application Owner" : "Change Application Owner" +} diff --git a/components/jaggery-apps/admin/src/main/admin/site/themes/wso2/css/custom.css b/components/jaggery-apps/admin/src/main/admin/site/themes/wso2/css/custom.css index 873d1ea39..2d83debf4 100644 --- a/components/jaggery-apps/admin/src/main/admin/site/themes/wso2/css/custom.css +++ b/components/jaggery-apps/admin/src/main/admin/site/themes/wso2/css/custom.css @@ -11,6 +11,12 @@ padding-top: 100px; padding-bottom: 100px; } +.might-overflow { + width:500px; + text-overflow: ellipsis; + overflow : hidden; + white-space: nowrap; +} input.ep-field{ min-width: 50%; @@ -293,4 +299,19 @@ table.table-bordered th:last-child, table.table-bordered td:last-child { .popover-content span.wrap-long-text{ word-break: break-all; white-space: pre-wrap; +} + +/* ======================================================================== + * custom styling + * ======================================================================== */ + + + +.copyright_logo { + background: transparent url(../images/logo-inverse.svg) no-repeat scroll left bottom; + display: inline-block; + height: 17px; + margin-bottom: 2px; + vertical-align: middle; + width: 65px; } \ No newline at end of file diff --git a/components/jaggery-apps/admin/src/main/admin/site/themes/wso2/images/favicon.png b/components/jaggery-apps/admin/src/main/admin/site/themes/wso2/images/favicon.png index 756e629c3..07688b91f 100644 Binary files a/components/jaggery-apps/admin/src/main/admin/site/themes/wso2/images/favicon.png and b/components/jaggery-apps/admin/src/main/admin/site/themes/wso2/images/favicon.png differ diff --git a/components/jaggery-apps/admin/src/main/admin/site/themes/wso2/images/logo-white.png b/components/jaggery-apps/admin/src/main/admin/site/themes/wso2/images/logo-white.png index eebecfbae..3dd18468f 100644 Binary files a/components/jaggery-apps/admin/src/main/admin/site/themes/wso2/images/logo-white.png and b/components/jaggery-apps/admin/src/main/admin/site/themes/wso2/images/logo-white.png differ diff --git a/components/jaggery-apps/admin/src/main/admin/site/themes/wso2/libs/theme-wso2_1.0/css/theme-wso2.css b/components/jaggery-apps/admin/src/main/admin/site/themes/wso2/libs/theme-wso2_1.0/css/theme-wso2.css index 559777dd3..4374f05e0 100644 --- a/components/jaggery-apps/admin/src/main/admin/site/themes/wso2/libs/theme-wso2_1.0/css/theme-wso2.css +++ b/components/jaggery-apps/admin/src/main/admin/site/themes/wso2/libs/theme-wso2_1.0/css/theme-wso2.css @@ -2783,7 +2783,7 @@ select[multiple].input-lg, touch-action: manipulation; cursor: pointer; background-image: none; - border: 1px solid transparent; + border: none; white-space: nowrap; padding: 6px 12px; font-size: 14px; @@ -9296,6 +9296,9 @@ a.list-group-item:hover { .btn, a.btn { /*background-color: #0E75DC; color: #fff;*/ + box-shadow: 0px 3px 1px -2px rgba(0, 0, 0, 0.2), 0px 2px 2px 0px rgba(0, 0, 0, 0.14), 0px 1px 5px 0px rgba(0, 0, 0, 0.12); + transform: translate3d(0, 0, 0); + transition: background 400ms cubic-bezier(0.25, 0.8, 0.25, 1),box-shadow 280ms cubic-bezier(0.4, 0, 0.2, 1); } .btn .disabled, a.btn .disabled { @@ -9840,7 +9843,7 @@ a.list-group-item:hover { * Login * ================================================================== */ .data-container { - border-left: 3px solid #E38E4A; + border-left: 3px solid #009deb; border-right: 1px solid #E2E2E2; border-bottom: 1px solid #E2E2E2; border-top: 1px solid #E2E2E2; @@ -9860,14 +9863,13 @@ a.list-group-item:hover { .data-container .btn-primary { color: #ffffff; - background-color: #F27B21; - border: 1px solid #F27B21; -} + background-color: #009deb; + } .data-container .btn-secondary { color: #ffffff; background-color: #595959; - border: 1px solid #595959; + border: none; } .data-container .checkbox > input[type=checkbox]:checked + .helper:after { diff --git a/components/jaggery-apps/admin/src/main/admin/site/themes/wso2/libs/theme-wso2_1.0/images/logo-inverse.svg b/components/jaggery-apps/admin/src/main/admin/site/themes/wso2/libs/theme-wso2_1.0/images/logo-inverse.svg index 52f434473..fba5e1a03 100644 --- a/components/jaggery-apps/admin/src/main/admin/site/themes/wso2/libs/theme-wso2_1.0/images/logo-inverse.svg +++ b/components/jaggery-apps/admin/src/main/admin/site/themes/wso2/libs/theme-wso2_1.0/images/logo-inverse.svg @@ -1,60 +1 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - +Asset 1 \ No newline at end of file diff --git a/components/jaggery-apps/admin/src/main/admin/site/themes/wso2/templates/breadcumb/template.jag b/components/jaggery-apps/admin/src/main/admin/site/themes/wso2/templates/breadcumb/template.jag index ecb2b00d8..b7fe1d217 100644 --- a/components/jaggery-apps/admin/src/main/admin/site/themes/wso2/templates/breadcumb/template.jag +++ b/components/jaggery-apps/admin/src/main/admin/site/themes/wso2/templates/breadcumb/template.jag @@ -65,8 +65,9 @@ - + @@ -486,9 +512,9 @@ $(window).load(function(){ function catchTheFirstAPINameForTutorial() { var isNewUserInteractiveTutorialStarted = localStorage.getItem("isNewUserInteractiveTutorialStarted"); if (isNewUserInteractiveTutorialStarted) { - var apiName = $('.page-content').parent().find('.white-wrapper').children().find('.truncate')[0]; + var apiName = $('.page-content').parent().find('.white-wrapper').children().find('.truncate')[0].textContent; if (apiName == 'undefined') { - apiName = $('.page-content').parent().find('.white-wrapper').children().find('.apiNameWrap')[0]; + apiName = $('.page-content').parent().find('.white-wrapper').children().find('.apiNameWrap')[0].textContent; } localStorage.setItem("selectedAPIName", apiName); diff --git a/components/jaggery-apps/store/src/main/store/site/themes/wso2/templates/application/application-edit/template.jag b/components/jaggery-apps/store/src/main/store/site/themes/wso2/templates/application/application-edit/template.jag index 34a1f0a68..37de292e8 100644 --- a/components/jaggery-apps/store/src/main/store/site/themes/wso2/templates/application/application-edit/template.jag +++ b/components/jaggery-apps/store/src/main/store/site/themes/wso2/templates/application/application-edit/template.jag @@ -1,203 +1,203 @@ -<% jagg.template("application/application-edit", function(inputs, outputs, jagg) { - var APIUtil = org.wso2.carbon.apimgt.impl.utils.APIUtil; - var apiPath = ""; - var goBack = ""; - if(session.get('apiPath') != null){ - apiPath = session.get('apiPath'); - } - if(request.getParameter('goBack') != null){ - goBack = request.getParameter('goBack'); - } - var mod = jagg.module("manager"); - var httpsUrl= mod.getHTTPsURL(); - var i=0, tiers = outputs.tiers; - var app = outputs.application; - - var appConfig = require("/modules/application/application-attributes.jag"); - var attributesFromConfig = appConfig.readApplicationAttributes(); - var description = ""; - var groupId = ""; - var callbackUrl = ""; - var tokenType = ""; - var tokenTypeDefault = ""; - var tokenTypeJWT = ""; - if(app.description != null ){ - description = app.description; - } -if(app.groupId != null ){ - groupId = app.groupId; -} - if(app.callbackUrl != null ){ - callbackUrl = app.callbackUrl; - } - if (app.applicationAttributes != null) { - applicationAttributes = JSON.parse(app.applicationAttributes); - } - - function isRequiredAttribute(key) { - var flag = false; - for (var i = 0; i < attributesFromConfig.length; i++) { - if (key == attributesFromConfig[i].Attribute && (attributesFromConfig[i].Required || attributesFromConfig[i].required)) { - flag = true; - } - } - return flag; - } -if(app.tokenType != null ){ - tokenType = app.tokenType; - if(tokenType == "JWT"){ - tokenTypeJWT = "Selected"; - } else { - tokenTypeDefault = "Selected"; - } -} -%> - - - - - -
-
-
- - "/> - -
- -
- -
-
-
- <% - if(!APIUtil.isAdvanceThrottlingEnabled()){ - %> - - <% } else { %> - - <% } %> -
- -
- <%=encode.forHtml(unlimitedTierDesc+"")%> -
-
<%=i18n.localize("This feature allows you to assign an API request quota per access token. Allocated quota will be shared among all the subscribed APIs of the application.")%>
- "/> -
-
- -<% -if(jagg.isMultiGroupEnabled()){ -%> -
- -
- - - - -

<%=i18n.localize("Type a group and enter")%>

-
-
-<%}%> - -
- -
- -
-
- - <% // variable applicationAttributes is JSON Object - // Ex: {"External Reference Id" : "###", "Billing Tier" : "###"} - if (applicationAttributes != null) { - var count = 0; - for (var attributeKey in applicationAttributes) {%> -
- -
- - -
- <% } else { %> - -
- - - value="<%=encode.forHtml(applicationAttributes[attributeKey])%>" - <% } %> /> -
- <% } - count += 1; %> -
- <% } %> - - <% } %> - -
- -
- -
- -
- - - - -
-
-<% }); %> +<% jagg.template("application/application-edit", function(inputs, outputs, jagg) { + var APIUtil = org.wso2.carbon.apimgt.impl.utils.APIUtil; + var apiPath = ""; + var goBack = ""; + if(session.get('apiPath') != null){ + apiPath = session.get('apiPath'); + } + if(request.getParameter('goBack') != null){ + goBack = request.getParameter('goBack'); + } + var mod = jagg.module("manager"); + var httpsUrl= mod.getHTTPsURL(); + var i=0, tiers = outputs.tiers; + var app = outputs.application; + + var appConfig = require("/modules/application/application-attributes.jag"); + var attributesFromConfig = appConfig.readApplicationAttributes(); + var description = ""; + var groupId = ""; + var callbackUrl = ""; + var tokenType = ""; + var tokenTypeDefault = ""; + var tokenTypeJWT = ""; + if(app.description != null ){ + description = app.description; + } +if(app.groupId != null ){ + groupId = app.groupId; +} + if(app.callbackUrl != null ){ + callbackUrl = app.callbackUrl; + } + if (app.applicationAttributes != null) { + applicationAttributes = JSON.parse(app.applicationAttributes); + } + + function isRequiredAttribute(key) { + var flag = false; + for (var i = 0; i < attributesFromConfig.length; i++) { + if (key == attributesFromConfig[i].Attribute && (attributesFromConfig[i].Required || attributesFromConfig[i].required)) { + flag = true; + } + } + return flag; + } +if(app.tokenType != null ){ + tokenType = app.tokenType; + if(tokenType == "JWT"){ + tokenTypeJWT = "Selected"; + } else { + tokenTypeDefault = "Selected"; + } +} +%> + + + + + +
+
+
+ + "/> + +
+ +
+ +
+
+
+ <% + if(!APIUtil.isAdvanceThrottlingEnabled()){ + %> + + <% } else { %> + + <% } %> +
+ +
+ <%=encode.forHtml(unlimitedTierDesc+"")%> +
+
<%=i18n.localize("This feature allows you to assign an API request quota per access token. Allocated quota will be shared among all the subscribed APIs of the application.")%>
+ "/> +
+
+ +<% +if(jagg.isMultiGroupEnabled()){ +%> +
+ +
+ + + + +

<%=i18n.localize("Type a group and enter")%>

+
+
+<%}%> + +
+ +
+ +
+
+ + <% // variable applicationAttributes is JSON Object + // Ex: {"External Reference Id" : "###", "Billing Tier" : "###"} + if (applicationAttributes != null) { + var count = 0; + for (var attributeKey in applicationAttributes) {%> +
+ +
+ + +
+ <% } else { %> + +
+ + + value="<%=encode.forHtml(applicationAttributes[attributeKey])%>" + <% } %> /> +
+ <% } + count += 1; %> +
+ <% } %> + + <% } %> + +
+ +
+ +
+ +
+ + + + +
+
+<% }); %> diff --git a/components/jaggery-apps/store/src/main/store/site/themes/wso2/templates/user/sign-up/js/sign-up.js b/components/jaggery-apps/store/src/main/store/site/themes/wso2/templates/user/sign-up/js/sign-up.js index e36c9fcc8..8bd560627 100644 --- a/components/jaggery-apps/store/src/main/store/site/themes/wso2/templates/user/sign-up/js/sign-up.js +++ b/components/jaggery-apps/store/src/main/store/site/themes/wso2/templates/user/sign-up/js/sign-up.js @@ -1,85 +1,83 @@ var container; $(document).ready(function() { - $.validator.addMethod("matchPasswords", function(value) { - return value == $("#newPassword").val(); - }, i18n.t("The passwords you entered do not match.")); + $.validator.addMethod("matchPasswords", function (value) { + return value == $("#newPassword").val(); + }, i18n.t("The passwords you entered do not match.")); $.validator.addMethod('noSpace', function(value, element) { - return !/\s/g.test(value); + return !/\s/g.test(value); }, i18n.t('The name contains white spaces.')); - $.validator.addMethod("passwordValidate",function(value){ - var maxLength = 30; - var minLength = 6; - return (value.length >= minLength && value.length <= maxLength) && value.match(/[a-z]/) && value.match(/[A-Z]/) && value.match(/\d+/) && value.match(/.[!,@,#,$,%,^,&,*,?,_,~,-,(,)]/) - },i18n.t('Minimum system requirements not met')); - var purposes = document.getElementById("consentPurposes").value; if (purposes != undefined && purposes != null && purposes != "") { - purposes = JSON.parse(document.getElementById("consentPurposes").value); + purposes = JSON.parse(document.getElementById("consentPurposes").value); } var hasPurposes = document.getElementById("hasConsentPurposes").value; $("#sign-up").validate({ - submitHandler: function(form) { - var fieldCount = document.getElementById('fieldCount').value; - var allFieldsValues; - for(var i = 0; i < fieldCount; i++) { - var value = document.getElementById( i + '.0cliamUri').value; - if ( i == 0) { - allFieldsValues = value; - } else { - allFieldsValues = allFieldsValues + "|" + value; - } - } - var tenantDomain = document.getElementById('hiddenTenantDomain').value; - var fullUserName; - if(tenantDomain == "null" || tenantDomain == "carbon.super") { - fullUserName = document.getElementById('newUsername').value; - } else { - fullUserName = document.getElementById('newUsername').value + "@" + submitHandler: function (form) { + var fieldCount = document.getElementById('fieldCount').value; + var allFieldsValues; + for (var i = 0; i < fieldCount; i++) { + var value = document.getElementById(i + '.0cliamUri').value; + if (i == 0) { + allFieldsValues = value; + } else { + allFieldsValues = allFieldsValues + "|" + value; + } + } + var tenantDomain = document.getElementById('hiddenTenantDomain').value; + var fullUserName; + if (tenantDomain == "null" || tenantDomain == "carbon.super") { + fullUserName = document.getElementById('newUsername').value; + } else { + fullUserName = document.getElementById('newUsername').value + "@" + tenantDomain; - } + } - jagg.post("/site/blocks/user/sign-up/ajax/user-add.jag", { - action:"addUser", - username:fullUserName, - password:$('#newPassword').val(), - allFieldsValues:allFieldsValues - }, function (result) { - if (result.error == false) { - if(result.showWorkflowTip) { - jagg.message({content: i18n.t("User account awaiting Administrator approval.") ,type:"info", - cbk:function() { - if (hasPurposes == 'true') { - var receipt = addReceiptInformation(container); - $('').attr('type', 'hidden') - .attr('name', "consent") - .attr('value', JSON.stringify(receipt)) - .appendTo('#signUpRedirectForm'); + jagg.post("/site/blocks/user/sign-up/ajax/user-add.jag", { + action: "addUser", + username: fullUserName, + password: $('#newPassword').val(), + allFieldsValues: allFieldsValues + }, function (result) { + if (result.error == false) { + if (result.showWorkflowTip) { + jagg.message({ + content: i18n.t("User added successfully. You can now sign into the API store using the new user account."), + type: "info", + cbk: function () { + if (hasPurposes == 'true') { + var receipt = addReceiptInformation(container); + $('').attr('type', 'hidden') + .attr('name', "consent") + .attr('value', JSON.stringify(receipt)) + .appendTo('#signUpRedirectForm'); + } + $('#signUpRedirectForm').submit(); } - $('#signUpRedirectForm').submit(); - } - }); - } else { - jagg.message({content: i18n.t("User added successfully. You can now sign into the API store using the new user account."), type:"info", - cbk:function() { - if (hasPurposes == 'true') { - var receipt = addReceiptInformation(container); - $('').attr('type', 'hidden') - .attr('name', "consent") - .attr('value', JSON.stringify(receipt)) - .appendTo('#signUpRedirectForm'); + }); + } else { + jagg.message({ + content: i18n.t("User added successfully. You can now sign into the API store using the new user account."), + type: "info", + cbk: function () { + if (hasPurposes == 'true') { + var receipt = addReceiptInformation(container); + $('').attr('type', 'hidden') + .attr('name', "consent") + .attr('value', JSON.stringify(receipt)) + .appendTo('#signUpRedirectForm'); + } + $('#signUpRedirectForm').submit(); } - $('#signUpRedirectForm').submit(); - } - }); + }); + } + } else { + jagg.message({content: result.message, type: "error"}); } - } else { - jagg.message({content:result.message,type:"error"}); - } - }, "json"); - } + }, "json"); + } }); $("#newPassword").keyup(function() { $(this).valid(); @@ -99,16 +97,16 @@ $(document).ready(function() { if (agreementChk.length > 0) { registrationBtn.prop("disabled", true).addClass("disabled"); } - agreementChk.click(function() { + agreementChk.click(function () { if ($(this).is(":checked")) { registrationBtn.prop("disabled", false).removeClass("disabled"); } else { - registrationBtn.prop("disabled", true).addClass("disabled"); + registrationBtn.prop("disabled", true).addClass("disabled"); } - }); - if (hasPurposes == 'true') { - renderReceiptDetails(purposes); - } + }); + if (hasPurposes == 'true') { + renderReceiptDetails(purposes); + } }); function renderReceiptDetails(data) { @@ -209,12 +207,12 @@ function unflatten(arr) { } var showMoreFields = function () { - $('#moreFields').show(); - $('#moreFieldsLink').hide(); - $('#hideFieldsLink').show(); + $('#moreFields').show(); + $('#moreFieldsLink').hide(); + $('#hideFieldsLink').show(); } var hideMoreFields = function () { - $('#moreFields').hide(); - $('#hideFieldsLink').hide(); - $('#moreFieldsLink').show(); + $('#moreFields').hide(); + $('#hideFieldsLink').hide(); + $('#moreFieldsLink').show(); } diff --git a/components/jaggery-apps/store/src/main/store/site/themes/wso2/templates/user/sign-up/template.jag b/components/jaggery-apps/store/src/main/store/site/themes/wso2/templates/user/sign-up/template.jag index 1a8534912..ad4f7aedd 100644 --- a/components/jaggery-apps/store/src/main/store/site/themes/wso2/templates/user/sign-up/template.jag +++ b/components/jaggery-apps/store/src/main/store/site/themes/wso2/templates/user/sign-up/template.jag @@ -52,7 +52,7 @@
- +