Package org.wso2.carbon.registry.resource.beans

Examples of org.wso2.carbon.registry.resource.beans.PermissionEntry


* TODO: class description
*/
public final class Util {

    public static void checkAccess(String ownerTenantDomain, int ownerTenantId) {
        CarbonContext carbonContext = getCarbonContext();
        String callerTenantDomain = carbonContext.getTenantDomain();
        if (callerTenantDomain == null) {
            throw new IllegalStateException("Caller tenant domain cannot be null");
        }
        int callerTenantId = carbonContext.getTenantId();
        if (callerTenantId == MultitenantConstants.INVALID_TENANT_ID) {
            throw new IllegalStateException("Caller Tenant ID cannot be " + MultitenantConstants.INVALID_TENANT_ID);
        }

        if (callerTenantDomain.equals(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME) &&
View Full Code Here


                                        "],[" + callerTenantId + "]}");
        }
    }

    private static CarbonContext getCarbonContext() {
        CarbonContext carbonContext = CarbonContext.getThreadLocalCarbonContext();
        if (carbonContext == null) {
            throw new IllegalStateException("CarbonContext cannot be null");
        }
        return carbonContext;
    }
View Full Code Here

            PrivilegedCarbonContext.endTenantFlow();
        }
    }

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

        for (String raUser : raUsers) {
            if (raUser.equals(systemUserName) || raUser.equals(adminUserName)) {
                continue;
            }
            if (userPermissionMap.containsKey(raUser)) {
                PermissionEntry permission = userPermissionMap.get(raUser);
                permission.setReadAllow(true);
            } else {
                PermissionEntry permission = new PermissionEntry();
                permission.setUserName(raUser);
                permission.setReadAllow(true);
                userPermissionMap.put(raUser, permission);
            }
        }

        String[] rdUsers = authorizer.getExplicitlyDeniedUsersForResource(path, ActionConstants.GET);
        for (String rdUser : rdUsers) {
            if (rdUser.equals(systemUserName) || rdUser.equals(adminUserName)) {
                continue;
            }
            if (userPermissionMap.containsKey(rdUser)) {
                PermissionEntry permission = userPermissionMap.get(rdUser);
                permission.setReadDeny(true);
            } else {
                PermissionEntry permission = new PermissionEntry();
                permission.setUserName(rdUser);
                permission.setReadDeny(true);
                userPermissionMap.put(rdUser, permission);
            }
        }

        String[] waUsers = authorizer.getExplicitlyAllowedUsersForResource(path, ActionConstants.PUT);
        for (String waUser : waUsers) {
            if (waUser.equals(systemUserName) || waUser.equals(adminUserName)) {
                continue;
            }
            if (userPermissionMap.containsKey(waUser)) {
                PermissionEntry permission = userPermissionMap.get(waUser);
                permission.setWriteAllow(true);
            } else {
                PermissionEntry permission = new PermissionEntry();
                permission.setUserName(waUser);
                permission.setWriteAllow(true);
                userPermissionMap.put(waUser, permission);
            }
        }
       
        String[] wdUsers = authorizer.getExplicitlyDeniedUsersForResource(path, ActionConstants.PUT);
        for (String wdUser : wdUsers) {
            if (wdUser.equals(systemUserName) || wdUser.equals(adminUserName)) {
                continue;
            }
            if (userPermissionMap.containsKey(wdUser)) {
                PermissionEntry permission = userPermissionMap.get(wdUser);
                permission.setWriteDeny(true);
            } else {
                PermissionEntry permission = new PermissionEntry();
                permission.setUserName(wdUser);
                permission.setWriteDeny(true);
                userPermissionMap.put(wdUser, permission);
            }
        }

        String[] daUsers = authorizer.getExplicitlyAllowedUsersForResource(path, ActionConstants.DELETE);
        for (String daUser : daUsers) {
            if (daUser.equals(systemUserName) || daUser.equals(adminUserName)) {
                continue;
            }
            if (userPermissionMap.containsKey(daUser)) {
                PermissionEntry permission = userPermissionMap.get(daUser);
                permission.setDeleteAllow(true);
            } else {
                PermissionEntry permission = new PermissionEntry();
                permission.setUserName(daUser);
                permission.setDeleteAllow(true);
                userPermissionMap.put(daUser, permission);
            }
        }

        String[] ddUsers = authorizer.getExplicitlyDeniedUsersForResource(path, ActionConstants.DELETE);
        for (String ddUser : ddUsers) {
            if (ddUser.equals(systemUserName) || ddUser.equals(adminUserName)) {
                continue;
            }
            if (userPermissionMap.containsKey(ddUser)) {
                PermissionEntry permission = userPermissionMap.get(ddUser);
                permission.setDeleteDeny(true);
            } else {
                PermissionEntry permission = new PermissionEntry();
                permission.setUserName(ddUser);
                permission.setDeleteDeny(true);
                userPermissionMap.put(ddUser, permission);
            }
        }


        String[] aaUsers = authorizer.
                getExplicitlyAllowedUsersForResource(path, AccessControlConstants.AUTHORIZE);
        for (String aaUser : aaUsers) {
            if (aaUser.equals(systemUserName) || aaUser.equals(adminUserName)) {
                continue;
            }
            if (userPermissionMap.containsKey(aaUser)) {
                PermissionEntry permission = userPermissionMap.get(aaUser);
                permission.setAuthorizeAllow(true);
            } else {
                PermissionEntry permission = new PermissionEntry();
                permission.setUserName(aaUser);
                permission.setAuthorizeAllow(true);
                userPermissionMap.put(aaUser, permission);
            }
        }
        String[] adUsers = authorizer.
                getExplicitlyDeniedUsersForResource(path, AccessControlConstants.AUTHORIZE);
        for (String adUser : adUsers) {
            if (adUser.equals(systemUserName) || adUser.equals(adminUserName)) {
                continue;
            }
            if (userPermissionMap.containsKey(adUser)) {
                PermissionEntry permission = userPermissionMap.get(adUser);
                permission.setAuthorizeDeny(true);
            } else {
                PermissionEntry permission = new PermissionEntry();
                permission.setUserName(adUser);
                permission.setAuthorizeDeny(true);
                userPermissionMap.put(adUser, permission);
            }
        }

