diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml
index 11b998998d..56d1b5b78b 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/pom.xml
@@ -286,6 +286,11 @@
org.wso2.carbon.application.mgt.stub
provided
+
+ org.wso2.carbon.devicemgt
+ org.wso2.carbon.identity.jwt.client.extension
+ provided
+
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/admin/DeviceTypePublisherAdminServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/admin/DeviceTypePublisherAdminServiceImpl.java
index 66548fee52..0efa036da0 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/admin/DeviceTypePublisherAdminServiceImpl.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/admin/DeviceTypePublisherAdminServiceImpl.java
@@ -18,8 +18,6 @@
*/
package org.wso2.carbon.device.mgt.jaxrs.service.impl.admin;
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMXMLBuilderFactory;
import org.apache.axis2.client.Options;
import org.apache.axis2.java.security.SSLProtocolSocketFactory;
import org.apache.axis2.transport.http.HTTPConstants;
@@ -36,6 +34,7 @@ import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.core.util.Utils;
import org.wso2.carbon.device.mgt.jaxrs.service.api.admin.DeviceTypePublisherAdminService;
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
+import org.wso2.carbon.identity.jwt.client.extension.JWTClient;
import org.wso2.carbon.registry.core.Registry;
import org.wso2.carbon.registry.core.Resource;
import org.wso2.carbon.registry.core.ResourceImpl;
@@ -65,9 +64,14 @@ import java.util.List;
public class DeviceTypePublisherAdminServiceImpl implements DeviceTypePublisherAdminService {
/**
- * required soap header for mutualSSL
+ * required soap header for authorization
*/
- private static final String USER_NAME_HEADER = "UserName";
+ private static final String AUTHORIZATION_HEADER = "Authorization";
+
+ /**
+ * required soap header value for mutualSSL
+ */
+ private static final String AUTHORIZATION_HEADER_VALUE = "Bearer";
private static final String KEY_STORE_TYPE = "JKS";
/**
@@ -129,22 +133,16 @@ public class DeviceTypePublisherAdminServiceImpl implements DeviceTypePublisherA
//Call to load the TrustStore.
loadTrustStore(trustStoreLocation, trustStorePassword);
//Create the SSL context with the loaded TrustStore/keystore.
- initMutualSSLConnection();
-
- //Constructing the soap header that required for mutual SSL
- String strHeader =
- "'" + tenantAdminUser +
- "'";
+ initSSLConnection();
+ JWTClient jwtClient = DeviceMgtAPIUtils.getJWTClientManagerService().getJWTClient();
- InputStream is = new ByteArrayInputStream(strHeader.getBytes());
- OMElement header = OMXMLBuilderFactory.createOMBuilder(is).getDocumentElement();
+ String authValue = AUTHORIZATION_HEADER_VALUE + " " + new String(Base64.encodeBase64(
+ jwtClient.getJwtToken(tenantAdminUser).getBytes()));
List list = new ArrayList();
Header httpHeader = new Header();
- httpHeader.setName(USER_NAME_HEADER);
- byte[] encodedBytes = Base64.encodeBase64(tenantAdminUser.getBytes());
- httpHeader.setValue(new String(encodedBytes));
+ httpHeader.setName(AUTHORIZATION_HEADER);
+ httpHeader.setValue(authValue);
list.add(httpHeader);//"https"
File directory = new File(CAR_FILE_LOCATION + File.separator + type);
@@ -153,7 +151,6 @@ public class DeviceTypePublisherAdminServiceImpl implements DeviceTypePublisherA
if (uploadedFileItems.length > 0) {
CarbonAppUploaderStub carbonAppUploaderStub = new CarbonAppUploaderStub(Utils.replaceSystemProperty(
IOT_MGT_URL));
- carbonAppUploaderStub._getServiceClient().addHeader(header);
Options appUploaderOptions = carbonAppUploaderStub._getServiceClient().getOptions();
if (appUploaderOptions == null) {
appUploaderOptions = new Options();
@@ -168,7 +165,6 @@ public class DeviceTypePublisherAdminServiceImpl implements DeviceTypePublisherA
if (!DEVICE_MANAGEMENT_TYPE.equals(type.toLowerCase())) {
carbonAppUploaderStub = new CarbonAppUploaderStub(Utils.replaceSystemProperty(DAS_URL));
- carbonAppUploaderStub._getServiceClient().addHeader(header);
appUploaderOptions = carbonAppUploaderStub._getServiceClient().getOptions();
if (appUploaderOptions == null) {
appUploaderOptions = new Options();
@@ -297,7 +293,7 @@ public class DeviceTypePublisherAdminServiceImpl implements DeviceTypePublisherA
/**
* Initializes the SSL Context
*/
- private void initMutualSSLConnection() throws NoSuchAlgorithmException, UnrecoverableKeyException,
+ private void initSSLConnection() throws NoSuchAlgorithmException, UnrecoverableKeyException,
KeyStoreException, KeyManagementException {
KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KEY_MANAGER_TYPE);
keyManagerFactory.init(keyStore, keyStorePassword);
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java
index 2e562b03b3..87d055c34f 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/DeviceMgtAPIUtils.java
@@ -36,6 +36,7 @@ import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService;
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.InputValidationException;
+import org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerService;
import org.wso2.carbon.policy.mgt.common.PolicyMonitoringTaskException;
import org.wso2.carbon.policy.mgt.core.PolicyManagerService;
import org.wso2.carbon.policy.mgt.core.task.TaskScheduleService;
@@ -168,6 +169,18 @@ public class DeviceMgtAPIUtils {
return registryService;
}
+ public static JWTClientManagerService getJWTClientManagerService() {
+ JWTClientManagerService jwtClientManagerService;
+ PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
+ jwtClientManagerService = (JWTClientManagerService) ctx.getOSGiService(JWTClientManagerService.class, null);
+ if (jwtClientManagerService == null) {
+ String msg = "jwtClientManagerServicehas not initialized.";
+ log.error(msg);
+ throw new IllegalStateException(msg);
+ }
+ return jwtClientManagerService;
+ }
+
/**
* Getting the current tenant's user realm
*/
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.cloud.user-menu/public/js/user-menu.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.cloud.user-menu/public/js/user-menu.js
new file mode 100644
index 0000000000..fe5ac86b97
--- /dev/null
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.cloud.user-menu/public/js/user-menu.js
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+$(document).ready(function () {
+ $('#cloud-menu-popover i.fw-tiles').popover({
+ html: true,
+ trigger:'click',
+ title: function() {
+ return $("#popover-head").html();
+ },
+ content: function() {
+ return $("#popover-content").html();
+ }
+ });
+});
\ No newline at end of file
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.cloud.user-menu/user-menu.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.cloud.user-menu/user-menu.hbs
index 28f1e68b7c..a9379d3435 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.cloud.user-menu/user-menu.hbs
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.cloud.user-menu/user-menu.hbs
@@ -18,10 +18,10 @@
-
-
-
- App Publisher
-
-
-
-
-
- App Store
-
-
-
-
@@ -184,7 +186,8 @@
role="menu">
-
Profile
@@ -192,13 +195,15 @@
+ href="https://cloudmgt.clouddev.wso2.com/cloudmgt/site/pages/change-password.jag"
+ target="_self">
Change Password
-
+
Logout
@@ -216,4 +221,49 @@
-
\ No newline at end of file
+
+
+
+
+
+
+{{#zone "bottomJs"}}
+ {{js "/js/user-menu.js"}}
+{{/zone}}
\ No newline at end of file
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.logo/logo.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.logo/logo.hbs
index 070ed3088a..dd60f631f0 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.logo/logo.hbs
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.logo/logo.hbs
@@ -15,5 +15,11 @@
specific language governing permissions and limitations
under the License.
}}
-{{#zone "productName"}}WSO2 IoT Server{{/zone}}
-{{#zone "productNameResponsive"}}WSO2 IoT Server{{/zone}}
\ No newline at end of file
+
+{{#if isCloud}}
+ {{#zone "productName"}}WSO2 Cloud{{/zone}}
+ {{#zone "productNameResponsive"}}WSO2 Cloud{{/zone}}
+{{else}}
+ {{#zone "productName"}}WSO2 IoT Server{{/zone}}
+ {{#zone "productNameResponsive"}}WSO2 IoT Server{{/zone}}
+{{/if}}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.logo/logo.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.logo/logo.js
new file mode 100644
index 0000000000..e63ad073c3
--- /dev/null
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.header.logo/logo.js
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+function onRequest(context) {
+ var mdmProps = require("/app/modules/conf-reader/main.js")["conf"];
+ var viewModal = {};
+ viewModal.isCloud = mdmProps["isCloud"];
+ return viewModal;
+}
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.theme/public/css/custom-common.css b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.theme/public/css/custom-common.css
index a0e5807636..3ad7b3fe09 100644
--- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.theme/public/css/custom-common.css
+++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.theme/public/css/custom-common.css
@@ -109,3 +109,126 @@
header .brand h1 {
text-transform: none !important;
}
+
+.visible-inline-block {
+ display: inline-block !important;
+}
+
+.cloud-menu .popover {
+ border-radius: 0px;
+ width: 24em;
+ left: -21.1em !important;
+ max-width: 32em;
+ background-color: #006690
+}
+.cloud-menu .popover-title,.navbar-header .popover-title {
+ background-color: #006690;
+ font-size: 16px;
+ border-bottom: none;
+ font-weight: 400;
+}
+.cloud-menu .popover.bottom>.arrow{
+ margin-left:-2px;
+}
+.cloud-menu .popover.bottom>.arrow:after,.navbar-header .popover.bottom>.arrow:after{
+ border-bottom-color: #006690;
+}
+.cloud-block {
+ float: left;
+ width: 8.2em;
+ height: 8.2em;
+ background-color: #fff;
+ margin: 0.5em 0em 0.5em 0.5em;
+ text-align: center;
+ vertical-align: middle;
+}
+.cloud-name {
+ font-size:14px;
+ margin-top: .5em;
+ font-weight: 400;
+}
+.cloud-menu-popover {
+ position: relative;
+ float: right;
+ padding: 0px 8px;
+ background-color: transparent;
+ background-image: none;
+ border: 1px solid transparent;
+ border-radius: 4px;
+ color: #fff;
+ cursor: pointer;
+}
+#cloud-menu-popover-xs {
+ color: #fff;
+ line-height:24px;
+ border: none;
+ margin-right: 15px!important;
+}
+.navbar-toggle{
+ border:none;
+ border-radius: 0px;
+}
+.navbar-header .popover {
+ border-radius: 0px;
+ width: 21em;
+ max-width:32em;
+ background-color: #006690;
+}
+.navbar-header .popover .popover-content{
+ padding:0px;
+}
+.cloud-menu .popover-content {
+ padding: 0px;
+}
+.cloud-actions {
+ background-color: #005578;
+ float: left;
+ position: absolute;
+ width: 100%;
+ left: 0px;
+ overflow:hidden;
+}
+.cloud-actions h3 {
+ font-size: 16px;
+ font-weight: 400;
+ padding-left: 14px;
+ margin-top: 10px;
+}
+.cloud-block-invert {
+ color: #fff;
+ float: left;
+ width: 8.2em;
+ height: 8.2em;
+ background-color: #1f1f1f;
+ margin: 0.5em 0em 0.5em 0.5em;
+ text-align: center;
+ cursor: pointer;
+}
+
+.cloud-block-default {
+ color: #006690;
+ background-color: #fff;
+ cursor: pointer;
+}
+.cloud-actions a:hover {
+ color: #d7d5d5;
+ background-color: #3d3d3d;
+ text-decoration: none
+}
+.cloud-apps a {
+ text-decoration: none;
+ color: #006690 !important;
+ cursor: pointer
+}
+.cloud-apps a:hover {
+ text-decoration: none;
+ color: #006690;
+ background-color: #c5c5c5;
+}
+.cloud-apps .cloud-actions a {
+ color: #fff
+}
+
+.add-padding-top-3x {
+ padding-top: 15px !important;
+}
\ No newline at end of file
diff --git a/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/src/main/java/org/wso2/carbon/identity/jwt/client/extension/util/JWTClientUtil.java b/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/src/main/java/org/wso2/carbon/identity/jwt/client/extension/util/JWTClientUtil.java
index 20ff82c531..cbce86c405 100644
--- a/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/src/main/java/org/wso2/carbon/identity/jwt/client/extension/util/JWTClientUtil.java
+++ b/components/identity-extensions/org.wso2.carbon.identity.jwt.client.extension/src/main/java/org/wso2/carbon/identity/jwt/client/extension/util/JWTClientUtil.java
@@ -72,6 +72,10 @@ public class JWTClientUtil {
private static final String JWT_CONFIG_FILE_NAME = "jwt.properties";
private static final String SUPERTENANT_JWT_CONFIG_LOCATION =
CarbonUtils.getEtcCarbonConfigDirPath() + File.separator + JWT_CONFIG_FILE_NAME;
+ /**
+ * This is added for the carbon authenticator.
+ */
+ public static final String SIGNED_JWT_AUTH_USERNAME = "Username";
/**
* Return a http client instance
@@ -226,10 +230,11 @@ public class JWTClientUtil {
claimsSet.setIssueTime(new Date(iat));
claimsSet.setExpirationTime(new Date(exp));
claimsSet.setIssuer(iss);
- claimsSet.setSubject(username);
- claimsSet.setNotBeforeTime(new Date(nbf));
+ claimsSet.setSubject(username);
+ claimsSet.setNotBeforeTime(new Date(nbf));
claimsSet.setJWTID(jti);
claimsSet.setAudience(aud);
+ claimsSet.setClaim(SIGNED_JWT_AUTH_USERNAME, username);
if (customClaims != null && !customClaims.isEmpty()) {
for (String key : customClaims.keySet()) {
claimsSet.setClaim(key, customClaims.get(key));