Package org.apache.jackrabbit.oak.spi.security.authentication.external

Examples of org.apache.jackrabbit.oak.spi.security.authentication.external.SyncedIdentity


            log.debug("No credentials found for external login module. ignoring.");
            return false;
        }

        try {
            SyncedIdentity sId = null;
            if (userId != null) {
                sId = syncHandler.findIdentity(getUserManager(), userId);
                // if there exists an authorizable with the given userid but is not an external one or if it belongs to
                // another IDP, we just ignore it.
                if (sId != null) {
                    if (sId.getExternalIdRef() == null) {
                        log.debug("ignoring local user: {}", sId.getId());
                        return false;
                    }
                    if (!sId.getExternalIdRef().getProviderName().equals(idp.getName())) {
                        if (log.isDebugEnabled()) {
                            log.debug("ignoring foreign identity: {} (idp={})", sId.getExternalIdRef().getString(), idp.getName());
                        }
                        return false;
                    }
                }
            }

            if (preAuthLogin != null) {
                externalUser = idp.getUser(preAuthLogin.getUserId());
            } else {
                externalUser = idp.authenticate(credentials);
            }

            if (externalUser != null) {
                log.debug("IDP {} returned valid user {}", idp.getName(), externalUser);

                if (credentials != null) {
                    //noinspection unchecked
                    sharedState.put(SHARED_KEY_CREDENTIALS, credentials);
                }

                //noinspection unchecked
                sharedState.put(SHARED_KEY_LOGIN_NAME, externalUser.getId());

                syncUser(externalUser);

                return true;
            } else {
                if (log.isDebugEnabled()) {
                    if (userId != null) {
                        log.debug("IDP {} returned null for simple creds of {}", idp.getName(), userId);
                    } else {
                        log.debug("IDP {} returned null for {}", idp.getName(), credentials);
                    }
                }

                if (sId != null) {
                    // invalidate the user if it exists as synced variant
                    log.debug("local user exists for '{}'. re-validating.", sId.getId());
                    validateUser(sId.getId());
                }
                return false;
            }
        } catch (ExternalIdentityException e) {
            log.error("Error while authenticating '{}' with {}",
View Full Code Here


        }

        // remember userID as we need this so often
        final String userId = credentials instanceof SimpleCredentials ? ((SimpleCredentials) credentials).getUserID() : null;
        try {
            SyncedIdentity sId = null;
            if (userId != null) {
                sId = syncHandler.findIdentity(getUserManager(), userId);
                // if there exists an authorizable with the given userid but is not an external one or if it belongs to
                // another IDP, we just ignore it.
                if (sId != null) {
                    if (sId.getExternalIdRef() == null) {
                        log.debug("ignoring local user: {}", sId.getId());
                        return false;
                    }
                    if (!sId.getExternalIdRef().getProviderName().equals(idp.getName())) {
                        if (log.isDebugEnabled()) {
                            log.debug("ignoring foreign identity: {} (idp={})", sId.getExternalIdRef().getString(), idp.getName());
                        }
                        return false;
                    }
                }
            }

            externalUser = idp.authenticate(credentials);
            if (externalUser != null) {
                log.debug("IDP {} returned valid user {}", idp.getName(), externalUser);

                //noinspection unchecked
                sharedState.put(SHARED_KEY_CREDENTIALS, credentials);

                //noinspection unchecked
                sharedState.put(SHARED_KEY_LOGIN_NAME, externalUser.getId());

                syncUser(externalUser);

                return true;
            } else {
                if (log.isDebugEnabled()) {
                    if (userId != null) {
                        log.debug("IDP {} returned null for simple creds of {}", idp.getName(), userId);
                    } else {
                        log.debug("IDP {} returned null for {}", idp.getName(), credentials);
                    }
                }

                if (sId != null) {
                    // invalidate the user if it exists as synced variant
                    log.debug("local user exists for '{}'. re-validating.", sId.getId());
                    validateUser(sId.getId());
                }
                return false;
            }
        } catch (ExternalIdentityException e) {
            log.error("Error while authenticating '{}' with {}",
View Full Code Here

            @Override
            protected SyncedIdentity getNext() {
                while (iter.hasNext()) {
                    try {
                        SyncedIdentity id = createSyncedIdentity(iter.next());
                        if (id != null) {
                            return id;
                        }
                    } catch (RepositoryException e) {
                        log.error("Error while fetching authorizables", e);
View Full Code Here

            log.debug("No credentials found for external login module. ignoring.");
            return false;
        }

        try {
            SyncedIdentity sId = null;
            if (userId != null) {
                sId = syncHandler.findIdentity(getUserManager(), userId);
                // if there exists an authorizable with the given userid but is not an external one or if it belongs to
                // another IDP, we just ignore it.
                if (sId != null) {
                    if (sId.getExternalIdRef() == null) {
                        log.debug("ignoring local user: {}", sId.getId());
                        return false;
                    }
                    if (!sId.getExternalIdRef().getProviderName().equals(idp.getName())) {
                        if (log.isDebugEnabled()) {
                            log.debug("ignoring foreign identity: {} (idp={})", sId.getExternalIdRef().getString(), idp.getName());
                        }
                        return false;
                    }
                }
            }

            if (preAuthLogin != null) {
                externalUser = idp.getUser(preAuthLogin.getUserId());
            } else {
                externalUser = idp.authenticate(credentials);
            }

            if (externalUser != null) {
                log.debug("IDP {} returned valid user {}", idp.getName(), externalUser);

                if (credentials != null) {
                    //noinspection unchecked
                    sharedState.put(SHARED_KEY_CREDENTIALS, credentials);
                }

                //noinspection unchecked
                sharedState.put(SHARED_KEY_LOGIN_NAME, externalUser.getId());

                syncUser(externalUser);

                return true;
            } else {
                if (log.isDebugEnabled()) {
                    if (userId != null) {
                        log.debug("IDP {} returned null for simple creds of {}", idp.getName(), userId);
                    } else {
                        log.debug("IDP {} returned null for {}", idp.getName(), credentials);
                    }
                }

                if (sId != null) {
                    // invalidate the user if it exists as synced variant
                    log.debug("local user exists for '{}'. re-validating.", sId.getId());
                    validateUser(sId.getId());
                }
                return false;
            }
        } catch (ExternalIdentityException e) {
            log.error("Error while authenticating '{}' with {}",
View Full Code Here

                context.setKeepMissing(!purge)
                        .setForceGroupSync(true)
                        .setForceUserSync(true);
                Iterator<SyncedIdentity> iter = handler.listIdentities(userMgr);
                while (iter.hasNext()) {
                    SyncedIdentity id = iter.next();
                    if (isMyIDP(id)) {
                        try {
                            SyncResult r = context.sync(id.getId());
                            systemSession.save();
                            list.add(getJSONString(r));
                        } catch (SyncException e) {
                            list.add(getJSONString(id, e));
                        } catch (RepositoryException e) {
View Full Code Here

        public String[] listOrphanedUsers() {
            List<String> list = new ArrayList<String>();
            try {
                Iterator<SyncedIdentity> iter = handler.listIdentities(userMgr);
                while (iter.hasNext()) {
                    SyncedIdentity id = iter.next();
                    if (isMyIDP(id)) {
                        ExternalIdentity extId = idp.getIdentity(id.getExternalIdRef());
                        if (extId == null) {
                            list.add(id.getId());
                        }
                    }
                }
            } catch (RepositoryException e) {
                log.error("Error while listing orphaned users", e);
View Full Code Here

            @Override
            protected SyncedIdentity getNext() {
                while (iter.hasNext()) {
                    try {
                        SyncedIdentity id = createSyncedIdentity(iter.next());
                        if (id != null) {
                            return id;
                        }
                    } catch (RepositoryException e) {
                        log.error("Error while fetching authorizables", e);
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.oak.spi.security.authentication.external.SyncedIdentity

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.