use of org.apereo.cas.authentication.principal.ShibbolethCompatiblePersistentIdGenerator in project cas by apereo.
the class AbstractResourceBasedServiceRegistryDaoTests method verifySaveMethodWithDefaultAnonymousAttribute.
@Test
public void verifySaveMethodWithDefaultAnonymousAttribute() {
final RegexRegisteredService r = new RegexRegisteredService();
r.setName("testSaveMethodWithDefaultAnonymousAttribute");
r.setServiceId(SERVICE_ID);
r.setTheme(THEME);
r.setDescription(DESCRIPTION);
r.setUsernameAttributeProvider(new AnonymousRegisteredServiceUsernameAttributeProvider(new ShibbolethCompatiblePersistentIdGenerator("helloworld")));
final RegisteredService r2 = this.dao.save(r);
this.dao.load();
final RegisteredService r3 = this.dao.findServiceById(r2.getId());
final AnonymousRegisteredServiceUsernameAttributeProvider anon = (AnonymousRegisteredServiceUsernameAttributeProvider) r3.getUsernameAttributeProvider();
final ShibbolethCompatiblePersistentIdGenerator ss = (ShibbolethCompatiblePersistentIdGenerator) anon.getPersistentIdGenerator();
assertEquals(new String(ss.getSalt()), "helloworld");
assertEquals(r2, r3);
}
use of org.apereo.cas.authentication.principal.ShibbolethCompatiblePersistentIdGenerator in project cas by apereo.
the class AnonymousRegisteredServiceUsernameAttributeProviderTests method verifyEquality.
@Test
public void verifyEquality() {
final AnonymousRegisteredServiceUsernameAttributeProvider provider = new AnonymousRegisteredServiceUsernameAttributeProvider(new ShibbolethCompatiblePersistentIdGenerator(CASROX));
final AnonymousRegisteredServiceUsernameAttributeProvider provider2 = new AnonymousRegisteredServiceUsernameAttributeProvider(new ShibbolethCompatiblePersistentIdGenerator(CASROX));
assertEquals(provider, provider2);
}
use of org.apereo.cas.authentication.principal.ShibbolethCompatiblePersistentIdGenerator in project cas by apereo.
the class AnonymousRegisteredServiceUsernameAttributeProviderTests method verifyPrincipalResolution.
@Test
public void verifyPrincipalResolution() {
final AnonymousRegisteredServiceUsernameAttributeProvider provider = new AnonymousRegisteredServiceUsernameAttributeProvider(new ShibbolethCompatiblePersistentIdGenerator(CASROX));
final Service service = mock(Service.class);
when(service.getId()).thenReturn("id");
final Principal principal = mock(Principal.class);
when(principal.getId()).thenReturn("uid");
final String id = provider.resolveUsername(principal, service);
assertNotNull(id);
}
use of org.apereo.cas.authentication.principal.ShibbolethCompatiblePersistentIdGenerator in project cas by apereo.
the class AnonymousRegisteredServiceUsernameAttributeProviderTests method verifySerializeADefaultRegisteredServiceUsernameProviderToJson.
@Test
public void verifySerializeADefaultRegisteredServiceUsernameProviderToJson() throws IOException {
final AnonymousRegisteredServiceUsernameAttributeProvider providerWritten = new AnonymousRegisteredServiceUsernameAttributeProvider(new ShibbolethCompatiblePersistentIdGenerator(CASROX));
MAPPER.writeValue(JSON_FILE, providerWritten);
final RegisteredServiceUsernameAttributeProvider providerRead = MAPPER.readValue(JSON_FILE, AnonymousRegisteredServiceUsernameAttributeProvider.class);
assertEquals(providerWritten, providerRead);
}
use of org.apereo.cas.authentication.principal.ShibbolethCompatiblePersistentIdGenerator in project cas by apereo.
the class LdapServiceRegistryDaoTests method getRegexRegisteredService.
private static RegisteredService getRegexRegisteredService() {
final AbstractRegisteredService rs = new RegexRegisteredService();
rs.setName("Service Name Regex");
rs.setProxyPolicy(new RefuseRegisteredServiceProxyPolicy());
rs.setUsernameAttributeProvider(new AnonymousRegisteredServiceUsernameAttributeProvider(new ShibbolethCompatiblePersistentIdGenerator("hello")));
rs.setDescription("Service description");
rs.setServiceId("^http?://.+");
rs.setTheme("the theme name");
rs.setEvaluationOrder(123);
rs.setDescription("Here is another description");
rs.setRequiredHandlers(Stream.of("handler1", "handler2").collect(Collectors.toSet()));
final Map<String, RegisteredServiceProperty> propertyMap = new HashMap<>();
final DefaultRegisteredServiceProperty property = new DefaultRegisteredServiceProperty();
final Set<String> values = new HashSet<>();
values.add("value1");
values.add("value2");
property.setValues(values);
propertyMap.put("field1", property);
rs.setProperties(propertyMap);
return rs;
}
Aggregations