View Full Code Here

        for (String raRole : raRoles) {
            if (raRole.equals(adminRoleName)) {
                continue;
            }
            if (rolePermissionMap.containsKey(raRole)) {
                PermissionEntry permission = rolePermissionMap.get(raRole);
                permission.setReadAllow(true);
            } else {
                PermissionEntry permission = new PermissionEntry();
                permission.setUserName(raRole);
                permission.setReadAllow(true);
                rolePermissionMap.put(raRole, permission);
            }
        }

        String[] rdRoles = authorizer.getDeniedRolesForResource(path, ActionConstants.GET);
        for (String rdRole : rdRoles) {
            if (rolePermissionMap.containsKey(rdRole)) {
                PermissionEntry permission = rolePermissionMap.get(rdRole);
                permission.setReadDeny(true);
            } else {
                PermissionEntry permission = new PermissionEntry();
                permission.setUserName(rdRole);
                permission.setReadDeny(true);
                rolePermissionMap.put(rdRole, permission);
            }
        }


        String[] waRoles = authorizer.getAllowedRolesForResource(path, ActionConstants.PUT);
        for (String waRole : waRoles) {
            if (waRole.equals(adminRoleName)) {
                continue;
            }
            if (rolePermissionMap.containsKey(waRole)) {
                PermissionEntry permission = rolePermissionMap.get(waRole);
                permission.setWriteAllow(true);
            } else {
                PermissionEntry permission = new PermissionEntry();
                permission.setUserName(waRole);
                permission.setWriteAllow(true);
                rolePermissionMap.put(waRole, permission);
            }
        }

        String[] wdRoles = authorizer.getDeniedRolesForResource(path, ActionConstants.PUT);
        for (String wdRole : wdRoles) {
            if (rolePermissionMap.containsKey(wdRole)) {
                PermissionEntry permission = rolePermissionMap.get(wdRole);
                permission.setWriteDeny(true);
            } else {
                PermissionEntry permission = new PermissionEntry();
                permission.setUserName(wdRole);
                permission.setWriteDeny(true);
                rolePermissionMap.put(wdRole, permission);
            }
        }
       
        String[] daRoles = authorizer.getAllowedRolesForResource(path, ActionConstants.DELETE);
        for (String daRole : daRoles) {
            if (daRole.equals(adminRoleName)) {
                continue;
            }
            if (rolePermissionMap.containsKey(daRole)) {
                PermissionEntry permission = rolePermissionMap.get(daRole);
                permission.setDeleteAllow(true);
            } else {
                PermissionEntry permission = new PermissionEntry();
                permission.setUserName(daRole);
                permission.setDeleteAllow(true);
                rolePermissionMap.put(daRole, permission);
            }
        }
       
        String[] ddRoles = authorizer.getDeniedRolesForResource(path, ActionConstants.DELETE);
        for (String ddRole : ddRoles) {
            if (rolePermissionMap.containsKey(ddRole)) {
                PermissionEntry permission = rolePermissionMap.get(ddRole);
                permission.setDeleteDeny(true);
            } else {
                PermissionEntry permission = new PermissionEntry();
                permission.setUserName(ddRole);
                permission.setDeleteDeny(true);
                rolePermissionMap.put(ddRole, permission);
            }
        }


        String[] aaRoles = authorizer.
                getAllowedRolesForResource(path, AccessControlConstants.AUTHORIZE);
        for (String aaRole : aaRoles) {
            if (aaRole.equals(adminRoleName)) {
                continue;
            }
            if (rolePermissionMap.containsKey(aaRole)) {
                PermissionEntry permission = rolePermissionMap.get(aaRole);
                permission.setAuthorizeAllow(true);
            } else {
                PermissionEntry permission = new PermissionEntry();
                permission.setUserName(aaRole);
                permission.setAuthorizeAllow(true);
                rolePermissionMap.put(aaRole, permission);
            }
        }
       
        String[] adRoles = authorizer.
                getDeniedRolesForResource(path, AccessControlConstants.AUTHORIZE);
        for (String adRole : adRoles) {
            if (rolePermissionMap.containsKey(adRole)) {
                PermissionEntry permission = rolePermissionMap.get(adRole);
                permission.setAuthorizeDeny(true);
            } else {
                PermissionEntry permission = new PermissionEntry();
                permission.setUserName(adRole);
                permission.setAuthorizeDeny(true);
                rolePermissionMap.put(adRole, permission);
            }
        }

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.registry.resource.beans.PermissionEntry

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.