001package org.apache.archiva.admin.model.beans; 002/* 003 * Licensed to the Apache Software Foundation (ASF) under one 004 * or more contributor license agreements. See the NOTICE file 005 * distributed with this work for additional information 006 * regarding copyright ownership. The ASF licenses this file 007 * to you under the Apache License, Version 2.0 (the 008 * "License"); you may not use this file except in compliance 009 * with the License. You may obtain a copy of the License at 010 * 011 * http://www.apache.org/licenses/LICENSE-2.0 012 * 013 * Unless required by applicable law or agreed to in writing, 014 * software distributed under the License is distributed on an 015 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 016 * KIND, either express or implied. See the License for the 017 * specific language governing permissions and limitations 018 * under the License. 019 */ 020 021import javax.xml.bind.annotation.XmlRootElement; 022import java.io.Serializable; 023import java.util.ArrayList; 024import java.util.Collections; 025import java.util.HashMap; 026import java.util.List; 027import java.util.Map; 028 029/** 030 * @author Olivier Lamy 031 * @since 1.4-M4 032 */ 033@XmlRootElement(name = "redbackRuntimeConfiguration") 034public class RedbackRuntimeConfiguration 035 implements Serializable 036{ 037 038 /** 039 * Field userManagerImpls. 040 */ 041 private List<String> userManagerImpls = new ArrayList<>(); 042 043 /** 044 * Field rbacManagerImpls. 045 */ 046 private java.util.List<String> rbacManagerImpls = new ArrayList<>(); 047 048 private LdapConfiguration ldapConfiguration; 049 050 /** 051 * flag to know if redback configuration has been checked/migrated. 052 */ 053 private boolean migratedFromRedbackConfiguration = false; 054 055 private Map<String, String> configurationProperties; 056 057 /** 058 * field to ease json mapping wrapper on <code>configurationProperties</code> field 059 */ 060 private List<PropertyEntry> configurationPropertiesEntries; 061 062 /** 063 * flag to know if redback will use a cache to prevent 064 * searching users already found. 065 */ 066 private boolean useUsersCache = true; 067 068 private CacheConfiguration usersCacheConfiguration; 069 070 /** 071 * Field ldapGroupMappings. 072 */ 073 private List<LdapGroupMapping> ldapGroupMappings; 074 075 public RedbackRuntimeConfiguration() 076 { 077 // no op 078 } 079 080 public List<String> getUserManagerImpls() 081 { 082 return userManagerImpls; 083 } 084 085 public void setUserManagerImpls( List<String> userManagerImpls ) 086 { 087 this.userManagerImpls = userManagerImpls; 088 } 089 090 public LdapConfiguration getLdapConfiguration() 091 { 092 return ldapConfiguration; 093 } 094 095 public void setLdapConfiguration( LdapConfiguration ldapConfiguration ) 096 { 097 this.ldapConfiguration = ldapConfiguration; 098 } 099 100 public boolean isMigratedFromRedbackConfiguration() 101 { 102 return migratedFromRedbackConfiguration; 103 } 104 105 public void setMigratedFromRedbackConfiguration( boolean migratedFromRedbackConfiguration ) 106 { 107 this.migratedFromRedbackConfiguration = migratedFromRedbackConfiguration; 108 } 109 110 public Map<String, String> getConfigurationProperties() 111 { 112 if ( this.configurationProperties == null ) 113 { 114 this.configurationProperties = new HashMap<>(); 115 } 116 return configurationProperties; 117 } 118 119 public void setConfigurationProperties( Map<String, String> configurationProperties ) 120 { 121 this.configurationProperties = configurationProperties; 122 } 123 124 public List<PropertyEntry> getConfigurationPropertiesEntries() 125 { 126 configurationPropertiesEntries = new ArrayList<PropertyEntry>( getConfigurationProperties().size() ); 127 for ( Map.Entry<String, String> entry : getConfigurationProperties().entrySet() ) 128 { 129 configurationPropertiesEntries.add( new PropertyEntry( entry.getKey(), entry.getValue() ) ); 130 } 131 Collections.sort( configurationPropertiesEntries ); 132 return configurationPropertiesEntries; 133 } 134 135 public void setConfigurationPropertiesEntries( List<PropertyEntry> configurationPropertiesEntries ) 136 { 137 this.configurationPropertiesEntries = configurationPropertiesEntries; 138 if ( configurationPropertiesEntries != null ) 139 { 140 this.configurationProperties = new HashMap<>( configurationPropertiesEntries.size() ); 141 for ( PropertyEntry propertyEntry : configurationPropertiesEntries ) 142 { 143 this.configurationProperties.put( propertyEntry.getKey(), propertyEntry.getValue() ); 144 } 145 } 146 } 147 148 public boolean isUseUsersCache() 149 { 150 return useUsersCache; 151 } 152 153 public void setUseUsersCache( boolean useUsersCache ) 154 { 155 this.useUsersCache = useUsersCache; 156 } 157 158 public CacheConfiguration getUsersCacheConfiguration() 159 { 160 return usersCacheConfiguration; 161 } 162 163 public void setUsersCacheConfiguration( CacheConfiguration usersCacheConfiguration ) 164 { 165 this.usersCacheConfiguration = usersCacheConfiguration; 166 } 167 168 public List<String> getRbacManagerImpls() 169 { 170 return rbacManagerImpls; 171 } 172 173 public void setRbacManagerImpls( List<String> rbacManagerImpls ) 174 { 175 this.rbacManagerImpls = rbacManagerImpls; 176 } 177 178 public List<LdapGroupMapping> getLdapGroupMappings() 179 { 180 return ldapGroupMappings; 181 } 182 183 public void setLdapGroupMappings( List<LdapGroupMapping> ldapGroupMappings ) 184 { 185 this.ldapGroupMappings = ldapGroupMappings; 186 } 187 188 @Override 189 public String toString() 190 { 191 final StringBuilder sb = new StringBuilder(); 192 sb.append( "RedbackRuntimeConfiguration" ); 193 sb.append( "{userManagerImpls=" ).append( userManagerImpls ); 194 sb.append( ", rbacManagerImpls=" ).append( rbacManagerImpls ); 195 sb.append( ", ldapConfiguration=" ).append( ldapConfiguration ); 196 sb.append( ", migratedFromRedbackConfiguration=" ).append( migratedFromRedbackConfiguration ); 197 sb.append( ", configurationProperties=" ).append( configurationProperties ); 198 sb.append( ", configurationPropertiesEntries=" ).append( configurationPropertiesEntries ); 199 sb.append( ", useUsersCache=" ).append( useUsersCache ); 200 sb.append( ", usersCacheConfiguration=" ).append( usersCacheConfiguration ); 201 sb.append( '}' ); 202 return sb.toString(); 203 } 204}