forked from community/device-mgt-core
Merge branch 'master' of https://github.com/wso2/carbon-device-mgt
commit
df49788219
@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
package org.wso2.carbon.apimgt.webapp.publisher.lifecycle.util;
|
||||
|
||||
import org.scannotation.AnnotationDB;
|
||||
import org.scannotation.archiveiterator.Filter;
|
||||
import org.scannotation.archiveiterator.StreamIterator;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
|
||||
public class ExtendedAnnotationDB extends AnnotationDB {
|
||||
|
||||
public ExtendedAnnotationDB() {
|
||||
super();
|
||||
}
|
||||
|
||||
public void scanArchives(URL... urls) throws IOException {
|
||||
URL[] arr$ = urls;
|
||||
int len$ = urls.length;
|
||||
|
||||
for(int i$ = 0; i$ < len$; ++i$) {
|
||||
URL url = arr$[i$];
|
||||
Filter filter = new Filter() {
|
||||
public boolean accepts(String filename) {
|
||||
if(filename.endsWith(".class")) {
|
||||
if(filename.startsWith("/") || filename.startsWith("\\")) {
|
||||
filename = filename.substring(1);
|
||||
}
|
||||
|
||||
if(!ExtendedAnnotationDB.this.ignoreScan(filename.replace('/', '.'))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
StreamIterator it = ExtendedIteratorFactory.create(url, filter);
|
||||
|
||||
InputStream stream;
|
||||
while((stream = it.next()) != null) {
|
||||
this.scanClass(stream);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean ignoreScan(String intf) {
|
||||
String[] arr$;
|
||||
int len$;
|
||||
int i$;
|
||||
String ignored;
|
||||
if(this.scanPackages != null) {
|
||||
arr$ = this.scanPackages;
|
||||
len$ = arr$.length;
|
||||
|
||||
for(i$ = 0; i$ < len$; ++i$) {
|
||||
ignored = arr$[i$];
|
||||
if(intf.startsWith(ignored + ".")) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
arr$ = this.ignoredPackages;
|
||||
len$ = arr$.length;
|
||||
|
||||
for(i$ = 0; i$ < len$; ++i$) {
|
||||
ignored = arr$[i$];
|
||||
if(intf.startsWith(ignored + ".")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
package org.wso2.carbon.apimgt.webapp.publisher.lifecycle.util;
|
||||
|
||||
import org.scannotation.archiveiterator.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
public class ExtendedFileProtocolIteratorFactory implements DirectoryIteratorFactory {
|
||||
|
||||
private static final String ENCODING_SCHEME = "UTF-8";
|
||||
|
||||
@Override
|
||||
public StreamIterator create(URL url, Filter filter) throws IOException {
|
||||
File f = new File(java.net.URLDecoder.decode(url.getPath(), ENCODING_SCHEME));
|
||||
return f.isDirectory()?new FileIterator(f, filter):new JarIterator(url.openStream(), filter);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
package org.wso2.carbon.apimgt.webapp.publisher.lifecycle.util;
|
||||
|
||||
import org.scannotation.archiveiterator.DirectoryIteratorFactory;
|
||||
import org.scannotation.archiveiterator.Filter;
|
||||
import org.scannotation.archiveiterator.JarIterator;
|
||||
import org.scannotation.archiveiterator.StreamIterator;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class ExtendedIteratorFactory {
|
||||
|
||||
private static final ConcurrentHashMap<String, DirectoryIteratorFactory> registry = new ConcurrentHashMap();
|
||||
|
||||
public static StreamIterator create(URL url, Filter filter) throws IOException {
|
||||
String urlString = url.toString();
|
||||
if(urlString.endsWith("!/")) {
|
||||
urlString = urlString.substring(4);
|
||||
urlString = urlString.substring(0, urlString.length() - 2);
|
||||
url = new URL(urlString);
|
||||
}
|
||||
|
||||
if(!urlString.endsWith("/")) {
|
||||
return new JarIterator(url.openStream(), filter);
|
||||
} else {
|
||||
DirectoryIteratorFactory factory = registry.get(url.getProtocol());
|
||||
if(factory == null) {
|
||||
throw new IOException("Unable to scan directory of protocol: " + url.getProtocol());
|
||||
} else {
|
||||
return factory.create(url, filter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
registry.put("file", new ExtendedFileProtocolIteratorFactory());
|
||||
}
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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.
|
||||
*/
|
||||
|
||||
var config = function () {
|
||||
var conf = application.get("PINCH_CONFIG");
|
||||
if (!conf) {
|
||||
var pinch = require('/app/modules/pinch.min.js').pinch;
|
||||
var server = require('carbon').server;
|
||||
var config = require('/app/conf/config.json');
|
||||
pinch(config, /^/, function (path, key, value) {
|
||||
if ((typeof value === 'string') && value.indexOf('%https.ip%') > -1) {
|
||||
return value.replace('%https.ip%', server.address("https"));
|
||||
} else if ((typeof value === 'string') && value.indexOf('%http.ip%') > -1) {
|
||||
return value.replace('%http.ip%', server.address("http"));
|
||||
} else if ((typeof value === 'string') && value.indexOf('%date-year%') > -1) {
|
||||
var year = new Date().getFullYear();
|
||||
return value.replace("%date-year%", year);
|
||||
}
|
||||
return value;
|
||||
});
|
||||
application.put("PINCH_CONFIG", config);
|
||||
conf = config;
|
||||
}
|
||||
return conf;
|
||||
};
|
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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.
|
||||
*/
|
||||
|
||||
var conf = function () {
|
||||
var conf = application.get("UI_CONF");
|
||||
if (!conf) {
|
||||
conf = require("/app/conf/config.json");
|
||||
var pinch = require("/app/conf/reader/pinch.min.js")["pinch"];
|
||||
var server = require("carbon")["server"];
|
||||
pinch(conf, /^/,
|
||||
function (path, key, value) {
|
||||
if ((typeof value === "string") && value.indexOf("%https.ip%") > -1) {
|
||||
return value.replace("%https.ip%", server.address("https"));
|
||||
} else if ((typeof value === "string") && value.indexOf("%http.ip%") > -1) {
|
||||
return value.replace("%http.ip%", server.address("http"));
|
||||
} else if ((typeof value === "string") && value.indexOf("%date-year%") > -1) {
|
||||
var year = new Date().getFullYear();
|
||||
return value.replace("%date-year%", year);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
);
|
||||
application.put("UI_CONF", conf);
|
||||
}
|
||||
return conf;
|
||||
}();
|
@ -1,64 +1,76 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
{{!-- 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
|
||||
|
||||
<title>{{#defineZone "title"}}WSO2 Template{{/defineZone}}</title>
|
||||
{{defineZone "favicon"}}
|
||||
{{defineZone "topCss"}}
|
||||
{{defineZone "topJs"}}
|
||||
</head>
|
||||
<body>
|
||||
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. --}}
|
||||
|
||||
<!--modal-->
|
||||
<div class="wr-modalpopup">
|
||||
<div class="modalpopup-container">
|
||||
<div class="modalpopup-close-btn" onclick="hidePopup();">
|
||||
<span class="fw-stack">
|
||||
<i class="fw fw-ring fw-stack-2x"></i>
|
||||
<i class="fw fw-left-arrow fw-stack-1x"></i>
|
||||
</span>
|
||||
GO BACK
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
{{defineZone "favicon"}}
|
||||
<title>
|
||||
{{defineZone "title"}}
|
||||
</title>
|
||||
{{defineZone "topLibCss"}}
|
||||
{{defineZone "topCss"}}
|
||||
{{defineZone "topJs"}}
|
||||
</head>
|
||||
<body>
|
||||
<!--modal-->
|
||||
<div class="wr-modalpopup">
|
||||
<div class="modalpopup-container">
|
||||
<div class="modalpopup-close-btn" onclick="hidePopup();">
|
||||
<span class="fw-stack">
|
||||
<i class="fw fw-ring fw-stack-2x"></i>
|
||||
<i class="fw fw-left-arrow fw-stack-1x"></i>
|
||||
</span>
|
||||
GO BACK
|
||||
</div>
|
||||
<div class="modalpopup-content">
|
||||
<!-- dynamic content -->
|
||||
</div>
|
||||
</div>
|
||||
<div class="modalpopup-bg"></div>
|
||||
</div>
|
||||
<div class="modalpopup-content"><!-- dynamic content --></div>
|
||||
</div>
|
||||
<div class="modalpopup-bg"></div>
|
||||
</div>
|
||||
<!--modal-->
|
||||
<!--modal-->
|
||||
|
||||
<!-- header -->
|
||||
{{defineZone "header"}}
|
||||
<!-- /header -->
|
||||
{{defineZone "header"}}
|
||||
|
||||
<!-- navbars -->
|
||||
<div class="navbar-wrapper">
|
||||
{{defineZone "navbars"}}
|
||||
</div>
|
||||
<!-- /navbars -->
|
||||
<div class="navbar-wrapper">
|
||||
{{defineZone "navbars"}}
|
||||
</div>
|
||||
|
||||
<!-- sidepanes -->
|
||||
{{defineZone "sidePanes"}}
|
||||
<!-- /sidepanes -->
|
||||
{{defineZone "sidePanes"}}
|
||||
|
||||
<!-- page-content-wrapper -->
|
||||
<div class="page-content-wrapper">
|
||||
{{defineZone "contentTitle"}}
|
||||
<div class="container-fluid body-wrapper">
|
||||
{{defineZone "content"}}
|
||||
</div>
|
||||
</div>
|
||||
<!-- /page-content-wrapper -->
|
||||
<!-- page-content-wrapper -->
|
||||
<div class="page-content-wrapper">
|
||||
{{defineZone "contentTitle"}}
|
||||
<div class="container-fluid body-wrapper">
|
||||
{{defineZone "content"}}
|
||||
</div>
|
||||
</div>
|
||||
<!-- /page-content-wrapper -->
|
||||
|
||||
<!-- footer -->
|
||||
<footer class="footer">
|
||||
<div class="container-fluid">
|
||||
{{defineZone "footer"}}
|
||||
</div>
|
||||
</footer>
|
||||
<!-- /footer -->
|
||||
<footer class="footer">
|
||||
<div class="container-fluid">
|
||||
{{defineZone "footer"}}
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
{{defineZone "bottomJs"}}
|
||||
</body>
|
||||
{{defineZone "bottomLibJs"}}
|
||||
{{defineZone "bottomJs"}}
|
||||
</body>
|
||||
</html>
|
@ -1,55 +1,62 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
* 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
|
||||
* 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
|
||||
* "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.
|
||||
*/
|
||||
|
||||
var apiWrapperUtil = function () {
|
||||
var module = {};
|
||||
var tokenUtil = require("/app/modules/util.js").util;
|
||||
// var log = new Log("/app/modules/api-wrapper-util.js");
|
||||
|
||||
var tokenUtil = require("/app/modules/util.js")["util"];
|
||||
var constants = require("/app/modules/constants.js");
|
||||
var devicemgtProps = require('/app/conf/devicemgt-props.js').config();
|
||||
var log = new Log("/app/modules/api-wrapper-util.js");
|
||||
|
||||
module.refreshToken = function () {
|
||||
var tokenPair = session.get(constants.ACCESS_TOKEN_PAIR_IDENTIFIER);
|
||||
var clientData = session.get(constants.ENCODED_CLIENT_KEYS_IDENTIFIER);
|
||||
tokenPair = tokenUtil.refreshToken(tokenPair, clientData);
|
||||
session.put(constants.ACCESS_TOKEN_PAIR_IDENTIFIER, tokenPair);
|
||||
var devicemgtProps = require("/app/conf/reader/main.js")["conf"];
|
||||
|
||||
var publicMethods = {};
|
||||
|
||||
publicMethods.refreshToken = function () {
|
||||
var accessTokenPair = session.get(constants["ACCESS_TOKEN_PAIR_IDENTIFIER"]);
|
||||
// accessTokenPair includes current access token as well as current refresh token
|
||||
var encodedClientCredentials = session.get(constants["ENCODED_CLIENT_KEYS_IDENTIFIER"]);
|
||||
accessTokenPair = tokenUtil.refreshToken(accessTokenPair, encodedClientCredentials);
|
||||
session.put(constants["ACCESS_TOKEN_PAIR_IDENTIFIER"], accessTokenPair);
|
||||
};
|
||||
module.setupAccessTokenPair = function (type, properties) {
|
||||
var tokenPair;
|
||||
var clientData = tokenUtil.getDyanmicCredentials(properties);
|
||||
var jwtToken = tokenUtil.getTokenWithJWTGrantType(clientData);
|
||||
clientData = tokenUtil.getTenantBasedAppCredentials(properties.username, jwtToken);
|
||||
var encodedClientKeys = tokenUtil.encode(clientData.clientId + ":" + clientData.clientSecret);
|
||||
session.put(constants.ENCODED_CLIENT_KEYS_IDENTIFIER, encodedClientKeys);
|
||||
if (type == constants.GRANT_TYPE_PASSWORD) {
|
||||
var scopes = devicemgtProps.scopes;
|
||||
var scope = "";
|
||||
scopes.forEach(function(entry) {
|
||||
scope += entry + " ";
|
||||
});
|
||||
tokenPair =
|
||||
tokenUtil.getTokenWithPasswordGrantType(properties.username, encodeURIComponent(properties.password),
|
||||
encodedClientKeys, scope);
|
||||
} else if (type == constants.GRANT_TYPE_SAML) {
|
||||
tokenPair = tokenUtil.
|
||||
getTokenWithSAMLGrantType(properties.samlToken, encodedClientKeys, "PRODUCTION");
|
||||
|
||||
publicMethods.setupAccessTokenPair = function (type, properties) {
|
||||
var dynamicClientCredentials = tokenUtil.getDyanmicCredentials(properties);
|
||||
var jwtToken = tokenUtil.getTokenWithJWTGrantType(dynamicClientCredentials);
|
||||
var tenantBasedClientCredentials = tokenUtil.getTenantBasedAppCredentials(properties["username"], jwtToken);
|
||||
var encodedTenantBasedClientCredentials = tokenUtil.
|
||||
encode(tenantBasedClientCredentials["clientId"] + ":" + tenantBasedClientCredentials["clientSecret"]);
|
||||
|
||||
session.put(constants["ENCODED_CLIENT_KEYS_IDENTIFIER"], encodedTenantBasedClientCredentials);
|
||||
|
||||
var accessTokenPair;
|
||||
// accessTokenPair will include current access token as well as current refresh token
|
||||
if (type == constants["GRANT_TYPE_PASSWORD"]) {
|
||||
var arrayOfScopes = devicemgtProps["scopes"];
|
||||
var stringOfScopes = "";
|
||||
arrayOfScopes.forEach(function (entry) { stringOfScopes += entry + " "; });
|
||||
accessTokenPair = tokenUtil.getTokenWithPasswordGrantType(properties["username"],
|
||||
encodeURIComponent(properties["password"]), encodedTenantBasedClientCredentials, stringOfScopes);
|
||||
} else if (type == constants["GRANT_TYPE_SAML"]) {
|
||||
accessTokenPair = tokenUtil.getTokenWithSAMLGrantType(properties["samlToken"],
|
||||
encodedTenantBasedClientCredentials, "PRODUCTION");
|
||||
}
|
||||
session.put(constants.ACCESS_TOKEN_PAIR_IDENTIFIER, tokenPair);
|
||||
|
||||
session.put(constants["ACCESS_TOKEN_PAIR_IDENTIFIER"], accessTokenPair);
|
||||
};
|
||||
return module;
|
||||
|
||||
return publicMethods;
|
||||
}();
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"version": "1.0.0",
|
||||
"uri": "/user/add",
|
||||
"uri": "/user/add",
|
||||
"layout": "cdmf.layout.default"
|
||||
}
|
@ -0,0 +1,281 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* =========================================================
|
||||
* data-tables extended function (Server-side Pagination)
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
* @namespace $
|
||||
* The $ is just a function.
|
||||
* It is actually an alias for the function called jQuery.
|
||||
* For ex: $(this) means jQuery(this) and S.fn.x means jQuery.fn.x
|
||||
*/
|
||||
|
||||
$.fn.datatables_extended_serverside_paging = function (settings , url, dataFilter,
|
||||
columns, fnCreatedRow, fnDrawCallback) {
|
||||
var elem = $(this);
|
||||
|
||||
// EMM related function
|
||||
if (initiateViewOption) {
|
||||
$(".viewEnabledIcon").bind("click", initiateViewOption);
|
||||
}
|
||||
//--- End of EMM related codes
|
||||
|
||||
$(elem).DataTable(
|
||||
$.extend({},{
|
||||
serverSide: true,
|
||||
bSortCellsTop: true,
|
||||
ajax : {
|
||||
url: "/emm/api/data-tables/invoker",
|
||||
data : function (params) {
|
||||
var filter = "";
|
||||
var i;
|
||||
for (i = 0; i < params.columns.length; i++) {
|
||||
// console.log(i);
|
||||
filter += "&" + params.columns[i].data + "=" + params.columns[i].search.value;
|
||||
}
|
||||
// console.log(filter);
|
||||
params.offset = params.start;
|
||||
params.limit = params.length;
|
||||
params.filter = filter;
|
||||
params.url = url;
|
||||
},
|
||||
dataFilter: dataFilter
|
||||
},
|
||||
columns: columns,
|
||||
responsive: false,
|
||||
autoWidth: false,
|
||||
dom:'<"dataTablesTop"' +
|
||||
'f' +
|
||||
'<"dataTables_toolbar">' +
|
||||
'>' +
|
||||
'rt' +
|
||||
'<"dataTablesBottom"' +
|
||||
'lip' +
|
||||
'>',
|
||||
language: {
|
||||
searchPlaceholder: 'Search by Role name',
|
||||
search: ''
|
||||
},
|
||||
fnCreatedRow: fnCreatedRow,
|
||||
"fnDrawCallback": fnDrawCallback,
|
||||
initComplete: function () {
|
||||
this.api().columns().every(function () {
|
||||
|
||||
var column = this;
|
||||
var filterColumn = $('.filter-row th', elem);
|
||||
|
||||
/**
|
||||
* Create & add select/text filters to each column
|
||||
*/
|
||||
if (filterColumn.eq(column.index()).hasClass('select-filter')) {
|
||||
var select = $('<select class="form-control"><option value="">All</option></select>')
|
||||
.appendTo(filterColumn.eq(column.index()).empty())
|
||||
.on('change', function () {
|
||||
var val = $.fn.dataTable.util.escapeRegex(
|
||||
$(this).val()
|
||||
);
|
||||
|
||||
column
|
||||
//.search(val ? '^' + val + '$' : '', true, false)
|
||||
.search(val ? val : '', true, false)
|
||||
.draw();
|
||||
|
||||
if (filterColumn.eq(column.index()).hasClass('data-platform')) {
|
||||
if (val == null || val == undefined || val == "") {
|
||||
$("#operation-bar").hide();
|
||||
$("#operation-guide").show();
|
||||
} else {
|
||||
$("#operation-guide").hide();
|
||||
$("#operation-bar").show();
|
||||
loadOperationBar(val);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$(column).each(function () {
|
||||
if ($(column.nodes()).attr('data-search')) {
|
||||
var titles = [];
|
||||
column.nodes().unique().sort().each(function (d, j) {
|
||||
var title = $(d).attr('data-display');
|
||||
if ($.inArray(title, titles) < 0) {
|
||||
titles.push(title);
|
||||
if (title !== undefined) {
|
||||
select.append('<option value="' + title + '">' + title + '</option>')
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
column.data().unique().sort().each(function (d, j) {
|
||||
select.append('<option value="' + d + '">' + d + '</option>')
|
||||
});
|
||||
}
|
||||
});
|
||||
} else if (filterColumn.eq(column.index()).hasClass('text-filter')) {
|
||||
var title = filterColumn.eq(column.index()).attr('data-for');
|
||||
$(filterColumn.eq(column.index()).empty()).html('<input type="text" class="form-control" placeholder="Search ' + title + '" />');
|
||||
|
||||
filterColumn.eq(column.index()).find('input').on('keyup change', function () {
|
||||
column.search($(this).val()).draw();
|
||||
if ($('.dataTables_empty').length > 0) {
|
||||
$('.bulk-action-row').addClass("hidden");
|
||||
} else {
|
||||
$('.bulk-action-row').removeClass("hidden");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* search input default styles override
|
||||
*/
|
||||
var search_input = $(this).closest('.dataTables_wrapper').find('div[id$=_filter] input');
|
||||
search_input.before('<i class="fw fw-search search-icon"></i>').removeClass('input-sm');
|
||||
|
||||
/**
|
||||
* create sorting dropdown menu for list table advance operations
|
||||
*/
|
||||
var dropdownmenu = $('<ul class="dropdown-menu arrow arrow-top-right dark sort-list add-margin-top-2x"><li class="dropdown-header">Sort by</li></ul>');
|
||||
$('.sort-row th', elem).each(function () {
|
||||
if (!$(this).hasClass('no-sort')) {
|
||||
dropdownmenu.append('<li><a href="#' + $(this).html() + '" data-column="' + $(this).index() + '">' + $(this).html() + '</a></li>');
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* append advance operations to list table toolbar
|
||||
*/
|
||||
$('.dataTable.list-table').closest('.dataTables_wrapper').find('.dataTablesTop .dataTables_toolbar').html('' +
|
||||
'<ul class="nav nav-pills navbar-right remove-margin" role="tablist">' +
|
||||
'<li><button data-click-event="toggle-selectable" class="btn btn-default btn-primary select-enable-btn">Select</li>' +
|
||||
'<li><button data-click-event="toggle-selected" id="dt-select-all" class="btn btn-default btn-primary disabled">Select All</li>' +
|
||||
'<li><button data-click-event="toggle-list-view" data-view="grid" class="btn btn-default"><i class="fw fw-grid"></i></button></li>' +
|
||||
'<li><button data-click-event="toggle-list-view" data-view="list" class="btn btn-default"><i class="fw fw-list"></i></button></li>' +
|
||||
'<li><button class="btn btn-default" data-toggle="dropdown"><i class="fw fw-sort"></i></button>' + dropdownmenu[0].outerHTML + '</li>' +
|
||||
'</ul>'
|
||||
);
|
||||
|
||||
/**
|
||||
* sorting dropdown menu select function
|
||||
*/
|
||||
$('.dataTables_wrapper .sort-list li a').click(function () {
|
||||
$(this).closest('li').siblings('li').find('a').removeClass('sorting_asc').removeClass('sorting_desc');
|
||||
|
||||
var thisTable = $(this).closest('.dataTables_wrapper').find('.dataTable').dataTable();
|
||||
|
||||
if (!($(this).hasClass('sorting_asc')) && !($(this).hasClass('sorting_desc'))) {
|
||||
$(this).addClass('sorting_asc');
|
||||
thisTable.fnSort([[$(this).attr('data-column'), 'asc']]);
|
||||
}
|
||||
else if ($(this).hasClass('sorting_asc')) {
|
||||
$(this).switchClass('sorting_asc', 'sorting_desc');
|
||||
thisTable.fnSort([[$(this).attr('data-column'), 'desc']]);
|
||||
}
|
||||
else if ($(this).hasClass('sorting_desc')) {
|
||||
$(this).switchClass('sorting_desc', 'sorting_asc');
|
||||
thisTable.fnSort([[$(this).attr('data-column'), 'asc']]);
|
||||
}
|
||||
});
|
||||
|
||||
var rowSelectedClass = 'DTTT_selected selected';
|
||||
|
||||
/**
|
||||
* Enable/Disable selection on rows
|
||||
*/
|
||||
$('.dataTables_wrapper [data-click-event=toggle-selectable]').click(function () {
|
||||
var button = this,
|
||||
thisTable = $(this).closest('.dataTables_wrapper').find('.dataTable').dataTable();
|
||||
if ($(button).html() == 'Select') {
|
||||
thisTable.addClass("table-selectable");
|
||||
$(button).addClass("active").html('Cancel');
|
||||
$(button).parent().next().children("button").removeClass("disabled");
|
||||
// EMM related code
|
||||
$(".viewEnabledIcon").unbind("click");
|
||||
//--- End of EMM related codes
|
||||
} else if ($(button).html() == 'Cancel') {
|
||||
thisTable.removeClass("table-selectable");
|
||||
$(button).addClass("active").html('Select');
|
||||
$(button).parent().next().children().addClass("disabled");
|
||||
// EMM related function
|
||||
$(".viewEnabledIcon").bind("click", initiateViewOption);
|
||||
//--- End of EMM related codes
|
||||
}
|
||||
});
|
||||
/**
|
||||
* select/deselect all rows function
|
||||
*/
|
||||
$('.dataTables_wrapper [data-click-event=toggle-selected]').click(function () {
|
||||
var button = this,
|
||||
thisTable = $(this).closest('.dataTables_wrapper').find('.dataTable').dataTable();
|
||||
if (!$(button).hasClass('disabled')) {
|
||||
if ($(button).html() == 'Select All') {
|
||||
thisTable.api().rows().every(function () {
|
||||
$(this.node()).addClass(rowSelectedClass);
|
||||
$(button).html('Deselect All');
|
||||
});
|
||||
}
|
||||
else if ($(button).html() == 'Deselect All') {
|
||||
thisTable.api().rows().every(function () {
|
||||
$(this.node()).removeClass(rowSelectedClass);
|
||||
$(button).html('Select All');
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* on row click select/deselect row function
|
||||
*/
|
||||
$('body').on('click', '[data-type=selectable]', function () {
|
||||
var rowSelectedClass = 'DTTT_selected selected';
|
||||
$(this).toggleClass(rowSelectedClass);
|
||||
var button = this,
|
||||
thisTable = $(this).closest('.dataTables_wrapper').find('.dataTable').dataTable();
|
||||
|
||||
thisTable.api().rows().every(function () {
|
||||
if (!$(this.node()).hasClass(rowSelectedClass)) {
|
||||
$(button).closest('.dataTables_wrapper').find('[data-click-event=toggle-selected]').html('Select All');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* list table list/grid view toggle function
|
||||
*/
|
||||
var toggleButton = $('[data-click-event=toggle-list-view]');
|
||||
toggleButton.click(function () {
|
||||
if ($(this).attr('data-view') == 'grid') {
|
||||
$(this).closest('.dataTables_wrapper').find('.dataTable').addClass('grid-view');
|
||||
//$(this).closest('li').hide();
|
||||
//$(this).closest('li').siblings().show();
|
||||
}
|
||||
else {
|
||||
$(this).closest('.dataTables_wrapper').find('.dataTable').removeClass('grid-view');
|
||||
//$(this).closest('li').hide();
|
||||
//$(this).closest('li').siblings().show();
|
||||
}
|
||||
})
|
||||
}
|
||||
},settings)
|
||||
);
|
||||
|
||||
};
|
@ -1,72 +1,70 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
* 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
|
||||
* 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
|
||||
* "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.
|
||||
*/
|
||||
|
||||
var invokerUtil = function () {
|
||||
|
||||
var module = {};
|
||||
var publicMethods = {};
|
||||
var privateMethods = {};
|
||||
|
||||
var END_POINT = window.location.origin+"/devicemgt/api/invoker/execute/";
|
||||
privateMethods.execute = function (requestMethod, requestURL, requestPayload, successCallback, errorCallback) {
|
||||
var restAPIRequestDetails = {};
|
||||
restAPIRequestDetails["requestMethod"] = requestMethod;
|
||||
restAPIRequestDetails["requestURL"] = requestURL;
|
||||
restAPIRequestDetails["requestPayload"] = JSON.stringify(requestPayload);
|
||||
|
||||
module.get = function (url, successCallback, errorCallback, contentType, acceptType) {
|
||||
var payload = null;
|
||||
execute("GET", url, payload, successCallback, errorCallback, contentType, acceptType);
|
||||
var request = {
|
||||
url: context + "/api/invoker/execute/",
|
||||
type: "POST",
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify(restAPIRequestDetails),
|
||||
accept: "application/json",
|
||||
success: successCallback,
|
||||
error: function (jqXHR) {
|
||||
if (jqXHR.status == 401) {
|
||||
console.log("Unauthorized access attempt!");
|
||||
$(modalPopupContent).html($("#error-msg").html());
|
||||
showPopup();
|
||||
} else {
|
||||
errorCallback(jqXHR);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$.ajax(request);
|
||||
};
|
||||
module.post = function (url, payload, successCallback, errorCallback, contentType, acceptType) {
|
||||
execute("POST", url, payload, successCallback, errorCallback, contentType, acceptType);
|
||||
|
||||
publicMethods.get = function (requestURL, successCallback, errorCallback) {
|
||||
var requestPayload = null;
|
||||
privateMethods.execute("GET", requestURL, requestPayload, successCallback, errorCallback);
|
||||
};
|
||||
module.put = function (url, payload, successCallback, errorCallback, contentType, acceptType) {
|
||||
execute("PUT", url, payload, successCallback, errorCallback, contentType, acceptType);
|
||||
|
||||
publicMethods.post = function (requestURL, requestPayload, successCallback, errorCallback) {
|
||||
privateMethods.execute("POST", requestURL, requestPayload, successCallback, errorCallback);
|
||||
};
|
||||
module.delete = function (url, successCallback, errorCallback, contentType, acceptType) {
|
||||
var payload = null;
|
||||
execute("DELETE", url, payload, successCallback, errorCallback, contentType, acceptType);
|
||||
|
||||
publicMethods.put = function (requestURL, requestPayload, successCallback, errorCallback) {
|
||||
privateMethods.execute("PUT", requestURL, requestPayload, successCallback, errorCallback);
|
||||
};
|
||||
function execute (methoad, url, payload, successCallback, errorCallback, contentType, acceptType) {
|
||||
if(contentType == undefined){
|
||||
contentType = "application/json";
|
||||
}
|
||||
if(acceptType == undefined){
|
||||
acceptType = "application/json";
|
||||
}
|
||||
var data = {
|
||||
url: END_POINT,
|
||||
type: "POST",
|
||||
contentType: contentType,
|
||||
accept: acceptType,
|
||||
success: successCallback
|
||||
};
|
||||
var paramValue = {};
|
||||
paramValue.actionMethod = methoad;
|
||||
paramValue.actionUrl = url;
|
||||
paramValue.actionPayload = payload;
|
||||
if(contentType == "application/json"){
|
||||
paramValue.actionPayload = JSON.stringify(payload);
|
||||
}
|
||||
data.data = JSON.stringify(paramValue);
|
||||
$.ajax(data).fail(function (jqXHR) {
|
||||
if (jqXHR.status == "401") {
|
||||
console.log("Unauthorized access attempt!");
|
||||
$(modalPopupContent).html($('#error-msg').html());
|
||||
showPopup();
|
||||
} else {
|
||||
errorCallback(jqXHR);
|
||||
}
|
||||
});
|
||||
|
||||
publicMethods.delete = function (requestURL, successCallback, errorCallback) {
|
||||
var requestPayload = null;
|
||||
privateMethods.execute("DELETE", requestURL, requestPayload, successCallback, errorCallback);
|
||||
};
|
||||
return module;
|
||||
|
||||
return publicMethods;
|
||||
}();
|
||||
|
@ -0,0 +1,8 @@
|
||||
CREATE TABLE IF NOT EXISTS DM_DEVICE_CERTIFICATE (
|
||||
ID INTEGER auto_increment NOT NULL,
|
||||
SERIAL_NUMBER VARCHAR(500) DEFAULT NULL,
|
||||
CERTIFICATE BLOB DEFAULT NULL,
|
||||
TENANT_ID INTEGER DEFAULT 0,
|
||||
USERNAME VARCHAR(500) DEFAULT NULL,
|
||||
PRIMARY KEY (ID)
|
||||
);
|
@ -0,0 +1,8 @@
|
||||
CREATE TABLE DM_DEVICE_CERTIFICATE (
|
||||
ID INTEGER IDENTITY NOT NULL,
|
||||
SERIAL_NUMBER VARCHAR(500) DEFAULT NULL,
|
||||
CERTIFICATE VARBINARY(max) DEFAULT NULL,
|
||||
TENANT_ID INTEGER DEFAULT 0,
|
||||
USERNAME VARCHAR(500) DEFAULT NULL,
|
||||
PRIMARY KEY (ID)
|
||||
);
|
@ -0,0 +1,8 @@
|
||||
CREATE TABLE IF NOT EXISTS DM_DEVICE_CERTIFICATE (
|
||||
ID INTEGER auto_increment NOT NULL,
|
||||
SERIAL_NUMBER VARCHAR(500) DEFAULT NULL,
|
||||
CERTIFICATE BLOB DEFAULT NULL,
|
||||
TENANT_ID INTEGER DEFAULT 0,
|
||||
USERNAME VARCHAR(500) DEFAULT NULL,
|
||||
PRIMARY KEY (ID)
|
||||
)ENGINE = InnoDB;
|
@ -0,0 +1,8 @@
|
||||
CREATE TABLE DM_DEVICE_CERTIFICATE (
|
||||
ID NUMBER(10) NOT NULL,
|
||||
SERIAL_NUMBER VARCHAR2(500) DEFAULT NULL,
|
||||
CERTIFICATE BLOB DEFAULT NULL,
|
||||
TENANT_ID NUMBER(10) DEFAULT 0,
|
||||
USERNAME VARCHAR2(500) DEFAULT NULL,
|
||||
PRIMARY KEY (ID)
|
||||
)
|
@ -0,0 +1,7 @@
|
||||
CREATE TABLE IF NOT EXISTS DM_DEVICE_CERTIFICATE (
|
||||
ID BIGSERIAL NOT NULL PRIMARY KEY,
|
||||
SERIAL_NUMBER VARCHAR(500) DEFAULT NULL,
|
||||
CERTIFICATE BYTEA DEFAULT NULL,
|
||||
TENANT_ID INTEGER DEFAULT 0,
|
||||
USERNAME VARCHAR(500) DEFAULT NULL
|
||||
);
|
@ -1,3 +1,4 @@
|
||||
instructions.configure = \
|
||||
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.certificate.mgt.server_${feature.version}/conf/wso2certs.jks,target:${installFolder}/../../resources/security/wso2certs.jks,overwrite:true);\
|
||||
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.certificate.mgt.server_${feature.version}/conf/certificate-config.xml,target:${installFolder}/../../conf/certificate-config.xml,overwrite:true);\
|
||||
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.certificate.mgt.server_${feature.version}/dbscripts/cdm/,target:${installFolder}/../../../dbscripts/cdm,overwrite:true);\
|
Loading…
Reference in new issue