Package org.wso2.carbon.directory.server.manager

Examples of org.wso2.carbon.directory.server.manager.DirectoryServerManagerException


                MessageDigest messageDigest = MessageDigest.getInstance(passwordHashMethod);
                byte[] digestValue = messageDigest.digest(password.getBytes());
                passwordToStore = "{" + passwordHashMethod + "}" + Base64.encode(digestValue);

            } catch (NoSuchAlgorithmException e) {
                throw new DirectoryServerManagerException("Invalid hashMethod", e);
            }
        }

        return passwordToStore;
    }
View Full Code Here


                    if (password.startsWith("{")) {
                        passwordHashMethod = password.substring(password.indexOf("{") + 1, password.indexOf("}"));
                    }

                    if (!password.equals(getPasswordToStore((String) oldCredential, passwordHashMethod))) {
                        throw new DirectoryServerManagerException("Old password does not match");
                    }
                }
            } catch (NamingException e) {
                log.error("Unable to retrieve old password details. ");
                throw new DirectoryServerManagerException("Could not find old password details");
            }
        }

        Attribute passwordAttribute = new BasicAttribute(LDAPServerManagerConstants.LDAP_PASSWORD);
        passwordAttribute.add(getPasswordToStore((String) newPassword, passwordHashMethod));
View Full Code Here

        DirContext dirContext;

        try {
            dirContext = this.connectionSource.getContext();
        } catch (UserStoreException e) {
            throw new DirectoryServerManagerException("Unable to retrieve directory connection.", e);
        }

        //first search the existing user entry.
        String searchBase = this.realmConfiguration.getUserStoreProperty(LDAPConstants.USER_SEARCH_BASE);
        String searchFilter = getServicePrincipleFilter(serverName);

        SearchControls searchControls = new SearchControls();
        searchControls.setSearchScope(SearchControls.SUBTREE_SCOPE);
        searchControls.setReturningAttributes(new String[]{LDAPServerManagerConstants.LDAP_PASSWORD});

        try {
            NamingEnumeration<SearchResult> namingEnumeration = dirContext
                    .search(searchBase, searchFilter, searchControls);
            // here we assume only one user
            while (namingEnumeration.hasMore()) {

                BasicAttributes basicAttributes = new BasicAttributes(true);

                SearchResult searchResult = namingEnumeration.next();
                Attributes attributes = searchResult.getAttributes();

                Attribute userPassword = attributes.get(LDAPServerManagerConstants.LDAP_PASSWORD);
                Attribute newPasswordAttribute =
                        getChangePasswordAttribute(userPassword, oldCredential, newCredentials);
                basicAttributes.put(newPasswordAttribute);

                String dnName = searchResult.getName();
                dirContext = (DirContext) dirContext.lookup(searchBase);

                dirContext.modifyAttributes(dnName, DirContext.REPLACE_ATTRIBUTE, basicAttributes);
            }

        } catch (NamingException e) {
            log.error("Unable to update server principle password details. Server name - " + serverName);
            throw new DirectoryServerManagerException("Can not access the directory service", e);
        } finally {
            try {
                JNDIUtil.closeContext(dirContext);
            } catch (UserStoreException e) {
                log.error("Unable to close directory context.", e);
View Full Code Here

        DirContext dirContext;
        try {
            dirContext = this.connectionSource.getContext();
        } catch (UserStoreException e) {
            throw new DirectoryServerManagerException("Unable to retrieve directory connection.", e);
        }

        //first search the existing user entry.
        String searchBase = this.realmConfiguration.getUserStoreProperty(LDAPConstants.USER_SEARCH_BASE);
        String searchFilter = getServicePrincipleFilter(serverName);

        SearchControls searchControls = new SearchControls();
        searchControls.setSearchScope(SearchControls.SUBTREE_SCOPE);
        searchControls.setReturningAttributes(new String[]{LDAPServerManagerConstants.LDAP_PASSWORD});

        try {
            NamingEnumeration<SearchResult> namingEnumeration = dirContext
                    .search(searchBase, searchFilter, searchControls);
            // here we assume only one user
            while (namingEnumeration.hasMore()) {

                SearchResult searchResult = namingEnumeration.next();
                Attributes attributes = searchResult.getAttributes();

                Attribute userPassword = attributes.get(LDAPServerManagerConstants.LDAP_PASSWORD);

                NamingEnumeration passwords = userPassword.getAll();

                String passwordHashMethod = null;
                if (passwords.hasMore()) {
                    byte[] byteArray = (byte[]) passwords.next();
                    String password = new String(byteArray);

                    if (password.startsWith("{")) {
                        passwordHashMethod = password.substring(password.indexOf("{") + 1, password.indexOf("}"));
                    }

                    return password.equals(getPasswordToStore((String) existingCredentials, passwordHashMethod));
                }
            }

        } catch (NamingException e) {
            log.error("Failed, validating password. " +
                    "Can not access the directory service", e);
            throw new DirectoryServerManagerException("Failed, validating password. " +
                    "Can not access the directory service", e);
        } finally {
            try {
                JNDIUtil.closeContext(dirContext);
            } catch (UserStoreException e) {
View Full Code Here

        DirContext dirContext;
        try {
            dirContext = this.connectionSource.getContext();
        } catch (UserStoreException e) {
            throw new DirectoryServerManagerException("Unable to retrieve directory connection.", e);
        }

        String searchBase = this.realmConfiguration.getUserStoreProperty(LDAPConstants.USER_SEARCH_BASE);

        //first search the existing user entry.
        String searchFilter = getServicePrincipleFilter(serverName);

        SearchControls searchControls = new SearchControls();
        searchControls.setSearchScope(SearchControls.SUBTREE_SCOPE);
        searchControls.setReturningAttributes(new String[]{"uid"});
        try {
            NamingEnumeration<SearchResult> namingEnumeration = dirContext.
                    search(searchBase, searchFilter, searchControls);

            // here we assume only one user
            if (namingEnumeration.hasMore()) {

                SearchResult searchResult;

                searchResult = namingEnumeration.next();

                Attributes attributes = searchResult.getAttributes();

                Attribute userId = attributes.get("uid");
                return (String) userId.get();
            } else {
                return null;
            }

        } catch (NamingException e) {
            log.error("Could not find user id for given server " + serverName, e);
            throw new DirectoryServerManagerException("Could not find user id for given server " + serverName, e);
        } finally {
            try {
                JNDIUtil.closeContext(dirContext);
            } catch (UserStoreException e) {
                log.error("Unable to close directory context.", e);
View Full Code Here

        DirContext dirContext;
        try {
            dirContext = this.connectionSource.getContext();
        } catch (UserStoreException e) {
            throw new DirectoryServerManagerException("Unable to retrieve directory connection.", e);
        }

        String searchBase = this.realmConfiguration.getUserStoreProperty(LDAPConstants.USER_SEARCH_BASE);

        String userId = lookupUserId(serverName);

        if (userId == null) {
            throw new DirectoryServerManagerException("Could not find user id for given server principle " +
                    serverName);
        }

        try {
            dirContext = (DirContext) dirContext.lookup(searchBase);
            dirContext.unbind("uid=" + userId);

        } catch (NamingException e) {
            log.error("Could not remove service principle " + serverName, e);
            throw new DirectoryServerManagerException("Could not remove service principle " + serverName, e);
        } finally {
            try {
                JNDIUtil.closeContext(dirContext);
            } catch (UserStoreException e) {
                log.error("Unable to close directory context.", e);
View Full Code Here

        }

        public void run() {
            try {
                MessageContext msgCtx = ((Axis2MessageContext) synCtx).getAxis2MessageContext();
                Event<MessageContext> event = new Event(msgCtx);
                subscriptions = subscriptionManager.getMatchingSubscriptions(event);
            } catch (EventException e) {
                handleException("Matching subscriptions fetching error", e);
            }
View Full Code Here

     * @throws EventException event
     */
    private void processGetStatusRequest(MessageContext mc,
                                         ResponseMessageBuilder messageBuilder)
            throws AxisFault, EventException {
        Subscription subscription =
                SubscriptionMessageBuilder.createGetStatusMessage(mc);
        if (log.isDebugEnabled()) {
            log.debug("GetStatus request recived for SynapseSubscription ID : " +
                    subscription.getId());
        }
        subscription = subscriptionManager.getSubscription(subscription.getId());
        if (subscription != null) {
            if (log.isDebugEnabled()) {
                log.debug("Sending GetStatus responce for SynapseSubscription ID : " +
                        subscription.getId());
            }
            //send the responce
            SOAPEnvelope soapEnvelope = messageBuilder.genGetStatusResponse(subscription);
            dispatchResponse(soapEnvelope, EventingConstants.WSE_GET_STATUS_RESPONSE,
                    mc, false);
View Full Code Here

            // Adding static subscriptions
            List<Subscription> staticSubscriptionList =
                    eventSource.getSubscriptionManager().getStaticSubscriptions();
            for (Iterator<Subscription> iterator = staticSubscriptionList.iterator();
                 iterator.hasNext();) {
                Subscription staticSubscription = iterator.next();
                OMElement staticSubElem =
                        fac.createOMElement("subscription", XMLConfigConstants.SYNAPSE_OMNAMESPACE);
                staticSubElem.addAttribute(
                        fac.createOMAttribute("id", nullNS, staticSubscription.getId()));
                OMElement filterElem =
                        fac.createOMElement("filter", XMLConfigConstants.SYNAPSE_OMNAMESPACE);
                filterElem.addAttribute(fac.createOMAttribute("source", nullNS,
                        (String) staticSubscription.getFilterValue()));
                filterElem.addAttribute(fac.createOMAttribute("dialect", nullNS,
                        (String) staticSubscription.getFilterDialect()));
                staticSubElem.addChild(filterElem);
                OMElement endpointElem =
                        fac.createOMElement("endpoint", XMLConfigConstants.SYNAPSE_OMNAMESPACE);
                OMElement addressElem =
                        fac.createOMElement("address", XMLConfigConstants.SYNAPSE_OMNAMESPACE);
                addressElem.addAttribute(
                        fac.createOMAttribute("uri", nullNS, staticSubscription.getEndpointUrl()));
                endpointElem.addChild(addressElem);
                staticSubElem.addChild(endpointElem);
                if (staticSubscription.getExpires() != null) {
                    OMElement expiresElem =
                            fac.createOMElement("expires", XMLConfigConstants.SYNAPSE_OMNAMESPACE);
                    fac.createOMText(expiresElem,
                            ConverterUtil.convertToString(staticSubscription.getExpires()));
                    staticSubElem.addChild(expiresElem);
                }
                evenSourceElem.addChild(staticSubElem);
            }
View Full Code Here


    public SynapseSubscription() {
        this.setId(UIDGenerator.generateURNString());
        this.setDeliveryMode(EventingConstants.WSE_DEFAULT_DELIVERY_MODE);
        SubscriptionData subscriptionData = new SubscriptionData();
        subscriptionData.setProperty(SynapseEventingConstants.STATIC_ENTRY, "false");
        this.setSubscriptionData(subscriptionData);
    }
View Full Code Here

TOP

Related Classes of org.wso2.carbon.directory.server.manager.DirectoryServerManagerException

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.