1 /*
2 * Copyright 2008 University Corporation for Advanced Internet Development, Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package edu.internet2.middleware.shibboleth.idp.config.profile.authn;
18
19 import java.util.List;
20
21 import edu.internet2.middleware.shibboleth.idp.authn.provider.IPAddressLoginHandler;
22
23 /**
24 * Spring factory for {@link IPAddressLoginHandler}.
25 */
26 public class IPAddressLoginHandlerFactoryBean extends AbstractLoginHandlerFactoryBean {
27
28 /** The list of denied or permitted IPs. */
29 private List<String> addresses;
30
31 /** The username to use for IP-address "authenticated" users. */
32 private String username;
33
34 /** Are the IPs in ipList a permitted list or a deny list. */
35 private boolean defaultDeny;
36
37 /** {@inheritDoc} */
38 protected Object createInstance() throws Exception {
39 IPAddressLoginHandler handler = new IPAddressLoginHandler();
40 handler.setUsername(getUsername());
41 handler.setEntries(getAddresses(), isDefaultDeny());
42 populateHandler(handler);
43 return handler;
44 }
45
46 /** {@inheritDoc} */
47 public Class getObjectType() {
48 return IPAddressLoginHandler.class;
49 }
50
51 /**
52 * Get the list of denied or permitted IPs.
53 *
54 * @return list of denied or permitted IPs
55 */
56 public List<String> getAddresses() {
57 return addresses;
58 }
59
60 /**
61 * Set the list of denied or permitted IPs.
62 *
63 * @param newAddresses list of denied or permitted IPs
64 */
65 public void setAddresses(List<String> newAddresses) {
66 addresses = newAddresses;
67 }
68
69 /**
70 * Get the username to use for IP-address "authenticated" users.
71 *
72 * @return username to use for IP-address "authenticated" users
73 */
74 public String getUsername() {
75 return username;
76 }
77
78 /**
79 * Set the username to use for IP-address "authenticated" users.
80 *
81 * @param newUsername username to use for IP-address "authenticated" users
82 */
83 public void setUsername(String newUsername) {
84 username = newUsername;
85 }
86
87 /**
88 * Get whether the IPs in ipList a permitted list or a deny list.
89 *
90 * @return whether the IPs in ipList a permitted list or a deny list
91 */
92 public boolean isDefaultDeny() {
93 return defaultDeny;
94 }
95
96 /**
97 * Set whether the IPs in ipList a permitted list or a deny list.
98 *
99 * @param newDefaultDeny whether the IPs in ipList a permitted list or a deny list.
100 */
101 public void setDefaultDeny(boolean newDefaultDeny) {
102 defaultDeny = newDefaultDeny;
103 }
104
105 }