Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
criluc committed Apr 29, 2022
2 parents d9ceca1 + 916e689 commit 2a9c3f6
Show file tree
Hide file tree
Showing 146 changed files with 2,335 additions and 1,146 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.5.1] - 2022-04-29
### Added
- Aggiunto controllo su API rest contracts/byPerson per fornire un messaggio di errore
quando si tenta di leggere un contratto con previousContract non coerente
- Aggiunto campo enumerato per la gestione del buono pasto sul modello di absenceType
Risolve anche la problematica del 103RT che non deve permettere l'attribuzione del buono
pasto per coloro i quali fanno telelavoro che finisce sul cartellino come orario di lavoro.
### Changed
- Migliorato messaggio di errore in caso di inserimento via REST di buoni pasto già esistenti
- Fix bug del permesso breve che non veniva eliminato quando si completava la giornata
- Modificata procedura di allineamento dei codici di assenza con gli enumerati per risolvere
il problema CNR/INAF su alcuni codici.
- Reinserito il codice 31_2020 per le esigenze INAF

## [2.5.0] - 2022-04-14
### Added
- Aggiunta possiblità di trattare gli orari in telelavoro inseriti dai livelli I-III
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.5.0
2.5.1
1 change: 1 addition & 0 deletions app/cnr/sync/dto/CompetenceDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class CompetenceDto {

/**
* Applica la conversione da dto a oggetto.
*
* @author dario
*
*/
Expand Down
1 change: 1 addition & 0 deletions app/cnr/sync/dto/PersonDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public class PersonDto {

/**
* Sotto classe definizione dell'indirizzo.
*
* @author dario
*
*/
Expand Down
1 change: 1 addition & 0 deletions app/cnr/sync/dto/SimplePersonDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class SimplePersonDto {

/**
* Applica la conversione da dto a oggetto.
*
* @author dario
*
*/
Expand Down
8 changes: 7 additions & 1 deletion app/cnr/sync/dto/v2/ContractShowDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,16 @@ public class ContractShowDto extends ContractShowTerseDto {
* Nuova instanza di un ContractShowDto contenente i valori
* dell'oggetto contract passato.
*/
public static ContractShowDto build(Contract contract) {
public static ContractShowDto build(Contract contract) throws IllegalStateException {
val contractDto = modelMapper.map(contract, ContractShowDto.class);
contractDto.setPerson(PersonShowTerseDto.build(contract.person));
if (contract.getPreviousContract() != null) {
if (contract.getPreviousContract().id.equals(contract.id)) {
throw new IllegalStateException(
String.format(
"The previous contract is equal to the current contract (id=%s), "
+ "please correct this error", contract.id));
}
contractDto.setPreviousContract(ContractShowTerseDto.build(contract.getPreviousContract()));
}
contractDto.setWorkingTimeTypes(
Expand Down
8 changes: 7 additions & 1 deletion app/cnr/sync/dto/v2/ContractShowTerseDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,16 @@ public class ContractShowTerseDto {
* Nuova instanza di un ContractShowTerseDto contenente i valori
* dell'oggetto contract passato.
*/
public static ContractShowTerseDto build(Contract contract) {
public static ContractShowTerseDto build(Contract contract) throws IllegalStateException {
val contractDto = modelMapper.map(contract, ContractShowTerseDto.class);
contractDto.setPerson(PersonShowTerseDto.build(contract.person));
if (contract.getPreviousContract() != null) {
if (contract.getPreviousContract().id.equals(contract.id)) {
throw new IllegalStateException(
String.format(
"The previous contract is equal to the current contract (id=%s), "
+ "please correct this error", contract.id));
}
contractDto.setPreviousContract(ContractShowTerseDto.build(contract.getPreviousContract()));
}
return contractDto;
Expand Down
3 changes: 2 additions & 1 deletion app/cnr/sync/dto/v3/BadgeReaderShowTerseDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ public class BadgeReaderShowTerseDto extends BadgeReaderShowMinimalDto {
public static BadgeReaderShowTerseDto build(BadgeReader badgeReader) {
val dto = modelMapper.map(badgeReader, BadgeReaderShowTerseDto.class);
dto.setUsername(badgeReader.user.username);
dto.setBadgeSystems(badgeReader.badgeSystems.stream().map(bs -> BadgeSystemShowMinimalDto.build(bs))
dto.setBadgeSystems(badgeReader.badgeSystems.stream()
.map(bs -> BadgeSystemShowMinimalDto.build(bs))
.collect(Collectors.toList()));
return dto;
}
Expand Down
3 changes: 2 additions & 1 deletion app/cnr/sync/dto/v3/BadgeSystemShowTerseDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ public class BadgeSystemShowTerseDto extends BadgeSystemShowMinimalDto {
public static BadgeSystemShowTerseDto build(BadgeSystem badgeSystem) {
val dto = modelMapper.map(badgeSystem, BadgeSystemShowTerseDto.class);
dto.setOffice(OfficeDto.build(badgeSystem.office));
dto.setBadgeReaders(badgeSystem.badgeReaders.stream().map(br -> BadgeReaderShowMinimalDto.buildMinimal(br))
dto.setBadgeReaders(badgeSystem.badgeReaders.stream()
.map(br -> BadgeReaderShowMinimalDto.buildMinimal(br))
.collect(Collectors.toSet()));
return dto;
}
Expand Down
1 change: 1 addition & 0 deletions app/cnr/sync/dto/v3/BlockMealTicketCreateDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package cnr.sync.dto.v3;

import common.injection.StaticInject;
Expand Down
1 change: 1 addition & 0 deletions app/cnr/sync/dto/v3/BlockMealTicketShowTerseDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package cnr.sync.dto.v3;

import cnr.sync.dto.v2.PersonShowTerseDto;
Expand Down
2 changes: 1 addition & 1 deletion app/cnr/sync/dto/v3/CompetenceCodeShowDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static CompetenceCodeShowDto build(CompetenceCode competenceCode) {
val dto = modelMapper.map(competenceCode, CompetenceCodeShowDto.class);
if (competenceCode.competenceCodeGroup != null) {
dto.setCompetenceCodeGroup(
CompetenceCodeGroupShowTerseDto.build(competenceCode.competenceCodeGroup));
CompetenceCodeGroupShowTerseDto.build(competenceCode.competenceCodeGroup));
}
return dto;
}
Expand Down
1 change: 1 addition & 0 deletions app/cnr/sync/dto/v3/MealTicketShowTerseDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package cnr.sync.dto.v3;

import cnr.sync.dto.v2.PersonShowTerseDto;
Expand Down
2 changes: 2 additions & 0 deletions app/cnr/sync/dto/v3/OfficeMonthValidationStatusDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public class OfficeMonthValidationStatusDto {
private List<PersonShowTerseDto> notValidatedPersons = Lists.newArrayList();

/**
* Controlla se tutti gli attestati sono stati validati.
*
* @return true se tutti gli attestati sono stati validati, false altrimenti.
*/
public boolean isAllCertificationsValidated() {
Expand Down
6 changes: 6 additions & 0 deletions app/common/injection/InjectionPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ public void onApplicationStart() {
play.inject.Injector.inject(this);
}

/**
* Classe staticInject estende abstractModule.
*
* @author Marco
*
*/
@AutoRegister
public static class StaticInjectModule extends AbstractModule {

Expand Down
6 changes: 6 additions & 0 deletions app/common/oauth2/AccessInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
import java.time.LocalDateTime;
import lombok.Data;

/**
* classe di informazioni sull'accesso.
*
* @author Cristian
*
*/
@Data
public class AccessInfo {
private final LocalDateTime when;
Expand Down
6 changes: 6 additions & 0 deletions app/common/oauth2/Oauth2Authorization.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
import lombok.extern.slf4j.Slf4j;
import lombok.val;

/**
* classe di autorizzazione oauth2.
*
* @author cristian
*
*/
@Slf4j
@RequiredArgsConstructor
public class Oauth2Authorization implements RequestInterceptor {
Expand Down
72 changes: 64 additions & 8 deletions app/common/oauth2/OpenIdClientsModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@
import play.Play;
import play.mvc.Router;

/**
* Modulo OpenIdClient.
*
* @author Cristian
*
*/
@Slf4j
@AutoRegister
public class OpenIdClientsModule extends AbstractModule {
Expand All @@ -52,9 +58,9 @@ public class OpenIdClientsModule extends AbstractModule {
*/
@Provides
public OpenIdConnectClient openIdConnectClient(@Named(KEYCLOAK_CLIENT_ID) String clientId,
@Named(KEYCLOAK_CLIENT_SECRET) String clientSecret,
@Named(KEYCLOAK_CLIENT_CONFIG_URI) String configUrl,
@Named(KEYCLOAK_JWT_FIELD) Optional<String> jwtField) {
@Named(KEYCLOAK_CLIENT_SECRET) String clientSecret,
@Named(KEYCLOAK_CLIENT_CONFIG_URI) String configUrl,
@Named(KEYCLOAK_JWT_FIELD) Optional<String> jwtField) {
try {
return new OpenIdConnectClient(configUrl,
() -> Router.getFullUrl("Resecure.oauthCallback"),
Expand Down Expand Up @@ -89,6 +95,11 @@ public String keycloakRealm() {
return Play.configuration.getProperty(KEYCLOAK_REALM);
}

/**
* Ritorna l'uri di configurazione del keycloack.
*
* @return l'uri di configurazione del keycloack
*/
@Provides
@Named(KEYCLOAK_CLIENT_CONFIG_URI)
public String keycloakConfigUri() {
Expand All @@ -103,6 +114,12 @@ public Optional<String> keycloakJwtField() {
return Optional.ofNullable(Play.configuration.getProperty(KEYCLOAK_JWT_FIELD));
}

/**
* Costruisce l'oggetto TokenData.
*
* @author Cristian
*
*/
@Data
public static class TokenData {
@JsonProperty("access_token")
Expand All @@ -123,6 +140,12 @@ public static class TokenData {
private String tokenType;
}

/**
* Api auth.
*
* @author Cristian
*
*/
public interface AuthApi {

@RequestLine("POST /protocol/openid-connect/token")
Expand All @@ -133,12 +156,24 @@ TokenData generateToken(@Param("realm") String realm,
@Param("client_secret") String clientSecret);
}

/**
* Costruisce il configData.
*
* @author Cristian
*
*/
@Data
public static class ConfigData {
private final OkHttpClient client;
private final Slf4jLogger logger;
}

/**
* ClientFactory.
*
* @author Cristian
*
*/
@FunctionalInterface
public interface ClientFactory {
ApiClient builder(Function<Exception, ?> fallback);
Expand All @@ -151,6 +186,15 @@ public ConfigData config() {
new Slf4jLogger("keycloak"));
}

/**
* Ritorna l'api di autenticazione.
*
* @param openIdConnectClient il client openidconnect
* @param config la configurazione
* @param encoder l'encoder
* @param decoder il decoder
* @return l'api auth.
*/
@Singleton
@Provides
public AuthApi authApi(OpenIdConnectClient openIdConnectClient,
Expand All @@ -162,6 +206,17 @@ public AuthApi authApi(OpenIdConnectClient openIdConnectClient,
.target(AuthApi.class, openIdConnectClient.getConfig().getIssuer());
}

/**
* Il clientFactory.
*
* @param adminUri l'uri admin del keycloack
* @param realm il realm keycloack
* @param clientId l'id client del keycloack
* @param clientSecret il secret del keycloack
* @param config la configurazione
* @param authApi l'api di autenticazione
* @return il clientFactory.
*/
@Singleton
@Provides
public ClientFactory clientFactory(@Named(KEYCLOAK_ADMIN_URI) String adminUri,
Expand All @@ -171,7 +226,8 @@ public ClientFactory clientFactory(@Named(KEYCLOAK_ADMIN_URI) String adminUri,
ConfigData config,
AuthApi authApi) {

// Attenzione: occorre un feignbuilder separato per evitare interazioni con il request-interceptor
// Attenzione: occorre un feignbuilder separato per evitare interazioni con il
//request-interceptor
return fallback -> {
val api = new ApiClient().setBasePath(adminUri);
val decorator = FeignDecorators.builder()
Expand All @@ -198,8 +254,8 @@ public RealmsAdminApi keycloakAdminApi(ClientFactory factory) {
return factory.builder(RealmsAdminApiFallback::new).buildClient(RealmsAdminApi.class);
}

// @Override
// public void configure() {
// bind(UserManagerEvents.class).asEagerSingleton();
// }
// @Override
// public void configure() {
// bind(UserManagerEvents.class).asEagerSingleton();
// }
}
Loading

0 comments on commit 2a9c3f6

Please sign in to comment.