Skip to content

Commit

Permalink
feat: remove fido u2f endpoints #978
Browse files Browse the repository at this point in the history
  • Loading branch information
yurem committed Mar 7, 2022
1 parent bcc733b commit e2cad3c
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 263 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
import io.jans.as.server.service.CleanerTimer;
import io.jans.as.server.service.ClientService;
import io.jans.as.server.service.GrantService;
import io.jans.as.server.service.fido.u2f.DeviceRegistrationService;
import io.jans.as.server.service.fido.u2f.RegistrationService;
import io.jans.as.server.uma.authorization.UmaPCT;
import io.jans.as.server.uma.authorization.UmaRPT;
import io.jans.as.server.uma.service.UmaPctService;
Expand Down Expand Up @@ -79,10 +77,7 @@ public class CleanerTimerTest extends BaseComponentTest {
private AuthorizationGrantList authorizationGrantList;
@Inject
private GrantService grantService;
@Inject
private RegistrationService u2fRegistrationService;
@Inject
private DeviceRegistrationService deviceRegistrationService;


@Test(enabled = false) // disabled temporarily. It works perfectly locally but fails on jenkins. Reason is unclear.
public void client_whichIsExpiredAndDeletable_MustBeRemoved() throws StringEncrypter.EncryptionException {
Expand Down Expand Up @@ -157,90 +152,6 @@ public void client_whichIsNotExpiredAndDeletable_MustNotBeRemoved() throws Strin
assertNotNull(clientService.getClient(client.getClientId()));
}

@Test
public void u2fDevice_whichIsExpiredAndDeletable_MustBeRemoved() throws StringEncrypter.EncryptionException {
final Client client = createClient();
clientService.persist(client);

// 1. create device
String userInum = "";
String appId = "https://testapp.com";
final DeviceRegistration device = new DeviceRegistration();
device.setStatus(DeviceRegistrationStatus.ACTIVE);
device.setApplication(appId);
device.setId(String.valueOf(System.currentTimeMillis()));
device.setDn(deviceRegistrationService.getDnForU2fDevice(userInum, device.getId()));

deviceRegistrationService.addOneStepDeviceRegistration(device);

// 2. device exists
assertNotNull(deviceRegistrationService.findUserDeviceRegistration(userInum, device.getId()));

// 3. clean up
cleanerTimer.processImpl();
cacheService.clear();

// 4. device exists
assertNotNull(deviceRegistrationService.findUserDeviceRegistration(userInum, device.getId()));

final Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MINUTE, -10);
device.setExpirationDate(calendar.getTime());

deviceRegistrationService.merge(device);

// 5. clean up
cleanerTimer.processImpl();
cacheService.clear();

// 6. no device in persistence
try {
deviceRegistrationService.findUserDeviceRegistration(userInum, device.getId());
throw new AssertionError("No exception, expected EntryPersistenceException on find.");
} catch (EntryPersistenceException e) {
// ignore
}
}

@Test
public void u2fRequest_whichIsExpiredAndDeletable_MustBeRemoved() throws StringEncrypter.EncryptionException {
final Client client = createClient();
clientService.persist(client);

// 1. create token
String userInum = "";
String appId = "https://testapp.com";
final RequestMessageLdap request = u2fRegistrationService.storeRegisterRequestMessage(u2fRegistrationService.builRegisterRequestMessage(appId, userInum), userInum, userInum);

// 2. request exists
assertNotNull(u2fRegistrationService.getRegisterRequestMessage(request.getId()));

// 3. clean up
cleanerTimer.processImpl();
cacheService.clear();

// 4. request exists
assertNotNull(u2fRegistrationService.getRegisterRequestMessage(request.getId()));

final Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MINUTE, -10);
request.setExpirationDate(calendar.getTime());

u2fRegistrationService.merge(request);

// 5. clean up
cleanerTimer.processImpl();
cacheService.clear();

// 6. no request in persistence
try {
u2fRegistrationService.getRegisterRequestMessage(request.getId());
throw new AssertionError("No exception, expected EntryPersistenceException on find request.");
} catch (EntryPersistenceException e) {
// ignore
}
}

@Test
public void token_whichIsExpiredAndDeletable_MustBeRemoved() throws StringEncrypter.EncryptionException {
final Client client = createClient();
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit e2cad3c

Please sign in to comment.