Search in sources :

Example 1 with AnonymousAuthenticationHandler

use of org.apache.syncope.client.lib.AnonymousAuthenticationHandler in project syncope by apache.

the class VirSchemaITCase method anonymous.

@Test
public void anonymous() {
    SchemaService unauthenticated = clientFactory.create().getService(SchemaService.class);
    try {
        unauthenticated.search(new SchemaQuery.Builder().type(SchemaType.VIRTUAL).build());
        fail("This should not happen");
    } catch (AccessControlException e) {
        assertNotNull(e);
    }
    SchemaService anonymous = clientFactory.create(new AnonymousAuthenticationHandler(ANONYMOUS_UNAME, ANONYMOUS_KEY)).getService(SchemaService.class);
    assertFalse(anonymous.search(new SchemaQuery.Builder().type(SchemaType.VIRTUAL).build()).isEmpty());
}
Also used : SchemaService(org.apache.syncope.common.rest.api.service.SchemaService) AccessControlException(java.security.AccessControlException) AnonymousAuthenticationHandler(org.apache.syncope.client.lib.AnonymousAuthenticationHandler) SchemaQuery(org.apache.syncope.common.rest.api.beans.SchemaQuery) Test(org.junit.jupiter.api.Test)

Example 2 with AnonymousAuthenticationHandler

use of org.apache.syncope.client.lib.AnonymousAuthenticationHandler in project syncope by apache.

the class SAML2ITCase method setup.

@BeforeAll
public static void setup() {
    anonymous = new SyncopeClientFactoryBean().setAddress(ADDRESS).create(new AnonymousAuthenticationHandler(ANONYMOUS_UNAME, ANONYMOUS_KEY));
    WSSConfig.init();
    OpenSAMLUtil.initSamlEngine(false);
}
Also used : SyncopeClientFactoryBean(org.apache.syncope.client.lib.SyncopeClientFactoryBean) AnonymousAuthenticationHandler(org.apache.syncope.client.lib.AnonymousAuthenticationHandler) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 3 with AnonymousAuthenticationHandler

use of org.apache.syncope.client.lib.AnonymousAuthenticationHandler in project syncope by apache.

the class GroupITCase method anonymous.

@Test
public void anonymous() {
    GroupService unauthenticated = clientFactory.create().getService(GroupService.class);
    try {
        unauthenticated.search(new AnyQuery.Builder().realm("/even").build());
        fail("This should not happen");
    } catch (AccessControlException e) {
        assertNotNull(e);
    }
    SyncopeClient anonymous = clientFactory.create(new AnonymousAuthenticationHandler(ANONYMOUS_UNAME, ANONYMOUS_KEY));
    try {
        anonymous.getService(GroupService.class).search(new AnyQuery.Builder().realm("/even").build());
        fail("This should not happen");
    } catch (ForbiddenException e) {
        assertNotNull(e);
    }
    assertFalse(anonymous.getService(SyncopeService.class).searchAssignableGroups("/even", null, 1, 100).getResult().isEmpty());
}
Also used : ForbiddenException(javax.ws.rs.ForbiddenException) AccessControlException(java.security.AccessControlException) AnonymousAuthenticationHandler(org.apache.syncope.client.lib.AnonymousAuthenticationHandler) AnyQuery(org.apache.syncope.common.rest.api.beans.AnyQuery) GroupService(org.apache.syncope.common.rest.api.service.GroupService) SyncopeClient(org.apache.syncope.client.lib.SyncopeClient) Test(org.junit.jupiter.api.Test)

Example 4 with AnonymousAuthenticationHandler

use of org.apache.syncope.client.lib.AnonymousAuthenticationHandler in project syncope by apache.

the class SyncopeConsoleApplication method getDomains.

public List<String> getDomains() {
    synchronized (LOG) {
        if (domains == null) {
            domains = newClientFactory().create(new AnonymousAuthenticationHandler(anonymousUser, anonymousKey)).getService(DomainService.class).list().stream().map(EntityTO::getKey).collect(Collectors.toList());
            domains.add(0, SyncopeConstants.MASTER_DOMAIN);
            domains = ListUtils.unmodifiableList(domains);
        }
    }
    return domains;
}
Also used : EntityTO(org.apache.syncope.common.lib.to.EntityTO) DomainService(org.apache.syncope.common.rest.api.service.DomainService) AnonymousAuthenticationHandler(org.apache.syncope.client.lib.AnonymousAuthenticationHandler)

Example 5 with AnonymousAuthenticationHandler

use of org.apache.syncope.client.lib.AnonymousAuthenticationHandler in project syncope by apache.

the class SAML2SPAgentSetup method contextInitialized.

@Override
public void contextInitialized(final ServletContextEvent sce) {
    // read saml2spagent.properties
    Properties props = PropertyUtils.read(getClass(), SAML2SP_AGENT_PROPERTIES, "conf.directory").getLeft();
    String anonymousUser = props.getProperty("anonymousUser");
    assertNotNull(anonymousUser, "<anonymousUser>");
    String anonymousKey = props.getProperty("anonymousKey");
    assertNotNull(anonymousKey, "<anonymousKey>");
    String scheme = props.getProperty("scheme");
    assertNotNull(scheme, "<scheme>");
    String host = props.getProperty("host");
    assertNotNull(host, "<host>");
    String port = props.getProperty("port");
    assertNotNull(port, "<port>");
    String rootPath = props.getProperty("rootPath");
    assertNotNull(rootPath, "<rootPath>");
    String useGZIPCompression = props.getProperty("useGZIPCompression");
    assertNotNull(useGZIPCompression, "<useGZIPCompression>");
    SyncopeClientFactoryBean clientFactory = new SyncopeClientFactoryBean().setAddress(scheme + "://" + host + ":" + port + "/" + rootPath).setUseCompression(BooleanUtils.toBoolean(useGZIPCompression));
    sce.getServletContext().setAttribute(Constants.SYNCOPE_CLIENT_FACTORY, clientFactory);
    sce.getServletContext().setAttribute(Constants.SYNCOPE_ANONYMOUS_CLIENT, clientFactory.create(new AnonymousAuthenticationHandler(anonymousUser, anonymousKey)));
}
Also used : SyncopeClientFactoryBean(org.apache.syncope.client.lib.SyncopeClientFactoryBean) AnonymousAuthenticationHandler(org.apache.syncope.client.lib.AnonymousAuthenticationHandler) Properties(java.util.Properties)

Aggregations

AnonymousAuthenticationHandler (org.apache.syncope.client.lib.AnonymousAuthenticationHandler)6 SyncopeClientFactoryBean (org.apache.syncope.client.lib.SyncopeClientFactoryBean)3 AccessControlException (java.security.AccessControlException)2 Test (org.junit.jupiter.api.Test)2 Properties (java.util.Properties)1 ForbiddenException (javax.ws.rs.ForbiddenException)1 SyncopeClient (org.apache.syncope.client.lib.SyncopeClient)1 EntityTO (org.apache.syncope.common.lib.to.EntityTO)1 AnyQuery (org.apache.syncope.common.rest.api.beans.AnyQuery)1 SchemaQuery (org.apache.syncope.common.rest.api.beans.SchemaQuery)1 DomainService (org.apache.syncope.common.rest.api.service.DomainService)1 GroupService (org.apache.syncope.common.rest.api.service.GroupService)1 SAML2SPService (org.apache.syncope.common.rest.api.service.SAML2SPService)1 SchemaService (org.apache.syncope.common.rest.api.service.SchemaService)1 BeforeAll (org.junit.jupiter.api.BeforeAll)1