Package org.wso2.carbon.issue.tracker.adapter.api

Examples of org.wso2.carbon.issue.tracker.adapter.api.GenericCredentials


            PrivilegedCarbonContext.endTenantFlow();
        }
    }

    private void setTenantCredentialsInCarbonContext() {
        PrivilegedCarbonContext cc = PrivilegedCarbonContext.getThreadLocalCarbonContext();
        cc.setTenantId(ownerTenantId);
        cc.setTenantDomain(ownerTenantDomain);
    }
View Full Code Here


     * @throws IssueTrackerException
     */
    public GenericCredentials getAccountCredentials(String name) throws IssueTrackerException {

        List<AccountInfo> accountInfoList = null;
        GenericCredentials credentials = new GenericCredentials();

        try {
            accountInfoList = this.getAccountInfo();
        } catch (IssueTrackerException e) {
            ExceptionHandler.handleException("Error in retrieving account info from registry", e, log);
        }

        if (null != accountInfoList) {

            for (AccountInfo info : accountInfoList) {

                if (name.equals(info.getKey())) {
                    credentials.setUrl(info.getCredentials().getUrl());
                    credentials.setUsername(info.getCredentials().getUsername());
                    credentials.setPassword(info.getCredentials().getPassword());
                    break;
                }
            }

        }
View Full Code Here


    public AccountInfo getAccount(String name) throws IssueTrackerException {

        List<AccountInfo> accountInfoList = null;
        GenericCredentials credentials = new GenericCredentials();
        AccountInfo accountInfo = null;

        try {
            accountInfoList = this.getAccountInfo();
        } catch (IssueTrackerException e) {
View Full Code Here

            }
        } catch (RegistryException e) {
            ExceptionHandler.handleException("Error accessing registry", e, log);
        }

        GenericCredentials credentials;
        credentials = accountInfo.getCredentials();

        if (resource != null) {
            resource.addProperty(IssueTrackerConstants.ACCOUNT_KEY, accountInfo.getKey());
            resource.addProperty(IssueTrackerConstants.ISSUE_TRACKER_URL, credentials.getUrl());
            resource.addProperty(IssueTrackerConstants.ACCOUNT_USERNAME, credentials.getUsername());

            if (accountInfo.isAutoReportingEnable()) {

                AutoReportingSettings settings = accountInfo.getAutoReportingSettings();
                resource.addProperty(IssueTrackerConstants.AUTO_REPORTING, IssueTrackerConstants.IS_AUTO_REPORTING_ENABLED);
                resource.addProperty(IssueTrackerConstants.AUTO_REPORTING_PROJECT, settings.getProjectName());
                resource.addProperty(IssueTrackerConstants.AUTO_REPORTING_PRIORITY, settings.getPriority());
                resource.addProperty(IssueTrackerConstants.AUTO_REPORTING_ISSUE_TYPE, settings.getIssueType());

            } else {
                resource.addProperty(IssueTrackerConstants.AUTO_REPORTING, IssueTrackerConstants.IS_AUTO_REPORTING_DISABLED);
            }

            //encrypt and store password

            byte[] bytes = (credentials.getPassword()).getBytes();

            try {
                byte[] encrypted = CryptoUtil.getDefaultCryptoUtil().encrypt(bytes);
                String base64String = new sun.misc.BASE64Encoder().encode(encrypted);
                resource.addProperty(IssueTrackerConstants.ACCOUNT_PASSWORD, base64String);
View Full Code Here

                    String[] paths = collection.getChildren();

                    for (String path : paths) {

                        AccountInfo accountInfo = new AccountInfo();
                        GenericCredentials credentials = new GenericCredentials();
                        Resource resource = registry.get(path);

                        List<String> accountPropertySet= resource.getPropertyValues(IssueTrackerConstants.ACCOUNT_KEY);
                        accountInfo.setKey(accountPropertySet.get(accountPropertySet.size()-1));

                        List<String> urlPropertySet = resource.getPropertyValues(IssueTrackerConstants.ISSUE_TRACKER_URL);                               
                        String url = urlPropertySet.get(urlPropertySet.size()-1);

                        List<String> usernamePropertySet= resource.getPropertyValues(IssueTrackerConstants.ACCOUNT_USERNAME);
                        String username = usernamePropertySet.get(usernamePropertySet.size()-1);

                        List<String> passwordPropertySet = resource.getPropertyValues(IssueTrackerConstants.ACCOUNT_PASSWORD);
                        String encryptedPassword = passwordPropertySet.get(passwordPropertySet.size()-1);

                        byte[] base64DecodedBytes = (new BASE64Decoder()).decodeBuffer(encryptedPassword);

                        String password = new String(CryptoUtil.getDefaultCryptoUtil().decrypt(base64DecodedBytes));


                        String isAutoReportingEnabled = resource.getProperty(IssueTrackerConstants.AUTO_REPORTING);

                        if (null != isAutoReportingEnabled &&
                                IssueTrackerConstants.IS_AUTO_REPORTING_ENABLED.equals(isAutoReportingEnabled)) {
                            accountInfo.setAutoReportingEnable(true);

                            AutoReportingSettings settings=new AutoReportingSettings();
                            String projectName=resource.getProperty(IssueTrackerConstants.AUTO_REPORTING_PROJECT);
                            settings.setProjectName(projectName);
                            String priority = resource.getProperty(IssueTrackerConstants.AUTO_REPORTING_PRIORITY);
                            settings.setPriority(priority);
                            String type = resource.getProperty(IssueTrackerConstants.AUTO_REPORTING_ISSUE_TYPE);
                            settings.setIssueType(type);
                            accountInfo.setAutoReportingSettings(settings);
                        } else {
                            accountInfo.setAutoReportingEnable(false);
                        }


                        if (!"".equals(url) && !"".equals(username) && !"".equals(password)) {
                            credentials.setUrl(url);
                            credentials.setUsername(username);
                            credentials.setPassword(password);
                            accountInfo.setCredentials(credentials);
                            accounts.add(accountInfo);
                        }
                    }
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

                    .getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, "class"));
            if (clazz != null) {
                String className = clazz.getAttributeValue();
                try {
                    Class subscriptionManagerClass = Class.forName(className);
                    SubscriptionManager manager =
                            (SubscriptionManager) subscriptionManagerClass.newInstance();
                    Iterator itr = subscriptionManagerElem.getChildrenWithName(PROPERTIES_QNAME);
                    while (itr.hasNext()) {
                        OMElement propElem = (OMElement) itr.next();
                        String propName =
                                propElem.getAttribute(new QName("name")).getAttributeValue();
                        String propValue =
                                propElem.getAttribute(new QName("value")).getAttributeValue();
                        if (propName != null && !"".equals(propName.trim()) &&
                                propValue != null && !"".equals(propValue.trim())) {

                            propName = propName.trim();
                            propValue = propValue.trim();

                            PasswordManager passwordManager =
                                    PasswordManager.getInstance();
                            String key = eventSource.getName() + "." + propName;

                            if (passwordManager.isInitialized()
                                    && passwordManager.isTokenProtected(key)) {
                                eventSource.putConfigurationProperty(propName, propValue);
                                propValue = passwordManager.resolve(propValue);
                            }

                            manager.addProperty(propName, propValue);
                        }
                    }
                    eventSource.setSubscriptionManager(manager);
                    eventSource.getSubscriptionManager()
                            .init(); // Initialise before doing further processing, required for static subscriptions
View Full Code Here

TOP

Related Classes of org.wso2.carbon.issue.tracker.adapter.api.GenericCredentials

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.