commit
80136681f0
34 changed files with 684 additions and 183 deletions
|
|
@ -254,6 +254,21 @@
|
||||||
<artifactId>springfox-swagger-ui</artifactId>
|
<artifactId>springfox-swagger-ui</artifactId>
|
||||||
<version>3.0.0</version>
|
<version>3.0.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.jsonwebtoken</groupId>
|
||||||
|
<artifactId>jjwt</artifactId>
|
||||||
|
<version>0.9.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.jsonwebtoken</groupId>
|
||||||
|
<artifactId>jjwt</artifactId>
|
||||||
|
<version>0.9.1</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.vaadin.olli</groupId>
|
||||||
|
<artifactId>clipboardhelper</artifactId>
|
||||||
|
<version>1.1.2</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,64 @@
|
||||||
|
package org.chtijbug.drools.console.middle;
|
||||||
|
|
||||||
|
import io.jsonwebtoken.Claims;
|
||||||
|
import io.jsonwebtoken.JwtBuilder;
|
||||||
|
import io.jsonwebtoken.Jwts;
|
||||||
|
import io.jsonwebtoken.SignatureAlgorithm;
|
||||||
|
import org.chtijbug.drools.proxy.persistence.model.ProjectPersist;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.crypto.spec.SecretKeySpec;
|
||||||
|
import javax.xml.bind.DatatypeConverter;
|
||||||
|
import java.security.Key;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class JwtService {
|
||||||
|
|
||||||
|
@Value("${secretkey}")
|
||||||
|
public String secretKey;
|
||||||
|
|
||||||
|
public String createJWT(ProjectPersist projectPersist, long ttlMillis) {
|
||||||
|
|
||||||
|
//The JWT signature algorithm we will be using to sign the token
|
||||||
|
SignatureAlgorithm signatureAlgorithm = SignatureAlgorithm.HS256;
|
||||||
|
|
||||||
|
long nowMillis = System.currentTimeMillis();
|
||||||
|
Date now = new Date(nowMillis);
|
||||||
|
|
||||||
|
//We will sign our JWT with our ApiKey secret
|
||||||
|
byte[] apiKeySecretBytes = DatatypeConverter.parseBase64Binary(secretKey);
|
||||||
|
Key signingKey = new SecretKeySpec(apiKeySecretBytes, signatureAlgorithm.getJcaName());
|
||||||
|
|
||||||
|
//Let's set the JWT Claims
|
||||||
|
JwtBuilder builder = Jwts.builder().setId(projectPersist.getUuid())
|
||||||
|
.setIssuedAt(now)
|
||||||
|
.setSubject("api")
|
||||||
|
.setIssuer("pymma")
|
||||||
|
.claim("groupID",projectPersist.getGroupID())
|
||||||
|
.claim("artifactID",projectPersist.getArtifactID())
|
||||||
|
.claim("branch",projectPersist.getBranch())
|
||||||
|
.claim("mainClass",projectPersist.getMainClass())
|
||||||
|
.claim("uuid",projectPersist.getUuid())
|
||||||
|
.signWith(signatureAlgorithm, signingKey);
|
||||||
|
|
||||||
|
//if it has been specified, let's add the expiration
|
||||||
|
if (ttlMillis >= 0) {
|
||||||
|
long expMillis = nowMillis + ttlMillis;
|
||||||
|
Date exp = new Date(expMillis);
|
||||||
|
builder.setExpiration(exp);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Builds the JWT and serializes it to a compact, URL-safe string
|
||||||
|
return builder.compact();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Claims decodeJWT(String jwt) {
|
||||||
|
return Jwts.parser()
|
||||||
|
.setSigningKey(DatatypeConverter.parseBase64Binary(secretKey))
|
||||||
|
.parseClaimsJws(jwt.replace("bearer","")).getBody();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -187,7 +187,12 @@ public class ProjectPersistService {
|
||||||
projectPersist.setContainerID(projectPersist.getDeploymentName() + "-" + projectPersist.getProjectName());
|
projectPersist.setContainerID(projectPersist.getDeploymentName() + "-" + projectPersist.getProjectName());
|
||||||
projectPersist.getServerNames().clear();
|
projectPersist.getServerNames().clear();
|
||||||
ReverseProxyUpdate reverseProxyUpdate = new ReverseProxyUpdate();
|
ReverseProxyUpdate reverseProxyUpdate = new ReverseProxyUpdate();
|
||||||
|
reverseProxyUpdate.setContainerID(projectPersist.getContainerID());
|
||||||
|
if (projectPersist.isUseJWTToConnect()) {
|
||||||
|
reverseProxyUpdate.setTokenUUID(projectPersist.getUuid());
|
||||||
|
}else{
|
||||||
reverseProxyUpdate.setPath("/" + projectPersist.getContainerID());
|
reverseProxyUpdate.setPath("/" + projectPersist.getContainerID());
|
||||||
|
}
|
||||||
for (RuntimePersist runtimePersist : runtimePersists) {
|
for (RuntimePersist runtimePersist : runtimePersists) {
|
||||||
List<String> names = new ArrayList<>();
|
List<String> names = new ArrayList<>();
|
||||||
names.add(runtimePersist.getServerName());
|
names.add(runtimePersist.getServerName());
|
||||||
|
|
@ -201,7 +206,8 @@ public class ProjectPersistService {
|
||||||
newContainer.setServerName(runtimePersist.getServerName());
|
newContainer.setServerName(runtimePersist.getServerName());
|
||||||
newContainer.setGroupId(projectPersist.getGroupID());
|
newContainer.setGroupId(projectPersist.getGroupID());
|
||||||
newContainer.setArtifactId(projectPersist.getArtifactID());
|
newContainer.setArtifactId(projectPersist.getArtifactID());
|
||||||
|
newContainer.setProjectUUID(projectPersist.getUuid());
|
||||||
|
newContainer.setDisableRuleLogging(projectPersist.isDisableRuleLogging());
|
||||||
newContainer.setVersion(projectPersist.getProjectVersion());
|
newContainer.setVersion(projectPersist.getProjectVersion());
|
||||||
containerRepository.save(newContainer);
|
containerRepository.save(newContainer);
|
||||||
List<ContainerRuntimePojoPersist> elts = containerRuntimeRepository.findByServerNameAndContainerId(runtimePersist.getServerName(), projectPersist.getContainerID());
|
List<ContainerRuntimePojoPersist> elts = containerRuntimeRepository.findByServerNameAndContainerId(runtimePersist.getServerName(), projectPersist.getContainerID());
|
||||||
|
|
@ -217,9 +223,15 @@ public class ProjectPersistService {
|
||||||
runtimePojoPersist.setHostname(runtimePersist.getHostname());
|
runtimePojoPersist.setHostname(runtimePersist.getHostname());
|
||||||
runtimePojoPersist.setContainerId(projectPersist.getContainerID());
|
runtimePojoPersist.setContainerId(projectPersist.getContainerID());
|
||||||
runtimePojoPersist.setStatus(ContainerRuntimePojoPersist.STATUS.TODEPLOY.name());
|
runtimePojoPersist.setStatus(ContainerRuntimePojoPersist.STATUS.TODEPLOY.name());
|
||||||
|
runtimePojoPersist.setProjectUUID(projectPersist.getUuid());
|
||||||
|
runtimePojoPersist.setDisableRuleLogging(projectPersist.isDisableRuleLogging());
|
||||||
containerRuntimeRepository.save(runtimePojoPersist);
|
containerRuntimeRepository.save(runtimePojoPersist);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}else{
|
||||||
|
existingContainer.setDisableRuleLogging(projectPersist.isDisableRuleLogging());
|
||||||
|
existingContainer.setProjectUUID(projectPersist.getUuid());
|
||||||
|
containerRepository.save(existingContainer);
|
||||||
}
|
}
|
||||||
|
|
||||||
String hostName = runtimePersist.getServerUrl() + "/api/" + projectPersist.getContainerID();
|
String hostName = runtimePersist.getServerUrl() + "/api/" + projectPersist.getContainerID();
|
||||||
|
|
@ -288,6 +300,7 @@ public class ProjectPersistService {
|
||||||
runtimePojoPersist.setHostname(server.getHostname());
|
runtimePojoPersist.setHostname(server.getHostname());
|
||||||
runtimePojoPersist.setContainerId(projectPersist.getContainerID());
|
runtimePojoPersist.setContainerId(projectPersist.getContainerID());
|
||||||
runtimePojoPersist.setStatus(ContainerRuntimePojoPersist.STATUS.TODEPLOY.name());
|
runtimePojoPersist.setStatus(ContainerRuntimePojoPersist.STATUS.TODEPLOY.name());
|
||||||
|
runtimePojoPersist.setProjectUUID(projectPersist.getUuid());
|
||||||
containerRuntimeRepository.save(runtimePojoPersist);
|
containerRuntimeRepository.save(runtimePojoPersist);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,11 @@
|
||||||
package org.chtijbug.drools.console.service;
|
package org.chtijbug.drools.console.service;
|
||||||
|
|
||||||
import org.chtijbug.drools.console.service.model.ReturnPerso;
|
import org.chtijbug.drools.console.service.model.ReturnPerso;
|
||||||
|
import org.chtijbug.drools.proxy.persistence.model.ContainerPojoPersist;
|
||||||
|
import org.chtijbug.drools.proxy.persistence.model.ContainerRuntimePojoPersist;
|
||||||
|
import org.chtijbug.drools.proxy.persistence.model.ProjectPersist;
|
||||||
|
import org.chtijbug.drools.proxy.persistence.repository.ContainerRepository;
|
||||||
|
import org.chtijbug.drools.proxy.persistence.repository.ContainerRuntimeRepository;
|
||||||
import org.chtijbug.drools.proxy.persistence.repository.RuntimeRepository;
|
import org.chtijbug.drools.proxy.persistence.repository.RuntimeRepository;
|
||||||
import org.chtijbug.drools.proxy.persistence.model.RuntimePersist;
|
import org.chtijbug.drools.proxy.persistence.model.RuntimePersist;
|
||||||
import org.kie.server.api.model.KieServerInfo;
|
import org.kie.server.api.model.KieServerInfo;
|
||||||
|
|
@ -16,6 +21,8 @@ import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@DependsOn("applicationContext")
|
@DependsOn("applicationContext")
|
||||||
public class RuntimeService {
|
public class RuntimeService {
|
||||||
|
|
@ -26,6 +33,12 @@ public class RuntimeService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private RuntimeRepository runtimeRepository;
|
private RuntimeRepository runtimeRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ContainerRepository containerRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ContainerRuntimeRepository containerRuntimeRepository;
|
||||||
|
|
||||||
private RestTemplate restTemplateKiewb = new RestTemplate();
|
private RestTemplate restTemplateKiewb = new RestTemplate();
|
||||||
|
|
||||||
public ReturnPerso<KieServerInfo> verifyIfKieServerExist(String url) {
|
public ReturnPerso<KieServerInfo> verifyIfKieServerExist(String url) {
|
||||||
|
|
@ -64,4 +77,22 @@ public class RuntimeService {
|
||||||
public void setRuntimeRepository(RuntimeRepository runtimeRepository) {
|
public void setRuntimeRepository(RuntimeRepository runtimeRepository) {
|
||||||
this.runtimeRepository = runtimeRepository;
|
this.runtimeRepository = runtimeRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateRuntimes(ProjectPersist projectPersist) {
|
||||||
|
if (projectPersist!= null && projectPersist.getUuid()!= null) {
|
||||||
|
List<ContainerPojoPersist> containerPojoPersists = containerRepository.findByProjectUUID(projectPersist.getUuid());
|
||||||
|
for (ContainerPojoPersist containerPojoPersist : containerPojoPersists){
|
||||||
|
containerPojoPersist.setDisableRuleLogging(projectPersist.isDisableRuleLogging());
|
||||||
|
containerRepository.save(containerPojoPersist);
|
||||||
|
|
||||||
|
List<ContainerRuntimePojoPersist> containerRuntimePojoPersists = containerRuntimeRepository.findByContainerId(containerPojoPersist.getContainerId());
|
||||||
|
for (ContainerRuntimePojoPersist containerRuntimePojoPersist : containerRuntimePojoPersists){
|
||||||
|
containerRuntimePojoPersist.setDisableRuleLogging(projectPersist.isDisableRuleLogging());
|
||||||
|
containerRuntimePojoPersist.setProjectUUID(projectPersist.getUuid());
|
||||||
|
containerRuntimeRepository.save(containerRuntimePojoPersist);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,27 @@
|
||||||
package org.chtijbug.drools.console.vaadincomponent.componentview;
|
package org.chtijbug.drools.console.vaadincomponent.componentview;
|
||||||
|
|
||||||
|
import com.vaadin.flow.component.AbstractField;
|
||||||
|
import com.vaadin.flow.component.ClickEvent;
|
||||||
|
import com.vaadin.flow.component.ComponentEventListener;
|
||||||
|
import com.vaadin.flow.component.HasValue;
|
||||||
import com.vaadin.flow.component.button.Button;
|
import com.vaadin.flow.component.button.Button;
|
||||||
|
import com.vaadin.flow.component.checkbox.Checkbox;
|
||||||
import com.vaadin.flow.component.dialog.Dialog;
|
import com.vaadin.flow.component.dialog.Dialog;
|
||||||
import com.vaadin.flow.component.html.Label;
|
import com.vaadin.flow.component.html.Label;
|
||||||
import com.vaadin.flow.component.icon.VaadinIcon;
|
import com.vaadin.flow.component.icon.VaadinIcon;
|
||||||
import com.vaadin.flow.component.notification.Notification;
|
import com.vaadin.flow.component.notification.Notification;
|
||||||
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
|
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
|
||||||
import com.vaadin.flow.data.value.ValueChangeMode;
|
import com.vaadin.flow.data.value.ValueChangeMode;
|
||||||
|
import io.jsonwebtoken.Claims;
|
||||||
|
import org.chtijbug.drools.console.middle.JwtService;
|
||||||
import org.chtijbug.drools.console.service.ProjectPersistService;
|
import org.chtijbug.drools.console.service.ProjectPersistService;
|
||||||
|
import org.chtijbug.drools.console.service.RuntimeService;
|
||||||
import org.chtijbug.drools.console.service.util.AppContext;
|
import org.chtijbug.drools.console.service.util.AppContext;
|
||||||
import org.chtijbug.drools.console.vaadincomponent.componentperso.ComboBoxPerso;
|
import org.chtijbug.drools.console.vaadincomponent.componentperso.ComboBoxPerso;
|
||||||
import org.chtijbug.drools.console.vaadincomponent.componentperso.TextFieldPerso;
|
import org.chtijbug.drools.console.vaadincomponent.componentperso.TextFieldPerso;
|
||||||
import org.chtijbug.drools.console.view.DeploymentView;
|
import org.chtijbug.drools.console.view.DeploymentView;
|
||||||
import org.chtijbug.drools.proxy.persistence.model.ProjectPersist;
|
import org.chtijbug.drools.proxy.persistence.model.ProjectPersist;
|
||||||
|
import org.vaadin.olli.ClipboardHelper;
|
||||||
|
|
||||||
public class DefineProject extends VerticalLayout {
|
public class DefineProject extends VerticalLayout {
|
||||||
|
|
||||||
|
|
@ -30,12 +39,31 @@ public class DefineProject extends VerticalLayout {
|
||||||
|
|
||||||
private Button valider;
|
private Button valider;
|
||||||
|
|
||||||
|
private Checkbox disableRuleLoggingCheckbox;
|
||||||
|
|
||||||
|
private Checkbox enableHotDeployCheckbox;
|
||||||
|
private Checkbox useJWTToConnectCheckbox;
|
||||||
|
|
||||||
|
private TextFieldPerso jwtTokenTextField;
|
||||||
|
|
||||||
|
private TextFieldPerso jwtPeriod;
|
||||||
|
|
||||||
|
private Button createJWTButton;
|
||||||
|
|
||||||
|
private Button copyJWTTextButton;
|
||||||
|
|
||||||
private transient ProjectPersistService projectPersistService;
|
private transient ProjectPersistService projectPersistService;
|
||||||
|
|
||||||
|
private transient RuntimeService runtimeService;
|
||||||
|
|
||||||
private boolean createMode;
|
private boolean createMode;
|
||||||
|
|
||||||
|
private JwtService jwtService;
|
||||||
|
|
||||||
public DefineProject(DeploymentView deploymentView,Dialog dialog, ProjectPersist projectPersist){
|
public DefineProject(DeploymentView deploymentView,Dialog dialog, ProjectPersist projectPersist){
|
||||||
|
|
||||||
|
jwtService = AppContext.getApplicationContext().getBean(JwtService.class);
|
||||||
|
runtimeService = AppContext.getApplicationContext().getBean(RuntimeService.class);
|
||||||
projectPersistService=AppContext.getApplicationContext().getBean(ProjectPersistService.class);
|
projectPersistService=AppContext.getApplicationContext().getBean(ProjectPersistService.class);
|
||||||
|
|
||||||
setClassName("creation-runtime-content");
|
setClassName("creation-runtime-content");
|
||||||
|
|
@ -44,7 +72,7 @@ public class DefineProject extends VerticalLayout {
|
||||||
label.setClassName("creation-runtime-title");
|
label.setClassName("creation-runtime-title");
|
||||||
add(label);
|
add(label);
|
||||||
|
|
||||||
label2=new Label("this step is essential before you can associate your project with a workbench");
|
label2=new Label("this step is essential before you can work on your project");
|
||||||
label2.setClassName("creation-runtime-title2");
|
label2.setClassName("creation-runtime-title2");
|
||||||
add(label2);
|
add(label2);
|
||||||
|
|
||||||
|
|
@ -98,6 +126,106 @@ public class DefineProject extends VerticalLayout {
|
||||||
|
|
||||||
add(processID);
|
add(processID);
|
||||||
|
|
||||||
|
enableHotDeployCheckbox = new Checkbox("Enable Hot deployment (needs 2 runtimes)");
|
||||||
|
if (projectPersist.isEnableHotDeploy()){
|
||||||
|
enableHotDeployCheckbox.setValue(true);
|
||||||
|
}else{
|
||||||
|
enableHotDeployCheckbox.setValue(false);
|
||||||
|
}
|
||||||
|
enableHotDeployCheckbox.addValueChangeListener(new HasValue.ValueChangeListener<AbstractField.ComponentValueChangeEvent<Checkbox, Boolean>>() {
|
||||||
|
@Override
|
||||||
|
public void valueChanged(AbstractField.ComponentValueChangeEvent<Checkbox, Boolean> checkboxBooleanComponentValueChangeEvent) {
|
||||||
|
projectPersist.setEnableHotDeploy(checkboxBooleanComponentValueChangeEvent.getValue());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
add(enableHotDeployCheckbox);
|
||||||
|
|
||||||
|
disableRuleLoggingCheckbox = new Checkbox("Disable Rule logging");
|
||||||
|
if (projectPersist.isDisableRuleLogging()){
|
||||||
|
disableRuleLoggingCheckbox.setValue(true);
|
||||||
|
}else{
|
||||||
|
disableRuleLoggingCheckbox.setValue(false);
|
||||||
|
}
|
||||||
|
disableRuleLoggingCheckbox.addValueChangeListener(new HasValue.ValueChangeListener<AbstractField.ComponentValueChangeEvent<Checkbox, Boolean>>() {
|
||||||
|
@Override
|
||||||
|
public void valueChanged(AbstractField.ComponentValueChangeEvent<Checkbox, Boolean> checkboxBooleanComponentValueChangeEvent) {
|
||||||
|
projectPersist.setDisableRuleLogging(disableRuleLoggingCheckbox.getValue());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
add(disableRuleLoggingCheckbox);
|
||||||
|
|
||||||
|
useJWTToConnectCheckbox =new Checkbox("Use JWT token to connect to API");
|
||||||
|
add(useJWTToConnectCheckbox);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
jwtTokenTextField=new TextFieldPerso("JWT Token for API","",VaadinIcon.TASKS.create());
|
||||||
|
|
||||||
|
if (projectPersist.getJwtAPIToken()!= null
|
||||||
|
&& projectPersist.getJwtAPIToken().length()>0){
|
||||||
|
jwtTokenTextField.getTextField().setValue(projectPersist.getJwtAPIToken());
|
||||||
|
}
|
||||||
|
jwtTokenTextField.getTextField().setEnabled(false);
|
||||||
|
|
||||||
|
|
||||||
|
add(jwtTokenTextField);
|
||||||
|
copyJWTTextButton = new Button("Copy JWT token");
|
||||||
|
ClipboardHelper clipboardHelper = new ClipboardHelper(projectPersist.getJwtAPIToken(), copyJWTTextButton);
|
||||||
|
add(clipboardHelper);
|
||||||
|
jwtPeriod=new TextFieldPerso("JWT validity for API","",VaadinIcon.TASKS.create());
|
||||||
|
jwtPeriod.setEnabled(false);
|
||||||
|
if (projectPersist.getJwtAPIToken()!= null
|
||||||
|
&& projectPersist.getJwtAPIToken().length()>0){
|
||||||
|
try {
|
||||||
|
Claims claims = jwtService.decodeJWT(projectPersist.getJwtAPIToken());
|
||||||
|
jwtPeriod.getTextField().setValue(claims.getExpiration().toString());
|
||||||
|
}catch (Exception e){
|
||||||
|
|
||||||
|
}
|
||||||
|
jwtTokenTextField.getTextField().setValue(projectPersist.getJwtAPIToken());
|
||||||
|
}
|
||||||
|
add(jwtPeriod);
|
||||||
|
createJWTButton = new Button("Generate JWT token for one year");
|
||||||
|
createJWTButton.addClickListener(new ComponentEventListener<ClickEvent<Button>>() {
|
||||||
|
@Override
|
||||||
|
public void onComponentEvent(ClickEvent<Button> buttonClickEvent) {
|
||||||
|
String token = jwtService.createJWT(projectPersist, 1000*3600*24*(long)365);
|
||||||
|
projectPersist.setJwtAPIToken(token);
|
||||||
|
jwtTokenTextField.getTextField().setValue(token);
|
||||||
|
Claims claims = jwtService.decodeJWT(projectPersist.getJwtAPIToken());
|
||||||
|
jwtPeriod.getTextField().setValue(claims.getExpiration().toString());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
add(createJWTButton);
|
||||||
|
if (projectPersist.isUseJWTToConnect()){
|
||||||
|
useJWTToConnectCheckbox.setValue(true);
|
||||||
|
}else{
|
||||||
|
useJWTToConnectCheckbox.setValue(false);
|
||||||
|
jwtTokenTextField.getTextField().setValue("");
|
||||||
|
jwtTokenTextField.setEnabled(false);
|
||||||
|
projectPersist.setJwtAPIToken(null);
|
||||||
|
createJWTButton.setEnabled(false);
|
||||||
|
jwtPeriod.getTextField().setValue("");
|
||||||
|
copyJWTTextButton.setEnabled(false);
|
||||||
|
}
|
||||||
|
useJWTToConnectCheckbox.addValueChangeListener(new HasValue.ValueChangeListener<AbstractField.ComponentValueChangeEvent<Checkbox, Boolean>>() {
|
||||||
|
@Override
|
||||||
|
public void valueChanged(AbstractField.ComponentValueChangeEvent<Checkbox, Boolean> checkboxBooleanComponentValueChangeEvent) {
|
||||||
|
projectPersist.setUseJWTToConnect(useJWTToConnectCheckbox.getValue());
|
||||||
|
if (!useJWTToConnectCheckbox.getValue()){
|
||||||
|
jwtTokenTextField.getTextField().setValue("");
|
||||||
|
createJWTButton.setEnabled(false);
|
||||||
|
projectPersist.setJwtAPIToken(null);
|
||||||
|
jwtPeriod.getTextField().setValue("");
|
||||||
|
copyJWTTextButton.setEnabled(false);
|
||||||
|
}else{
|
||||||
|
jwtTokenTextField.setEnabled(true);
|
||||||
|
copyJWTTextButton.setEnabled(true);
|
||||||
|
createJWTButton.setEnabled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
valider=new Button("Save");
|
valider=new Button("Save");
|
||||||
if (projectPersist.getProcessID()!= null
|
if (projectPersist.getProcessID()!= null
|
||||||
&& projectPersist.getProcessID().length()>0){
|
&& projectPersist.getProcessID().length()>0){
|
||||||
|
|
@ -112,6 +240,7 @@ public class DefineProject extends VerticalLayout {
|
||||||
if (createMode) {
|
if (createMode) {
|
||||||
projectPersist.setStatus(ProjectPersist.DEFINI);
|
projectPersist.setStatus(ProjectPersist.DEFINI);
|
||||||
}
|
}
|
||||||
|
runtimeService.updateRuntimes(projectPersist);
|
||||||
projectPersistService.getProjectRepository().save(projectPersist);
|
projectPersistService.getProjectRepository().save(projectPersist);
|
||||||
deploymentView.setDataProvider();
|
deploymentView.setDataProvider();
|
||||||
dialog.close();
|
dialog.close();
|
||||||
|
|
@ -128,5 +257,10 @@ public class DefineProject extends VerticalLayout {
|
||||||
valider.setEnabled(true);
|
valider.setEnabled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public void verifyToken(){
|
||||||
|
|
||||||
|
valider.setEnabled(true);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,9 @@ package org.chtijbug.drools.console.vaadincomponent.leftMenu.Action;
|
||||||
import com.vaadin.flow.component.button.Button;
|
import com.vaadin.flow.component.button.Button;
|
||||||
import com.vaadin.flow.component.icon.VaadinIcon;
|
import com.vaadin.flow.component.icon.VaadinIcon;
|
||||||
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
|
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
|
||||||
|
import org.chtijbug.drools.console.middle.JwtService;
|
||||||
import org.chtijbug.drools.console.service.ProjectPersistService;
|
import org.chtijbug.drools.console.service.ProjectPersistService;
|
||||||
|
import org.chtijbug.drools.console.service.UserConnectedService;
|
||||||
import org.chtijbug.drools.console.service.util.AppContext;
|
import org.chtijbug.drools.console.service.util.AppContext;
|
||||||
import org.chtijbug.drools.console.vaadincomponent.componentperso.DialogPerso;
|
import org.chtijbug.drools.console.vaadincomponent.componentperso.DialogPerso;
|
||||||
import org.chtijbug.drools.console.vaadincomponent.Squelette.SqueletteComposant;
|
import org.chtijbug.drools.console.vaadincomponent.Squelette.SqueletteComposant;
|
||||||
|
|
|
||||||
|
|
@ -32,3 +32,6 @@ spring.servlet.multipart.max-request-size=100MB
|
||||||
# Server properties
|
# Server properties
|
||||||
server.tomcat.max-http-post-size=100000000
|
server.tomcat.max-http-post-size=100000000
|
||||||
server.tomcat.max-swallow-size=100MB
|
server.tomcat.max-swallow-size=100MB
|
||||||
|
|
||||||
|
|
||||||
|
secretkey=eRaYY7Wo24sDqKSX3IM9ASGmdGPmkTd9jo1QTy4b7P9Ze5_9hKolVX8xNrQDcNRfVEdTZNOuOyqEGhXEbdJI-ZQ19k_o9MI0y3eZN2lp9jow55FfXMiINEdt1XR85VipRLSOkT6kSpzs2x-jbLDiz9iFVzkd81YKxMgPA7VfZeQUm4n-mOmnWMaVX30zGFU4L3oPBctYKkl4dYfqYWqRNfrgPJVi5DGFjywgxx0ASEiJHtV72paI3fDR2XwlSkyhhmY-ICjCRmsJN4fX1pdoL8a18-aQrvyu4j0Os6dVPYIoPvvY0SAZtWYKHfM15g7A3HD4cVREf9cUsprCRK93w
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
package org.chtijbug.drools.common.rest;
|
||||||
|
|
||||||
|
public class Constants {
|
||||||
|
public final static String AUTHORISATION_HEADER = "Authorization";
|
||||||
|
}
|
||||||
|
|
@ -32,7 +32,7 @@ import org.springframework.context.annotation.PropertySource;
|
||||||
|
|
||||||
@EnableAutoConfiguration
|
@EnableAutoConfiguration
|
||||||
@PropertySource("classpath:application.properties")
|
@PropertySource("classpath:application.properties")
|
||||||
public class Application {
|
public class SwimmingPoolApplication {
|
||||||
|
|
||||||
@Value(value = "${url.swimmingpool.calculate}")
|
@Value(value = "${url.swimmingpool.calculate}")
|
||||||
private String url;
|
private String url;
|
||||||
|
|
@ -42,7 +42,7 @@ public class Application {
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(Application.class, args);
|
SpringApplication.run(SwimmingPoolApplication.class, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|
@ -27,6 +27,6 @@ import org.springframework.boot.web.servlet.support.SpringBootServletInitializer
|
||||||
public class WebInitializer extends SpringBootServletInitializer {
|
public class WebInitializer extends SpringBootServletInitializer {
|
||||||
@Override
|
@Override
|
||||||
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
|
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
|
||||||
return application.sources(Application.class);
|
return application.sources(SwimmingPoolApplication.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ package org.chtijbug.swimmingpool.web.controller;
|
||||||
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import org.chtijbug.drools.common.rest.Constants;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
|
@ -52,10 +53,10 @@ public class QuoteController {
|
||||||
Quote responseMoteur=null;
|
Quote responseMoteur=null;
|
||||||
try {
|
try {
|
||||||
|
|
||||||
String completeurl = urlCalcul+"/"+containerid;
|
String completeurl = urlCalcul+"/";
|
||||||
logger.info("url moteur reco : " + completeurl);
|
logger.info("url moteur reco : " + completeurl);
|
||||||
ResponseEntity<Quote> response = restTemplateKieServer
|
ResponseEntity<Quote> response = restTemplateKieServer
|
||||||
.execute(completeurl, HttpMethod.PUT, requestCallback(quoteRequest), clientHttpResponse -> {
|
.execute(completeurl, HttpMethod.PUT, requestCallback(quoteRequest,containerid), clientHttpResponse -> {
|
||||||
Quote extractedResponse = null;
|
Quote extractedResponse = null;
|
||||||
if (clientHttpResponse.getBody() != null) {
|
if (clientHttpResponse.getBody() != null) {
|
||||||
Scanner s = new Scanner(clientHttpResponse.getBody()).useDelimiter("\\A");
|
Scanner s = new Scanner(clientHttpResponse.getBody()).useDelimiter("\\A");
|
||||||
|
|
@ -79,7 +80,7 @@ public class QuoteController {
|
||||||
}
|
}
|
||||||
return responseMoteur;
|
return responseMoteur;
|
||||||
}
|
}
|
||||||
private RequestCallback requestCallback(final Quote updatedInstance) {
|
private RequestCallback requestCallback(final Quote updatedInstance,String token) {
|
||||||
return clientHttpRequest -> {
|
return clientHttpRequest -> {
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
mapper.writeValue(clientHttpRequest.getBody(), updatedInstance);
|
mapper.writeValue(clientHttpRequest.getBody(), updatedInstance);
|
||||||
|
|
@ -89,6 +90,8 @@ public class QuoteController {
|
||||||
"transactionId", updatedInstance.getSessionLogging());
|
"transactionId", updatedInstance.getSessionLogging());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
clientHttpRequest.getHeaders().add(
|
||||||
|
Constants.AUTHORISATION_HEADER, token);
|
||||||
clientHttpRequest.getHeaders().add(
|
clientHttpRequest.getHeaders().add(
|
||||||
HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
|
HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
|
||||||
clientHttpRequest.getHeaders().add(
|
clientHttpRequest.getHeaders().add(
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
# See http://docs.spring.io/spring-boot/docs/1.1.4.RELEASE/reference/htmlsingle/#boot-features-external-config-profile-specific-properties
|
# See http://docs.spring.io/spring-boot/docs/1.1.4.RELEASE/reference/htmlsingle/#boot-features-external-config-profile-specific-properties
|
||||||
# for more details about creating profile-specific property files
|
# for more details about creating profile-specific property files
|
||||||
# See http://docs.spring.io/spring-boot/docs/1.1.4.RELEASE/reference/htmlsingle/#howto-initialize-a-database-using-jpa
|
# See http://docs.spring.io/spring-boot/docs/1.1.4.RELEASE/reference/htmlsingle/#howto-initialize-a-database-using-jpa
|
||||||
url.swimmingpool.calculate=http://localhost:9500/
|
url.swimmingpool.calculate=http://localhost:9500
|
||||||
|
#url.swimmingpool.calculate=https://proxy.kie.infra.pymma-software.net
|
||||||
url.swimmingpool.calculate.username=kieserver
|
url.swimmingpool.calculate.username=kieserver
|
||||||
url.swimmingpool.calculate.password=kieserver1!
|
url.swimmingpool.calculate.password=kieserver1!
|
||||||
server.port=12099
|
server.port=12099
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td><label for="containerid" class="control-label">Container id :</label></td>
|
<td><label for="containerid" class="control-label">Container id :</label></td>
|
||||||
<td><input id="containerid" type="text" ng-model="containerid" ng-maxlength="30"/></td>
|
<td><input id="containerid" type="text" ng-model="containerid" ng-maxlength="20000"/></td>
|
||||||
|
|
||||||
<td><label for="aClassName" class="control-label">Class name :</label></td>
|
<td><label for="aClassName" class="control-label">Class name :</label></td>
|
||||||
<td><input id="aClassName" type="text" ng-model="aClassName" ng-maxlength="50"/></td>
|
<td><input id="aClassName" type="text" ng-model="aClassName" ng-maxlength="50"/></td>
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ productManagerModule.controller('quoteManagerController', function ($scope, $htt
|
||||||
$scope.productSearch = "";
|
$scope.productSearch = "";
|
||||||
$http.defaults.headers.post["Content-Type"] = "application/json";
|
$http.defaults.headers.post["Content-Type"] = "application/json";
|
||||||
$scope.allSessionExecutionDetails = [];
|
$scope.allSessionExecutionDetails = [];
|
||||||
$scope.containerid = "dev";
|
$scope.containerid = "eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiI2MDk5OWEyZGQ3YWUyODNmY2MyNWFhNzciLCJpYXQiOjE2MjY4NzkxMjUsInN1YiI6ImFwaSIsImlzcyI6InB5bW1hIiwiZ3JvdXBJRCI6ImNvbS5weW1tYXNvZnR3YXJlLmpicG0udHJhaW5pbmciLCJhcnRpZmFjdElEIjoic3dpbW1pbmdwb29sLXR1dG9yaWFsIiwicHJvamVjdFZlcnNpb24iOiIyLjAuMC1TTkFQU0hPVCIsImJyYW5jaCI6Im1hc3RlciIsIm1haW5DbGFzcyI6Im9yZy50cmFpbmluZy5sZWlzdXJlLnN3aW1taW5ncG9vbC5RdW90ZSIsImV4cCI6MTY1ODQxNTEyNX0.sKYOY98Hsk4JcS546f7xmj1tPNxdrqRtw5y6w0qdu88";
|
||||||
$scope.aClassName = "org.training.leisure.swimmingpool.Quote";
|
$scope.aClassName = "org.training.leisure.swimmingpool.Quote";
|
||||||
var _lastGoodResult = '';
|
var _lastGoodResult = '';
|
||||||
$scope.toPrettyJSON = function (objStr, tabWidth) {
|
$scope.toPrettyJSON = function (objStr, tabWidth) {
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ package org.chtijbug.kieserver.services.drools;
|
||||||
|
|
||||||
import org.chtijbug.drools.ChtijbugObjectRequest;
|
import org.chtijbug.drools.ChtijbugObjectRequest;
|
||||||
import org.chtijbug.drools.SessionContext;
|
import org.chtijbug.drools.SessionContext;
|
||||||
|
import org.chtijbug.drools.entity.history.HistoryEvent;
|
||||||
import org.chtijbug.drools.kieserver.extension.KieServerAddOnElement;
|
import org.chtijbug.drools.kieserver.extension.KieServerAddOnElement;
|
||||||
import org.chtijbug.drools.kieserver.extension.KieServerGlobalVariableDefinition;
|
import org.chtijbug.drools.kieserver.extension.KieServerGlobalVariableDefinition;
|
||||||
import org.chtijbug.drools.kieserver.extension.KieServerListenerDefinition;
|
import org.chtijbug.drools.kieserver.extension.KieServerListenerDefinition;
|
||||||
|
|
@ -32,9 +33,7 @@ import org.kie.server.services.api.KieServerRegistry;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Direct rules execution service that allow use of typed objects instead of string only
|
* Direct rules execution service that allow use of typed objects instead of string only
|
||||||
|
|
@ -130,7 +129,10 @@ public class DroolsChtijbugRulesExecutionService {
|
||||||
RuleBasePackage ruleBasePackage = this.ruleBasePackages.get(kci.getResource().getContainerId());
|
RuleBasePackage ruleBasePackage = this.ruleBasePackages.get(kci.getResource().getContainerId());
|
||||||
if (ruleBasePackage != null) {
|
if (ruleBasePackage != null) {
|
||||||
Date startTime = new Date();
|
Date startTime = new Date();
|
||||||
ChtijbugHistoryListener chtijbugHistoryListener = new ChtijbugHistoryListener();
|
ChtijbugHistoryListener chtijbugHistoryListener=null;
|
||||||
|
if (!chtijbugObjectRequest.isDisableLogging()) {
|
||||||
|
chtijbugHistoryListener = new ChtijbugHistoryListener();
|
||||||
|
}
|
||||||
RuleBaseSession session = ruleBasePackage.createRuleBaseSession(sessionMaxNumberRulesToExecute, chtijbugHistoryListener, sessionName);
|
RuleBaseSession session = ruleBasePackage.createRuleBaseSession(sessionMaxNumberRulesToExecute, chtijbugHistoryListener, sessionName);
|
||||||
if (kieServerAddOnElement != null) {
|
if (kieServerAddOnElement != null) {
|
||||||
|
|
||||||
|
|
@ -145,7 +147,11 @@ public class DroolsChtijbugRulesExecutionService {
|
||||||
result = session.fireAllRulesAndStartProcess(chtijbugObjectRequest.getObjectRequest(), processID);
|
result = session.fireAllRulesAndStartProcess(chtijbugObjectRequest.getObjectRequest(), processID);
|
||||||
session.dispose();
|
session.dispose();
|
||||||
Date stopTime = new Date();
|
Date stopTime = new Date();
|
||||||
SessionContext sessionContext = this.messageHandlerResolver.getSessionFromHistoryEvent(chtijbugHistoryListener.getHistoryEventLinkedList());
|
List<HistoryEvent> events=new ArrayList<>();
|
||||||
|
if (chtijbugHistoryListener!= null){
|
||||||
|
events = chtijbugHistoryListener.getHistoryEventLinkedList();
|
||||||
|
}
|
||||||
|
SessionContext sessionContext = this.messageHandlerResolver.getSessionFromHistoryEvent(events);
|
||||||
sessionContext.setGroupID(kci.getResource().getReleaseId().getGroupId());
|
sessionContext.setGroupID(kci.getResource().getReleaseId().getGroupId());
|
||||||
sessionContext.setArtefactID(kci.getResource().getReleaseId().getArtifactId());
|
sessionContext.setArtefactID(kci.getResource().getReleaseId().getArtifactId());
|
||||||
sessionContext.setVersion(kci.getResource().getReleaseId().getVersion());
|
sessionContext.setVersion(kci.getResource().getReleaseId().getVersion());
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,8 @@ public class ChtijbugObjectRequest {
|
||||||
|
|
||||||
private SessionContext sessionLogging;
|
private SessionContext sessionLogging;
|
||||||
|
|
||||||
|
private boolean disableLogging;
|
||||||
|
|
||||||
public String getTransactionID() {
|
public String getTransactionID() {
|
||||||
return transactionID;
|
return transactionID;
|
||||||
}
|
}
|
||||||
|
|
@ -102,4 +104,12 @@ public class ChtijbugObjectRequest {
|
||||||
public void setVersion(String version) {
|
public void setVersion(String version) {
|
||||||
this.version = version;
|
this.version = version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isDisableLogging() {
|
||||||
|
return disableLogging;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDisableLogging(boolean disableLogging) {
|
||||||
|
this.disableLogging = disableLogging;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,10 @@ import java.util.List;
|
||||||
public class ReverseProxyUpdate {
|
public class ReverseProxyUpdate {
|
||||||
private String path;
|
private String path;
|
||||||
|
|
||||||
|
private String tokenUUID;
|
||||||
|
|
||||||
|
private String containerID;
|
||||||
|
|
||||||
List<String> serverNames = new ArrayList<>();
|
List<String> serverNames = new ArrayList<>();
|
||||||
|
|
||||||
public String getPath() {
|
public String getPath() {
|
||||||
|
|
@ -16,6 +20,14 @@ public class ReverseProxyUpdate {
|
||||||
this.path = path;
|
this.path = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getTokenUUID() {
|
||||||
|
return tokenUUID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTokenUUID(String tokenUUID) {
|
||||||
|
this.tokenUUID = tokenUUID;
|
||||||
|
}
|
||||||
|
|
||||||
public List<String> getServerNames() {
|
public List<String> getServerNames() {
|
||||||
return serverNames;
|
return serverNames;
|
||||||
}
|
}
|
||||||
|
|
@ -23,4 +35,12 @@ public class ReverseProxyUpdate {
|
||||||
public void setServerNames(List<String> serverNames) {
|
public void setServerNames(List<String> serverNames) {
|
||||||
this.serverNames = serverNames;
|
this.serverNames = serverNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setContainerID(String containerID) {
|
||||||
|
this.containerID = containerID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getContainerID() {
|
||||||
|
return containerID;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,7 @@ public class StoreLoggingService {
|
||||||
item.setServerName(sessionContext.getServerName());
|
item.setServerName(sessionContext.getServerName());
|
||||||
Map<Long, BusinessTransactionAction> actions = new HashMap<>();
|
Map<Long, BusinessTransactionAction> actions = new HashMap<>();
|
||||||
SessionExecution sessionExecution = sessionContext.getSessionExecution();
|
SessionExecution sessionExecution = sessionContext.getSessionExecution();
|
||||||
|
if (sessionExecution != null) {
|
||||||
BusinessTransactionAction businessTransactionoutput = null;
|
BusinessTransactionAction businessTransactionoutput = null;
|
||||||
for (Fact fact : sessionExecution.getFacts()) {
|
for (Fact fact : sessionExecution.getFacts()) {
|
||||||
BusinessTransactionAction businessTransactionAction = new BusinessTransactionAction();
|
BusinessTransactionAction businessTransactionAction = new BusinessTransactionAction();
|
||||||
|
|
@ -150,10 +151,12 @@ public class StoreLoggingService {
|
||||||
|
|
||||||
actions.put(businessTransactionActionEnd.getEventNumber(), businessTransactionActionEnd);
|
actions.put(businessTransactionActionEnd.getEventNumber(), businessTransactionActionEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (businessTransactionoutput != null) {
|
if (businessTransactionoutput != null) {
|
||||||
businessTransactionoutput.setEventNumber(ii++);
|
businessTransactionoutput.setEventNumber(ii++);
|
||||||
actions.put(businessTransactionoutput.getEventNumber(), businessTransactionoutput);
|
actions.put(businessTransactionoutput.getEventNumber(), businessTransactionoutput);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
List<Long> keys = new ArrayList<>(actions.keySet());
|
List<Long> keys = new ArrayList<>(actions.keySet());
|
||||||
Collections.sort(keys);
|
Collections.sort(keys);
|
||||||
List<BusinessTransactionAction> sortedList = new LinkedList<>();
|
List<BusinessTransactionAction> sortedList = new LinkedList<>();
|
||||||
|
|
|
||||||
|
|
@ -13,12 +13,14 @@ public class DroolsRouter extends RouteBuilder {
|
||||||
private String projectName;
|
private String projectName;
|
||||||
private Class<?> clazzUser;
|
private Class<?> clazzUser;
|
||||||
private String processID;
|
private String processID;
|
||||||
|
private boolean disableRuleLogging;
|
||||||
|
|
||||||
public DroolsRouter(CamelContext camelContext, Class<?> clazzUser, String projectName, String processID) {
|
public DroolsRouter(CamelContext camelContext, Class<?> clazzUser, String projectName, String processID, boolean disableRuleLogging) {
|
||||||
super(camelContext);
|
super(camelContext);
|
||||||
this.clazzUser = clazzUser;
|
this.clazzUser = clazzUser;
|
||||||
this.projectName = projectName;
|
this.projectName = projectName;
|
||||||
this.processID = processID;
|
this.processID = processID;
|
||||||
|
this.disableRuleLogging = disableRuleLogging;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -33,6 +35,6 @@ public class DroolsRouter extends RouteBuilder {
|
||||||
.param().name("body").type(body).description("The Data drools should work on").endParam()
|
.param().name("body").type(body).description("The Data drools should work on").endParam()
|
||||||
.responseMessage().code(200).message("Data drools worked on").endResponseMessage()
|
.responseMessage().code(200).message("Data drools worked on").endResponseMessage()
|
||||||
|
|
||||||
.to("bean:ruleService?method=runSessionObject(${header.transactionId}," + this.projectName + "," + this.processID + ",${body})");
|
.to("bean:ruleService?method=runSessionObject(${header.transactionId}," + this.projectName + "," + this.processID + ",${body},"+disableRuleLogging+")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ import org.chtijbug.drools.proxy.persistence.model.ContainerRuntimePojoPersist;
|
||||||
import org.chtijbug.drools.proxy.persistence.model.RuntimePersist;
|
import org.chtijbug.drools.proxy.persistence.model.RuntimePersist;
|
||||||
import org.chtijbug.drools.proxy.persistence.repository.ContainerRepository;
|
import org.chtijbug.drools.proxy.persistence.repository.ContainerRepository;
|
||||||
import org.chtijbug.drools.proxy.persistence.repository.ContainerRuntimeRepository;
|
import org.chtijbug.drools.proxy.persistence.repository.ContainerRuntimeRepository;
|
||||||
|
import org.chtijbug.drools.proxy.persistence.repository.ProjectRepository;
|
||||||
import org.chtijbug.drools.proxy.persistence.repository.RuntimeRepository;
|
import org.chtijbug.drools.proxy.persistence.repository.RuntimeRepository;
|
||||||
import org.chtijbug.kieserver.services.drools.DroolsChtijbugKieServerExtension;
|
import org.chtijbug.kieserver.services.drools.DroolsChtijbugKieServerExtension;
|
||||||
import org.chtijbug.kieserver.services.drools.DroolsChtijbugRulesExecutionService;
|
import org.chtijbug.kieserver.services.drools.DroolsChtijbugRulesExecutionService;
|
||||||
|
|
@ -72,6 +73,8 @@ public class KieServiceCommon {
|
||||||
private RuntimeRepository runtimeRepository;
|
private RuntimeRepository runtimeRepository;
|
||||||
@Inject
|
@Inject
|
||||||
private ContainerRuntimeRepository containerRuntimeRepository;
|
private ContainerRuntimeRepository containerRuntimeRepository;
|
||||||
|
@Inject
|
||||||
|
private ProjectRepository projectRepository;
|
||||||
|
|
||||||
@Value("${server.port}")
|
@Value("${server.port}")
|
||||||
private int serverPort;
|
private int serverPort;
|
||||||
|
|
@ -185,6 +188,7 @@ public class KieServiceCommon {
|
||||||
containerRuntimePojoPersist.setServerName(serverName);
|
containerRuntimePojoPersist.setServerName(serverName);
|
||||||
containerRuntimePojoPersist.setHostname(hostName);
|
containerRuntimePojoPersist.setHostname(hostName);
|
||||||
containerRuntimePojoPersist.setStatus(ContainerRuntimePojoPersist.STATUS.UP.name());
|
containerRuntimePojoPersist.setStatus(ContainerRuntimePojoPersist.STATUS.UP.name());
|
||||||
|
containerRuntimePojoPersist.setProjectUUID(container.getProjectUUID());
|
||||||
containerRuntimeRepository.save(containerRuntimePojoPersist);
|
containerRuntimeRepository.save(containerRuntimePojoPersist);
|
||||||
this.createContainer(kieContainerResource.getContainerId(), kieContainerResource);
|
this.createContainer(kieContainerResource.getContainerId(), kieContainerResource);
|
||||||
this.initCamelBusinessRoute(container);
|
this.initCamelBusinessRoute(container);
|
||||||
|
|
@ -260,7 +264,7 @@ public class KieServiceCommon {
|
||||||
String projectName = container.getContainerId();
|
String projectName = container.getContainerId();
|
||||||
String processId = container.getProcessID();
|
String processId = container.getProcessID();
|
||||||
this.deleteCamelBusinessRoute(projectName);
|
this.deleteCamelBusinessRoute(projectName);
|
||||||
DroolsRouter droolsRouter = new DroolsRouter(camelContext, theClass, projectName, processId);
|
DroolsRouter droolsRouter = new DroolsRouter(camelContext, theClass, projectName, processId,container.isDisableRuleLogging());
|
||||||
camelContext.addRoutes(droolsRouter);
|
camelContext.addRoutes(droolsRouter);
|
||||||
routes.put(containerId, droolsRouter);
|
routes.put(containerId, droolsRouter);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,12 +27,13 @@ public class RuleService {
|
||||||
logger.info("Rule Service created");
|
logger.info("Rule Service created");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object runSessionObject(String transactionID, String id, String processID, Object input) {
|
public Object runSessionObject(String transactionID, String id, String processID, Object input, boolean disableRuleLogging) {
|
||||||
|
|
||||||
ChtijbugObjectRequest chtijbugObjectRequest = new ChtijbugObjectRequest();
|
ChtijbugObjectRequest chtijbugObjectRequest = new ChtijbugObjectRequest();
|
||||||
chtijbugObjectRequest.setTransactionID(transactionID);
|
chtijbugObjectRequest.setTransactionID(transactionID);
|
||||||
chtijbugObjectRequest.setProcessID(processID);
|
chtijbugObjectRequest.setProcessID(processID);
|
||||||
chtijbugObjectRequest.setContainerID(id);
|
chtijbugObjectRequest.setContainerID(id);
|
||||||
|
chtijbugObjectRequest.setDisableLogging(disableRuleLogging);
|
||||||
chtijbugObjectRequest.setTransactionStartTimeStamp(LocalDateTime.now());
|
chtijbugObjectRequest.setTransactionStartTimeStamp(LocalDateTime.now());
|
||||||
KieContainerInstance kci = kieServiceCommon.getRegistry().getContainer(id);
|
KieContainerInstance kci = kieServiceCommon.getRegistry().getContainer(id);
|
||||||
chtijbugObjectRequest.setArtifactID(kci.getKieContainer().getReleaseId().getArtifactId());
|
chtijbugObjectRequest.setArtifactID(kci.getKieContainer().getReleaseId().getArtifactId());
|
||||||
|
|
|
||||||
|
|
@ -4,15 +4,19 @@ import org.springframework.data.annotation.Id;
|
||||||
import org.springframework.data.mongodb.core.index.Indexed;
|
import org.springframework.data.mongodb.core.index.Indexed;
|
||||||
import org.springframework.data.mongodb.core.mapping.Document;
|
import org.springframework.data.mongodb.core.mapping.Document;
|
||||||
|
|
||||||
|
import java.security.PrivateKey;
|
||||||
|
|
||||||
@Document
|
@Document
|
||||||
public class ContainerPojoPersist {
|
public class ContainerPojoPersist {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
|
private boolean disableRuleLogging;
|
||||||
|
|
||||||
@Indexed
|
@Indexed
|
||||||
private String className;
|
private String className;
|
||||||
|
|
||||||
@Indexed
|
@Indexed
|
||||||
private String containerId;
|
private String containerId;
|
||||||
@Indexed
|
@Indexed
|
||||||
|
|
@ -22,14 +26,13 @@ public class ContainerPojoPersist {
|
||||||
|
|
||||||
private String projectName;
|
private String projectName;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private String groupId;
|
private String groupId;
|
||||||
|
|
||||||
private String artifactId;
|
private String artifactId;
|
||||||
|
|
||||||
private String version;
|
private String version;
|
||||||
|
|
||||||
|
private String projectUUID;
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return id;
|
return id;
|
||||||
|
|
@ -79,7 +82,21 @@ public class ContainerPojoPersist {
|
||||||
this.processID = processID;
|
this.processID = processID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getProjectUUID() {
|
||||||
|
return projectUUID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProjectUUID(String projectUUID) {
|
||||||
|
this.projectUUID = projectUUID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDisableRuleLogging() {
|
||||||
|
return disableRuleLogging;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDisableRuleLogging(boolean disableRuleLogging) {
|
||||||
|
this.disableRuleLogging = disableRuleLogging;
|
||||||
|
}
|
||||||
|
|
||||||
public String getGroupId() {
|
public String getGroupId() {
|
||||||
return groupId;
|
return groupId;
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,9 @@ public class ContainerRuntimePojoPersist {
|
||||||
|
|
||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
|
private String projectUUID;
|
||||||
|
|
||||||
|
private boolean disableRuleLogging;
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return id;
|
return id;
|
||||||
|
|
@ -33,6 +36,21 @@ public class ContainerRuntimePojoPersist {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getProjectUUID() {
|
||||||
|
return projectUUID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProjectUUID(String projectUUID) {
|
||||||
|
this.projectUUID = projectUUID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDisableRuleLogging() {
|
||||||
|
return disableRuleLogging;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDisableRuleLogging(boolean disableRuleLogging) {
|
||||||
|
this.disableRuleLogging = disableRuleLogging;
|
||||||
|
}
|
||||||
|
|
||||||
public String getContainerId() {
|
public String getContainerId() {
|
||||||
return containerId;
|
return containerId;
|
||||||
|
|
|
||||||
|
|
@ -18,11 +18,11 @@ import java.util.List;
|
||||||
})
|
})
|
||||||
public class ProjectPersist implements Serializable {
|
public class ProjectPersist implements Serializable {
|
||||||
|
|
||||||
public static final String ADEFINIR="A définir";
|
public static final String ADEFINIR = "A définir";
|
||||||
|
|
||||||
public static final String DEFINI="Défini";
|
public static final String DEFINI = "Défini";
|
||||||
|
|
||||||
public static final String Deployable="Déployable";
|
public static final String Deployable = "Déployable";
|
||||||
|
|
||||||
@Indexed
|
@Indexed
|
||||||
private String deploymentName;
|
private String deploymentName;
|
||||||
|
|
@ -51,13 +51,22 @@ public class ProjectPersist implements Serializable {
|
||||||
|
|
||||||
private String branch;
|
private String branch;
|
||||||
|
|
||||||
private List<String> serverNames= new ArrayList<>();
|
private List<String> serverNames = new ArrayList<>();
|
||||||
|
|
||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
private List<String> classNameList;
|
private List<String> classNameList;
|
||||||
|
|
||||||
public ProjectPersist(){}
|
private boolean disableRuleLogging;
|
||||||
|
|
||||||
|
private boolean enableHotDeploy;
|
||||||
|
|
||||||
|
private boolean useJWTToConnect;
|
||||||
|
|
||||||
|
private String jwtAPIToken;
|
||||||
|
|
||||||
|
public ProjectPersist() {
|
||||||
|
}
|
||||||
|
|
||||||
public ProjectPersist(String deploymentName, KieProject projectName, String mainClass, String groupID, String artifactID, String processID, String projectVersion, String containerID, List<String> serverNames, String status) {
|
public ProjectPersist(String deploymentName, KieProject projectName, String mainClass, String groupID, String artifactID, String processID, String projectVersion, String containerID, List<String> serverNames, String status) {
|
||||||
this.deploymentName = deploymentName;
|
this.deploymentName = deploymentName;
|
||||||
|
|
@ -72,6 +81,10 @@ public class ProjectPersist implements Serializable {
|
||||||
this.status = status;
|
this.status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getUuid() {
|
||||||
|
return uuid;
|
||||||
|
}
|
||||||
|
|
||||||
public String getDeploymentName() {
|
public String getDeploymentName() {
|
||||||
return deploymentName;
|
return deploymentName;
|
||||||
}
|
}
|
||||||
|
|
@ -180,22 +193,60 @@ public class ProjectPersist implements Serializable {
|
||||||
this.serverNames = serverNames;
|
this.serverNames = serverNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getWorkspaceName(){
|
public String getWorkspaceName() {
|
||||||
if (this.projectName!= null){
|
if (this.projectName != null) {
|
||||||
return projectName.getSpaceName();
|
return projectName.getSpaceName();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
public String getKieProjectName(){
|
|
||||||
if (this.projectName!= null){
|
public boolean isUseJWTToConnect() {
|
||||||
return projectName.getName()+"-"+this.branch;
|
return useJWTToConnect;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUseJWTToConnect(boolean useJWTToConnect) {
|
||||||
|
this.useJWTToConnect = useJWTToConnect;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getKieProjectName() {
|
||||||
|
if (this.projectName != null) {
|
||||||
|
return projectName.getName() + "-" + this.branch;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
public ProjectPersist duplicate(){
|
|
||||||
|
public boolean isDisableRuleLogging() {
|
||||||
|
return disableRuleLogging;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDisableRuleLogging(boolean disableRuleLogging) {
|
||||||
|
this.disableRuleLogging = disableRuleLogging;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEnableHotDeploy() {
|
||||||
|
return enableHotDeploy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnableHotDeploy(boolean enableHotDeploy) {
|
||||||
|
this.enableHotDeploy = enableHotDeploy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getJwtAPIToken() {
|
||||||
|
return jwtAPIToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setJwtAPIToken(String jwtAPIToken) {
|
||||||
|
this.jwtAPIToken = jwtAPIToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProjectPersist duplicate() {
|
||||||
ArrayList<String> listServerNames = new ArrayList<String>();
|
ArrayList<String> listServerNames = new ArrayList<String>();
|
||||||
listServerNames.addAll(serverNames);
|
listServerNames.addAll(serverNames);
|
||||||
ProjectPersist duplicate = new ProjectPersist(deploymentName,projectName,mainClass,groupID,artifactID,processID,projectVersion,containerID,listServerNames,status);
|
ProjectPersist duplicate = new ProjectPersist(deploymentName, projectName, mainClass, groupID, artifactID, processID, projectVersion, containerID, listServerNames, status);
|
||||||
|
duplicate.setEnableHotDeploy(enableHotDeploy);
|
||||||
|
duplicate.setJwtAPIToken(jwtAPIToken);
|
||||||
|
duplicate.setDisableRuleLogging(disableRuleLogging);
|
||||||
|
duplicate.setUseJWTToConnect(useJWTToConnect);
|
||||||
return duplicate;
|
return duplicate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ public interface ContainerRepository extends MongoRepository<ContainerPojoPersis
|
||||||
|
|
||||||
List<ContainerPojoPersist> findByServerName(String serverName);
|
List<ContainerPojoPersist> findByServerName(String serverName);
|
||||||
|
|
||||||
|
List<ContainerPojoPersist> findByProjectUUID(String projectUUID);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,9 @@ public interface ContainerRuntimeRepository extends MongoRepository<ContainerRun
|
||||||
List<ContainerRuntimePojoPersist> findByServerNameAndStatus(String serverName, String status);
|
List<ContainerRuntimePojoPersist> findByServerNameAndStatus(String serverName, String status);
|
||||||
List<ContainerRuntimePojoPersist> findByServerNameAndStatusAndHostname(String serverName, String status,String hostname);
|
List<ContainerRuntimePojoPersist> findByServerNameAndStatusAndHostname(String serverName, String status,String hostname);
|
||||||
List<ContainerRuntimePojoPersist> findByServerNameAndHostname(String serverName, String hostname);
|
List<ContainerRuntimePojoPersist> findByServerNameAndHostname(String serverName, String hostname);
|
||||||
|
List<ContainerRuntimePojoPersist> findByProjectUUID(String projectUUID);
|
||||||
|
List<ContainerRuntimePojoPersist> findByContainerId(String continuerID);
|
||||||
|
|
||||||
ContainerRuntimePojoPersist findByServerNameAndContainerIdAndHostname(String serverName, String containerId,String hostname);
|
ContainerRuntimePojoPersist findByServerNameAndContainerIdAndHostname(String serverName, String containerId,String hostname);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ public interface ProjectRepository extends MongoRepository<ProjectPersist, Strin
|
||||||
public List<ProjectPersist> findByProjectName(KieProject projectName);
|
public List<ProjectPersist> findByProjectName(KieProject projectName);
|
||||||
public ProjectPersist findByProjectNameAndBranch(KieProject projectName,String branch);
|
public ProjectPersist findByProjectNameAndBranch(KieProject projectName,String branch);
|
||||||
public ProjectPersist findByDeploymentName(String deploymentName);
|
public ProjectPersist findByDeploymentName(String deploymentName);
|
||||||
|
public ProjectPersist findByUuid(String UUID);
|
||||||
public List<ProjectPersist> findByServerNamesIn(List<String> serverNames);
|
public List<ProjectPersist> findByServerNamesIn(List<String> serverNames);
|
||||||
public List<ProjectPersist> findByServerNamesInAndDeploymentName(List<String> serverNames,String deploymentName);
|
public List<ProjectPersist> findByServerNamesInAndDeploymentName(List<String> serverNames,String deploymentName);
|
||||||
public List<ProjectPersist> findByKieWorkbench(KieWorkbench kieWorkbench);
|
public List<ProjectPersist> findByKieWorkbench(KieWorkbench kieWorkbench);
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,17 @@
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.jsonwebtoken</groupId>
|
||||||
|
<artifactId>jjwt</artifactId>
|
||||||
|
<version>0.9.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.jsonwebtoken</groupId>
|
||||||
|
<artifactId>jjwt</artifactId>
|
||||||
|
<version>0.9.1</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<!-- Spring-Boot and Camel BOM -->
|
<!-- Spring-Boot and Camel BOM -->
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ public class CustomForwardedRequestInterceptor implements ForwardedRequestInterc
|
||||||
private static final Logger logger = LoggerFactory.getLogger(CustomForwardedRequestInterceptor.class);
|
private static final Logger logger = LoggerFactory.getLogger(CustomForwardedRequestInterceptor.class);
|
||||||
@Override
|
@Override
|
||||||
public void intercept(RequestData data, MappingProperties mapping) {
|
public void intercept(RequestData data, MappingProperties mapping) {
|
||||||
logger.debug(data.toString());
|
logger.debug("data forwarded = {}",data);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -5,38 +5,63 @@ import com.github.mkopylec.charon.configuration.MappingProperties;
|
||||||
import com.github.mkopylec.charon.core.http.HttpClientProvider;
|
import com.github.mkopylec.charon.core.http.HttpClientProvider;
|
||||||
import com.github.mkopylec.charon.core.mappings.MappingsCorrector;
|
import com.github.mkopylec.charon.core.mappings.MappingsCorrector;
|
||||||
import com.github.mkopylec.charon.core.mappings.MappingsProvider;
|
import com.github.mkopylec.charon.core.mappings.MappingsProvider;
|
||||||
|
import io.jsonwebtoken.Claims;
|
||||||
|
import org.chtijbug.drools.common.rest.Constants;
|
||||||
|
import org.chtijbug.drools.reverseproxy.service.JwtService;
|
||||||
import org.chtijbug.drools.reverseproxy.service.UpdateService;
|
import org.chtijbug.drools.reverseproxy.service.UpdateService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.autoconfigure.web.ServerProperties;
|
import org.springframework.boot.autoconfigure.web.ServerProperties;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class CustomMappingsProvider extends MappingsProvider {
|
public class CustomMappingsProvider extends MappingsProvider {
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private UpdateService updateService;
|
private UpdateService updateService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private JwtService jwtService;
|
||||||
|
|
||||||
private Map<String,MappingProperties> mappingPropertiesMap = new HashMap<>();
|
private Map<String,MappingProperties> mappingPropertiesMap = new HashMap<>();
|
||||||
|
|
||||||
|
private Map<String, MappingProperties> mappingJWTPropertiesMap = new HashMap<>();
|
||||||
|
|
||||||
public CustomMappingsProvider(ServerProperties server, CharonProperties charon, MappingsCorrector mappingsCorrector, HttpClientProvider httpClientProvider) {
|
public CustomMappingsProvider(ServerProperties server, CharonProperties charon, MappingsCorrector mappingsCorrector, HttpClientProvider httpClientProvider) {
|
||||||
super(server, charon, mappingsCorrector,httpClientProvider);
|
super(server, charon, mappingsCorrector,httpClientProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MappingProperties resolveMapping(String originUri, HttpServletRequest request) {
|
public MappingProperties resolveMapping(String originUri, HttpServletRequest request) {
|
||||||
|
String token = request.getHeader(Constants.AUTHORISATION_HEADER);
|
||||||
|
if (token!= null && token.length()>0){
|
||||||
|
Claims claims = jwtService.decodeJWT(token);
|
||||||
|
String uuid = (String)claims.get("uuid");
|
||||||
|
Date expiration = claims.getExpiration();
|
||||||
|
long nowMillis = System.currentTimeMillis()-1000*3600*24*(long)6;
|
||||||
|
Date now = new Date(nowMillis);
|
||||||
|
if (!expiration.before(now)) {
|
||||||
|
MappingProperties result = mappingJWTPropertiesMap.get(uuid);
|
||||||
|
if (result != null) {
|
||||||
|
return result;
|
||||||
|
} else {
|
||||||
|
return super.resolveMapping(originUri, request);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
return super.resolveMapping(originUri, request);
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
|
||||||
MappingProperties result = mappingPropertiesMap.get(UpdateService.removeSlach(originUri));
|
MappingProperties result = mappingPropertiesMap.get(UpdateService.removeSlach(originUri));
|
||||||
if (result!= null){
|
if (result != null) {
|
||||||
return result;
|
return result;
|
||||||
}else {
|
} else {
|
||||||
return super.resolveMapping(originUri, request);
|
return super.resolveMapping(originUri, request);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean shouldUpdateMappings(HttpServletRequest httpServletRequest) {
|
protected boolean shouldUpdateMappings(HttpServletRequest httpServletRequest) {
|
||||||
|
|
@ -45,10 +70,17 @@ public class CustomMappingsProvider extends MappingsProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<MappingProperties> retrieveMappings() {
|
protected List<MappingProperties> retrieveMappings() {
|
||||||
return updateService.retrievePath();
|
List<MappingProperties> paths= new ArrayList<>();
|
||||||
|
paths.addAll(mappingPropertiesMap.values());
|
||||||
|
paths.addAll(mappingJWTPropertiesMap.values());
|
||||||
|
return paths;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMappingPropertiesMap(Map<String, MappingProperties> mappingPropertiesMap) {
|
public void setMappingPropertiesMap(Map<String, MappingProperties> mappingPropertiesMap) {
|
||||||
this.mappingPropertiesMap = mappingPropertiesMap;
|
this.mappingPropertiesMap = mappingPropertiesMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setMappingJWTPropertiesMap(Map<String, MappingProperties> mappingJWTPropertiesMap) {
|
||||||
|
this.mappingJWTPropertiesMap = mappingJWTPropertiesMap;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,6 @@ public class CustomReceivedResponseInterceptor implements ReceivedResponseInterc
|
||||||
private static final Logger logger = LoggerFactory.getLogger(CustomReceivedResponseInterceptor.class);
|
private static final Logger logger = LoggerFactory.getLogger(CustomReceivedResponseInterceptor.class);
|
||||||
@Override
|
@Override
|
||||||
public void intercept(ResponseData responseData, MappingProperties mappingProperties) {
|
public void intercept(ResponseData responseData, MappingProperties mappingProperties) {
|
||||||
logger.debug(responseData.toString());
|
logger.debug("data received = {}",responseData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
package org.chtijbug.drools.reverseproxy.service;
|
||||||
|
|
||||||
|
import io.jsonwebtoken.Claims;
|
||||||
|
import io.jsonwebtoken.Jwts;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.xml.bind.DatatypeConverter;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class JwtService {
|
||||||
|
|
||||||
|
@Value("${secretkey}")
|
||||||
|
public String secretKey;
|
||||||
|
|
||||||
|
public Claims decodeJWT(String jwt) {
|
||||||
|
return Jwts.parser()
|
||||||
|
.setSigningKey(DatatypeConverter.parseBase64Binary(secretKey))
|
||||||
|
.parseClaimsJws(jwt.replace("bearer","")).getBody();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -31,10 +31,10 @@ public class UpdateService {
|
||||||
|
|
||||||
private Boolean toUpdate = true;
|
private Boolean toUpdate = true;
|
||||||
|
|
||||||
private List<MappingProperties> mappings = new ArrayList<>();
|
|
||||||
|
|
||||||
private Map<String, MappingProperties> mappingPropertiesMap = new HashMap<>();
|
private Map<String, MappingProperties> mappingPropertiesMap = new HashMap<>();
|
||||||
|
private Map<String, MappingProperties> mappingJWTPropertiesMap = new HashMap<>();
|
||||||
@Autowired
|
@Autowired
|
||||||
private CustomMappingsProvider customMappingsProvider;
|
private CustomMappingsProvider customMappingsProvider;
|
||||||
|
|
||||||
|
|
@ -48,61 +48,78 @@ public class UpdateService {
|
||||||
containerFactory = "mappingKafkaListenerContainerFactory")
|
containerFactory = "mappingKafkaListenerContainerFactory")
|
||||||
public void store(ReverseProxyUpdate update) {
|
public void store(ReverseProxyUpdate update) {
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
for (MappingProperties mappingProperties : mappingPropertiesMap.values()) {
|
MappingProperties mappingProperties = null;
|
||||||
if (UpdateService.removeSlach(mappingProperties.getPath()).equals(UpdateService.removeSlach(update.getPath()))) {
|
if (update.getTokenUUID() != null && update.getTokenUUID().length() > 0) {
|
||||||
|
mappingProperties = mappingJWTPropertiesMap.get(update.getTokenUUID());
|
||||||
|
if (mappingProperties != null) {
|
||||||
found = true;
|
found = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
mappingProperties = mappingPropertiesMap.get(UpdateService.removeSlach(update.getPath()));
|
||||||
|
if (mappingProperties != null) {
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (found) {
|
||||||
mappingProperties.getDestinations().clear();
|
mappingProperties.getDestinations().clear();
|
||||||
logger.info("Updating path {}",update.getPath());
|
logger.info("Updating path {}", update.getPath());
|
||||||
for (String destination : update.getServerNames()) {
|
for (String destination : update.getServerNames()) {
|
||||||
mappingProperties.getDestinations().add(destination);
|
mappingProperties.getDestinations().add(destination);
|
||||||
logger.info("for path {} adding server {} ",update.getPath(),destination);
|
logger.info("for path {} adding server {} ", update.getPath(), destination);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!found) {
|
|
||||||
MappingProperties newMappingProperties = new MappingProperties();
|
MappingProperties newMappingProperties = new MappingProperties();
|
||||||
|
|
||||||
|
if (update.getTokenUUID() != null && update.getTokenUUID().length() > 0) {
|
||||||
|
mappingJWTPropertiesMap.put(update.getTokenUUID(), newMappingProperties);
|
||||||
|
} else {
|
||||||
newMappingProperties.setPath(UpdateService.removeSlach(update.getPath()));
|
newMappingProperties.setPath(UpdateService.removeSlach(update.getPath()));
|
||||||
logger.info("Creating path {}",update.getPath());
|
logger.info("Creating path {}", update.getPath());
|
||||||
for (String destination : update.getServerNames()) {
|
|
||||||
newMappingProperties.getDestinations().add(destination);
|
|
||||||
logger.info("for path {} adding server {} ",update.getPath(),destination);
|
|
||||||
}
|
|
||||||
mappingPropertiesMap.put(UpdateService.removeSlach(update.getPath()), newMappingProperties);
|
mappingPropertiesMap.put(UpdateService.removeSlach(update.getPath()), newMappingProperties);
|
||||||
}
|
}
|
||||||
mappings.clear();
|
newMappingProperties.setName(update.getContainerID());
|
||||||
mappings.addAll(mappingPropertiesMap.values());
|
|
||||||
|
newMappingProperties.getCustomConfiguration().put("connect", 2000);
|
||||||
|
newMappingProperties.getCustomConfiguration().put("read", 2000);
|
||||||
|
newMappingProperties.setStripPath(true);
|
||||||
|
for (String destination : update.getServerNames()) {
|
||||||
|
newMappingProperties.getDestinations().add(destination);
|
||||||
|
logger.info("for path {} adding server {} ", update.getPath(), destination);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.toUpdate = true;
|
this.toUpdate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<MappingProperties> retrievePath() {
|
|
||||||
this.toUpdate = false;
|
|
||||||
return mappings;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String removeSlach(String target){
|
|
||||||
if (target!= null) {
|
public static String removeSlach(String target) {
|
||||||
return target.replace("/", "").replace(" ","");
|
if (target != null) {
|
||||||
|
return target.replace("/", "").replace(" ", "");
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void generateUrlMap(){
|
||||||
|
Map<String, String> urlMap = new HashMap<>();
|
||||||
|
List<RuntimePersist> runtimePersists = runtimeRepository.findAll();
|
||||||
|
for (RuntimePersist runtimePersist : runtimePersists) {
|
||||||
|
if (!urlMap.containsKey(runtimePersist.getServerName()) ) {
|
||||||
|
urlMap.put(runtimePersist.getServerName(), runtimePersist.getServerUrl());
|
||||||
|
runtimes.put(runtimePersist.getServerName(), runtimePersist.duplicate());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private void generateMappings() {
|
private void generateMappings() {
|
||||||
projects.clear();
|
projects.clear();
|
||||||
mappingPropertiesMap.clear();
|
mappingPropertiesMap.clear();
|
||||||
List<MappingProperties> paths = new ArrayList<>();
|
List<MappingProperties> paths = new ArrayList<>();
|
||||||
Collection<ProjectPersist> projectPersists = projectRepository.findAll();
|
Collection<ProjectPersist> projectPersists = projectRepository.findAll();
|
||||||
Map<String, String> urlMap = new HashMap<>();
|
generateUrlMap();
|
||||||
List<RuntimePersist> runtimePersists = runtimeRepository.findAll();
|
|
||||||
for (RuntimePersist runtimePersist : runtimePersists) {
|
|
||||||
if (urlMap.containsKey(runtimePersist.getServerName()) == false) {
|
|
||||||
urlMap.put(runtimePersist.getServerName(), runtimePersist.getServerUrl());
|
|
||||||
runtimes.put(runtimePersist.getServerName(), runtimePersist.duplicate());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (ProjectPersist projectPersist : projectPersists) {
|
for (ProjectPersist projectPersist : projectPersists) {
|
||||||
if (projectPersist.getServerNames().size() > 0) {
|
if (!projectPersist.getServerNames().isEmpty()) {
|
||||||
projects.put(projectPersist.getContainerID(), projectPersist.duplicate());
|
projects.put(projectPersist.getContainerID(), projectPersist.duplicate());
|
||||||
MappingProperties mappingProperties2 = new MappingProperties();
|
MappingProperties mappingProperties2 = new MappingProperties();
|
||||||
String servList = null;
|
String servList = null;
|
||||||
|
|
@ -114,7 +131,9 @@ public class UpdateService {
|
||||||
if (servList == null) {
|
if (servList == null) {
|
||||||
servList = serverName;
|
servList = serverName;
|
||||||
} else {
|
} else {
|
||||||
servList = servList + ":" + serverName;
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
stringBuilder.append(servList).append(":").append(serverName);
|
||||||
|
servList = stringBuilder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -124,26 +143,35 @@ public class UpdateService {
|
||||||
mappingProperties2.getCustomConfiguration().put("connect", 2000);
|
mappingProperties2.getCustomConfiguration().put("connect", 2000);
|
||||||
mappingProperties2.getCustomConfiguration().put("read", 2000);
|
mappingProperties2.getCustomConfiguration().put("read", 2000);
|
||||||
mappingProperties2.setStripPath(true);
|
mappingProperties2.setStripPath(true);
|
||||||
if (mappingProperties2.getDestinations().size() > 0) {
|
if (!mappingProperties2.getDestinations().isEmpty()) {
|
||||||
mappingPropertiesMap.put(UpdateService.removeSlach(mappingProperties2.getPath()), mappingProperties2);
|
if (projectPersist.isUseJWTToConnect()) {
|
||||||
|
mappingJWTPropertiesMap.put(projectPersist.getUuid(), mappingProperties2);
|
||||||
paths.add(mappingProperties2);
|
paths.add(mappingProperties2);
|
||||||
logger.info("Startup creating path {}",mappingProperties2.getPath());
|
logger.info("Startup creating path / and for token uuid {}", projectPersist.getUuid());
|
||||||
for (String serverName : mappingProperties2.getDestinations()){
|
for (String serverName : mappingProperties2.getDestinations()) {
|
||||||
logger.info("---------for path {} adding server {} ",mappingProperties2.getPath(),serverName);
|
logger.info("---------for uuid {} adding server {} ", projectPersist.getUuid(), serverName);
|
||||||
}
|
}
|
||||||
logger.info("---------Project " + projectPersist.getContainerID() + " defined on servers - " + mappingProperties2.getDestinations().toString());
|
logger.info("---------Project {}} defined on servers -{} " ,projectPersist.getContainerID(), mappingProperties2.getDestinations());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
logger.error("Project " + projectPersist.getContainerID() + " defined on non existing server");
|
mappingPropertiesMap.put(UpdateService.removeSlach(mappingProperties2.getPath()), mappingProperties2);
|
||||||
|
paths.add(mappingProperties2);
|
||||||
|
logger.info("Startup creating path {}", mappingProperties2.getPath());
|
||||||
|
for (String serverName : mappingProperties2.getDestinations()) {
|
||||||
|
logger.info("---------for path {} adding server {} ", mappingProperties2.getPath(), serverName);
|
||||||
|
}
|
||||||
|
logger.info("---------Project {} defined on servers - {}" ,projectPersist.getContainerID(),mappingProperties2.getDestinations());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.error("Project {} defined on non existing server",projectPersist.getContainerID());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
mappings.clear();
|
|
||||||
mappings.addAll(paths);
|
|
||||||
this.customMappingsProvider.setMappingPropertiesMap(mappingPropertiesMap);
|
this.customMappingsProvider.setMappingPropertiesMap(mappingPropertiesMap);
|
||||||
|
this.customMappingsProvider.setMappingJWTPropertiesMap(mappingJWTPropertiesMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
|
|
|
||||||
|
|
@ -12,3 +12,4 @@ pymma.kafka.sslKeyPassword=${PYMMA_KAFKA_KEY_PASSWORD:}
|
||||||
pymma.kafka.sslKeystorePassword=${PYMMA_KAFKA_SSL_KEYSTORE_PASSWORD:}
|
pymma.kafka.sslKeystorePassword=${PYMMA_KAFKA_SSL_KEYSTORE_PASSWORD:}
|
||||||
pymma.kafka.sslKeystoreLocation=${PYMMA_KAFKA_SSL_KEYSTORE_LOCATION:}
|
pymma.kafka.sslKeystoreLocation=${PYMMA_KAFKA_SSL_KEYSTORE_LOCATION:}
|
||||||
pymma.kafka.sslKeystoreType=${PYMMA_KAFKA_SSL_KEYSTORE_TYPE:}
|
pymma.kafka.sslKeystoreType=${PYMMA_KAFKA_SSL_KEYSTORE_TYPE:}
|
||||||
|
secretkey=eRaYY7Wo24sDqKSX3IM9ASGmdGPmkTd9jo1QTy4b7P9Ze5_9hKolVX8xNrQDcNRfVEdTZNOuOyqEGhXEbdJI-ZQ19k_o9MI0y3eZN2lp9jow55FfXMiINEdt1XR85VipRLSOkT6kSpzs2x-jbLDiz9iFVzkd81YKxMgPA7VfZeQUm4n-mOmnWMaVX30zGFU4L3oPBctYKkl4dYfqYWqRNfrgPJVi5DGFjywgxx0ASEiJHtV72paI3fDR2XwlSkyhhmY-ICjCRmsJN4fX1pdoL8a18-aQrvyu4j0Os6dVPYIoPvvY0SAZtWYKHfM15g7A3HD4cVREf9cUsprCRK93w
|
||||||
|
|
|
||||||
Loading…
Add table
editor.link_modal.header
Reference in a new issue