Search in sources :

Example 21 with EntitlementException

use of org.wso2.carbon.identity.entitlement.EntitlementException in project carbon-identity-framework by wso2.

the class EntitlementAdminService method clearAllResourceCaches.

/**
 * Clears Carbon resource finder cache and All the resource cache implementations in each
 * PIP resource finder level
 *
 * @throws EntitlementException throws
 */
public void clearAllResourceCaches() throws EntitlementException {
    CarbonResourceFinder finder = EntitlementEngine.getInstance().getCarbonResourceFinder();
    if (finder != null) {
        finder.clearAttributeCache();
        // we need invalidate decision cache as well.
        clearDecisionCache();
    } else {
        throw new EntitlementException("Can not clear attribute cache - Carbon Attribute Finder " + "is not initialized");
    }
}
Also used : CarbonResourceFinder(org.wso2.carbon.identity.entitlement.pip.CarbonResourceFinder)

Example 22 with EntitlementException

use of org.wso2.carbon.identity.entitlement.EntitlementException in project carbon-identity-framework by wso2.

the class EntitlementAdminService method clearCarbonAttributeCache.

/**
 * Clears the carbon attribute cache
 *
 * @throws EntitlementException throws
 */
public void clearCarbonAttributeCache() throws EntitlementException {
    CarbonAttributeFinder finder = EntitlementEngine.getInstance().getCarbonAttributeFinder();
    if (finder != null) {
        finder.clearAttributeCache();
        // we need invalidate decision cache as well.
        clearDecisionCache();
    } else {
        throw new EntitlementException("Can not clear attribute cache - Carbon Attribute Finder " + "is not initialized");
    }
    Map<PIPAttributeFinder, Properties> designators = EntitlementServiceComponent.getEntitlementConfig().getDesignators();
    if (designators != null && !designators.isEmpty()) {
        Set<PIPAttributeFinder> pipAttributeFinders = designators.keySet();
        for (PIPAttributeFinder pipAttributeFinder : pipAttributeFinders) {
            if (pipAttributeFinder instanceof AbstractPIPAttributeFinder) {
                pipAttributeFinder.clearCache();
            }
        }
    }
}
Also used : CarbonAttributeFinder(org.wso2.carbon.identity.entitlement.pip.CarbonAttributeFinder) PIPAttributeFinder(org.wso2.carbon.identity.entitlement.pip.PIPAttributeFinder) AbstractPIPAttributeFinder(org.wso2.carbon.identity.entitlement.pip.AbstractPIPAttributeFinder) AbstractPIPAttributeFinder(org.wso2.carbon.identity.entitlement.pip.AbstractPIPAttributeFinder) Properties(java.util.Properties)

Example 23 with EntitlementException

use of org.wso2.carbon.identity.entitlement.EntitlementException in project carbon-identity-framework by wso2.

the class EntitlementAdminService method clearCarbonResourceCache.

/**
 * Clears the carbon resource cache
 *
 * @throws EntitlementException throws
 */
public void clearCarbonResourceCache() throws EntitlementException {
    CarbonResourceFinder finder = EntitlementEngine.getInstance().getCarbonResourceFinder();
    if (finder != null) {
        finder.clearAttributeCache();
        // we need invalidate decision cache as well.
        clearDecisionCache();
    } else {
        throw new EntitlementException("Can not clear attribute cache - Carbon Attribute Finder " + "is not initialized");
    }
    Map<PIPResourceFinder, Properties> resourceConfigs = EntitlementServiceComponent.getEntitlementConfig().getResourceFinders();
    if (resourceConfigs != null && !resourceConfigs.isEmpty()) {
        Set<PIPResourceFinder> resourceFinders = resourceConfigs.keySet();
        for (PIPResourceFinder pipResourceFinder : resourceFinders) {
            pipResourceFinder.clearCache();
        }
    }
}
Also used : CarbonResourceFinder(org.wso2.carbon.identity.entitlement.pip.CarbonResourceFinder) Properties(java.util.Properties) PIPResourceFinder(org.wso2.carbon.identity.entitlement.pip.PIPResourceFinder)

