Skip to content

Commit

Permalink
Migrated to crypto 1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
oharsta committed Nov 29, 2023
1 parent 0d90cd8 commit 433f52a
Show file tree
Hide file tree
Showing 18 changed files with 21 additions and 10 deletions.
2 changes: 1 addition & 1 deletion manage-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
<dependency>
<groupId>org.openconext</groupId>
<artifactId>java-crypto</artifactId>
<version>1.0.1</version>
<version>1.0.2</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import static java.util.stream.Collectors.toMap;

@Component
@SuppressWarnings("unchecked")
public class MetaDataAutoConfiguration {

private static final Logger LOG = LoggerFactory.getLogger(MetaDataAutoConfiguration.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@

@Component
@RestController
@SuppressWarnings("unchecked")
public class DatabaseController {

private final RestTemplate restTemplate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import java.util.TreeMap;

@SuppressWarnings("unchecked")
public class SanitizedTreeMap<K, V> extends TreeMap<K, V> {

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package manage.hook;

import crypto.KeyStore;
import crypto.RSAKeyStore;
import lombok.SneakyThrows;
import manage.conf.MetaDataAutoConfiguration;
import manage.repository.MetaDataRepository;
Expand Down Expand Up @@ -34,8 +35,8 @@ CompositeMetaDataHook hooks(MetaDataRepository metaDataRepository,
SSIDValidationHook ssidValidationHook = new SSIDValidationHook(metaDataRepository, metaDataAutoConfiguration);
RequiredAttributesHook requiredAttributesHook = new RequiredAttributesHook(metaDataAutoConfiguration);
ProvisioningHook provisioningHook = new ProvisioningHook(metaDataRepository, metaDataAutoConfiguration);
KeyStore keyStore = developmentMode ? new KeyStore() :
new KeyStore(IOUtils.toString(publicKeyResource.getInputStream(), Charset.defaultCharset()), true);
KeyStore keyStore = developmentMode ? new RSAKeyStore() :
new RSAKeyStore(IOUtils.toString(publicKeyResource.getInputStream(), Charset.defaultCharset()), true);
EncryptionHook encryptionHook = new EncryptionHook(keyStore);

return new CompositeMetaDataHook(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.util.regex.Pattern;
import java.util.stream.Collectors;

@SuppressWarnings("unchecked")
public class TypeSafetyHook extends MetaDataHookAdapter {

private final MetaDataAutoConfiguration metaDataAutoConfiguration;
Expand Down
1 change: 1 addition & 0 deletions manage-server/src/main/java/manage/model/MetaData.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(of = "id")
@SuppressWarnings("unchecked")
public class MetaData implements Serializable {

@Id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ private void addUIInfoExtension(Map data) {
private String addLanguageFallbackValue(Map metaDataFields, String attribute) {
AtomicReference<String> reference = new AtomicReference<>();
languages.forEach(lang -> {
if (StringUtils.isEmpty(reference.get())) {
if (!StringUtils.hasText(reference.get())) {
reference.set((String) metaDataFields.get(attribute + ":" + lang));
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import static manage.mongo.MongoChangelog.CHANGE_REQUEST_POSTFIX;

@Service
@SuppressWarnings("unchecked")
public class MetaDataService {

private static final Logger LOG = LoggerFactory.getLogger(MetaDataService.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ protected Object getPreAuthenticatedPrincipal(final HttpServletRequest request)
String displayName = getHeader(DISPLAY_NAME_HEADER_NAME, request);
String schacHomeOrganization = getHeader(SCHAC_HOME_HEADER, request);

if (StringUtils.isEmpty(uid) || StringUtils.isEmpty(displayName)) {
if (!StringUtils.hasText(uid) || !StringUtils.hasText(displayName)) {
//this is the contract. See AbstractPreAuthenticatedProcessingFilter#doAuthenticate
LOG.error("Missing required attribute(s): uid {} displayName {}", uid, displayName);
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class URIFormatValidator implements FormatValidator {

@Override
public Optional<String> validate(String subject) {
if (StringUtils.isEmpty(subject)) {
if (!StringUtils.hasText(subject)) {
return Optional.empty();
}
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class URLFormatValidator implements FormatValidator {

@Override
public Optional<String> validate(String subject) {
if (StringUtils.isEmpty(subject)) {
if (!StringUtils.hasText(subject)) {
return Optional.empty();
}
return pattern.matcher(subject).matches() ? Optional.empty() :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.boot.test.web.server.LocalServerPort;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.test.context.TestPropertySource;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public void update() {
.get("manage/api/client/scopes/3")
.as(Scope.class);
assertEquals("changed", scope.getName());
assertEquals(new Long(1), scope.getVersion());
assertEquals(Long.valueOf(1), scope.getVersion());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertEquals;

@SuppressWarnings("unchecked")
public class ValidationControllerTest extends AbstractIntegrationTest {

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package manage.hook;

import crypto.KeyStore;
import crypto.RSAKeyStore;
import manage.model.EntityType;
import manage.model.MetaData;
import org.junit.jupiter.api.Test;
Expand All @@ -20,7 +21,7 @@ class EncryptionHookTest {

{
try {
keyStore = new KeyStore();
keyStore = new RSAKeyStore();
encryptionHook = new EncryptionHook(keyStore);
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

@SuppressWarnings("unchecked")
public class SSIDValidationHookTest extends AbstractIntegrationTest {

private SSIDValidationHook subject;
Expand Down
1 change: 1 addition & 0 deletions manage-server/src/test/java/manage/model/MetaDataTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import static org.junit.Assert.*;

@SuppressWarnings("unchecked")
public class MetaDataTest implements TestUtils {

private MetaData subject;
Expand Down

0 comments on commit 433f52a

Please sign in to comment.