Search in sources :

Example 1 with ShibbolethCompatiblePersistentIdGenerator

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);
}
Also used : ShibbolethCompatiblePersistentIdGenerator(org.apereo.cas.authentication.principal.ShibbolethCompatiblePersistentIdGenerator) Test(org.junit.Test)

Example 2 with ShibbolethCompatiblePersistentIdGenerator

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);
}
Also used : ShibbolethCompatiblePersistentIdGenerator(org.apereo.cas.authentication.principal.ShibbolethCompatiblePersistentIdGenerator) Test(org.junit.Test)

Example 3 with ShibbolethCompatiblePersistentIdGenerator

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);
}
Also used : ShibbolethCompatiblePersistentIdGenerator(org.apereo.cas.authentication.principal.ShibbolethCompatiblePersistentIdGenerator) Service(org.apereo.cas.authentication.principal.Service) Principal(org.apereo.cas.authentication.principal.Principal) Test(org.junit.Test)

Example 4 with ShibbolethCompatiblePersistentIdGenerator

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);
}
Also used : ShibbolethCompatiblePersistentIdGenerator(org.apereo.cas.authentication.principal.ShibbolethCompatiblePersistentIdGenerator) Test(org.junit.Test)

Example 5 with ShibbolethCompatiblePersistentIdGenerator

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;
}
Also used : AnonymousRegisteredServiceUsernameAttributeProvider(org.apereo.cas.services.AnonymousRegisteredServiceUsernameAttributeProvider) RegisteredServiceProperty(org.apereo.cas.services.RegisteredServiceProperty) DefaultRegisteredServiceProperty(org.apereo.cas.services.DefaultRegisteredServiceProperty) HashMap(java.util.HashMap) ShibbolethCompatiblePersistentIdGenerator(org.apereo.cas.authentication.principal.ShibbolethCompatiblePersistentIdGenerator) AbstractRegisteredService(org.apereo.cas.services.AbstractRegisteredService) RegexRegisteredService(org.apereo.cas.services.RegexRegisteredService) RefuseRegisteredServiceProxyPolicy(org.apereo.cas.services.RefuseRegisteredServiceProxyPolicy) DefaultRegisteredServiceProperty(org.apereo.cas.services.DefaultRegisteredServiceProperty) HashSet(java.util.HashSet)

Aggregations

ShibbolethCompatiblePersistentIdGenerator (org.apereo.cas.authentication.principal.ShibbolethCompatiblePersistentIdGenerator)7 Test (org.junit.Test)4 AnonymousRegisteredServiceUsernameAttributeProvider (org.apereo.cas.services.AnonymousRegisteredServiceUsernameAttributeProvider)3 RegisteredServiceUsernameAttributeProviderEditBean (org.apereo.cas.mgmt.services.web.beans.RegisteredServiceUsernameAttributeProviderEditBean)2 DefaultRegisteredServiceUsernameProvider (org.apereo.cas.services.DefaultRegisteredServiceUsernameProvider)2 PrincipalAttributeRegisteredServiceUsernameProvider (org.apereo.cas.services.PrincipalAttributeRegisteredServiceUsernameProvider)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 PersistentIdGenerator (org.apereo.cas.authentication.principal.PersistentIdGenerator)1 Principal (org.apereo.cas.authentication.principal.Principal)1 Service (org.apereo.cas.authentication.principal.Service)1 AbstractRegisteredService (org.apereo.cas.services.AbstractRegisteredService)1 DefaultRegisteredServiceProperty (org.apereo.cas.services.DefaultRegisteredServiceProperty)1 RefuseRegisteredServiceProxyPolicy (org.apereo.cas.services.RefuseRegisteredServiceProxyPolicy)1 RegexRegisteredService (org.apereo.cas.services.RegexRegisteredService)1 RegisteredServiceProperty (org.apereo.cas.services.RegisteredServiceProperty)1