001/** 002 * Copyright 2014 Tampere University of Technology, Pori Department 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 */ 016package service.tut.pori.fuzzyvisuals; 017 018import java.util.Properties; 019 020import org.apache.commons.lang3.StringUtils; 021import org.apache.log4j.Logger; 022 023import core.tut.pori.properties.SystemProperty; 024 025/** 026 * Properties for fuzzy visuals 027 */ 028public class FuzzyProperties extends SystemProperty { 029 private static final String PROPERTY_SERVICE_TUT_PORI_FV = PROPERTY_SERVICE_PORI+".fuzzyvisuals"; 030 private static final String PROPERTY_SERVICE_TUT_PORI_FV_AUTH_PASSWORD = PROPERTY_SERVICE_TUT_PORI_FV+".auth_username"; 031 private static final String PROPERTY_SERVICE_TUT_PORI_FV_AUTH_USERNAME = PROPERTY_SERVICE_TUT_PORI_FV+".auth_password"; 032 private String _authPassword = null; 033 private String _authUsername = null; 034 035 @Override 036 public void initialize(Properties properties) throws IllegalArgumentException { 037 String temp = properties.getProperty(PROPERTY_SERVICE_TUT_PORI_FV_AUTH_USERNAME); 038 if(StringUtils.isBlank(temp)){ 039 Logger.getLogger(getClass()).debug("No "+PROPERTY_SERVICE_TUT_PORI_FV_AUTH_USERNAME+" set."); 040 return; // do not bother checking for password if no username is given 041 } 042 _authUsername = temp; 043 044 _authPassword = properties.getProperty(PROPERTY_SERVICE_TUT_PORI_FV_AUTH_PASSWORD); 045 if(StringUtils.isBlank(_authPassword)){ 046 _authUsername = null; 047 throw new IllegalArgumentException("Bad "+PROPERTY_SERVICE_TUT_PORI_FV_AUTH_PASSWORD); 048 } 049 } 050 051 @Override 052 public String getPropertyFilePath() { 053 return CONFIGURATION_FILE_PATH+Definitions.PROPERTY_FILE; 054 } 055 056 /** 057 * @return HTTP basic auth username or null if not set 058 */ 059 public String getAuthPassword() { 060 return _authPassword; 061 } 062 063 /** 064 * @return HTTP basic auth password or null if not set 065 */ 066 public String getAuthUsername() { 067 return _authUsername; 068 } 069}