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

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


    }

    public byte[] getProcessImage(String processId) {

        QName qName = decode(processId);
        SVGInterface svg = createSVG(qName);
        return svg.toPNGBytes();
    }
View Full Code Here


    private SVGInterface createSVG(QName qName) {

        // generate new
        InputStream in = getBpelDescriptor(qName);

        SVGInterface svg = null;

        try {
            svg = BPEL2SVGUtil.generate(in);

            if (svg == null)
View Full Code Here

   
    protected static SVGImpl generateSVGImpl(java.io.InputStream is) throws java.io.IOException {
      byte[] b=new byte[is.available()];
      is.read(b);
   
      BPELInterface bpel = new BPELImpl();
        OMElement bpelStr = bpel.load(new String(b));
       
        bpel.processBpelString(bpelStr);

        LayoutManager layoutManager = BPEL2SVGFactory.getInstance().getLayoutManager();
        layoutManager.setVerticalLayout(true);
        layoutManager.setYSpacing(20);
        layoutManager.setYSpacing(50);
        layoutManager.layoutSVG(bpel.getRootActivity());

        SVGImpl svg = new SVGImpl();
        svg.setRootActivity(bpel.getRootActivity());
       
        return(svg);
    }
View Full Code Here

   * @param transformer The optional image transformer
   * @throws java.io.IOException Failed to generate the representation
   */
    public static void generate(java.io.InputStream is, java.io.OutputStream os,
                SVGImageTransformer transformer) throws java.io.IOException {
        SVGImpl svg = generateSVGImpl(is);
       
        if (transformer == null) {
          String str=svg.getHeaders()+svg.generateSVGString();
          os.write(str.getBytes());
        } else {
          transformer.transform(svg, os);
        }
    }
View Full Code Here

        layoutManager.setVerticalLayout(true);
        layoutManager.setYSpacing(20);
        layoutManager.setYSpacing(50);
        layoutManager.layoutSVG(bpel.getRootActivity());

        SVGImpl svg = new SVGImpl();
        svg.setRootActivity(bpel.getRootActivity());
       
        return(svg);
    }
View Full Code Here

    public String getServiceName(String serverName)
            throws DirectoryServerManagerException {

        String[] components = serverName.split("/");
        if (components == null || components.length != 2) {
            throw new DirectoryServerManagerException("Invalid server name provided. " +
                    "Could not retrieve service component.");
        }

        // Check whether there is a uid by that name
        if (isExistingServiceUid(components[0])) {
View Full Code Here

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

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

        String filter =
                "(&(" + LDAPServerManagerConstants.LDAP_UID + "=" + uid + ")" + getServerPrincipleIncludeString() + ")";

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

        try {
            NamingEnumeration<SearchResult> namingEnumeration = dirContext.search(searchBase, filter, searchControls);
            return namingEnumeration.hasMore();

        } catch (NamingException e) {
            log.error("Unable to check whether service exists in directory server. UID - " + uid, e);
            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) {
            log.error("Unable to retrieve directory context.", e);
            throw new DirectoryServerManagerException("Unable to retrieve directory context.", e);
        }

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

        String filter = getServicePrincipleFilter(servicePrinciple);

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

        try {
            NamingEnumeration<SearchResult> namingEnumeration = dirContext.search(searchBase, filter, searchControls);
            return namingEnumeration.hasMore();

        } catch (NamingException e) {
            String message = "Unable to search entry with search base " + searchBase + ", filter -" + filter;
            log.error(message, e);
            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

            throw new DirectoryServerManagerException("Invalid server name provided - " + serverName +
                    ". Server name should take following form, ftp/wso2.example.com");
        }*/

        if (!(credentials instanceof String)) {
            throw new DirectoryServerManagerException("Invalid credentials provided");
        }

        /*String password = (String) credentials;

        if (!isPasswordValid(password)) {
            throw new DirectoryServerManagerException("Password does not meet password policy requirements.");
        }*/

        DirContext dirContext;
        try {
            dirContext = this.connectionSource.getContext();
        } catch (UserStoreException e) {
            throw new DirectoryServerManagerException("An error occurred while retrieving LDAP connection context.", e);
        }

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

            dirContext = (DirContext) dirContext.lookup(searchBase);

            BasicAttributes basicAttributes = new BasicAttributes(true);

            // Put only service name as uid. i.e. if server name is like ftp/wso2.example.com
            // then add only ftp as uid
            String serverUid = getServiceName(serverName);

            constructBasicAttributes(basicAttributes, serverUid, serverName, credentials, serverDescription,
                    LDAPServerManagerConstants.SERVER_PRINCIPAL_ATTRIBUTE_VALUE);

            dirContext.bind(LDAPServerManagerConstants.LDAP_UID + "=" + serverUid, null, basicAttributes);

        } catch (NamingException e) {
            String message = "Can not access the directory context or user " +
                    "already exists in the system";
            log.error(message, e);
            throw new DirectoryServerManagerException(message, e);
        } finally {
            try {
                JNDIUtil.closeContext(dirContext);
            } catch (UserStoreException e) {
                log.error("Unable to close directory context.", e);
View Full Code Here

        searchCtls.setSearchScope(SearchControls.SUBTREE_SCOPE);
        searchCtls.setCountLimit(maxItemLimit);

        if (filter.contains("?") || filter.contains("**")) {
            log.error("Invalid search character " + filter);
            throw new DirectoryServerManagerException(
                    "Invalid character sequence entered for service principle search. Please enter valid sequence.");
        }

        StringBuffer searchFilter;
        searchFilter = new StringBuffer(this.realmConfiguration.getUserStoreProperty(LDAPConstants.USER_FILTER));
        String searchBase = this.realmConfiguration.getUserStoreProperty(LDAPConstants.USER_SEARCH_BASE);

        StringBuffer buff = new StringBuffer();
        buff.append("(&").append(searchFilter).append("(")
                .append(LDAPServerManagerConstants.KRB5_PRINCIPAL_NAME_ATTRIBUTE).append("=")
                .append(filter).append(")").append(getServerPrincipleIncludeString()).append(")");

        String returnedAtts[] = {LDAPServerManagerConstants.KRB5_PRINCIPAL_NAME_ATTRIBUTE,
                LDAPServerManagerConstants.LDAP_COMMON_NAME};
        searchCtls.setReturningAttributes(returnedAtts);
        DirContext dirContext = null;
        try {
            dirContext = connectionSource.getContext();
            NamingEnumeration<SearchResult> answer = dirContext.search(searchBase, buff.toString(),
                    searchCtls);
            List<ServerPrinciple> list = new ArrayList<ServerPrinciple>();
            int i = 0;
            while (answer.hasMoreElements() && i < maxItemLimit) {
                SearchResult sr = answer.next();
                if (sr.getAttributes() != null) {
                    Attribute serverNameAttribute = sr.getAttributes()
                            .get(LDAPServerManagerConstants.KRB5_PRINCIPAL_NAME_ATTRIBUTE);
                    Attribute serverDescription = sr.getAttributes().get(LDAPServerManagerConstants.LDAP_COMMON_NAME);
                    if (serverNameAttribute != null) {

                        ServerPrinciple principle;
                        String serviceName;
                        String serverPrincipleFullName = (String) serverNameAttribute.get();

                        if (serverPrincipleFullName.toLowerCase(Locale.ENGLISH)
                                .contains(LDAPServerManagerConstants.KERBEROS_TGT)) {
                            continue;   
                        }

                        if (serverPrincipleFullName.contains("@")) {
                            serviceName = serverPrincipleFullName.split("@")[0];
                        } else {
                            serviceName = serverPrincipleFullName;
                        }

                        if (serverDescription != null) {
                            principle = new ServerPrinciple(serviceName,
                                    (String) serverDescription.get());
                        } else {

                            principle = new ServerPrinciple(serviceName);
                        }

                        list.add(principle);
                        i++;
                    }
                }
            }

            serverNames = list.toArray(new ServerPrinciple[list.size()]);
            Arrays.sort(serverNames);

        } catch (NamingException e) {
            log.error(e.getMessage(), e);
            throw new DirectoryServerManagerException("Unable to list service principles.", e);
        } catch (UserStoreException e) {
            log.error("Unable to retrieve LDAP connection context.", e);
            throw new DirectoryServerManagerException("Unable to list service principles.", e);
        } finally {
            try {
                JNDIUtil.closeContext(dirContext);
            } catch (UserStoreException e) {
                log.error("Unable to close directory context.", e);
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.