Skip to content

Commit

Permalink
Merge pull request #6248 from ORCID/migrationJava11_new
Browse files Browse the repository at this point in the history
Migration java11 new
  • Loading branch information
amontenegro authored Jun 8, 2021
2 parents f6de658 + d6c6d15 commit 997d5fa
Show file tree
Hide file tree
Showing 109 changed files with 998 additions and 302 deletions.
12 changes: 7 additions & 5 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@ on:
jobs:
build-and-test:

runs-on: ubuntu-18.04
runs-on: ubuntu-20.04

steps:
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
- name: Set up Open JDK 11
uses: actions/setup-java@v2
with:
java-version: 1.8
distribution: 'adopt'
java-version: '11'
check-latest: true
- name: Cache Maven packages
uses: actions/cache@v2
with:
Expand Down
19 changes: 18 additions & 1 deletion orcid-activemq/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<groupId>org.orcid</groupId>
<artifactId>orcid-parent</artifactId>
<relativePath>../pom.xml</relativePath>
<version>release-1.289.0</version>
<version>release-2.0.0</version>
</parent>

<properties>
Expand Down Expand Up @@ -38,6 +38,23 @@
<version>5.13.3</version>
</dependency>

<!-- javax.xml -->
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>2.3.3</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.3.3</version>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
</dependency>

<!-- Test dependencies -->
<dependency>
<groupId>org.orcid</groupId>
Expand Down
8 changes: 4 additions & 4 deletions orcid-api-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<groupId>org.orcid</groupId>
<artifactId>orcid-parent</artifactId>
<relativePath>../pom.xml</relativePath>
<version>release-1.289.0</version>
<version>release-2.0.0</version>
</parent>

