Package org.apache.directory.server.core

Examples of org.apache.directory.server.core.CoreSession


     * and the ManageDsaIT flag
     */
    @Test
    public void testModifyExistingEntryReferralCoreAPIManageDsaIT() throws Exception
    {
        CoreSession session = service.getAdminSession();
       
        ClientAttribute attr = new DefaultClientAttribute( "Description", "This is a description" );
        Modification mod = new ClientModification(
            ModificationOperation.ADD_ATTRIBUTE, attr );
        List<Modification> mods = new ArrayList<Modification>();
       
        mods.add( mod );
       
        session.modify( new DN( "ou=Roles,o=MNN,c=WW,ou=system" ), mods, true );
       
        // Now try to retrieve this attribute
        Attributes result = MNNCtx.getAttributes( "ou=Roles", new String[]{ "description" } );
       
        assertNotNull( result );
View Full Code Here


        PartitionNexus nexus = service.getPartitionNexus();
        DN adminDn = new DN( ServerDNConstants.ADMIN_SYSTEM_DN_NORMALIZED );
        adminDn.normalize( service.getSchemaManager().getNormalizerMapping() );
        LdapPrincipal principal = new LdapPrincipal( adminDn, AuthenticationLevel.STRONG );
        CoreSession session = service.getSession( principal );
        Set<String> suffixes = nexus.listSuffixes( new ListSuffixOperationContext( session ) );
        int launchedWindowCount = 0;
           
        for ( String suffix:suffixes )
        {
View Full Code Here

            LOG.debug( "Nexus succeeded on bind operation." );

            // bind succeeded if we got this far
            // TODO - authentication level not being set
            LdapPrincipal principal = new LdapPrincipal( opContext.getDn(), AuthenticationLevel.SIMPLE );
            CoreSession session = new DefaultCoreSession( principal, directoryService );
            opContext.setSession( session );

            // remove creds so there is no security risk
            opContext.setCredentials( null );
            return;
        }

        // TODO : we should refactor that.
        // try each authenticator
        for ( Authenticator authenticator : authenticators )
        {
            try
            {
                // perform the authentication
                LdapPrincipal principal = authenticator.authenticate( opContext );
               
                LdapPrincipal clonedPrincipal = (LdapPrincipal)(principal.clone());

                // remove creds so there is no security risk
                opContext.setCredentials( null );
                clonedPrincipal.setUserPassword( StringTools.EMPTY_BYTES );

                // authentication was successful
                CoreSession session = new DefaultCoreSession( clonedPrincipal, directoryService );
                opContext.setSession( session );

                return;
            }
            catch ( LdapAuthenticationException e )
View Full Code Here

        if ( dn == null )
        {
            dn = "";
        }

        CoreSession session = service.getSession( principal );
        LdapContext ctx = new ServerLdapContext( service, session, new DN( dn ) );
        return ctx;
    }
View Full Code Here

        if ( dn == null )
        {
            dn = "";
        }
       
        CoreSession session = service.getSession( principal );
        return session;
    }
View Full Code Here


    public static void apply( DirectoryService service, LdifEntry entry ) throws Exception
    {
        DN dn = new DN( entry.getDn() );
        CoreSession session = service.getAdminSession();

        switch( entry.getChangeType().getChangeType() )
        {
            case( ChangeType.ADD_ORDINAL ):
                session.add(
                    new DefaultServerEntry( service.getSchemaManager(), entry.getEntry() ) );
                break;
               
            case( ChangeType.DELETE_ORDINAL ):
                session.delete( dn );
                break;
               
            case( ChangeType.MODDN_ORDINAL ):
            case( ChangeType.MODRDN_ORDINAL ):
                RDN newRdn = new RDN( entry.getNewRdn() );
           
                if ( entry.getNewSuperior() != null )
                {
                    // It's a move. The superior have changed
                    // Let's see if it's a rename too
                    RDN oldRdn = dn.getRdn();
                    DN newSuperior = new DN( entry.getNewSuperior() );
                   
                    if ( dn.size() == 0 )
                    {
                        throw new IllegalStateException( I18n.err( I18n.ERR_475 ) );
                    }
                    else if ( oldRdn.equals( newRdn ) )
                    {
                        // Same rdn : it's a move
                        session.move( dn, newSuperior );
                    }
                    else
                    {
                        // it's a move and rename
                        session.moveAndRename( dn, newSuperior, newRdn, entry.isDeleteOldRdn() );
                    }
                }
                else
                {
                    // it's a rename
                    session.rename( dn, newRdn, entry.isDeleteOldRdn() );
                }
               
                break;

            case( ChangeType.MODIFY_ORDINAL ):
                session.modify( dn, entry.getModificationItems() );
                break;

            default:
                throw new IllegalStateException( I18n.err( I18n.ERR_476, entry.getChangeType() ) );
        }
View Full Code Here

    {
        super.init( directoryService );

        DN adminDn = new DN( ServerDNConstants.ADMIN_SYSTEM_DN_NORMALIZED );
        adminDn.normalize( directoryService.getSchemaManager().getNormalizerMapping() );
        CoreSession adminSession = new DefaultCoreSession(
            new LdapPrincipal( adminDn, AuthenticationLevel.STRONG ), directoryService );

        tupleCache = new TupleCache( adminSession );
        groupCache = new GroupCache( adminSession );
        schemaManager = directoryService.getSchemaManager();
View Full Code Here

            String userBaseDn = ldapSession.getLdapServer().getSearchBaseDn();
            ldapSession.putSaslProperty( SaslConstants.SASL_HOST, saslHost );
            ldapSession.putSaslProperty( SaslConstants.SASL_USER_BASE_DN, userBaseDn );
            Map<String, String> saslProps = new HashMap<String, String>();
           
            CoreSession adminSession = ldapSession.getLdapServer().getDirectoryService().getAdminSession();

            CallbackHandler callbackHandler = new CramMd5CallbackHandler( ldapSession, adminSession, bindRequest );

            ss = Sasl.createSaslServer( SupportedSaslMechanisms.CRAM_MD5, SaslConstants.LDAP_PROTOCOL, saslHost, saslProps, callbackHandler );
            ldapSession.putSaslProperty( SaslConstants.SASL_SERVER, ss );
View Full Code Here

    MultiBaseSearch( String catalogBaseDn, DirectoryService directoryService )
    {
        this.directoryService = directoryService;
        try
        {
            CoreSession session = directoryService.getSession();
            catalog = new DnsCatalog( ( Map<String, Object> ) new GetCatalog().execute( session, null ) );
        }
        catch ( Exception e )
        {
            LOG.error( e.getLocalizedMessage(), e );
View Full Code Here

    {
        try
        {
            GetRecords getRecords = new GetRecords( question );
            String baseDn = catalog.getBaseDn( question.getDomainName() );
            CoreSession session = directoryService.getSession();
            DirContext dirContext = new ServerLdapContext( directoryService, session, new DN( baseDn ) );
            return getRecords.execute( dirContext, null );
        }
        catch ( LdapNameNotFoundException lnnfe )
        {
View Full Code Here

TOP

Related Classes of org.apache.directory.server.core.CoreSession

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.