Examples of DirectoryService


Examples of org.apache.directory.server.core.api.DirectoryService

     * Modify his password
     */
    private void modifyOwnPassword( LdapSession requestor, Dn principalDn, byte[] oldPassword, byte[] newPassword,
        PwdModifyRequest req )
    {
        DirectoryService service = requestor.getLdapServer().getDirectoryService();
        CoreSession adminSession = service.getAdminSession();

        // Try to update the userPassword
        ModifyOperationContext modifyContext = new ModifyOperationContext( adminSession );
        modifyContext.setDn( principalDn );
        List<Modification> modifications = new ArrayList<Modification>();
        Modification modification = null;

        if ( oldPassword != null )
        {
            modification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE,
                SchemaConstants.USER_PASSWORD_AT, oldPassword );

            modifications.add( modification );
        }
        else
        {
            modification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE,
                SchemaConstants.USER_PASSWORD_AT );

            modifications.add( modification );
        }

        if ( newPassword != null )
        {
            modification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE,
                SchemaConstants.USER_PASSWORD_AT, newPassword );

            modifications.add( modification );
        }

        modifyContext.setModItems( modifications );

        try
        {
            service.getOperationManager().modify( modifyContext );

            LOG.debug( "Password modified for user " + principalDn );

            // Ok, all done
            requestor.getIoSession().write( new PwdModifyResponseImpl(
View Full Code Here

Examples of org.apache.directory.server.core.api.DirectoryService

    public void handleExtendedOperation( LdapSession requestor, PwdModifyRequest req ) throws Exception
    {
        LOG.debug( "Password modification requested" );

        // Grab the adminSession, we might need it later
        DirectoryService service = requestor.getLdapServer().getDirectoryService();
        CoreSession adminSession = service.getAdminSession();
        String userIdentity = Strings.utf8ToString( req.getUserIdentity() );
        Dn userDn = null;

        if ( !Strings.isEmpty( userIdentity ) )
        {
            try
            {
                userDn = service.getDnFactory().create( userIdentity );
            }
            catch ( LdapInvalidDnException lide )
            {
                LOG.error( "The user DN is invalid : " + userDn );
                // The userIdentity is not a DN : return with an error code.
                requestor.getIoSession().write( new PwdModifyResponseImpl(
                    req.getMessageId(), ResultCodeEnum.INVALID_DN_SYNTAX, "The user DN is invalid : " + userDn ) );
                return;
            }
        }

        byte[] oldPassword = req.getOldPassword();
        byte[] newPassword = req.getNewPassword();

        // First check if the user is bound or not
        if ( requestor.isAuthenticated() )
        {
            Dn principalDn = requestor.getCoreSession().getEffectivePrincipal().getDn();

            LOG.debug( "Trying to modify password for user " + principalDn );

            // First, check that the userDn is null : we can't change the password of someone else
            // except if we are admin
            if ( ( userDn != null ) && ( !userDn.equals( principalDn ) ) )
            {
                // Are we admin ?
                if ( !requestor.getCoreSession().isAdministrator() )
                {
                    // No : error
                    LOG.error( "Cannot access to another user's password to modify it" );
                    requestor.getIoSession().write( new PwdModifyResponseImpl(
                        req.getMessageId(), ResultCodeEnum.INSUFFICIENT_ACCESS_RIGHTS,
                        "Cannot access to another user's password to modify it" ) );
                }
                else
                {
                    // We are administrator, we can try to modify the user's credentials
                    modifyUserPassword( requestor, userDn, oldPassword, newPassword, req );
                }
            }
            else
            {
                // We are trying to modify our own password
                modifyOwnPassword( requestor, principalDn, oldPassword, newPassword, req );
            }
        }
        else
        {
            // The user is not authenticated : we have to use the provided userIdentity
            // and the oldPassword to check if the user is present
            BindOperationContext bindContext = new BindOperationContext( adminSession );
            bindContext.setDn( userDn );
            bindContext.setCredentials( oldPassword );

            try
            {
                service.getOperationManager().bind( bindContext );
            }
            catch ( LdapException le )
            {
                // We can't bind with the provided information : we thus can't
                // change the password...
                requestor.getIoSession().write( new PwdModifyResponseImpl(
                    req.getMessageId(), ResultCodeEnum.INVALID_CREDENTIALS ) );

                return;
            }

            // Ok, we were able to bind using the userIdentity and the password. Let's
            // modify the password now
            ModifyOperationContext modifyContext = new ModifyOperationContext( adminSession );
            modifyContext.setDn( userDn );
            List<Modification> modifications = new ArrayList<Modification>();
            Modification modification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE,
                SchemaConstants.USER_PASSWORD_AT, newPassword );
            modifications.add( modification );
            modifyContext.setModItems( modifications );

            try
            {
                service.getOperationManager().modify( modifyContext );

                // Ok, all done
                requestor.getIoSession().write( new PwdModifyResponseImpl(
                    req.getMessageId(), ResultCodeEnum.SUCCESS ) );
            }
View Full Code Here

Examples of org.apache.directory.server.core.api.DirectoryService

        })
    @CreateLdapServer(transports =
        { @CreateTransport(port = 16000, protocol = "LDAP") })
    public static void startProvider( final CountDownLatch counter ) throws Exception
    {
        DirectoryService provDirService = DSAnnotationProcessor.getDirectoryService();

        providerServer = ServerAnnotationProcessor.getLdapServer( provDirService );
        providerServer.setReplicationReqHandler( new SyncReplRequestHandler() );
        providerServer.startReplicationProducer();
View Full Code Here

Examples of org.apache.directory.server.core.api.DirectoryService

            refreshInterval = 1000,
            replicaId = 1
        )
        public static void startConsumer( final CountDownLatch counter ) throws Exception
    {
        DirectoryService provDirService = DSAnnotationProcessor.getDirectoryService();
        consumerServer = ServerAnnotationProcessor.getLdapServer( provDirService );

        final ReplicationConsumerImpl consumer = ( ReplicationConsumerImpl ) ServerAnnotationProcessor.createConsumer();

        List<ReplicationConsumer> replConsumers = new ArrayList<ReplicationConsumer>();
        replConsumers.add( consumer );

        consumerServer.setReplConsumers( replConsumers );

        Runnable r = new Runnable()
        {
            public void run()
            {
                try
                {
                    DirectoryService ds = consumerServer.getDirectoryService();

                    Dn configDn = new Dn( ds.getSchemaManager(), "ads-replConsumerId=localhost,ou=system" );
                    consumer.getConfig().setConfigEntryDn( configDn );

                    Entry provConfigEntry = new DefaultEntry( ds.getSchemaManager(), configDn,
                        "objectClass: ads-replConsumer",
                        "ads-replConsumerId: localhost",
                        "ads-searchBaseDN", consumer.getConfig().getBaseDn(),
                        "ads-replProvHostName", consumer.getConfig().getRemoteHost(),
                        "ads-replProvPort", String.valueOf( consumer.getConfig().getRemotePort() ),
View Full Code Here

Examples of org.apache.ldap.server.DirectoryService

    public void testNoBypass() throws NamingException
    {
        Name dn = new LdapName( "ou=system" );
        Context ctx = new DeadContext();
        DirectoryService ds = new MockDirectoryService();
        DirectoryPartitionNexusProxy proxy = new DirectoryPartitionNexusProxy( ctx, ds );
        Invocation i = new Invocation( proxy, ctx, "lookup", new Object[]{ dn } );
        InvocationStack.getInstance().push( i );

        try
View Full Code Here

Examples of org.elasticsearch.index.store.DirectoryService

        document.add(versionField);
        return new ParsedDocument(uidField, versionField, id, type, routing, timestamp, ttl, Arrays.asList(document), analyzer, source, mappingsModified);
    }

    protected Store createStore() throws IOException {
        DirectoryService directoryService = new RamDirectoryService(shardId, EMPTY_SETTINGS);
        return new Store(shardId, EMPTY_SETTINGS, null, directoryService, new LeastUsedDistributor(directoryService));
    }
View Full Code Here

Examples of org.nuxeo.ecm.directory.api.DirectoryService

            RelationshipKind kind) {
        if (kind == null) {
            throw new ClientRuntimeException("Type cannot be null");
        }

        DirectoryService directoryService = Framework.getLocalService(DirectoryService.class);
        Session relationshipsDirectory = null;
        try {
            relationshipsDirectory = directoryService.open(RELATIONSHIP_DIRECTORY_NAME);
            // try to get an existing entry
            Map<String, Serializable> relationship = new HashMap<String, Serializable>();
            relationship.put(RELATIONSHIP_FIELD_ACTOR, actorId);
            relationship.put(RELATIONSHIP_FIELD_TARGET, targetId);
            relationship.put(RELATIONSHIP_FIELD_KIND, kind.toString());
View Full Code Here

Examples of scfs.directoryService.DirectoryService

        } catch (Exception e1) {    e1.printStackTrace(); }
      }
      namespace = new NoSharingDirectoryService(namespaceStats.getIdPath(), namespaceStats.getKey(), true);
    }

    DirectoryService redirect = new DirectoryServiceRedirect(clientId, directoryService, namespace);

    this.lockService = new LockService(accessor, clientId);
    this.daS = new StorageService(clientId, config.getIsOptimizedCache(), config.getIsNomBlockCloud(), 4, 0, redirect, lockService);
    if(config.isNonSharing()){
      try {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.