Re: [Dev] [DS][DAS] Sample for DashboardServer - How to get back-end url, username, password for DAS to invoke DAS rest API from jaggery file

2015-12-21 Thread Rajeenthini Satkunam
Hi all,

Since it is a sample I am configuring this credentials with analytics.json
under folder of /carbon-dashboards/apps/portal/configs and getting
username,password and url by json file.

{
  "url" :"https://localhost:9465/analytics/search;,
  "username" : "admin",
  "password" : "admin"
}

Thank you for prompt replies.

On Fri, Dec 18, 2015 at 2:38 PM, Isuru Wijesinghe  wrote:

> Hi Rajeenthini,
>
> Can't you hold a configuration file at the back-end side for this ?? Here
> what I mean is something similar to below example. In the url tag you
> should have to keep the base url of the DAS. The rest of the part of the
> url u can append from the code. (Please note that if you keep a property
> file like below, you should have to add secure vault also. It  is used to
> secure plain text password which is contains in configuration  files of
> WSO2 products).  And then you can read it from your jaggery code . (see
> http://jaggeryjs.org/documentation.jag?api=file)
> eg:
> 
> http://wso2.org/pc/config;>
> 
> https://localhost:9445/
> admin
> admin
> 
> 
>
>
> On Fri, Dec 18, 2015 at 12:33 PM, Supun Sethunga  wrote:
>
>> Hi Rajeenthini,
>>
>> Instead of the DAS REST API, you can use the "Analytics javascript API"
>> [1]. This should eliminate the requirement of needing user-credentials. (or
>> doesn't need to send an Authorization header)
>>
>> [1] https://docs.wso2.com/display/DAS300/Analytics+JavaScript+(JS)+API
>>
>> Regards,
>> Supun
>>
>> On Fri, Dec 18, 2015 at 10:41 AM, Rajeenthini Satkunam <
>> rajeenth...@wso2.com> wrote:
>>
>>> Hi all,
>>>
>>> Currently I am working on creating sample for dashboard server with DAS
>>> integration.I need to invoke DAS rest API from Jaggery file(sample.jag) to
>>> get some data.As per documentation[1] of DAS rest API we need to send
>>> authorization header along with request to fetch data from DAS. So for
>>> workaround I have hard-coded the username password values to variable and
>>> concatenate them as username + ":" + password and encoded them then send as
>>> a authorization header.Here I need to get server username and
>>> password(credentials).IMHO it is not good practice that hard-coding
>>> credentials of server.
>>> I have shared my Jaggery code below
>>>
>>> try {
>>> var username = "admin";//hard-coded value of username
>>> var password = "admin";//hard-coded value of password
>>> var tableName = request.getParameter("tableName");
>>> var query = request.getParameter("query");
>>> var url = "https://localhost:9465/analytics/search;;
>>> var encoderJavaPkg = Packages.javax.xml.bind.DatatypeConverter;
>>> var bytes = [];
>>> var encodeString = username + ":" + password;
>>> for (var i = 0; i < encodeString.length; ++i) {
>>> bytes.push(encodeString.charCodeAt(i));
>>> }
>>> var authHeader = "Basic " + encoderJavaPkg.printBase64Binary(bytes);
>>> var result = post(url, stringify({
>>> "tableName": tableName,
>>> "start": 0,
>>> "count": 100,
>>> "query": query
>>> }), {"Authorization": authHeader, "Content-Type": "application/json"}, 
>>> "application/json");
>>> print(result.data);
>>> } catch (e) {
>>> log.info(e);
>>> }
>>>
>>> [1] - 
>>> https://docs.wso2.com/display/DAS300/Retrieving+All+Records+Matching+the+Given+Search+Query+via+REST+API
>>>
>>> As for now to start both server (DAS and DS) I have changed offset value 
>>> for DAS as "2" in carbon.xml.I can successfully start both server 
>>> simultaneously.It will be very useful if I can get the back-end URL and 
>>> server credentials of DAS and get rid of hard-coding those values.Can 
>>> anyone please help me and your suggestions mostly appreciate?
>>>
>>>
>>>
>>>
>>> --
>>>
>>> *Thank You.*
>>>
>>> *Rajeenthini Satkunam*
>>>
>>> *Associate Software Engineer | WSO2*
>>>
>>>
>>> *E:rajeenth...@wso2.com *
>>>
>>> *M :+94770832823 <%2B94770832823>   *
>>>
>>>
>>> ___
>>> Dev mailing list
>>> Dev@wso2.org
>>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>>
>>>
>>
>>
>> --
>> *Supun Sethunga*
>> Software Engineer
>> WSO2, Inc.
>> http://wso2.com/
>> lean | enterprise | middleware
>> Mobile : +94 716546324
>>
>> ___
>> Dev mailing list
>> Dev@wso2.org
>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>
>>
>
>
> --
> Isuru Wijesinghe
> *Software Engineer*
> WSO2 inc : http://wso2.com
> lean.enterprise.middleware
> Mobile: 0710933706
> isur...@wso2.com
>



-- 

*Thank You.*

*Rajeenthini Satkunam*

*Associate Software Engineer | WSO2*


*E:rajeenth...@wso2.com *

*M :+94770832823   *
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] [DS][DAS] Sample for DashboardServer - How to get back-end url, username, password for DAS to invoke DAS rest API from jaggery file

2015-12-18 Thread Isuru Wijesinghe
Hi Rajeenthini,

Can't you hold a configuration file at the back-end side for this ?? Here
what I mean is something similar to below example. In the url tag you
should have to keep the base url of the DAS. The rest of the part of the
url u can append from the code. (Please note that if you keep a property
file like below, you should have to add secure vault also. It  is used to
secure plain text password which is contains in configuration  files of
WSO2 products).  And then you can read it from your jaggery code . (see
http://jaggeryjs.org/documentation.jag?api=file)
eg:

http://wso2.org/pc/config;>

https://localhost:9445/
admin
admin




On Fri, Dec 18, 2015 at 12:33 PM, Supun Sethunga  wrote:

> Hi Rajeenthini,
>
> Instead of the DAS REST API, you can use the "Analytics javascript API"
> [1]. This should eliminate the requirement of needing user-credentials. (or
> doesn't need to send an Authorization header)
>
> [1] https://docs.wso2.com/display/DAS300/Analytics+JavaScript+(JS)+API
>
> Regards,
> Supun
>
> On Fri, Dec 18, 2015 at 10:41 AM, Rajeenthini Satkunam <
> rajeenth...@wso2.com> wrote:
>
>> Hi all,
>>
>> Currently I am working on creating sample for dashboard server with DAS
>> integration.I need to invoke DAS rest API from Jaggery file(sample.jag) to
>> get some data.As per documentation[1] of DAS rest API we need to send
>> authorization header along with request to fetch data from DAS. So for
>> workaround I have hard-coded the username password values to variable and
>> concatenate them as username + ":" + password and encoded them then send as
>> a authorization header.Here I need to get server username and
>> password(credentials).IMHO it is not good practice that hard-coding
>> credentials of server.
>> I have shared my Jaggery code below
>>
>> try {
>> var username = "admin";//hard-coded value of username
>> var password = "admin";//hard-coded value of password
>> var tableName = request.getParameter("tableName");
>> var query = request.getParameter("query");
>> var url = "https://localhost:9465/analytics/search;;
>> var encoderJavaPkg = Packages.javax.xml.bind.DatatypeConverter;
>> var bytes = [];
>> var encodeString = username + ":" + password;
>> for (var i = 0; i < encodeString.length; ++i) {
>> bytes.push(encodeString.charCodeAt(i));
>> }
>> var authHeader = "Basic " + encoderJavaPkg.printBase64Binary(bytes);
>> var result = post(url, stringify({
>> "tableName": tableName,
>> "start": 0,
>> "count": 100,
>> "query": query
>> }), {"Authorization": authHeader, "Content-Type": "application/json"}, 
>> "application/json");
>> print(result.data);
>> } catch (e) {
>> log.info(e);
>> }
>>
>> [1] - 
>> https://docs.wso2.com/display/DAS300/Retrieving+All+Records+Matching+the+Given+Search+Query+via+REST+API
>>
>> As for now to start both server (DAS and DS) I have changed offset value for 
>> DAS as "2" in carbon.xml.I can successfully start both server 
>> simultaneously.It will be very useful if I can get the back-end URL and 
>> server credentials of DAS and get rid of hard-coding those values.Can anyone 
>> please help me and your suggestions mostly appreciate?
>>
>>
>>
>>
>> --
>>
>> *Thank You.*
>>
>> *Rajeenthini Satkunam*
>>
>> *Associate Software Engineer | WSO2*
>>
>>
>> *E:rajeenth...@wso2.com *
>>
>> *M :+94770832823 <%2B94770832823>   *
>>
>>
>> ___
>> Dev mailing list
>> Dev@wso2.org
>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>
>>
>
>
> --
> *Supun Sethunga*
> Software Engineer
> WSO2, Inc.
> http://wso2.com/
> lean | enterprise | middleware
> Mobile : +94 716546324
>
> ___
> Dev mailing list
> Dev@wso2.org
> http://wso2.org/cgi-bin/mailman/listinfo/dev
>
>


-- 
Isuru Wijesinghe
*Software Engineer*
WSO2 inc : http://wso2.com
lean.enterprise.middleware
Mobile: 0710933706
isur...@wso2.com
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] [DS][DAS] Sample for DashboardServer - How to get back-end url, username, password for DAS to invoke DAS rest API from jaggery file

2015-12-17 Thread Supun Sethunga
Hi Rajeenthini,

Instead of the DAS REST API, you can use the "Analytics javascript API"
[1]. This should eliminate the requirement of needing user-credentials. (or
doesn't need to send an Authorization header)

[1] https://docs.wso2.com/display/DAS300/Analytics+JavaScript+(JS)+API

Regards,
Supun

On Fri, Dec 18, 2015 at 10:41 AM, Rajeenthini Satkunam  wrote:

> Hi all,
>
> Currently I am working on creating sample for dashboard server with DAS
> integration.I need to invoke DAS rest API from Jaggery file(sample.jag) to
> get some data.As per documentation[1] of DAS rest API we need to send
> authorization header along with request to fetch data from DAS. So for
> workaround I have hard-coded the username password values to variable and
> concatenate them as username + ":" + password and encoded them then send as
> a authorization header.Here I need to get server username and
> password(credentials).IMHO it is not good practice that hard-coding
> credentials of server.
> I have shared my Jaggery code below
>
> try {
> var username = "admin";//hard-coded value of username
> var password = "admin";//hard-coded value of password
> var tableName = request.getParameter("tableName");
> var query = request.getParameter("query");
> var url = "https://localhost:9465/analytics/search;;
> var encoderJavaPkg = Packages.javax.xml.bind.DatatypeConverter;
> var bytes = [];
> var encodeString = username + ":" + password;
> for (var i = 0; i < encodeString.length; ++i) {
> bytes.push(encodeString.charCodeAt(i));
> }
> var authHeader = "Basic " + encoderJavaPkg.printBase64Binary(bytes);
> var result = post(url, stringify({
> "tableName": tableName,
> "start": 0,
> "count": 100,
> "query": query
> }), {"Authorization": authHeader, "Content-Type": "application/json"}, 
> "application/json");
> print(result.data);
> } catch (e) {
> log.info(e);
> }
>
> [1] - 
> https://docs.wso2.com/display/DAS300/Retrieving+All+Records+Matching+the+Given+Search+Query+via+REST+API
>
> As for now to start both server (DAS and DS) I have changed offset value for 
> DAS as "2" in carbon.xml.I can successfully start both server 
> simultaneously.It will be very useful if I can get the back-end URL and 
> server credentials of DAS and get rid of hard-coding those values.Can anyone 
> please help me and your suggestions mostly appreciate?
>
>
>
>
> --
>
> *Thank You.*
>
> *Rajeenthini Satkunam*
>
> *Associate Software Engineer | WSO2*
>
>
> *E:rajeenth...@wso2.com *
>
> *M :+94770832823 <%2B94770832823>   *
>
>
> ___
> Dev mailing list
> Dev@wso2.org
> http://wso2.org/cgi-bin/mailman/listinfo/dev
>
>


-- 
*Supun Sethunga*
Software Engineer
WSO2, Inc.
http://wso2.com/
lean | enterprise | middleware
Mobile : +94 716546324
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


[Dev] [DS][DAS] Sample for DashboardServer - How to get back-end url, username, password for DAS to invoke DAS rest API from jaggery file

2015-12-17 Thread Rajeenthini Satkunam
Hi all,

Currently I am working on creating sample for dashboard server with DAS
integration.I need to invoke DAS rest API from Jaggery file(sample.jag) to
get some data.As per documentation[1] of DAS rest API we need to send
authorization header along with request to fetch data from DAS. So for
workaround I have hard-coded the username password values to variable and
concatenate them as username + ":" + password and encoded them then send as
a authorization header.Here I need to get server username and
password(credentials).IMHO it is not good practice that hard-coding
credentials of server.
I have shared my Jaggery code below

try {
var username = "admin";//hard-coded value of username
var password = "admin";//hard-coded value of password
var tableName = request.getParameter("tableName");
var query = request.getParameter("query");
var url = "https://localhost:9465/analytics/search;;
var encoderJavaPkg = Packages.javax.xml.bind.DatatypeConverter;
var bytes = [];
var encodeString = username + ":" + password;
for (var i = 0; i < encodeString.length; ++i) {
bytes.push(encodeString.charCodeAt(i));
}
var authHeader = "Basic " + encoderJavaPkg.printBase64Binary(bytes);
var result = post(url, stringify({
"tableName": tableName,
"start": 0,
"count": 100,
"query": query
}), {"Authorization": authHeader, "Content-Type":
"application/json"}, "application/json");
print(result.data);
} catch (e) {
log.info(e);
}

[1] - 
https://docs.wso2.com/display/DAS300/Retrieving+All+Records+Matching+the+Given+Search+Query+via+REST+API

As for now to start both server (DAS and DS) I have changed offset
value for DAS as "2" in carbon.xml.I can successfully start both
server simultaneously.It will be very useful if I can get the back-end
URL and server credentials of DAS and get rid of hard-coding those
values.Can anyone please help me and your suggestions mostly
appreciate?




-- 

*Thank You.*

*Rajeenthini Satkunam*

*Associate Software Engineer | WSO2*


*E:rajeenth...@wso2.com *

*M :+94770832823 <%2B94770832823>   *
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev