env container
parent
30bb161948
commit
ff3db5669a
|
|
@ -17,7 +17,23 @@
|
|||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.7.8</version>
|
||||
</parent>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>local</id>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
<properties>
|
||||
<spring.profiles.active>local</spring.profiles.active>
|
||||
</properties>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>container</id>
|
||||
<properties>
|
||||
<spring.profiles.active>container</spring.profiles.active>
|
||||
</properties>
|
||||
</profile>
|
||||
</profiles>
|
||||
<properties>
|
||||
<java.version>11</java.version>
|
||||
</properties>
|
||||
|
|
@ -173,5 +189,6 @@
|
|||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -8,11 +8,16 @@ import org.springframework.boot.builder.SpringApplicationBuilder;
|
|||
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.session.MapSessionRepository;
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
@SpringBootApplication
|
||||
public class ApiApplication extends SpringBootServletInitializer {
|
||||
|
||||
// @org.springframework.beans.factory.annotation.Value("${greeting.message}")
|
||||
// private String greetingMessage;
|
||||
|
||||
public static void main(String[] args) {
|
||||
//System.out.println(greetingMessage);
|
||||
SpringApplication.run(ApiApplication.class, args);
|
||||
}
|
||||
|
||||
|
|
@ -36,4 +41,16 @@ public class ApiApplication extends SpringBootServletInitializer {
|
|||
public MapSessionRepository sessionRepository() {
|
||||
return new MapSessionRepository(new ConcurrentHashMap<>());
|
||||
}
|
||||
|
||||
// @Bean
|
||||
// public String greetingMessage() {
|
||||
// return greetingMessage;
|
||||
// }
|
||||
|
||||
// @PostConstruct
|
||||
// public void printEnvValues(){
|
||||
// System.out.println("Print environment values");
|
||||
// System.out.println("$$$$$$$"+greetingMessage);
|
||||
|
||||
// }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,56 @@
|
|||
package com.nttdata.calender;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
||||
/**
|
||||
* Java API for Remedy
|
||||
*/
|
||||
@Service
|
||||
public class ApplicationConfig {
|
||||
|
||||
@Value("${rssoActive}")
|
||||
private Boolean rssoActive;
|
||||
|
||||
public Boolean getRssoActive() {
|
||||
if(rssoActive==null)
|
||||
return true;
|
||||
|
||||
return rssoActive;
|
||||
}
|
||||
|
||||
@Value("${arserver}")
|
||||
private String arserver;
|
||||
|
||||
public String getArserver() {
|
||||
return arserver;
|
||||
}
|
||||
|
||||
@Value("${arport}")
|
||||
private Integer arport;
|
||||
|
||||
public Integer getArport() {
|
||||
return arport;
|
||||
}
|
||||
|
||||
@Value("${aruser}")
|
||||
private String aruser;
|
||||
|
||||
public String getAruser() {
|
||||
return aruser;
|
||||
}
|
||||
|
||||
@Value("${arpassword}")
|
||||
private String arpassword;
|
||||
|
||||
public String getArpassword() {
|
||||
return arpassword;
|
||||
}
|
||||
}
|
||||
|
|
@ -24,6 +24,9 @@ import com.nttdata.calender.errorhandling.ErrorTypes.NotFoundError;
|
|||
import com.nttdata.calender.states.State;
|
||||
import com.nttdata.calender.supportgroup.SupportGroup;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import com.nttdata.calender.ApplicationConfig;
|
||||
|
||||
/**
|
||||
* Java API for Remedy
|
||||
*/
|
||||
|
|
@ -35,17 +38,24 @@ public class RemedyJavaAPI {
|
|||
private static Logger applicationLogger = LogManager.getLogger("application");
|
||||
// TODO: work with form CTM:Support Group
|
||||
private static final String QUALSTR = "\'Request ID\' != \"\"";
|
||||
private ApplicationConfig appConfig;
|
||||
|
||||
// @org.springframework.beans.factory.annotation.Value("${greeting.message}")
|
||||
// private String greetingMessage;
|
||||
|
||||
/**
|
||||
* Sets up the Remedy API with the server and admin user/password.
|
||||
*/
|
||||
public RemedyJavaAPI() throws ARException, NotFoundError {
|
||||
|
||||
public RemedyJavaAPI(ApplicationConfig appConfig) throws ARException, NotFoundError {
|
||||
this.appConfig=appConfig;
|
||||
System.out.println(appConfig.getRssoActive());
|
||||
server = new ARServerUser();
|
||||
// server.setServer("itsm-app-dev.asfinag.at");
|
||||
server.setServer("itsm-app-dev-neu.asfinag.at");
|
||||
server.setUser("changecalender_integration");
|
||||
server.setPassword("VXrvLm4q#8P#MXthfZNc");
|
||||
server.setPort(46262);
|
||||
server.setServer(this.appConfig.getArserver());
|
||||
server.setUser(this.appConfig.getAruser());
|
||||
server.setPassword(this.appConfig.getArpassword());
|
||||
server.setPort(this.appConfig.getArport());
|
||||
// server.setPort(50000);
|
||||
this.connect();
|
||||
|
||||
|
|
@ -75,6 +85,10 @@ public class RemedyJavaAPI {
|
|||
* @throws ARException when the user is unknown
|
||||
*/
|
||||
public void impersonateUser(String userName) throws ARException {
|
||||
|
||||
if(!this.appConfig.rssoActive)
|
||||
server.impersonateUser("WuiQualityKV");
|
||||
|
||||
server.impersonateUser(userName);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.nttdata.calender.api;
|
|||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.method.HandlerMethod;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
|
||||
|
|
@ -27,14 +28,21 @@ import java.util.List;
|
|||
|
||||
@Component
|
||||
public class RequestInterceptor implements HandlerInterceptor {
|
||||
|
||||
|
||||
// @org.springframework.beans.factory.annotation.Value("${greeting.message}")
|
||||
// private String greetingMessage;
|
||||
|
||||
@Autowired
|
||||
private RemedyJavaAPI api;
|
||||
|
||||
private static final String FORM_NAME = "ASF:CHG_CAL_Transactions";
|
||||
private static final Logger logger = LogManager.getLogger("application");
|
||||
private static final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
api = new RemedyJavaAPI();
|
||||
//api = new RemedyJavaAPI(greetingMessage);
|
||||
String currentDateTime = LocalDateTime.now().format(dateTimeFormatter);
|
||||
long transactionId = System.currentTimeMillis();
|
||||
String out = String.format("Transaction ID = %d %s - handling request: %s", transactionId, currentDateTime, request.getRequestURI());
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import org.springframework.web.servlet.HandlerInterceptor;
|
|||
|
||||
import com.bmc.thirdparty.org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.nttdata.calender.ApplicationConfig;
|
||||
/**
|
||||
* Interceptor for handling Rsso related operations.
|
||||
*/
|
||||
|
|
@ -17,10 +18,12 @@ public class RssoInterceptor implements HandlerInterceptor {
|
|||
private final static boolean DEBUG = true;
|
||||
private final Rsso rsso;
|
||||
private static final Logger applicationLogger = LogManager.getLogger("application");
|
||||
private ApplicationConfig appConfig;
|
||||
|
||||
@Autowired
|
||||
public RssoInterceptor(Rsso rsso) {
|
||||
public RssoInterceptor(Rsso rsso, ApplicationConfig appConfig) {
|
||||
this.rsso = rsso;
|
||||
this.appConfig=appConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -39,7 +42,7 @@ public class RssoInterceptor implements HandlerInterceptor {
|
|||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
|
||||
throws Exception {
|
||||
// Check if a session exists, create one if not
|
||||
if (DEBUG) {
|
||||
if (!this.appConfig.getRssoActive()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
rssoActive=true
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
rssoActive=false
|
||||
arserver=itsm-app-dev-neu.asfinag.at
|
||||
# arserver=${test}
|
||||
arport=46262
|
||||
aruser=changecalender_integration
|
||||
arpassword="VXrvLm4q#8P#MXthfZNc"
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
rssoActive=false
|
||||
arserver=slwien4dev
|
||||
arport=2000
|
||||
aruser=Demo
|
||||
arpassword=ars$adm1
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
#server.servlet.context-path=/test
|
||||
server.servlet.session.timeout=24h
|
||||
# server.port=${PROBE_PORT:8080}
|
||||
spring.profiles.active=@spring.profiles.active@
|
||||
|
|
|
|||
Loading…
Reference in New Issue