001/* 002 * (C) Copyright 2018 Nuxeo (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Remi Cattiau 018 * Florent Guillaume 019 */ 020package org.nuxeo.runtime.aws; 021 022import static org.apache.commons.lang3.StringUtils.defaultString; 023 024import org.nuxeo.common.xmap.annotation.XNode; 025import org.nuxeo.common.xmap.annotation.XObject; 026import org.nuxeo.runtime.model.Descriptor; 027 028@XObject("configuration") 029public class AWSConfigurationDescriptor implements Descriptor { 030 031 public static final String DEFAULT_CONFIG_ID = "default"; 032 033 @XNode("@id") 034 protected String id = DEFAULT_CONFIG_ID; 035 036 @XNode("accessKeyId") 037 protected String accessKeyId; 038 039 @XNode("secretKey") 040 protected String secretKey; 041 042 @XNode("sessionToken") 043 protected String sessionToken; 044 045 @XNode("region") 046 protected String region; 047 048 @Override 049 public String getId() { 050 return id; 051 } 052 053 public String getAccessKeyId() { 054 return accessKeyId; 055 } 056 057 public String getSecretKey() { 058 return secretKey; 059 } 060 061 public String getSessionToken() { 062 return sessionToken; 063 } 064 065 public String getRegion() { 066 return region; 067 } 068 069 @Override 070 public AWSConfigurationDescriptor merge(Descriptor o) { 071 AWSConfigurationDescriptor other = (AWSConfigurationDescriptor) o; 072 AWSConfigurationDescriptor merged = new AWSConfigurationDescriptor(); 073 merged.accessKeyId = defaultString(other.accessKeyId, accessKeyId); 074 merged.secretKey = defaultString(other.secretKey, secretKey); 075 merged.sessionToken = defaultString(other.sessionToken, sessionToken); 076 merged.region = defaultString(other.region, region); 077 return merged; 078 } 079 080}