org.apache.ranger.authorization.hadoop.config.RangerConfiguration Java Examples

The following examples show how to use org.apache.ranger.authorization.hadoop.config.RangerConfiguration. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RangerNiFiAuthorizer.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
/**
 * Adds a resource to the RangerConfiguration singleton so it is already there by the time RangerBasePlugin.init()
 * is called.
 *
 * @param name the name of the given PropertyValue from the AuthorizationConfigurationContext
 * @param resourceValue the value for the given name, should be a full path to a file
 */
private void addRequiredResource(final String name, final PropertyValue resourceValue) {
    if (resourceValue == null || StringUtils.isBlank(resourceValue.getValue())) {
        throw new AuthorizerCreationException(name + " must be specified.");
    }

    final File resourceFile = new File(resourceValue.getValue());
    if (!resourceFile.exists() || !resourceFile.canRead()) {
        throw new AuthorizerCreationException(resourceValue + " does not exist, or can not be read");
    }

    try {
        RangerConfiguration.getInstance().addResource(resourceFile.toURI().toURL());
    } catch (MalformedURLException e) {
        throw new AuthorizerCreationException("Error creating URI for " + resourceValue, e);
    }
}
 
Example #2
Source File: RangerGaianAuthorizer.java    From egeria with Apache License 2.0 6 votes vote down vote up
private RangerServerProperties loadRangerServerProperties() {
    RangerServerProperties serverProperties = new RangerServerProperties();

    if(RangerConfiguration.getInstance() != null){
        String rangerURL = RangerConfiguration.getInstance().get("ranger.plugin.gaian.policy.rest.url");
        if(rangerURL != null){
            serverProperties.setServerURL(rangerURL);
        }

        String rangerAuthorization = RangerConfiguration.getInstance().get("ranger.plugin.gaian.policy.rest.authorization");
        if(rangerAuthorization != null) {
            serverProperties.setServerAuthorization(rangerAuthorization);
        }
    }

    return serverProperties;
}
 
Example #3
Source File: RangerAuthorizer.java    From nifi-registry with Apache License 2.0 6 votes vote down vote up
/**
 * Adds a resource to the RangerConfiguration singleton so it is already there by the time RangerBasePlugin.init()
 * is called.
 *
 * @param name          the name of the given PropertyValue from the AuthorizationConfigurationContext
 * @param resourceValue the value for the given name, should be a full path to a file
 */
private void addRequiredResource(final String name, final PropertyValue resourceValue) {
    if (resourceValue == null || StringUtils.isBlank(resourceValue.getValue())) {
        throw new SecurityProviderCreationException(name + " must be specified.");
    }

    final File resourceFile = new File(resourceValue.getValue());
    if (!resourceFile.exists() || !resourceFile.canRead()) {
        throw new SecurityProviderCreationException(resourceValue + " does not exist, or can not be read");
    }

    try {
        RangerConfiguration.getInstance().addResource(resourceFile.toURI().toURL());
    } catch (MalformedURLException e) {
        throw new SecurityProviderCreationException("Error creating URI for " + resourceValue, e);
    }
}
 
Example #4
Source File: RangerNiFiAuthorizer.java    From nifi with Apache License 2.0 6 votes vote down vote up
/**
 * Adds a resource to the RangerConfiguration singleton so it is already there by the time RangerBasePlugin.init()
 * is called.
 *
 * @param name the name of the given PropertyValue from the AuthorizationConfigurationContext
 * @param resourceValue the value for the given name, should be a full path to a file
 */
private void addRequiredResource(final String name, final PropertyValue resourceValue) {
    if (resourceValue == null || StringUtils.isBlank(resourceValue.getValue())) {
        throw new AuthorizerCreationException(name + " must be specified.");
    }

    final File resourceFile = new File(resourceValue.getValue());
    if (!resourceFile.exists() || !resourceFile.canRead()) {
        throw new AuthorizerCreationException(resourceValue + " does not exist, or can not be read");
    }

    try {
        RangerConfiguration.getInstance().addResource(resourceFile.toURI().toURL());
    } catch (MalformedURLException e) {
        throw new AuthorizerCreationException("Error creating URI for " + resourceValue, e);
    }
}
 
Example #5
Source File: RangerPolicyResultFilter.java    From egeria with Apache License 2.0 5 votes vote down vote up
private Boolean isNullMasking() {
    if (RangerConfiguration.getInstance() != null
            && RangerConfiguration.getInstance().getProperties() != null
            && RangerConfiguration.getInstance().getProperties().getProperty("ranger.plugin.gaian.masking.pattern") != null) {
        String maskingPattern = RangerConfiguration.getInstance().getProperties().getProperty("ranger.plugin.gaian.masking.pattern");
        if (maskingPattern != null) {
            return maskingPattern.equalsIgnoreCase("NULL");
        }
    }
    return Boolean.FALSE;
}
 
Example #6
Source File: RangerPolicyResultFilter.java    From egeria with Apache License 2.0 4 votes vote down vote up
private Properties loadProperties() {
    return RangerConfiguration.getInstance().getProperties();
}