Merge branch 'release-2.0.x' of https://github.com/wso2/carbon-device-mgt into release-2.0.x

revert-70aa11f8
inoshperera 8 years ago
commit e6a70b2394

@ -119,7 +119,7 @@ public class ApiPermissionFilter implements Filter {
.getThreadLocalCarbonContext().getTenantId()); .getThreadLocalCarbonContext().getTenantId());
return userRealm.getAuthorizationManager().isUserAuthorized(username, permission, action); return userRealm.getAuthorizationManager().isUserAuthorized(username, permission, action);
} catch (UserStoreException e) { } catch (UserStoreException e) {
String errorMsg = String.format("Unable to authorize the user : %s", username, e); String errorMsg = String.format("Unable to authorize the user : %s", username);
log.error(errorMsg, e); log.error(errorMsg, e);
return false; return false;
} }

@ -83,11 +83,7 @@ public class GsonMessageBodyHandler implements MessageBodyWriter<Object>, Messag
OutputStreamWriter writer = new OutputStreamWriter(entityStream, UTF_8); OutputStreamWriter writer = new OutputStreamWriter(entityStream, UTF_8);
try { try {
Type jsonType = null; getGson().toJson(object, type, writer);
if (type.equals(type)) {
jsonType = type;
}
getGson().toJson(object, jsonType, writer);
} finally { } finally {
writer.close(); writer.close();
} }

@ -83,11 +83,7 @@ public class GsonMessageBodyHandler implements MessageBodyWriter<Object>, Messag
OutputStreamWriter writer = new OutputStreamWriter(entityStream, UTF_8); OutputStreamWriter writer = new OutputStreamWriter(entityStream, UTF_8);
try { try {
Type jsonType = null; getGson().toJson(object, type, writer);
if (type.equals(type)) {
jsonType = type;
}
getGson().toJson(object, jsonType, writer);
} finally { } finally {
writer.close(); writer.close();
} }

@ -91,6 +91,7 @@
<Import-Package> <Import-Package>
javax.naming, javax.naming,
javax.sql, javax.sql,
javax.xml,
javax.xml.bind, javax.xml.bind,
javax.xml.bind.annotation, javax.xml.bind.annotation,
javax.xml.parsers; version="${javax.xml.parsers.import.pkg.version}", javax.xml.parsers; version="${javax.xml.parsers.import.pkg.version}",