<properties>
Expand Down Expand Up @@ -92,9 +92,9 @@
<artifactId>validation-api</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
</dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-agroal</artifactId>
</dependency>
<dependency>
<groupId>org.apache.jena</groupId>
<artifactId>jena-arq</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void handle(HttpServletRequest request, HttpServletResponse response, Acc
public void handleAsOrcidError(HttpServletRequest request, HttpServletResponse response, Exception authException) throws IOException, ServletException {
try {
ResponseEntity<OAuth2Exception> result = exceptionTranslator.translate(authException);
result = enhanceResponse(result, authException);
result = (ResponseEntity<OAuth2Exception>) enhanceResponse(result, authException);
OrcidError orcidError = new OrcidError();
orcidError.setResponseCode(result.getStatusCode().value());
orcidError.setDeveloperMessage(result.getBody().getLocalizedMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public Authentication attemptAuthentication(HttpServletRequest request, HttpServ
}

clientId = clientId.trim();
UsernamePasswordAuthenticationToken authRequest = new UsernamePasswordAuthenticationToken(clientId, clientSecret);
UsernamePasswordAuthenticationToken authRequest = new UsernamePasswordAuthenticationToken(clientId, "{noop}"+clientSecret);

authentication = this.getAuthenticationManager().authenticate(authRequest);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public Authentication attemptAuthentication(HttpServletRequest request, HttpServ
}

clientId = clientId.trim();
UsernamePasswordAuthenticationToken authRequest = new UsernamePasswordAuthenticationToken(clientId, clientSecret);
UsernamePasswordAuthenticationToken authRequest = new UsernamePasswordAuthenticationToken(clientId, "{noop}"+clientSecret);

Authentication authenticationResult = this.getAuthenticationManager().authenticate(authRequest);
if (authenticationResult != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ public Authentication attemptAuthentication(HttpServletRequest request, HttpServ
}

clientId = clientId.trim();
UsernamePasswordAuthenticationToken authRequest = new UsernamePasswordAuthenticationToken(clientId, clientSecret);

return this.getAuthenticationManager().authenticate(authRequest);
UsernamePasswordAuthenticationToken authRequest = new UsernamePasswordAuthenticationToken(clientId, "{noop}"+clientSecret);
authentication = this.getAuthenticationManager().authenticate(authRequest);
return authentication;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha
clientSecret = "";
}

UsernamePasswordAuthenticationToken authRequest = new UsernamePasswordAuthenticationToken(clientId, clientSecret);
UsernamePasswordAuthenticationToken authRequest = new UsernamePasswordAuthenticationToken(clientId, "{noop}"+clientSecret);

try {
Authentication auth = clientAuthenticationProvider.authenticate(authRequest);
Expand Down
2 changes: 1 addition & 1 deletion orcid-api-web/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>org.orcid</groupId>
<artifactId>orcid-parent</artifactId>
<version>release-1.289.0</version>
<version>release-2.0.0</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xmlns:sec="http://www.springframework.org/schema/security"
xmlns:oauth2="http://www.springframework.org/schema/security/oauth2"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-4.2.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-5.3.xsd
http://www.springframework.org/schema/security/oauth2 http://www.springframework.org/schema/security/spring-security-oauth2-2.0.xsd">

<import resource="classpath*:orcid-oauth2-common-config.xml"/>
Expand Down
5 changes: 1 addition & 4 deletions orcid-api-web/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>

<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>


<!-- Tell Spring where to find the context file -->
<context-param>
Expand Down
11 changes: 9 additions & 2 deletions orcid-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.orcid</groupId>
<artifactId>orcid-parent</artifactId>
<version>release-1.289.0</version>
<version>release-2.0.0</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down Expand Up @@ -176,6 +176,7 @@
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.sf.opencsv</groupId>
Expand Down Expand Up @@ -296,8 +297,14 @@
<artifactId>commons-net</artifactId>
<version>3.6</version>
</dependency>

<dependency>
<groupId>javax.jms</groupId>
<artifactId>javax.jms-api</artifactId>
<version>2.0.1</version>
</dependency>


<!-- Test dependencies -->

</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Required;
import org.springframework.security.authentication.encoding.PasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;

public class EncryptionManagerImpl implements EncryptionManager, PasswordEncoder, InitializingBean {
public class EncryptionManagerImpl implements EncryptionManager,PasswordEncoder, InitializingBean {

private String passPhraseForInternalEncryption;

Expand Down Expand Up @@ -166,8 +166,8 @@ public String decryptForLegacyExternalUse(String stringToDecrypt) {
* @return encoded password
*/
@Override
public String encodePassword(String rawPass, Object salt) {
return hashForInternalUse(rawPass);
public String encode(CharSequence rawPass) {
return hashForInternalUse(rawPass.toString());
}

/**
Expand Down Expand Up @@ -195,7 +195,6 @@ public String encodePassword(String rawPass, Object salt) {
* password before encoding. A <code>null</code> value is legal.
* @return true if the password is valid , false otherwise
*/
@Override
public boolean isPasswordValid(String encPass, String rawPass, Object salt) {
LOGGER.debug("About to start password check");
StopWatch stopWatch = new StopWatch();
Expand Down Expand Up @@ -224,5 +223,16 @@ public String getEmailHash(String email) {
} catch(NoSuchAlgorithmException nsae) {
throw new RuntimeException(nsae);
}
}
}

@Override
public boolean matches(CharSequence rawPass, String encPass) {
LOGGER.debug("About to start password check");
StopWatch stopWatch = new StopWatch();
stopWatch.start();
boolean result = hashMatches(rawPass.toString(), encPass);
stopWatch.stop();
LOGGER.debug("Password check took {} ms", stopWatch.getTime());
return result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.crypto.password.NoOpPasswordEncoder;

/**
*
Expand All @@ -35,9 +36,13 @@ protected void additionalAuthenticationChecks(UserDetails userDetails, UsernameP
}

String presentedPassword = authentication.getCredentials().toString();

ClientDetailsEntity clientDetailsEntity = clientDetailsManager.findByClientId(userDetails.getUsername());
for (ClientSecretEntity clientSecretEntity : clientDetailsEntity.getClientSecrets()) {
if (getPasswordEncoder().isPasswordValid(encryptionManager.decryptForInternalUse(clientSecretEntity.getClientSecret()), presentedPassword, null)) {
if(!presentedPassword.startsWith("{noop}")){
presentedPassword = "{noop}" + presentedPassword;
}
if (getPasswordEncoder().matches(encryptionManager.decryptForInternalUse(clientSecretEntity.getClientSecret()), presentedPassword)) {
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.io.OutputStream;

import javax.servlet.ServletOutputStream;
import javax.servlet.WriteListener;

/**
* Extends ServletOutputStream for JsonpCallbackFilter
Expand Down Expand Up @@ -32,4 +33,16 @@ public void write(byte[] b, int off, int len) throws IOException {
stream.write(b, off, len);
}

//TODO:Cami Do we need to overwrite those 2 methods and change the OutputStream to ServletOutputStream ?
@Override
public boolean isReady() {
//do nothing
return true;
}

@Override
public void setWriteListener(WriteListener writeListener) {
//do nothing
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ public void tryToCreateRefreshTokenWithInvalidParentTokenValueTest() {
String tokenValue = "parent-token-" + time;
String refreshTokenValue = "refresh-token-" + time;
Boolean revokeOld = true;
Date parentTokenExpiration = new Date(time + 10000);
Date parentTokenExpiration = new Date(time + 15000);
Long expireIn = null;

OrcidOauth2TokenDetail parent = createToken(CLIENT_ID_1, USER_ORCID, tokenValue, refreshTokenValue, parentTokenExpiration, parentScope);
Expand Down
2 changes: 1 addition & 1 deletion orcid-integration-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>org.orcid</groupId>
<artifactId>orcid-parent</artifactId>
<version>release-1.289.0</version>
<version>release-2.0.0</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion orcid-internal-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<groupId>org.orcid</groupId>
<artifactId>orcid-parent</artifactId>
<relativePath>../pom.xml</relativePath>
<version>release-1.289.0</version>
<version>release-2.0.0</version>
</parent>

<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xmlns:sec="http://www.springframework.org/schema/security"
xmlns:oauth2="http://www.springframework.org/schema/security/oauth2"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-4.2.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-5.3.xsd
http://www.springframework.org/schema/security/oauth2 http://www.springframework.org/schema/security/spring-security-oauth2-2.0.xsd">

<sec:http pattern="/resources/**" security="none"/>
Expand Down
4 changes: 0 additions & 4 deletions orcid-internal-api/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>

<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>

<!-- Tell Spring where to find the context file -->
<context-param>
<param-name>contextConfigLocation</param-name>
Expand Down
Loading

0 comments on commit 997d5fa

Please sign in to comment.