@Test public void isPersonalCertificateRequiredForPermission() throws Exception { PersonalCertificatePermissionConfig config = new PersonalCertificatePermissionConfig(); config.setPermissionsRequiringPersonalCertificate(Sets.newHashSet(PERM_1, PERM_2)); config.setPermissionsWithoutPersonalCertificate(Sets.newHashSet(PERM_3)); PermissionService instance = new PermissionService(config); assertThat(instance.isPersonalCertificateRequiredForPermission(PERM_1).getResponse()).isEqualTo( IsPersonalCertificateRequiredModel.Response.REQUIRED_PERSONAL_CERTIFICATE); assertThat(instance.isPersonalCertificateRequiredForPermission(PERM_3).getResponse()).isEqualTo( IsPersonalCertificateRequiredModel.Response.IGNORED_PERSONAL_CERTIFICATE); assertThat(instance.isPersonalCertificateRequiredForPermission(PERM_4).getResponse()).isEqualTo( IsPersonalCertificateRequiredModel.Response.ERROR_UNKNOWN_PERMISSION); }
public IsPersonalCertificateRequiredModel isPersonalCertificateRequiredForPermission( String permission) { if (personalCertificatePermissionConfig.getPermissionsRequiringPersonalCertificate() != null && personalCertificatePermissionConfig.getPermissionsRequiringPersonalCertificate().contains(permission)) { LOGGER.debug("Required personal certificate for permission {}", permission); return new IsPersonalCertificateRequiredModel( IsPersonalCertificateRequiredModel.Response.REQUIRED_PERSONAL_CERTIFICATE); } if (personalCertificatePermissionConfig.getPermissionsWithoutPersonalCertificate() != null && personalCertificatePermissionConfig.getPermissionsWithoutPersonalCertificate().contains(permission)) { LOGGER.debug("Non required personal certificate for permission {}", permission); return new IsPersonalCertificateRequiredModel( IsPersonalCertificateRequiredModel.Response.IGNORED_PERSONAL_CERTIFICATE); } LOGGER.error("Unknown permission {}", permission); return new IsPersonalCertificateRequiredModel( IsPersonalCertificateRequiredModel.Response.ERROR_UNKNOWN_PERMISSION); }
PermissionService { public IsPersonalCertificateRequiredModel isPersonalCertificateRequiredForPermission( String permission) { if (personalCertificatePermissionConfig.getPermissionsRequiringPersonalCertificate() != null && personalCertificatePermissionConfig.getPermissionsRequiringPersonalCertificate().contains(permission)) { LOGGER.debug("Required personal certificate for permission {}", permission); return new IsPersonalCertificateRequiredModel( IsPersonalCertificateRequiredModel.Response.REQUIRED_PERSONAL_CERTIFICATE); } if (personalCertificatePermissionConfig.getPermissionsWithoutPersonalCertificate() != null && personalCertificatePermissionConfig.getPermissionsWithoutPersonalCertificate().contains(permission)) { LOGGER.debug("Non required personal certificate for permission {}", permission); return new IsPersonalCertificateRequiredModel( IsPersonalCertificateRequiredModel.Response.IGNORED_PERSONAL_CERTIFICATE); } LOGGER.error("Unknown permission {}", permission); return new IsPersonalCertificateRequiredModel( IsPersonalCertificateRequiredModel.Response.ERROR_UNKNOWN_PERMISSION); } }
PermissionService { public IsPersonalCertificateRequiredModel isPersonalCertificateRequiredForPermission( String permission) { if (personalCertificatePermissionConfig.getPermissionsRequiringPersonalCertificate() != null && personalCertificatePermissionConfig.getPermissionsRequiringPersonalCertificate().contains(permission)) { LOGGER.debug("Required personal certificate for permission {}", permission); return new IsPersonalCertificateRequiredModel( IsPersonalCertificateRequiredModel.Response.REQUIRED_PERSONAL_CERTIFICATE); } if (personalCertificatePermissionConfig.getPermissionsWithoutPersonalCertificate() != null && personalCertificatePermissionConfig.getPermissionsWithoutPersonalCertificate().contains(permission)) { LOGGER.debug("Non required personal certificate for permission {}", permission); return new IsPersonalCertificateRequiredModel( IsPersonalCertificateRequiredModel.Response.IGNORED_PERSONAL_CERTIFICATE); } LOGGER.error("Unknown permission {}", permission); return new IsPersonalCertificateRequiredModel( IsPersonalCertificateRequiredModel.Response.ERROR_UNKNOWN_PERMISSION); } PermissionService(
        PersonalCertificatePermissionConfig personalCertificatePermissionConfig); }
PermissionService { public IsPersonalCertificateRequiredModel isPersonalCertificateRequiredForPermission( String permission) { if (personalCertificatePermissionConfig.getPermissionsRequiringPersonalCertificate() != null && personalCertificatePermissionConfig.getPermissionsRequiringPersonalCertificate().contains(permission)) { LOGGER.debug("Required personal certificate for permission {}", permission); return new IsPersonalCertificateRequiredModel( IsPersonalCertificateRequiredModel.Response.REQUIRED_PERSONAL_CERTIFICATE); } if (personalCertificatePermissionConfig.getPermissionsWithoutPersonalCertificate() != null && personalCertificatePermissionConfig.getPermissionsWithoutPersonalCertificate().contains(permission)) { LOGGER.debug("Non required personal certificate for permission {}", permission); return new IsPersonalCertificateRequiredModel( IsPersonalCertificateRequiredModel.Response.IGNORED_PERSONAL_CERTIFICATE); } LOGGER.error("Unknown permission {}", permission); return new IsPersonalCertificateRequiredModel( IsPersonalCertificateRequiredModel.Response.ERROR_UNKNOWN_PERMISSION); } PermissionService(
        PersonalCertificatePermissionConfig personalCertificatePermissionConfig); IsPersonalCertificateRequiredModel isPersonalCertificateRequiredForPermission(
        String permission); }
PermissionService { public IsPersonalCertificateRequiredModel isPersonalCertificateRequiredForPermission( String permission) { if (personalCertificatePermissionConfig.getPermissionsRequiringPersonalCertificate() != null && personalCertificatePermissionConfig.getPermissionsRequiringPersonalCertificate().contains(permission)) { LOGGER.debug("Required personal certificate for permission {}", permission); return new IsPersonalCertificateRequiredModel( IsPersonalCertificateRequiredModel.Response.REQUIRED_PERSONAL_CERTIFICATE); } if (personalCertificatePermissionConfig.getPermissionsWithoutPersonalCertificate() != null && personalCertificatePermissionConfig.getPermissionsWithoutPersonalCertificate().contains(permission)) { LOGGER.debug("Non required personal certificate for permission {}", permission); return new IsPersonalCertificateRequiredModel( IsPersonalCertificateRequiredModel.Response.IGNORED_PERSONAL_CERTIFICATE); } LOGGER.error("Unknown permission {}", permission); return new IsPersonalCertificateRequiredModel( IsPersonalCertificateRequiredModel.Response.ERROR_UNKNOWN_PERMISSION); } PermissionService(
        PersonalCertificatePermissionConfig personalCertificatePermissionConfig); IsPersonalCertificateRequiredModel isPersonalCertificateRequiredForPermission(
        String permission);  }