-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #103 from Luis-Cruz/feature/CgdWebServiceIntegration
Added integration with CGD for production of ULisboa IdCards.
- Loading branch information
Showing
9 changed files
with
194 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...ration/src/main/java/pt/ist/fenixedu/integration/domain/cgd/NumberObfuscationAdaptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package pt.ist.fenixedu.integration.domain.cgd; | ||
|
||
import java.time.Year; | ||
|
||
import org.fenixedu.academic.domain.Person; | ||
import org.fenixedu.bennu.core.domain.User; | ||
|
||
import com.qubit.solution.fenixedu.integration.cgd.webservices.resolver.memberid.IMemberIDAdapter; | ||
|
||
public class NumberObfuscationAdaptor implements IMemberIDAdapter { | ||
|
||
@Override | ||
public String retrieveMemberID(final Person person) { | ||
final User user = person.getUser(); | ||
return CgdCardCounter.getNextSerialNumber(user); | ||
} | ||
|
||
@Override | ||
public Person readPerson(final String memberId) { | ||
final CgdCardCounter counter = CgdCardCounter.findCounterForYear(CgdCard.yearFor(memberId)); | ||
final int serialNumber = CgdCard.serialNumberFor(memberId); | ||
return counter == null ? null : counter.getCgdCardSet().stream().filter(c -> c.getSerialNumber() == serialNumber) | ||
.map(c -> c.getUser().getPerson()).findAny().orElse(null); | ||
} | ||
|
||
@Override | ||
public boolean isAllowedAccessToMember(final Person person) { | ||
final User user = person.getUser(); | ||
if (user != null) { | ||
final int year = Year.now().getValue(); | ||
for (final CgdCard card : user.getCgdCardSet()) { | ||
if (card.getAllowSendDetails() && card.getCgdCardCounter().getYear() == year) { | ||
return true; | ||
} | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
} |
47 changes: 47 additions & 0 deletions
47
.../ist/fenixedu/integration/ui/spring/controller/AuthorizePersonalDataAccessController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** | ||
* Copyright © 2013 Instituto Superior Técnico | ||
* | ||
* This file is part of FenixEdu IST Integration. | ||
* | ||
* FenixEdu IST Integration is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* FenixEdu IST Integration is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with FenixEdu IST Integration. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package pt.ist.fenixedu.integration.ui.spring.controller; | ||
|
||
import org.fenixedu.bennu.spring.portal.SpringApplication; | ||
import org.fenixedu.bennu.spring.portal.SpringFunctionality; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.ui.Model; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
|
||
import pt.ist.fenixedu.integration.domain.cgd.CgdCard; | ||
|
||
@SpringApplication(group = "#logged", path = "authorize-personal-data-access", title = "authorize.personal.data.access.title") | ||
@SpringFunctionality(app = AuthorizePersonalDataAccessController.class, title = "authorize.personal.data.access.title") | ||
@Controller | ||
@RequestMapping("/authorize-personal-data-access") | ||
public class AuthorizePersonalDataAccessController { | ||
|
||
@RequestMapping(method = RequestMethod.POST) | ||
public String setCandiadteCGDAccess(@RequestParam(required = false) Boolean allowAccess, @RequestParam(required = false) String qs, Model model) { | ||
final boolean authorize = allowAccess != null && allowAccess.booleanValue(); | ||
final CgdCard card = CgdCard.setGrantAccess(authorize); | ||
if (card != null) { | ||
card.send(); | ||
} | ||
return "redirect:" + qs; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters