001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 018package org.apache.camel.util; 019 020import java.util.Arrays; 021import java.util.HashSet; 022import java.util.Locale; 023import java.util.Set; 024 025public final class SensitiveUtils { 026 private static final Set<String> SENSITIVE_KEYS = new HashSet<>( 027 Arrays.asList( 028 // Generated by camel build tools - do NOT edit this list! 029 // SENSITIVE-KEYS: START 030 "accesskey", 031 "accesstoken", 032 "accesstokensecret", 033 "accountkey", 034 "accountsid", 035 "acltoken", 036 "authkey", 037 "authorizationtoken", 038 "blobaccesskey", 039 "blobstoragesharedkeycredential", 040 "certresourcepassword", 041 "cipherkey", 042 "clientsecret", 043 "connectionstring", 044 "consumerkey", 045 "consumersecret", 046 "emailaddress", 047 "fulltokenid", 048 "httpproxypassword", 049 "keypassword", 050 "keystore", 051 "keystorepassword", 052 "login", 053 "oauthaccesstoken", 054 "oauthappid", 055 "oauthappsecret", 056 "oauthclientid", 057 "oauthclientsecret", 058 "oauthtoken", 059 "oauthtokenurl", 060 "p12filename", 061 "passcode", 062 "passphrase", 063 "password", 064 "privatekey", 065 "privatekeyfile", 066 "privatekeyname", 067 "privatekeypassword", 068 "proxyauthpassword", 069 "proxyauthusername", 070 "proxypassword", 071 "proxyuser", 072 "publickeyid", 073 "publishkey", 074 "queueownerawsaccountid", 075 "refreshtoken", 076 "sasljaasconfig", 077 "secretkey", 078 "securerandom", 079 "sharedaccesskey", 080 "sslkeypassword", 081 "sslkeystore", 082 "sslkeystorepassword", 083 "sslpassword", 084 "ssltruststorepassword", 085 "subscribekey", 086 "systemid", 087 "token", 088 "user", 089 "userauthenticationcredentials", 090 "username", 091 "userpassword", 092 "verificationcode", 093 "zookeeperpassword" 094 // SENSITIVE-KEYS: END 095 )); 096 097 private SensitiveUtils() { 098 } 099 100 /** 101 * Whether the given configuration property contains a sensitive a sensitive key (such as password, accesstoken, 102 * etc.) 103 * 104 * @param text the configuration property 105 * @return true if sensitive, false otherwise 106 */ 107 public static boolean containsSensitive(String text) { 108 int lastPeriod = text.lastIndexOf('.'); 109 if (lastPeriod >= 0) { 110 text = text.substring(lastPeriod + 1); 111 } 112 text = text.toLowerCase(Locale.ENGLISH); 113 text = StringHelper.replaceAll(text, "-", ""); 114 return SENSITIVE_KEYS.contains(text); 115 } 116}