UC_RTE_ACCESS_TOKEN
The type defines decoded access token used to secure RESTful service image requests.
Attributes
Attribute | Type | Description |
---|---|---|
session_id | NUMBER | An APEX application session id when an access token was created. |
valid_till | DATE | A date till when an access token is valid. |
url_get_image | VARACHAR2(4000) | A RESTful service handler URL displaying an uploaded image defined using an application components settings or on a page item level using the plug-in attributes. |
Static functions
create_from_decoded
Creates access token instance based on valid JSON.
- Syntax
- Example
static function create_from_decoded( p_decoded in varchar2 ) return UC_RTE_ACCESS_TOKEN
declare
v_access_token uc_rte_access_token;
v_access_token_decoded VARCHAR2(32767) := '{"session_id":15662391058632,"valid_till":"2024-01-03 03:19:37","url_get_image":"http://your-domain.com/ucfroalasamplerest/get/"}';
begin
// highlight-next-line
v_access_token := uc_rte_access_token.create_from_decoded( v_access_token_decoded );
htp.p( v_access_token.session_id );
htp.p( v_access_token.valid_till );
htp.p( v_access_token.url_get_image );
end;
The result is the text presented below.
15662391058632
01/03/2024
http://your-domain.com/ucfroalasamplerest/get/
encode
Encodes given string using the plug-in salt string. Encoded string can be decoded using static function decode.
- Syntax
- Example
static function encode( p_string in varchar2 ) return varchar2
declare
v_string_plain varchar2(4000) := 'This text will be encoded';
v_string_encoded varchar2(4000);
begin
v_string_encoded := UC_RTE_ACCESS_TOKEN.encode( v_string_plain );
htp.p( v_string_encoded );
htp.p( UC_RTE_ACCESS_TOKEN.decode( v_string_encoded ) );
end;
The result is the text presented below.
DC8E69DB11065A88A122F00232C64408134CC5E21D564BAEDFA4CA328D89B5EB
This text will be encoded
decode
Decodes given access token and returns access token as JSON string.
- Syntax
- Example
static function decode( p_token in varchar2 ) return varchar2
declare
v_token_encoded varchar2(32767) := 'FFB1AA3251184974B045E8D0A7D83598D977B2AD96873CB5B2C59EACCBE6CC04D188C37BB9288743A851BAF0CD5D839C5DEEEF216E430792B94C7F547FB2FCC1963BE48B75C3E9431004D6DF924D44CB8A377BC4F0AE46BF079876A7D1D7DA2262F77F61F2AB53832D6508E6DD7EA2B94C1B97EB11A5CFAB13E06C75C35B23E109769EA863641BDC7CEAA77DBBE97CA0';
v_access_token_decoded varchar2(32767);
begin
// highlight-next-line
v_access_token_decoded := UC_RTE_ACCESS_TOKEN.decode( v_token_encoded );
htp.p( v_access_token_decoded );
end;
The result is the text presented below.
{"session_id":15662391058632,"valid_till":"2024-01-03 03:18:37","url_get_image":"http://your-domain.com/ucfroalasamplerest/get/"}
create_from_token
Creates an access token type instance based on given encoded JSON.
- Syntax
- Example
static function create_from_token( p_token in varchar2 ) return UC_RTE_ACCESS_TOKEN
declare
v_token_encoded varchar2(32767) := 'FFB1AA3251184974B045E8D0A7D83598D977B2AD96873CB5B2C59EACCBE6CC04D188C37BB9288743A851BAF0CD5D839C5DEEEF216E430792B94C7F547FB2FCC1963BE48B75C3E9431004D6DF924D44CB8A377BC4F0AE46BF079876A7D1D7DA2262F77F61F2AB53832D6508E6DD7EA2B94C1B97EB11A5CFAB13E06C75C35B23E109769EA863641BDC7CEAA77DBBE97CA0';
v_access_token UC_RTE_ACCESS_TOKEN;
begin
// highlight-next-line
v_access_token := UC_RTE_ACCESS_TOKEN.create_from_token( v_token_encoded );
htp.p( v_access_token.session_id );
htp.p( v_access_token.valid_till );
htp.p( v_access_token.url_get_image );
end;
The result is the text presented below.
15662391058632
01/03/2024
http://your-domain.com/ucfroalasamplerest/get/
is_valid
Checks if given encoded access token is not expired. The function returns 1
when access token is not expired and 0
when it's expired.
- Syntax
- Example
static function is_valid( p_token in varchar2 ) return number
declare
v_token_encoded varchar2(32767) := 'FFB1AA3251184974B045E8D0A7D83598D977B2AD96873CB5B2C59EACCBE6CC04D188C37BB9288743A851BAF0CD5D839C5DEEEF216E430792B94C7F547FB2FCC1963BE48B75C3E9431004D6DF924D44CB8A377BC4F0AE46BF079876A7D1D7DA2262F77F61F2AB53832D6508E6DD7EA2B94C1B97EB11A5CFAB13E06C75C35B23E109769EA863641BDC7CEAA77DBBE97CA0';
begin
// highlight-next-line
if UC_RTE_ACCESS_TOKEN.is_valid( v_token_encoded ) = 1 then
htp.p('Access token is not expired');
else
htp.p('Access token is expired');
end;
Memeber functions
getJSON
Return the current access token instance as JSON string.
- Syntax
- Example
member function getJSON return varchar2
declare
v_access_token uc_rte_access_token;
begin
v_access_token := UC_RTE_ACCESS_TOKEN(
p_session_id => '1836361766431',
p_url_get_image => 'http://your-domain.com/ucfroalasamplerest/get/'
);
// highlight-next-line
htp.p( v_access_token.getJSON );
end;
encode
Encodes the access token type using salt defined in the plug-in package UC_FROALA_SETTINGS
as package variable g_froala_access_token
.
- Syntax
- Example
member function encode return varchar2
declare
v_access_token uc_rte_access_token;
begin
v_access_token := UC_RTE_ACCESS_TOKEN(
p_session_id => '1836361766431',
p_url_get_image => 'http://your-domain.com/ucfroalasamplerest/get/'
);
// highlight-next-line
htp.p( v_access_token.encode );
end;
is_valid
Checks if access token instance is not expired. The function returns 1
when access token instance is not expired and 0
when it's expired.
- Syntax
- Example
member function is_valid return number
declare
v_token_encoded varchar2(32767) := 'FFB1AA3251184974B045E8D0A7D83598D977B2AD96873CB5B2C59EACCBE6CC04D188C37BB9288743A851BAF0CD5D839C5DEEEF216E430792B94C7F547FB2FCC1963BE48B75C3E9431004D6DF924D44CB8A377BC4F0AE46BF079876A7D1D7DA2262F77F61F2AB53832D6508E6DD7EA2B94C1B97EB11A5CFAB13E06C75C35B23E109769EA863641BDC7CEAA77DBBE97CA0';
v_access_token uc_rte_access_token;
begin
v_access_token := UC_RTE_ACCESS_TOKEN.create_from_token( v_token_encoded );
// highlight-next-line
if v_access_token.is_valid = 1 then
htp.p('Access token is not expired');
else
htp.p('Access token is expired');
end;