All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.sdmcraft.slingdynamo.impl.SlingDynamoCredentialProvider Maven / Gradle / Ivy

The newest version!
package com.github.sdmcraft.slingdynamo.impl;

import java.util.Map;

import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.commons.osgi.PropertiesUtil;
import org.osgi.framework.BundleContext;

import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.AWSCredentialsProvider;
import com.amazonaws.auth.BasicAWSCredentials;


@Component(immediate = true, metatype = true)
@Service
public class SlingDynamoCredentialProvider implements AWSCredentialsProvider {
    /** The Constant PROP_ACCESS_KEY. */
    @Property
    private static final String PROP_ACCESS_KEY = "aws.access.key";

    /** The Constant PROP_SECRET_ACCESS_KEY. */
    @Property
    private static final String PROP_SECRET_ACCESS_KEY = "aws.secret.access.key";
    private AWSCredentials awsCredentials;

    @Activate
    protected void activate(BundleContext context, Map config) {
        String accessKey = PropertiesUtil.toString(config.get(PROP_ACCESS_KEY),
                "");
        String secretAccessKey = PropertiesUtil.toString(config.get(
                    PROP_SECRET_ACCESS_KEY), "");
        awsCredentials = new BasicAWSCredentials(accessKey, secretAccessKey);
    }

    public AWSCredentials getCredentials() {
        return awsCredentials;
    }

    public void refresh() {
        throw new UnsupportedOperationException();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy