Skip to content

Commit 0e73306

Browse files
pujavsmoabu
andauthored
feat(jans-config-api): agama flow endpoint (#1898)
* feat(jans-config-api): agama endpoints * feat(jans-config-api): test case for agama endpoints * feat(jans-config-api): agama endpoints data validation code * feat(jans-config-api): agama POST endpoint with source data in payload * feat(jans-config-api): added agama endpoint test case * feat(jans-config-api): added validation for post request * feat(jans-config-api): added validation for post request * feat(jans-config-api): added validation for endpoint method * feat(jans-config-api): added validation error message for agama POST endpoint * feat(jans-config-api): agama endpoint code refactor * feat(jans-config-api): agama endpoint code refactor * feat(jans-config-api): agama endpoint code refactor * feat(jans-config-api): agama POST endpoint validation check * feat(jans-config-api): swagger spec change for agama endpoint * feat(jans-config-api): sonar review changes for agama endpoint * feat(jans-config-api): agama endpoint changes for validation and swagger change * feat(jans-config-api): config-api linux setup template change for agama endpoint * feat(jans-config-api): modified test case for agama * docs: test Co-authored-by: Mohammad Abudayyeh <[email protected]>
1 parent 9bbfd99 commit 0e73306

File tree

27 files changed

+1390
-47
lines changed

27 files changed

+1390
-47
lines changed

agama/engine/src/main/java/io/jans/agama/engine/service/FlowService.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ private void verifyCode(Flow fl) throws IOException {
234234

235235
String code = fl.getTranspiled();
236236
if (code == null) {
237-
String msg = "Source code of flow " + fl.getQName() + " ";
237+
String msg = "Source code of flow " + fl.getQname() + " ";
238238
msg += fl.getCodeError() == null ? "has not been parsed yet" : "has errors";
239239
throw new IOException(msg);
240240
}

agama/engine/src/main/java/io/jans/agama/timer/Transpilation.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public void process() throws IOException {
101101
ProtoFlow.class, Filter.createEqualityFilter("jansEnabled", true), null);
102102

103103
Map<String, ProtoFlow> map = flows.stream().collect(
104-
Collectors.toMap(ProtoFlow::getQName, Function.identity()));
104+
Collectors.toMap(ProtoFlow::getQname, Function.identity()));
105105

106106
if (traces == null) {
107107
traces = map.entrySet().stream().collect(Collectors.toMap(

agama/model/src/main/java/io/jans/agama/model/ProtoFlow.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
public class ProtoFlow extends Entry {
1616

1717
@AttributeName(name = Flow.ATTR_NAMES.QNAME)
18-
private String QName;
18+
private String qname;
1919

2020
@AttributeName(name = Flow.ATTR_NAMES.HASH)
2121
private String transHash;
@@ -26,12 +26,12 @@ public class ProtoFlow extends Entry {
2626
@AttributeName(name = "jansEnabled")
2727
private boolean enabled;
2828

29-
public String getQName() {
30-
return QName;
29+
public String getQname() {
30+
return qname;
3131
}
3232

33-
public void setQName(String QName) {
34-
this.QName = QName;
33+
public void setQname(String qname) {
34+
this.qname = qname;
3535
}
3636

3737
public String getTransHash() {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package io.jans.configapi.model.configuration;
2+
3+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4+
import java.util.List;
5+
6+
@JsonIgnoreProperties(ignoreUnknown = true)
7+
public class AgamaConfiguration {
8+
9+
/**
10+
* List of attributes required to create the Agama Flow
11+
*/
12+
private List<String> mandatoryAttributes;
13+
14+
/**
15+
* List of attributes that are optional
16+
*/
17+
private List<String> optionalAttributes;
18+
19+
public List<String> getMandatoryAttributes() {
20+
return mandatoryAttributes;
21+
}
22+
23+
public void setMandatoryAttributes(List<String> mandatoryAttributes) {
24+
this.mandatoryAttributes = mandatoryAttributes;
25+
}
26+
27+
public List<String> getOptionalAttributes() {
28+
return optionalAttributes;
29+
}
30+
31+
public void setOptionalAttributes(List<String> optionalAttributes) {
32+
this.optionalAttributes = optionalAttributes;
33+
}
34+
35+
@Override
36+
public String toString() {
37+
return "AgamaConfiguration [" + " mandatoryAttributes=" + mandatoryAttributes + ", optionalAttributes="
38+
+ optionalAttributes + "]";
39+
}
40+
41+
}

jans-config-api/common/src/main/java/io/jans/configapi/model/configuration/ApiAppConfiguration.java

+10
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public class ApiAppConfiguration implements Configuration {
3535

3636
private List<String> userExclusionAttributes;
3737
private List<String> userMandatoryAttributes;
38+
private AgamaConfiguration agamaConfiguration;
3839

3940
public boolean isConfigOauthEnabled() {
4041
return configOauthEnabled;
@@ -221,6 +222,14 @@ public List<String> getUserMandatoryAttributes() {
221222
public void setUserMandatoryAttributes(List<String> userMandatoryAttributes) {
222223
this.userMandatoryAttributes = userMandatoryAttributes;
223224
}
225+
226+
public AgamaConfiguration getAgamaConfiguration() {
227+
return agamaConfiguration;
228+
}
229+
230+
public void setAgamaConfiguration(AgamaConfiguration agamaConfiguration) {
231+
this.agamaConfiguration = agamaConfiguration;
232+
}
224233

225234
@Override
226235
public String toString() {
@@ -236,6 +245,7 @@ public String toString() {
236245
+ disableJdkLogger + " , maxCount =" + maxCount
237246
+ " , userExclusionAttributes="+ userExclusionAttributes
238247
+ " , userMandatoryAttributes="+ userMandatoryAttributes
248+
+ " , agamaConfiguration="+ agamaConfiguration
239249
+ "]";
240250
}
241251

jans-config-api/common/src/main/java/io/jans/configapi/util/ApiAccessConstants.java

+5
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,10 @@ private ApiAccessConstants() {
6868
public static final String USER_READ_ACCESS = "https://jans.io/oauth/config/user.readonly";
6969
public static final String USER_WRITE_ACCESS = "https://jans.io/oauth/config/user.write";
7070
public static final String USER_DELETE_ACCESS = "https://jans.io/oauth/config/user.delete";
71+
72+
public static final String AGAMA_READ_ACCESS = "https://jans.io/oauth/config/agama.readonly";
73+
public static final String AGAMA_WRITE_ACCESS = "https://jans.io/oauth/config/agama.write";
74+
public static final String AGAMA_DELETE_ACCESS = "https://jans.io/oauth/config/agama.delete";
75+
7176

7277
}

jans-config-api/common/src/main/java/io/jans/configapi/util/ApiConstants.java

+4
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ private ApiConstants() {}
7575
public static final String SERVER_STAT = "/server-stat";
7676
public static final String USERNAME_PATH = "/{username}";
7777
public static final String CLIENTID_PATH = "/{clientId}";
78+
public static final String AGAMA = "/agama";
79+
public static final String QNAME_PATH = "{qname}";
80+
public static final String ENABLED = "enabled";
81+
public static final String QNAME = "qname";
7882

7983
public static final String LIMIT = "limit";
8084
public static final String START_INDEX = "startIndex";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<!-- Marker file indicating CDI should be enabled -->
2+
<beans xmlns="https://jakarta.ee/xml/ns/jakartaee"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/beans_3_0.xsd"
5+
bean-discovery-mode="annotated" version="3.0">
6+
</beans>

jans-config-api/docs/jans-config-api-swagger.yaml

+214
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ tags:
3131
- name: OAuth - OpenID Connect - Clients
3232
- name: OAuth - UMA Resources
3333
- name: OAuth - Scopes
34+
- name: Configuration – Agama Flow
3435
- name: Statistics - User
3536
- name: Health - Check
3637
- name: Server Stats
@@ -2420,6 +2421,153 @@ paths:
24202421
description: Internal Server Error
24212422
security:
24222423
- oauth2: [https://jans.io/oauth/config/scopes.write]
2424+
2425+
/jans-config-api/api/v1/agama:
2426+
get:
2427+
summary: Fetches all agama flow.
2428+
description: Fetches all agama flow.
2429+
operationId: get-agama-flows
2430+
tags:
2431+
- Configuration – Agama Flow
2432+
responses:
2433+
'200':
2434+
description: OK
2435+
content:
2436+
application/json:
2437+
schema:
2438+
items:
2439+
$ref: '#/components/schemas/AgamaFlow'
2440+
'401':
2441+
$ref: '#/components/responses/Unauthorized'
2442+
'500':
2443+
$ref: '#/components/responses/InternalServerError'
2444+
security:
2445+
- oauth2: [https://jans.io/oauth/config/agama.readonly]
2446+
post:
2447+
summary: Create a new agama flow.
2448+
description: Create a new agama flow.
2449+
operationId: post-agama-flow
2450+
tags:
2451+
- Configuration – Agama Flow
2452+
requestBody:
2453+
content:
2454+
application/json:
2455+
schema:
2456+
$ref: '#/components/schemas/AgamaFlow'
2457+
responses:
2458+
'201':
2459+
description: CREATED
2460+
content:
2461+
application/json:
2462+
schema:
2463+
$ref: '#/components/schemas/AgamaFlow'
2464+
'401':
2465+
$ref: '#/components/responses/Unauthorized'
2466+
'500':
2467+
$ref: '#/components/responses/InternalServerError'
2468+
security:
2469+
- oauth2: [https://jans.io/oauth/config/agama.write]
2470+
2471+
/jans-config-api/api/v1/agama/{qname}:
2472+
parameters:
2473+
- schema:
2474+
type: string
2475+
name: qname
2476+
in: path
2477+
description: flow qname.
2478+
required: true
2479+
get:
2480+
summary: Gets an agama flow based on Qname.
2481+
description: Gets an agama flow based on Qname.
2482+
operationId: get-agama-flow
2483+
tags:
2484+
- Configuration – Agama Flow
2485+
responses:
2486+
'200':
2487+
description: OK
2488+
content:
2489+
application/json:
2490+
schema:
2491+
items:
2492+
$ref: '#/components/schemas/AgamaFlow'
2493+
'401':
2494+
$ref: '#/components/responses/Unauthorized'
2495+
'500':
2496+
$ref: '#/components/responses/InternalServerError'
2497+
security:
2498+
- oauth2: [https://jans.io/oauth/config/agama.readonly]
2499+
2500+
post:
2501+
summary: Create a new agama flow from source file.
2502+
description: Create a new agama flow from source file.
2503+
operationId: post-agama-flow-from-source
2504+
tags:
2505+
- Configuration – Agama Flow
2506+
requestBody:
2507+
content:
2508+
text/plain:
2509+
schema:
2510+
type: string
2511+
2512+
responses:
2513+
'201':
2514+
description: CREATED
2515+
content:
2516+
application/json:
2517+
schema:
2518+
$ref: '#/components/schemas/AgamaFlow'
2519+
'401':
2520+
$ref: '#/components/responses/Unauthorized'
2521+
'500':
2522+
$ref: '#/components/responses/InternalServerError'
2523+
security:
2524+
- oauth2: [https://jans.io/oauth/config/agama.write]
2525+
2526+
2527+
put:
2528+
summary: Updates an agama flow based on Qname.
2529+
description: Updates an agama based on Qname.
2530+
operationId: put-agama-flow
2531+
tags:
2532+
- Configuration – Agama Flow
2533+
requestBody:
2534+
content:
2535+
application/json:
2536+
schema:
2537+
$ref: '#/components/schemas/AgamaFlow'
2538+
responses:
2539+
'200':
2540+
description: OK
2541+
content:
2542+
application/json:
2543+
schema:
2544+
$ref: '#/components/schemas/AgamaFlow'
2545+
'401':
2546+
$ref: '#/components/responses/Unauthorized'
2547+
'404':
2548+
$ref: '#/components/responses/NotFound'
2549+
'500':
2550+
$ref: '#/components/responses/InternalServerError'
2551+
security:
2552+
- oauth2: [https://jans.io/oauth/config/agama.write]
2553+
delete:
2554+
summary: Deletes an agama flow based on Qname.
2555+
description: Deletes an agama flow based on Qname.
2556+
operationId: delete-agama-flow
2557+
tags:
2558+
- Configuration – Agama Flow
2559+
responses:
2560+
'204':
2561+
description: No Content
2562+
'401':
2563+
description: Unauthorized
2564+
'404':
2565+
description: Not Found
2566+
'500':
2567+
description: Internal Server Error
2568+
security:
2569+
- oauth2: [https://jans.io/oauth/config/agama.delete]
2570+
24232571
/jans-config-api/api/v1/stat:
24242572
get:
24252573
summary: Provides server with basic statistic.
@@ -7079,3 +7227,69 @@ components:
70797227
additionalProperties:
70807228
type: string
70817229

7230+
7231+
FlowMetadata:
7232+
title: Agama Flow meta data
7233+
description: Object for Agama Flow meta data.
7234+
type: object
7235+
properties:
7236+
funcName:
7237+
description: name of the function.
7238+
type: string
7239+
inputs:
7240+
description: Agama Flow inputs.
7241+
type: array
7242+
items:
7243+
type: string
7244+
timeout:
7245+
description: flow timeout value.
7246+
type: integer
7247+
format: int64
7248+
default: 0
7249+
displayName:
7250+
description: Flow name
7251+
type: string
7252+
author:
7253+
description: Author of the agama flow
7254+
type: string
7255+
timestamp:
7256+
description: flow update time.
7257+
type: string
7258+
format: date
7259+
7260+
7261+
AgamaFlow:
7262+
title: Agama Flow object
7263+
description: Object for Agama Flow.
7264+
type: object
7265+
properties:
7266+
dn:
7267+
description: Domain name
7268+
type: string
7269+
QName:
7270+
description: Agama flow identifier.
7271+
type: string
7272+
transHash:
7273+
description: Agama Flow custom message.
7274+
type: string
7275+
revision:
7276+
description: Update revision number of the script.
7277+
type: integer
7278+
format: int64
7279+
default: 0
7280+
enabled:
7281+
description: boolean value indicating if script enabled.
7282+
type: boolean
7283+
default: false
7284+
metadata:
7285+
description: Agama Flow metadata.
7286+
$ref: '#/components/schemas/FlowMetadata'
7287+
source:
7288+
description: Agama Flow source.
7289+
type: string
7290+
transpiled:
7291+
description: Agama Flow translate compiler.
7292+
type: string
7293+
codeError:
7294+
type: string
7295+
description: Possible errors assosiated with the flow.

jans-config-api/pom.xml

+12-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,18 @@
222222
<groupId>io.jans</groupId>
223223
<artifactId>uma-rs-core</artifactId>
224224
<version>${jans.version}</version>
225-
</dependency>
225+
</dependency>
226+
<dependency>
227+
<groupId>io.jans</groupId>
228+
<artifactId>agama-model</artifactId>
229+
<version>${jans.version}</version>
230+
</dependency>
231+
<dependency>
232+
<groupId>io.jans</groupId>
233+
<artifactId>agama-transpiler</artifactId>
234+
<version>${jans.version}</version>
235+
</dependency>
236+
226237

227238
<!-- Security -->
228239
<dependency>

0 commit comments

Comments
 (0)