Here you can find the source of parseAWSUri(URI uri, String defaultAccessKey, String defaultSecretAccessKey)
Parameter | Description |
---|---|
uri | a parameter |
defaultAccessKey | a parameter |
defaultSecretAccessKey | a parameter |
@Deprecated public static String[] parseAWSUri(URI uri, String defaultAccessKey, String defaultSecretAccessKey)
//package com.java2s; /*/*from w ww . j a v a 2s .c o m*/ * Copyright (c) 2007-2010 Concurrent, Inc. All Rights Reserved. * * Project and contact information: http://www.cascading.org/ * * This file is part of the Cascading project. * * Cascading is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Cascading is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Cascading. If not, see <http://www.gnu.org/licenses/>. */ import java.net.URI; public class Main { /** * Parses the userinfo username and password out of the given URI, and retuns the embedded, or default, AWS access and secret keys. * <p/> * This code will handle underscores in bucket names. * * @param uri * @param defaultAccessKey * @param defaultSecretAccessKey * @return a String[] with accessKey and secretKey */ @Deprecated public static String[] parseAWSUri(URI uri, String defaultAccessKey, String defaultSecretAccessKey) { String accessKey = null; String secretAccessKey = null; String userInfo = uri.getUserInfo(); // special handling for underscores in bucket names if (userInfo == null) { String authority = uri.getAuthority(); String split[] = authority.split("[:@]"); if (split.length >= 2) userInfo = split[0] + ":" + split[1]; } if (userInfo != null) { int index = userInfo.indexOf(':'); if (index != -1) { accessKey = userInfo.substring(0, index); secretAccessKey = userInfo.substring(index + 1); } else { accessKey = userInfo; } } if (accessKey == null) accessKey = defaultAccessKey; if (secretAccessKey == null) secretAccessKey = defaultSecretAccessKey; if (accessKey == null && secretAccessKey == null) throw new IllegalArgumentException( "AWS Access Key ID and Secret Access Key must be specified as the username or password in the given URI"); else if (accessKey == null) throw new IllegalArgumentException( "AWS Access Key ID must be specified as the username of the given URI"); else if (secretAccessKey == null) throw new IllegalArgumentException( "AWS Secret Access Key must be specified as the password of the given URI"); return new String[] { accessKey, secretAccessKey }; } }