Skip to content

Commit

Permalink
Merge pull request #1456 from GRIDAPPSD/releases/2020.12.0
Browse files Browse the repository at this point in the history
Release of version 2020.12.0
  • Loading branch information
poorva1209 authored Feb 22, 2021
2 parents a5db0bc + 0688c5f commit fe1ce8e
Show file tree
Hide file tree
Showing 24 changed files with 239 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void sendLogMessage() throws JMSException{
LogLevel log_level = LogLevel.DEBUG;
ProcessStatus process_status = ProcessStatus.RUNNING;
Boolean storeToDB = true;
LogMessage logMessage = new LogMessage(source, requestId,timestamp, log_message, log_level, process_status, storeToDB);
LogMessage logMessage = new LogMessage(source, requestId,timestamp, log_message, log_level, process_status, storeToDB, null);

String id = client.getResponse(logMessage, destination, null).toString();

Expand Down
3 changes: 2 additions & 1 deletion gov.pnnl.goss.gridappsd/bnd.bnd
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
httpclient,\
com.bigdata.rdf,\
proven-client;version=0.3,\
proven-message;version=0.4
proven-message;version=0.4,\
com.nimbusds.nimbus-jose-jwt-dependencies

-plugin org.apache.felix.dm.annotation.plugin.bnd.AnnotationPlugin;log=debug

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
admin=queue:*,topic:*,temp-queue:*,fusion:*:read,fusion:*:write
operator=queue:*,topic:*,temp-queue:*,fusion:*:read,fusion:*:write
evaluator=queue:*,topic:*,temp-queue:*,fusion:*:read,fusion:*:write
testmanager=queue:*,topic:*,temp-queue:*,fusion:*:read,fusion:*:write
application=queue:*,topic:*,temp-queue:*,fusion:*:read,fusion:*:write
service=queue:*,topic:*,temp-queue:*,fusion:*:read,fusion:*:write

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
load=true
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
load=true
18 changes: 18 additions & 0 deletions gov.pnnl.goss.gridappsd/conf/pnnl.goss.core.security.userfile.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
system=manager,admin,operator,evaluator,testmanager,application,service
operator1=operator,operator
operator2=operator,operator
operator3=operator,operator
evaluator1=evaluator,evaluator
evaluator2=evaluator,evaluator
testmanager1=testmanager,testmanager
testmanager2=testmanager,testmanager
application1=application,application
application2=application,application
service1=service,service
service2=service,service






This file was deleted.

11 changes: 9 additions & 2 deletions gov.pnnl.goss.gridappsd/run.bnd.bndrun
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
pnnl.goss.core.goss-core-server-api;version=latest,\
pnnl.goss.core.goss-core-server-registry;version=latest,\
pnnl.goss.core.security-propertyfile;version=latest,\
pnnl.goss.core.security-system;version=latest,\
pnnl.goss.core.security-jwt;version=latest,\
org.apache.felix.http.jetty;version='[2.2.2,2.3)',\
gov.pnnl.goss.gridappsd.gridappsd.api;version=latest,\
gov.pnnl.goss.gridappsd.gridappsd;version=latest,\
Expand All @@ -76,7 +78,6 @@
xml-apis,\
blazegraph.cim2glm;version=19.1.1,\
org.eclipse.jetty.aggregate.jetty-all-server;version=7.6.9,\
javax.servlet-api,\
com.bigdata.rdf,\
proven-message;version=0.4,\
proven-client;version=0.3,\
Expand All @@ -100,7 +101,13 @@
org.glassfish.jersey.core.jersey-server;version=2.26.0,\
org.glassfish.jersey.inject.jersey-hk2,\
org.glassfish.hk2.locator;version=2.5.0,\
javassist
javassist,\
com.nimbusds.nimbus-jose-jwt-dependencies,\
bouncycastle-jce-jdk13,\
org.apache.felix.http.servlet-api,\
com.fasterxml.jackson.jaxrs.jackson-jaxrs-base,\
javax.ws.rs.jsr311-api,\
javax.ws.rs-api



Expand Down
3 changes: 2 additions & 1 deletion gov.pnnl.goss.gridappsd/runproperties.config
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ activemq.props = \
activemq.start.broker=true,\
openwire.port=61616,\
stomp.port=61613,\
ws.port=61614
ws.port=61614,\
advisorySupport=false

#activemq.broker.file=

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,6 @@ public interface LogManager {

LogLevel getLogLevel();

public void setProcessType(String processId, String process_type);

}
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public void process(String processId, DataResponse event, Serializable message)
if (client == null) {
Credentials credentials = new UsernamePasswordCredentials(
securityConfig.getManagerUser(), securityConfig.getManagerPassword());
client = clientFactory.create(PROTOCOL.STOMP, credentials);
client = clientFactory.create(PROTOCOL.STOMP, credentials, true);
}
Destination replyDestination = event.getReplyDestination();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public void start(){
try {
Credentials credentials = new UsernamePasswordCredentials(
securityConfig.getManagerUser(), securityConfig.getManagerPassword());
client = clientFactory.create(PROTOCOL.STOMP,credentials);
client = clientFactory.create(PROTOCOL.STOMP,credentials,true);
connection = dataSources.getDataSourceByKey("gridappsd").getConnection();

} catch (SQLException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ private void subscribeAndStoreDataFromTopic(String topic, String appOrServiceid,

Credentials credentials = new UsernamePasswordCredentials(
securityConfig.getManagerUser(), securityConfig.getManagerPassword());
Client inputClient = clientFactory.create(PROTOCOL.STOMP,credentials);
Client inputClient = clientFactory.create(PROTOCOL.STOMP,credentials,true);
inputClient.subscribe(topic, new GossResponseEvent() {
@Override
public void onMessage(Serializable message) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,15 @@ public enum ProcessStatus {

public LogMessage(){}

public LogMessage(String source, String requestId, long timestamp, String logMessage, LogLevel logLevel, ProcessStatus processStatus, Boolean storeToDb){
public LogMessage(String source, String requestId, long timestamp, String logMessage, LogLevel logLevel, ProcessStatus processStatus, Boolean storeToDb, String process_type){
this.source = source;
this.processId = requestId;
this.timestamp = timestamp;
this.logLevel = logLevel;
this.logMessage = logMessage;
this.processStatus = processStatus;
this.storeToDb = storeToDb;
this.process_type = process_type;
}

public String getSource() {
Expand Down
133 changes: 133 additions & 0 deletions gov.pnnl.goss.gridappsd/src/gov/pnnl/goss/gridappsd/dto/UserToken.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
/*******************************************************************************
* Copyright (c) 2017, Battelle Memorial Institute All rights reserved.
* Battelle Memorial Institute (hereinafter Battelle) hereby grants permission to any person or entity
* lawfully obtaining a copy of this software and associated documentation files (hereinafter the
* Software) to redistribute and use the Software in source and binary forms, with or without modification.
* Such person or entity may use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and may permit others to do so, subject to the following conditions:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimers.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
* Other than as used herein, neither the name Battelle Memorial Institute or Battelle may be used in any
* form whatsoever without the express written consent of Battelle.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* BATTELLE OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
* General disclaimer for use with OSS licenses
*
* This material was prepared as an account of work sponsored by an agency of the United States Government.
* Neither the United States Government nor the United States Department of Energy, nor Battelle, nor any
* of their employees, nor any jurisdiction or organization that has cooperated in the development of these
* materials, makes any warranty, express or implied, or assumes any legal liability or responsibility for
* the accuracy, completeness, or usefulness or any information, apparatus, product, software, or process
* disclosed, or represents that its use would not infringe privately owned rights.
*
* Reference herein to any specific commercial product, process, or service by trade name, trademark, manufacturer,
* or otherwise does not necessarily constitute or imply its endorsement, recommendation, or favoring by the United
* States Government or any agency thereof, or Battelle Memorial Institute. The views and opinions of authors expressed
* herein do not necessarily state or reflect those of the United States Government or any agency thereof.
*
* PACIFIC NORTHWEST NATIONAL LABORATORY operated by BATTELLE for the
* UNITED STATES DEPARTMENT OF ENERGY under Contract DE-AC05-76RL01830
******************************************************************************/
package gov.pnnl.goss.gridappsd.dto;


import java.io.Serializable;
import java.util.List;

import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;

public class UserToken implements Serializable {
/**
*
*/
private static final long serialVersionUID = -6949464126224009033L;

String sub;
long nbf;
List<String> roles;
String iss;
long exp;
long iat;
String jti;

public String getSub() {
return sub;
}

public void setSub(String sub) {
this.sub = sub;
}

public long getNbf() {
return nbf;
}

public void setNbf(long nbf) {
this.nbf = nbf;
}

public List<String> getRoles() {
return roles;
}

public void setRoles(List<String> roles) {
this.roles = roles;
}

public String getIss() {
return iss;
}

public void setIss(String iss) {
this.iss = iss;
}

public long getExp() {
return exp;
}

public void setExp(long exp) {
this.exp = exp;
}

public long getIat() {
return iat;
}

public void setIat(long iat) {
this.iat = iat;
}

public String getJti() {
return jti;
}

public void setJti(String jti) {
this.jti = jti;
}

@Override
public String toString() {
Gson gson = new Gson();
return gson.toJson(this);
}

public static UserToken parse(String jsonString){
Gson gson = new Gson();
UserToken obj = gson.fromJson(jsonString, UserToken.class);
if(obj.sub==null)
throw new JsonSyntaxException("Expected attribute sub not found");
return obj;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public void start() {
try {
Credentials credentials = new UsernamePasswordCredentials(
securityConfig.getManagerUser(), securityConfig.getManagerPassword());
client = clientFactory.create(PROTOCOL.STOMP, credentials);
client = clientFactory.create(PROTOCOL.STOMP, credentials, true);



Expand Down Expand Up @@ -157,7 +157,6 @@ private void logToConsole(LogMessage message, String username, String topic) {
ProcessStatus processStatus = message.getProcessStatus();
Boolean storeToDb = message.getStoreToDb();
String process_type = message.getProcess_type();

String logString;
if(requestId!=null)
logString = String.format("%s|%s|%s|%s|%s|%s\n%s\n", timestamp, source, requestId,
Expand Down Expand Up @@ -193,47 +192,53 @@ private void logToConsole(LogMessage message, String username, String topic) {

public void trace(ProcessStatus processStatus, String processId, String message) {
String source = Thread.currentThread().getStackTrace()[2].getClassName();
this.log(processStatus, processId, message, LogLevel.TRACE, source);
this.log(processStatus, processId, message, LogLevel.TRACE, source, null);
}

public void debug(ProcessStatus processStatus, String processId, String message) {
String source = Thread.currentThread().getStackTrace()[2].getClassName();
this.log(processStatus, processId, message, LogLevel.DEBUG, source);
this.log(processStatus, processId, message, LogLevel.DEBUG, source, null);
}

public void info(ProcessStatus processStatus, String processId, String message) {
String source = Thread.currentThread().getStackTrace()[2].getClassName();
this.log(processStatus, processId, message, LogLevel.INFO, source);
this.log(processStatus, processId, message, LogLevel.INFO, source, null);
}

public void warn(ProcessStatus processStatus, String processId, String message) {
String source = Thread.currentThread().getStackTrace()[2].getClassName();
this.log(processStatus, processId, message, LogLevel.WARN, source);
this.log(processStatus, processId, message, LogLevel.WARN, source, null);
}

public void error(ProcessStatus processStatus, String processId, String message) {
String source = Thread.currentThread().getStackTrace()[2].getClassName();
this.log(processStatus, processId, message, LogLevel.ERROR, source);
this.log(processStatus, processId, message, LogLevel.ERROR, source, null);
}

public void fatal(ProcessStatus processStatus, String processId, String message) {
String source = Thread.currentThread().getStackTrace()[2].getClassName();
this.log(processStatus, processId, message, LogLevel.FATAL, source);
this.log(processStatus, processId, message, LogLevel.FATAL, source, null);
}

public void setProcessType(String processId, String process_type) {
String source = Thread.currentThread().getStackTrace()[2].getClassName();
this.log(ProcessStatus.RUNNING, processId, "New process id generated with new process type", LogLevel.INFO, source, process_type);
}

public void logMessageFromSource(ProcessStatus processStatus, String processId, String message, String source, LogLevel logLevel) {
this.log(processStatus, processId, message, logLevel, source);
this.log(processStatus, processId, message, logLevel, source, null);
}

public void log(ProcessStatus processStatus, String processId, String message, LogLevel logLevel, String source) {
private void log(ProcessStatus processStatus, String processId, String message, LogLevel logLevel, String source, String process_type) {
LogMessage logMessage = new LogMessage(
source,
processId,
new Date().getTime(),
message,
logLevel,
processStatus,
true);
true,
process_type);
String topic = "/topic/"+GridAppsDConstants.topic_platformLog;
if(processId!=null) {
topic = GridAppsDConstants.topic_simulationLog + processId;
Expand Down
Loading

0 comments on commit fe1ce8e

Please sign in to comment.