Example 24 with EntitlementException

use of org.wso2.carbon.identity.entitlement.EntitlementException in project carbon-identity-framework by wso2.

the class EntitlementPolicyAdminService method publishToPDP.

/**
 * @param policyIds
 * @throws EntitlementException
 */
private void publishToPDP(String[] policyIds, String version, String action) throws EntitlementException {
    PolicyPublisher publisher = EntitlementAdminEngine.getInstance().getPolicyPublisher();
    String[] subscribers = new String[] { EntitlementConstants.PDP_SUBSCRIBER_ID };
    publisher.publishPolicy(policyIds, version, action, false, 0, subscribers, null);
}
Also used : PolicyPublisher(org.wso2.carbon.identity.entitlement.policy.publisher.PolicyPublisher)

Example 25 with EntitlementException

use of org.wso2.carbon.identity.entitlement.EntitlementException in project carbon-identity-framework by wso2.

the class EntitlementPolicyAdminService method publishPolicies.

/**
 * Publishes given set of policies to all subscribers
 *
 * @param policyIds     policy ids to publish,  if null or empty, all policies are published
 * @param subscriberIds subscriber ids to publish,  if null or empty, all policies are published
 * @param action        publishing action
 * @param version       version
 * @param enabled       whether policy must be enabled or not
 * @param order         order of the policy
 * @throws EntitlementException throws, if fails
 */
public void publishPolicies(String[] policyIds, String[] subscriberIds, String action, String version, boolean enabled, int order) throws EntitlementException {
    PolicyPublisher publisher = EntitlementAdminEngine.getInstance().getPolicyPublisher();
    if (policyIds == null || policyIds.length < 1) {
        policyIds = EntitlementAdminEngine.getInstance().getPapPolicyStoreManager().getPolicyIds();
    }
    if (subscriberIds == null || subscriberIds.length < 1) {
        subscriberIds = publisher.retrieveSubscriberIds("*");
    }
    if (policyIds == null || policyIds.length < 1) {
        throw new EntitlementException("There are no policies to publish");
    }
    if (subscriberIds == null || subscriberIds.length < 1) {
        throw new EntitlementException("There are no subscribers to publish");
    }
    publisher.publishPolicy(policyIds, version, action, enabled, order, subscriberIds, null);
}
Also used : PolicyPublisher(org.wso2.carbon.identity.entitlement.policy.publisher.PolicyPublisher)

Aggregations

EntitlementException (org.wso2.carbon.identity.entitlement.EntitlementException)42 RegistryException (org.wso2.carbon.registry.core.exceptions.RegistryException)23 ArrayList (java.util.ArrayList)19 PolicyDTO (org.wso2.carbon.identity.entitlement.dto.PolicyDTO)18 Resource (org.wso2.carbon.registry.core.Resource)18 Registry (org.wso2.carbon.registry.core.Registry)13 Collection (org.wso2.carbon.registry.core.Collection)12 Properties (java.util.Properties)11 AbstractPolicy (org.wso2.balana.AbstractPolicy)9 PolicyPublisher (org.wso2.carbon.identity.entitlement.policy.publisher.PolicyPublisher)9 PolicyStoreDTO (org.wso2.carbon.identity.entitlement.dto.PolicyStoreDTO)7 Map (java.util.Map)6 StatusHolder (org.wso2.carbon.identity.entitlement.dto.StatusHolder)6 PAPPolicyStoreManager (org.wso2.carbon.identity.entitlement.pap.store.PAPPolicyStoreManager)6 AttributeDTO (org.wso2.carbon.identity.entitlement.dto.AttributeDTO)5 PAPPolicyStore (org.wso2.carbon.identity.entitlement.pap.store.PAPPolicyStore)5 PolicyAttributeBuilder (org.wso2.carbon.identity.entitlement.policy.PolicyAttributeBuilder)5 PolicyVersionManager (org.wso2.carbon.identity.entitlement.policy.version.PolicyVersionManager)5 CertificateEncodingException (java.security.cert.CertificateEncodingException)4 SignatureException (org.opensaml.xmlsec.signature.support.SignatureException)4