@ -21,8 +21,10 @@ package org.wso2.carbon.device.mgt.extensions.device.type.deployer.util;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.exception.DeviceTypeConfigurationException; import org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.exception.DeviceTypeConfigurationException;
import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import java.io.File; import java.io.File;
/** /**
@ -34,8 +36,12 @@ public class DeviceTypeConfigUtil {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true); factory.setNamespaceAware(true);
try { try {
factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
DocumentBuilder docBuilder = factory.newDocumentBuilder(); DocumentBuilder docBuilder = factory.newDocumentBuilder();
return docBuilder.parse(file); return docBuilder.parse(file);
} catch (ParserConfigurationException e) {
e.printStackTrace();
return null;
} catch (Exception e) { } catch (Exception e) {
throw new DeviceTypeConfigurationException("Error occurred while parsing file, while converting " + throw new DeviceTypeConfigurationException("Error occurred while parsing file, while converting " +
"to a org.w3c.dom.Document", e); "to a org.w3c.dom.Document", e);

@ -83,11 +83,7 @@ public class GsonMessageBodyHandler implements MessageBodyWriter<Object>, Messag
OutputStreamWriter writer = new OutputStreamWriter(entityStream, UTF_8); OutputStreamWriter writer = new OutputStreamWriter(entityStream, UTF_8);
try { try {
Type jsonType = null; getGson().toJson(object, type, writer);
if (type.equals(type)) {
jsonType = type;
}
getGson().toJson(object, jsonType, writer);
} finally { } finally {
writer.close(); writer.close();
} }

@ -370,7 +370,7 @@ public class DeviceInfo implements Serializable {
} }
public Date getUpdatedTime() { public Date getUpdatedTime() {
if(updatedTime.equals(null)){ if(updatedTime == null){
updatedTime = new Date(); updatedTime = new Date();
} }
return updatedTime; return updatedTime;

@ -137,7 +137,7 @@ public class DeviceLocation implements Serializable {
} }
public Date getUpdatedTime() { public Date getUpdatedTime() {
if(updatedTime.equals(null)){ if(updatedTime == null ){
updatedTime = new Date(); updatedTime = new Date();
} }
return updatedTime; return updatedTime;

@ -48,6 +48,10 @@ public class NotificationContext {
return properties; return properties;
} }
public void setProperties(Map<String, String> propertiesMap) {
properties = propertiesMap;
}
public Operation getOperation() { public Operation getOperation() {
return operation; return operation;
} }

@ -121,9 +121,9 @@ if (uriMatcher.match("/{context}/api/user/authenticate")) {
} else { } else {
userRoles = String(addUserFormData.userRoles).split(","); userRoles = String(addUserFormData.userRoles).split(",");
} }
if (username.length < devicemgtProps.usernameLength) { if (username.length < devicemgtProps.userValidationConfig.usernameLength) {
log.error("Username Must be between 1 and " + devicemgtProps.usernameLength + " characters long"); log.error("Username Must be between 1 and " + devicemgtProps.userValidationConfig.usernameLength + " characters long");
result = "Username Must be between 1 and " + devicemgtProps.usernameLength + " characters long"; result = "Username Must be between 1 and " + devicemgtProps.userValidationConfig.usernameLength + " characters long";
} else { } else {
try { try {
result = userModule.addUser(username, firstname, lastname, emailAddress, userRoles); result = userModule.addUser(username, firstname, lastname, emailAddress, userRoles);

@ -1,7 +1,5 @@
{ {
"appContext": "/devicemgt/", "appContext": "/devicemgt/",
"webAgentContext" : "/emm-web-agent/",
"apiContext": "api",
"httpsURL" : "%https.ip%", "httpsURL" : "%https.ip%",
"httpURL" : "%http.ip%", "httpURL" : "%http.ip%",
"httpsWebURL" : "%https.ip%", "httpsWebURL" : "%https.ip%",
@ -15,7 +13,7 @@
"iOSConfigRoot" : "%https.ip%/ios-enrollment/", "iOSConfigRoot" : "%https.ip%/ios-enrollment/",
"iOSAPIRoot" : "%https.ip%/ios/", "iOSAPIRoot" : "%https.ip%/ios/",
"adminService": "%https.ip%", "adminService": "%https.ip%",
"apimgt-gateway": false, "gatewayEnabled": false,
"oauthProvider": { "oauthProvider": {
"appRegistration": { "appRegistration": {
"appType": "webapp", "appType": "webapp",
@ -32,19 +30,8 @@
"adminUser":"admin@carbon.super", "adminUser":"admin@carbon.super",
"adminUserTenantId":"-1234", "adminUserTenantId":"-1234",
"adminRole":"admin", "adminRole":"admin",
"usernameLength":30,
"pageSize":10,
"ssoConfiguration" : {
"enabled" : false,
"issuer" : "devicemgt",
"appName" : "devicemgt",
"identityProviderURL" : "%https.ip%/sso/samlsso.jag",
"responseSigningEnabled" : "true",
"keyStorePassword" : "wso2carbon",
"identityAlias" : "wso2carbon",
"keyStoreName" : "/repository/resources/security/wso2carbon.jks"
},
"userValidationConfig" : { "userValidationConfig" : {
"usernameLength":30,
"usernameJSRegEx" : "^[\\S]{3,30}$", "usernameJSRegEx" : "^[\\S]{3,30}$",
"usernameRegExViolationErrorMsg" : "Provided username is invalid.", "usernameRegExViolationErrorMsg" : "Provided username is invalid.",
"usernameHelpMsg" : "Should be in minimum 3 characters long and do not include any whitespaces.", "usernameHelpMsg" : "Should be in minimum 3 characters long and do not include any whitespaces.",

@ -138,7 +138,7 @@ var handlers = function () {
"client credentials to session context. No username of logged in user is found as " + "client credentials to session context. No username of logged in user is found as " +
"input - setUpEncodedTenantBasedClientAppCredentials(x)"); "input - setUpEncodedTenantBasedClientAppCredentials(x)");
} else { } else {
if (devicemgtProps["apimgt-gateway"]) { if (devicemgtProps["gatewayEnabled"]) {
var tenantBasedClientAppCredentials = tokenUtil.getTenantBasedClientAppCredentials(username); var tenantBasedClientAppCredentials = tokenUtil.getTenantBasedClientAppCredentials(username);
if (!tenantBasedClientAppCredentials) { if (!tenantBasedClientAppCredentials) {
throw new Error("{/app/modules/oauth/token-handlers.js} Could not set up encoded tenant " + throw new Error("{/app/modules/oauth/token-handlers.js} Could not set up encoded tenant " +
@ -176,7 +176,7 @@ var handlers = function () {
"client credentials to session context. No username of logged in user is found as " + "client credentials to session context. No username of logged in user is found as " +
"input - setUpEncodedTenantBasedWebSocketClientAppCredentials(x)"); "input - setUpEncodedTenantBasedWebSocketClientAppCredentials(x)");
} else { } else {
if (devicemgtProps["apimgt-gateway"]) { if (devicemgtProps["gatewayEnabled"]) {
var tenantBasedWebSocketClientAppCredentials var tenantBasedWebSocketClientAppCredentials
= tokenUtil.getTenantBasedWebSocketClientAppCredentials(username); = tokenUtil.getTenantBasedWebSocketClientAppCredentials(username);
if (!tenantBasedWebSocketClientAppCredentials) { if (!tenantBasedWebSocketClientAppCredentials) {

@ -33,7 +33,7 @@ function onRequest(context) {
viewModel["roles"] = response["content"]; viewModel["roles"] = response["content"];
} }
viewModel["charLimit"] = mdmProps["usernameLength"]; viewModel["charLimit"] = mdmProps["userValidationConfig"]["usernameLength"];
viewModel["usernameJSRegEx"] = mdmProps["userValidationConfig"]["usernameJSRegEx"]; viewModel["usernameJSRegEx"] = mdmProps["userValidationConfig"]["usernameJSRegEx"];
viewModel["usernameHelpText"] = mdmProps["userValidationConfig"]["usernameHelpMsg"]; viewModel["usernameHelpText"] = mdmProps["userValidationConfig"]["usernameHelpMsg"];
viewModel["usernameRegExViolationErrorMsg"] = mdmProps["userValidationConfig"]["usernameRegExViolationErrorMsg"]; viewModel["usernameRegExViolationErrorMsg"] = mdmProps["userValidationConfig"]["usernameRegExViolationErrorMsg"];

@ -40,7 +40,7 @@ function onRequest() {
} }
var userStores = userModule.getSecondaryUserStores(); var userStores = userModule.getSecondaryUserStores();
page["userStores"] = userStores; page["userStores"] = userStores;
page["charLimit"] = devicemgtProps["usernameLength"]; page["charLimit"] = devicemgtProps["userValidationConfig"]["usernameLength"];
page["usernameJSRegEx"] = devicemgtProps["userValidationConfig"]["usernameJSRegEx"]; page["usernameJSRegEx"] = devicemgtProps["userValidationConfig"]["usernameJSRegEx"];
page["usernameHelpMsg"] = devicemgtProps["userValidationConfig"]["usernameHelpMsg"]; page["usernameHelpMsg"] = devicemgtProps["userValidationConfig"]["usernameHelpMsg"];
page["usernameRegExViolationErrorMsg"] = devicemgtProps["userValidationConfig"]["usernameRegExViolationErrorMsg"]; page["usernameRegExViolationErrorMsg"] = devicemgtProps["userValidationConfig"]["usernameRegExViolationErrorMsg"];

@ -15,4 +15,5 @@
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
}} }}
{{#zone "productName"}}WSO2 IoT{{/zone}} {{#zone "productName"}}WSO2 IoT Server{{/zone}}
{{#zone "productNameResponsive"}}WSO2 IoT Server{{/zone}}

@ -90,6 +90,9 @@ public class JWTAuthenticator implements WebappAuthenticator {
if (requestUri == null || "".equals(requestUri)) { if (requestUri == null || "".equals(requestUri)) {
authenticationInfo.setStatus(Status.CONTINUE); authenticationInfo.setStatus(Status.CONTINUE);
} }
if (requestUri == null) {
requestUri = "";
}
StringTokenizer tokenizer = new StringTokenizer(requestUri, "/"); StringTokenizer tokenizer = new StringTokenizer(requestUri, "/");
String context = tokenizer.nextToken(); String context = tokenizer.nextToken();
if (context == null || "".equals(context)) { if (context == null || "".equals(context)) {

Loading…
Cancel
Save