1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 */ 19 20 package org.apache.guacamole.auth.radius; 21 22 23 import com.google.inject.Guice; 24 import com.google.inject.Injector; 25 import org.apache.guacamole.GuacamoleException; 26 import org.apache.guacamole.net.auth.AbstractAuthenticationProvider; 27 import org.apache.guacamole.net.auth.AuthenticatedUser; 28 import org.apache.guacamole.net.auth.Credentials; 29 30 /** 31 * Allows users to be authenticated against an RADIUS server. Each user may have 32 * any number of authorized configurations. Authorized configurations may be 33 * shared. 34 */ 35 public class RadiusAuthenticationProvider extends AbstractAuthenticationProvider { 36 37 /** 38 * Injector which will manage the object graph of this authentication 39 * provider. 40 */ 41 private final Injector injector; 42 43 /** 44 * Creates a new RadiusAuthenticationProvider that authenticates users 45 * against an RADIUS service. 46 * 47 * @throws GuacamoleException 48 * If a required property is missing, or an error occurs while parsing 49 * a property. 50 */ RadiusAuthenticationProvider()51 public RadiusAuthenticationProvider() throws GuacamoleException { 52 53 // Set up Guice injector. 54 injector = Guice.createInjector( 55 new RadiusAuthenticationProviderModule(this) 56 ); 57 58 } 59 60 @Override getIdentifier()61 public String getIdentifier() { 62 return "radius"; 63 } 64 65 @Override authenticateUser(Credentials credentials)66 public AuthenticatedUser authenticateUser(Credentials credentials) throws GuacamoleException { 67 68 AuthenticationProviderService authProviderService = injector.getInstance(AuthenticationProviderService.class); 69 return authProviderService.authenticateUser(credentials); 70 71 } 72 73 } 74