Skip to content

Commit

Permalink
feat: initial agama commit #1322 (#1323)
Browse files Browse the repository at this point in the history
* feat: initial agama commit #1322

* ci: add codeowner

Co-authored-by: Mohammad Abudayyeh <47318409+moabu@users.noreply.github.com>
  • Loading branch information
jgomer2001 and moabu committed May 12, 2022
1 parent db4f080 commit 0148bc8
Show file tree
Hide file tree
Showing 74 changed files with 11,226 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@
/jans-linux-setup/ @mbaser @smansoft @yuriyz
/jans-linux-setup/jans_setup/setup_app/version.py @moabu
/jans-linux-setup/static/scripts/admin_ui_plugin.py @mbaser @duttarnab
/super-jans @harsukhbir
/super-jans @harsukhbir
/agama/ @jgomer2001
1 change: 1 addition & 0 deletions .github/workflows/central_code_quality_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ jobs:
jans-notify
jans-fido2
jans-eleven
agama
NON_JVM_PROJECTS: |
jans-linux-setup
jans-cli
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ jobs:
#max-parallel: 1
fail-fast: false
matrix:
maven: [ "jans-scim", "jans-orm", "jans-notify", "jans-fido2", "jans-eleven", "jans-core", "jans-config-api", "jans-client-api", "jans-bom", "jans-auth-server" ]
maven: [ "jans-scim", "jans-orm", "jans-notify", "jans-fido2", "jans-eleven", "jans-core", "jans-config-api", "jans-client-api", "jans-bom", "jans-auth-server", "agama" ]
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down
192 changes: 192 additions & 0 deletions agama/engine/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<artifactId>agama-engine</artifactId>
<packaging>jar</packaging>

<parent>
<groupId>io.jans</groupId>
<artifactId>agama</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>

<repositories>
<repository>
<id>jans</id>
<name>Jans repository</name>
<url>https://maven.jans.io/maven</url>
</repository>
</repositories>

<!--build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build-->

<dependencies>

<dependency>
<groupId>io.jans</groupId>
<artifactId>agama-model</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.jans</groupId>
<artifactId>agama-transpiler</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>

<!-- SERVLET -->
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<scope>provided</scope>
</dependency>

<!-- JSF -->
<dependency>
<groupId>jakarta.faces</groupId>
<artifactId>jakarta.faces-api</artifactId>
<scope>provided</scope>
</dependency>

<!-- JAX-RS -->
<dependency>
<groupId>org.jboss.spec.javax.ws.rs</groupId>
<artifactId>jboss-jaxrs-api_3.0_spec</artifactId>
<scope>provided</scope>
</dependency>

<!-- WELD -->
<dependency>
<groupId>org.jboss.weld.servlet</groupId>
<artifactId>weld-servlet-shaded</artifactId>
<scope>provided</scope>
</dependency>

<!-- FREEMARKER -->
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.31</version>
</dependency>

<!-- LOGGING -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<scope>provided</scope>
</dependency>

<!-- JACKSON -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<scope>provided</scope>
</dependency>

<!-- Mozilla Rhino -->
<dependency>
<groupId>org.mozilla</groupId>
<artifactId>rhino</artifactId>
<version>1.7.14</version>
</dependency>

<!-- Groovy -->
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy</artifactId>
<version>3.0.7</version>
</dependency>

<!-- JANS -->
<dependency>
<groupId>io.jans</groupId>
<artifactId>jans-core-util</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.jans</groupId>
<artifactId>jans-core-cdi</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.jans</groupId>
<artifactId>jans-core-service</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.jans</groupId>
<artifactId>jans-orm-core</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.jans</groupId>
<artifactId>jans-auth-model</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.esotericsoftware</groupId>
<artifactId>kryo</artifactId>
<version>5.3.0</version>
</dependency>

</dependencies>

