001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 * 019 */ 020package org.apache.directory.server.config.beans; 021 022 023import java.util.ArrayList; 024import java.util.List; 025 026import org.apache.directory.server.config.ConfigurationElement; 027 028 029/** 030 * A bean used to store the Authentictor interceptor condifuration 031 * 032 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 033 */ 034public class AuthenticationInterceptorBean extends InterceptorBean 035{ 036 /** The list of authenticators */ 037 @ConfigurationElement(objectClass = "ads-authenticator", container = "authenticators") 038 private List<AuthenticatorBean> authenticators = new ArrayList<>(); 039 040 /** The reference to the Password Policy component */ 041 @ConfigurationElement(objectClass = "ads-passwordPolicy", container = "passwordPolicies") 042 private List<PasswordPolicyBean> passwordPolicies = new ArrayList<>(); 043 044 045 /** 046 * Creates a new AuthenticationInterceptorBean instance 047 */ 048 public AuthenticationInterceptorBean() 049 { 050 super(); 051 } 052 053 054 /** 055 * @param authenticators the authenticators to set 056 */ 057 public void setAuthenticators( List<AuthenticatorBean> authenticators ) 058 { 059 this.authenticators = authenticators; 060 } 061 062 063 /** 064 * @param authenticators the authenticators to add 065 */ 066 public void addAuthenticators( AuthenticatorBean... authenticators ) 067 { 068 for ( AuthenticatorBean authenticator : authenticators ) 069 { 070 this.authenticators.add( authenticator ); 071 } 072 } 073 074 075 /** 076 * @return the extendedOps 077 */ 078 public List<AuthenticatorBean> getAuthenticators() 079 { 080 return authenticators; 081 } 082 083 084 /** 085 * @return the passwordPolicies 086 */ 087 public List<PasswordPolicyBean> getPasswordPolicies() 088 { 089 return passwordPolicies; 090 } 091 092 093 /** 094 * @param passwordPolicies the pwdPolicies to set 095 */ 096 public void setPasswordPolicies( List<PasswordPolicyBean> passwordPolicies ) 097 { 098 this.passwordPolicies = passwordPolicies; 099 } 100 101 102 /** 103 * @param ppolicies the password policies to add 104 */ 105 public void addPasswordPolicies( PasswordPolicyBean... ppolicies ) 106 { 107 for ( PasswordPolicyBean ppolicy : ppolicies ) 108 { 109 this.passwordPolicies.add( ppolicy ); 110 } 111 } 112 113 114 /** 115 * @param ppolicies the password policies to add 116 */ 117 public void removePasswordPolicies( PasswordPolicyBean... ppolicies ) 118 { 119 for ( PasswordPolicyBean ppolicy : ppolicies ) 120 { 121 this.passwordPolicies.remove( ppolicy ); 122 } 123 } 124 125 126 /** 127 * {@inheritDoc} 128 */ 129 @Override 130 public String toString( String tabs ) 131 { 132 StringBuilder sb = new StringBuilder(); 133 134 sb.append( tabs ).append( "AuthenticationInterceptor :\n" ); 135 sb.append( super.toString( tabs + " " ) ); 136 137 if ( ( authenticators != null ) && !authenticators.isEmpty() ) 138 { 139 sb.append( tabs ).append( " authenticator :\n" ); 140 141 for ( AuthenticatorBean authenticator : authenticators ) 142 { 143 sb.append( authenticator.toString( tabs + " " ) ); 144 } 145 } 146 147 if ( ( passwordPolicies != null ) && !passwordPolicies.isEmpty() ) 148 { 149 for ( PasswordPolicyBean ppolicy : passwordPolicies ) 150 { 151 sb.append( ppolicy.toString( " " ) ); 152 } 153 } 154 155 return sb.toString(); 156 } 157}