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 @XNode("accessKeyId") 032 protected String accessKeyId; 033 034 @XNode("secretKey") 035 protected String secretKey; 036 037 @XNode("sessionToken") 038 protected String sessionToken; 039 040 @XNode("region") 041 protected String region; 042 043 @Override 044 public String getId() { 045 return UNIQUE_DESCRIPTOR_ID; 046 } 047 048 public String getAccessKeyId() { 049 return accessKeyId; 050 } 051 052 public String getSecretKey() { 053 return secretKey; 054 } 055 056 public String getSessionToken() { 057 return sessionToken; 058 } 059 060 public String getRegion() { 061 return region; 062 } 063 064 @Override 065 public AWSConfigurationDescriptor merge(Descriptor o) { 066 AWSConfigurationDescriptor other = (AWSConfigurationDescriptor) o; 067 AWSConfigurationDescriptor merged = new AWSConfigurationDescriptor(); 068 merged.accessKeyId = defaultString(other.accessKeyId, accessKeyId); 069 merged.secretKey = defaultString(other.secretKey, secretKey); 070 merged.sessionToken = defaultString(other.sessionToken, sessionToken); 071 merged.region = defaultString(other.region, region); 072 return merged; 073 } 074 075}