</project>
87 changes: 87 additions & 0 deletions agama/engine/src/main/java/io/jans/agama/NativeJansFlowBridge.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package io.jans.agama;

import io.jans.agama.engine.model.FlowResult;
import io.jans.agama.engine.model.FlowStatus;
import io.jans.agama.engine.service.AgamaPersistenceService;
import io.jans.agama.engine.service.FlowService;
import io.jans.agama.engine.service.WebContext;
import io.jans.agama.engine.servlet.ExecutionServlet;
import io.jans.agama.model.EngineConfig;

import jakarta.inject.Inject;
import jakarta.enterprise.context.RequestScoped;
import java.io.IOException;

import org.slf4j.Logger;

@RequestScoped
public class NativeJansFlowBridge {

@Inject
private Logger logger;

@Inject
private AgamaPersistenceService aps;

@Inject
private FlowService fs;

@Inject
private EngineConfig conf;

@Inject
private WebContext webContext;

public String scriptPageUrl() {
return conf.getBridgeScriptPage();
}

public String getTriggerUrl() {
return webContext.getContextPath() + ExecutionServlet.URL_PREFIX +
"agama" + ExecutionServlet.URL_SUFFIX;
}

public Boolean prepareFlow(String sessionId, String qname, String jsonInput) throws Exception {

logger.info("Preparing flow '{}'", qname);
Boolean alreadyRunning = null;
if (fs.isEnabled(qname)) {

FlowStatus st = aps.getFlowStatus(sessionId);
alreadyRunning = st != null;

if (alreadyRunning && !st.getQname().equals(qname)) {
logger.warn("Flow {} is already running. Will be terminated", st.getQname());
fs.terminateFlow();
st = null;
}
if (st == null) {
st = new FlowStatus();
st.setStartedAt(FlowStatus.PREPARED);
st.setQname(qname);
st.setJsonInput(jsonInput);
aps.createFlowRun(sessionId, st, System.currentTimeMillis() + 1000*conf.getInterruptionTime());
}
}
return alreadyRunning;

}

public FlowResult close() throws IOException {

FlowStatus st = fs.getRunningFlowStatus();
if (st == null) {
logger.error("No current flow running");

} else if (st.getStartedAt() != FlowStatus.FINISHED) {
logger.error("Current flow hasn't finished");

} else {
fs.terminateFlow();
return st.getResult();
}
return null;

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package io.jans.agama.engine.continuation;

import org.mozilla.javascript.ContinuationPending;
import org.mozilla.javascript.NativeContinuation;

public class PendingException extends ContinuationPending {

private boolean allowCallbackResume;

public PendingException(NativeContinuation continuation) {
super(continuation);
}

@Override
public NativeContinuation getContinuation() {
return (NativeContinuation) super.getContinuation();
}

public boolean isAllowCallbackResume() {
return allowCallbackResume;
}

public void setAllowCallbackResume(boolean allowCallbackResume) {
this.allowCallbackResume = allowCallbackResume;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package io.jans.agama.engine.continuation;

import org.mozilla.javascript.NativeContinuation;

public class PendingRedirectException extends PendingException {

public PendingRedirectException(NativeContinuation continuation) {
super(continuation);
}

private String location;

public String getLocation() {
return location;
}

public void setLocation(String location) {
this.location = location;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package io.jans.agama.engine.continuation;

import java.util.Map;

import org.mozilla.javascript.NativeContinuation;

public class PendingRenderException extends PendingException {

private String templatePath;
private Map<String, Object> dataModel;

public PendingRenderException(NativeContinuation continuation) {
super(continuation);
}

public String getTemplatePath() {
return templatePath;
}

public void setTemplatePath(String templatePath) {
this.templatePath = templatePath;
}

public Map<String, Object> getDataModel() {
return dataModel;
}

public void setDataModel(Map<String, Object> dataModel) {
this.dataModel = dataModel;
}

}
Loading

0 comments on commit 0148bc8

Please sign in to comment.