registerkey.sas
Go to the documentation of this file.
1 /**
2  @file
3  @brief Register a new licence key
4  @details
5 
6  <h4> SAS Macros </h4>
7  @li mpeinit.sas
8  @li bitemporal_dataloader.sas
9  @li mp_abort.sas
10  @li mf_getuser.sas
11  @li mpe_getgroups.sas
12 
13  @version 9.3
14  @author 4GL Apps Ltd
15  @copyright 4GL Apps Ltd. This code may only be used within Data Controller
16  and may not be re-distributed or re-sold without the express permission of
17  4GL Apps Ltd.
18 
19  @test
20 
21  echo '{"keyupload":[{"activation_key":"slfdjasfda;dslf","licence_key":"asdfasdlfkajsfdas"}]}'>in.json
22  sasjs request admin/registerkey -d in.json
23 
24 **/
25 
26 %mpeinit()
27 
28 /* determine users group membership */
29 %mpe_getgroups(user=%mf_getuser(),outds=work.groups)
30 %global admin_check;
31 proc sql;
32 select count(*) into: admin_check
33  from groups where groupname="&mpeadmins";
34 
35 %mp_abort(iftrue= (&admin_check = 0)
36  ,mac=%str(&_program)
37  ,msg=%str(Only members of &mpeadmins may register a key)
38 )
39 
40 %global licencekey activation_key;
41 data _null_;
42  set work.keyupload;
43  call symputx('activation_key',activation_key);
44  call symputx('licencekey',licence_key);
45  call symputx('activlen',length(activation_key));
46  call symputx('liclen',length(licence_key));
47 run;
48 
49 %mp_abort(iftrue= (&activlen< 10)
50  ,mac=%str(&_program)
51  ,msg=%str(Invalid activation_key)
52 )
53 %mp_abort(iftrue= (&liclen < 10)
54  ,mac=%str(&_program)
55  ,msg=%str(Invalid licencekey)
56 )
57 
58 data work.loadme;
59  if 0 then set &mpelib..mpe_config;
60  VAR_SCOPE='DC';
61  VAR_NAME='DC_ACTIVATION_KEY';
62  VAR_VALUE=symget('activation_key');
63  VAR_ACTIVE=1;
64  output;
65  VAR_NAME='DC_LICENCE_KEY';
66  VAR_VALUE=symget('licencekey');
67  VAR_ACTIVE=1;
68  output;
69  keep VAR_: ;
70 run;
71 
72 %bitemporal_dataloader(
73  tech_from=tx_from
74  ,tech_to = tx_to
75  ,base_lib=&mpelib
76  ,base_dsn=mpe_config
77  ,append_lib=WORK
78  ,append_dsn=loadme
79  ,PK= VAR_SCOPE VAR_NAME
80  ,ETLSOURCE=%str(&_program STP)
81  ,LOADTYPE=TXTEMPORAL
82  ,dclib=&mpelib
83 )
84 
85 data work.return;
86  msg='SUCCESS';
87 run;
88 
89 %webout(OPEN)
90 %webout(OBJ,return)
91 %webout(CLOSE)