Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Db migration #49

Merged
merged 6 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,14 @@
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.4.1</version>
<version>42.4.4</version>
</dependency>
<dependency>
<groupId>com.mchange</groupId>
<artifactId>c3p0</artifactId>
<version>0.10.0</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.javers/javers-core -->
<dependency>
<groupId>org.javers</groupId>
Expand Down Expand Up @@ -65,37 +71,37 @@
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>5.3.22</version>
<version>5.3.33</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>5.3.22</version>
<version>5.3.33</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>5.3.22</version>
<version>5.3.33</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>5.3.22</version>
<version>5.3.33</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>5.3.22</version>
<version>5.3.33</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>5.3.22</version>
<version>5.3.33</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>5.3.22</version>
<version>5.3.33</version>
</dependency>

<dependency>
Expand All @@ -122,12 +128,12 @@
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk18on</artifactId>
<version>1.71</version>
<version>1.74</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpkix-jdk18on</artifactId>
<version>1.71</version>
<version>1.74</version>
</dependency>
<dependency>
<groupId>org.apache.velocity</groupId>
Expand All @@ -149,7 +155,7 @@
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.11</version>
<version>1.2.13</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
Expand Down
1 change: 0 additions & 1 deletion spreg-secrets.properties.tmpl
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
spreg.db.username=some_user
spreg.db.password=some_password
spreg.cookieCryptKey=some_cryptkey
11 changes: 8 additions & 3 deletions spreg.properties.eval
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@
# spreg will look for this file first in the spreg directory
# if that is undefined or not found this installed copy will be used
#
spreg.version=2.6.2
spreg.versionDate=2021-02-23
spreg.version=2.6.4
spreg.versionDate=2024-04-10
spreg.root=/data/local/spreg

# database parameters
spreg.db.url=iamdbeval20.s.uw.edu/spregdev
spreg.db.host=35.199.173.195
spreg.db.name=spregistry_eval
spreg.db.username=app_spregistry_eval
spreg.db.sslrootcert=/data/local/spreg/prodDb/iamtools-prod-server-ca.pem
spreg.db.sslcert=/data/local/spreg/prodDb/iamtools-prod-client-cert.pem
spreg.db.sslkey=/data/local/spreg/prodDb/iamtools-prod-client-key.pem.raw

# web service parameters
spreg.gws.baseUrl=https://dev.groups.uw.edu/group_sws/v2
Expand Down
12 changes: 9 additions & 3 deletions spreg.properties.prod
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@
# spreg will look for this file first in the spreg directory
# if that is undefined or not found this installed copy will be used
#
spreg.version=2.6.2
spreg.versionDate=2021-02-23
spreg.version=2.6.4
spreg.versionDate=2024-04-10
spreg.root=/data/local/spreg
spreg.db.url=iamdb21.s.uw.edu/spregistry

# database parameters
spreg.db.host=35.199.173.195
spreg.db.name=spregistry
spreg.db.username=app_spregistry_prod
spreg.db.sslrootcert=/data/local/spreg/prodDb/iamtools-prod-server-ca.pem
spreg.db.sslcert=/data/local/spreg/prodDb/iamtools-prod-client-cert.pem
spreg.db.sslkey=/data/local/spreg/prodDb/iamtools-prod-client-key.pem.raw

# web service parameters
spreg.gws.baseUrl=https://groups.uw.edu/group_sws/v2
Expand Down
11 changes: 6 additions & 5 deletions src/main/java/edu/washington/iam/registry/rp/DBMetadata.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,15 @@ public List<RelyingParty> getRelyingPartyHistoryById(String id) throws RelyingPa
try {
rps = template.query(
"select * from metadata where group_id = ? and entity_id = ?" +
"order by start_time ASC",
" order by start_time ASC",
new Object[]{groupId, id},
new RelyingPartyMapper());
log.info("Got a response in getRelyingPartyHistoryById");
return rps;
}
catch (Exception e){
String errorMsg = String.format("error getting rp: %s, rps size = %s", id, rps.size());
log.debug(errorMsg);
String errorMsg = String.format("error getting rp: %s, rps size = %s", id, (rps == null) ? 0 : rps.size());
log.error(errorMsg, e);
throw new RelyingPartyException(errorMsg);
}

Expand All @@ -79,8 +80,8 @@ public RelyingParty getRelyingPartyById(String id) throws RelyingPartyException
return rps.get(0);
}
else {
String errorMsg = String.format("error getting rp: %s, rps size = %s", id, rps.size());
log.debug(errorMsg);
String errorMsg = String.format("error getting rp: %s, rps size = %s", id, (rps == null) ? 0 : rps.size());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional nit: Extract into a local variable.

It can help to minimize computations done in format statements, so that readers can focus on understanding the format string.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going to ignore this for now. This error message is almost never used; I made the smallest update possible to get it to not NullPointerException.

log.error(errorMsg);
throw new RelyingPartyException(errorMsg);
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/main/webapp/WEB-INF/applicationContext.xml
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@
<property name="dataSource" ref="postgresDataSource" />
</bean>

<bean id="postgresDataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="org.postgresql.Driver"/>
<property name="url" value="jdbc:postgresql://${spreg.db.url}"/>
<property name="username" value="${spreg.db.username}"/>
<bean id="postgresDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="org.postgresql.Driver"/>
<property name="jdbcUrl" value="jdbc:postgresql://${spreg.db.host}/${spreg.db.name}?sslmode=verify-ca&amp;sslrootcert=${spreg.db.sslrootcert}&amp;sslcert=${spreg.db.sslcert}&amp;sslkey=${spreg.db.sslkey}"/>
<property name="user" value="${spreg.db.username}"/>
<property name="password" value="${spreg.db.password}"/>
<property name="testConnectionOnCheckout" value="true"/>
</bean>

</beans>
Loading