use of org.apache.jackrabbit.oak.spi.security.principal.PrincipalConfiguration in project jackrabbit-oak by apache.
the class InternalSecurityProviderTest method testSetPrincipalConfiguration.
@Test
public void testSetPrincipalConfiguration() {
PrincipalConfiguration pc = Mockito.mock(PrincipalConfiguration.class);
when(pc.getParameters()).thenReturn(PARAMS);
securityProvider.setPrincipalConfiguration(pc);
assertSame(pc, securityProvider.getConfiguration(PrincipalConfiguration.class));
for (SecurityConfiguration sc : securityProvider.getConfigurations()) {
if (sc instanceof PrincipalConfiguration) {
assertSame(pc, sc);
}
}
assertTrue(Iterables.contains(securityProvider.getConfigurations(), pc));
assertEquals(PARAMS, securityProvider.getParameters(PrincipalConfiguration.NAME));
}
use of org.apache.jackrabbit.oak.spi.security.principal.PrincipalConfiguration in project jackrabbit-oak by apache.
the class CugImporter method init.
//----------------------------------------------< ProtectedItemImporter >---
@Override
public boolean init(@Nonnull Session session, @Nonnull Root root, @Nonnull NamePathMapper namePathMapper, boolean isWorkspaceImport, int uuidBehavior, @Nonnull ReferenceChangeTracker referenceTracker, @Nonnull SecurityProvider securityProvider) {
if (initialized) {
throw new IllegalStateException("Already initialized");
}
try {
ConfigurationParameters config = securityProvider.getConfiguration(AuthorizationConfiguration.class).getParameters();
supportedPaths = CugUtil.getSupportedPaths(config, mountInfoProvider);
importBehavior = CugUtil.getImportBehavior(config);
if (isWorkspaceImport) {
PrincipalConfiguration pConfig = securityProvider.getConfiguration(PrincipalConfiguration.class);
principalManager = pConfig.getPrincipalManager(root, namePathMapper);
} else {
principalManager = ((JackrabbitSession) session).getPrincipalManager();
}
initialized = true;
} catch (RepositoryException e) {
log.warn("Error while initializing cug importer", e);
}
return initialized;
}
use of org.apache.jackrabbit.oak.spi.security.principal.PrincipalConfiguration in project jackrabbit-oak by apache.
the class AccessControlImporter method init.
//----------------------------------------------< ProtectedItemImporter >---
@Override
public boolean init(@Nonnull Session session, @Nonnull Root root, @Nonnull NamePathMapper namePathMapper, boolean isWorkspaceImport, int uuidBehavior, @Nonnull ReferenceChangeTracker referenceTracker, @Nonnull SecurityProvider securityProvider) {
if (initialized) {
throw new IllegalStateException("Already initialized");
}
if (!(session instanceof JackrabbitSession)) {
return false;
}
try {
AuthorizationConfiguration config = securityProvider.getConfiguration(AuthorizationConfiguration.class);
importBehavior = Util.getImportBehavior(config);
if (isWorkspaceImport) {
acMgr = config.getAccessControlManager(root, namePathMapper);
PrincipalConfiguration pConfig = securityProvider.getConfiguration(PrincipalConfiguration.class);
principalManager = pConfig.getPrincipalManager(root, namePathMapper);
} else {
acMgr = session.getAccessControlManager();
principalManager = ((JackrabbitSession) session).getPrincipalManager();
}
ntMgr = ReadOnlyNodeTypeManager.getInstance(root, namePathMapper);
initialized = true;
} catch (RepositoryException e) {
log.warn("Error while initializing access control importer", e);
}
return initialized;
}
use of org.apache.jackrabbit.oak.spi.security.principal.PrincipalConfiguration in project jackrabbit-oak by apache.
the class SecurityProviderImplTest method testBindPrincipalConfiguration.
@Test
public void testBindPrincipalConfiguration() {
PrincipalConfiguration defaultConfig = securityProvider.getConfiguration(PrincipalConfiguration.class);
assertTrue(defaultConfig instanceof CompositePrincipalConfiguration);
CompositePrincipalConfiguration cpc = (CompositePrincipalConfiguration) defaultConfig;
PrincipalConfiguration pc = Mockito.mock(PrincipalConfiguration.class);
when(pc.getParameters()).thenReturn(ConfigurationParameters.EMPTY);
securityProvider.bindPrincipalConfiguration(pc);
assertNotSame(pc, securityProvider.getConfiguration(PrincipalConfiguration.class));
assertSame(defaultConfig, securityProvider.getConfiguration(PrincipalConfiguration.class));
for (SecurityConfiguration sc : securityProvider.getConfigurations()) {
if (sc instanceof PrincipalConfiguration) {
assertSame(defaultConfig, sc);
}
}
assertTrue(cpc.getConfigurations().contains(pc));
}
use of org.apache.jackrabbit.oak.spi.security.principal.PrincipalConfiguration in project jackrabbit-oak by apache.
the class AbstractLoginModule method getPrincipalProvider.
/**
* Retrieves the {@link PrincipalProvider} that should be used to handle
* this authentication. If no principal provider has been configure this
* method returns {@code null}.
*
* @return A instance of {@code PrincipalProvider} or {@code null}.
*/
@CheckForNull
protected PrincipalProvider getPrincipalProvider() {
PrincipalProvider principalProvider = null;
SecurityProvider sp = getSecurityProvider();
Root r = getRoot();
if (r != null && sp != null) {
PrincipalConfiguration pc = sp.getConfiguration(PrincipalConfiguration.class);
principalProvider = pc.getPrincipalProvider(r, NamePathMapper.DEFAULT);
}
if (principalProvider == null && callbackHandler != null) {
try {
PrincipalProviderCallback principalCallBack = new PrincipalProviderCallback();
callbackHandler.handle(new Callback[] { principalCallBack });
principalProvider = principalCallBack.getPrincipalProvider();
} catch (IOException | UnsupportedCallbackException e) {
log.debug(e.getMessage());
}
}
return principalProvider;
}
Aggregations