Skip to content

Commit

Permalink
cleaning up
Browse files Browse the repository at this point in the history
  • Loading branch information
smakela committed Nov 25, 2011
1 parent e72b9b1 commit ac848c7
Showing 1 changed file with 22 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/* Copyright 2011 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.codehaus.groovy.grails.plugins.springsecurity.radius

import net.jradius.client.RadiusClient
Expand All @@ -37,11 +37,13 @@ import org.springframework.util.Assert
import org.codehaus.groovy.grails.plugins.springsecurity.SpringSecurityUtils

/**
* @author <a href="mailto:smakela@iki.fi">Sami Mäkelä</a>
*/
* @author <a href="mailto:smakela@iki.fi">Sami Mäkelä</a>
*/
class GrailsRadiusAuthenticatorImpl implements GrailsRadiusAuthenticator, InitializingBean {

static final List NO_ROLES = [new GrantedAuthorityImpl(SpringSecurityUtils.NO_ROLE)]
static final List NO_ROLES = [
new GrantedAuthorityImpl(SpringSecurityUtils.NO_ROLE)
]

RadiusAuthenticator radiusAuthenticator
String radiusHost
Expand All @@ -57,7 +59,7 @@ class GrailsRadiusAuthenticatorImpl implements GrailsRadiusAuthenticator, Initia

@Override
public UserDetails authenticate(
UsernamePasswordAuthenticationToken authentication) {
UsernamePasswordAuthenticationToken authentication) {

String username = authentication.getPrincipal()
String password = authentication.getCredentials()
Expand All @@ -69,7 +71,8 @@ class GrailsRadiusAuthenticatorImpl implements GrailsRadiusAuthenticator, Initia
RadiusPacket reply

try {
RadiusClient radiusClient = new RadiusClient(InetAddress.byName(radiusHost), sharedSecret, authenticationPort, accountingPort, timeout)
RadiusClient radiusClient = new RadiusClient(InetAddress.byName(radiusHost),
sharedSecret, authenticationPort, accountingPort, timeout)
RadiusPacket request = new AccessRequest(radiusClient, radiusAttributes)
radiusClient.authenticate(request, radiusAuthenticator, retries)
} catch (RadiusException re) {
Expand All @@ -85,7 +88,7 @@ class GrailsRadiusAuthenticatorImpl implements GrailsRadiusAuthenticator, Initia
}

if (!(reply instanceof AccessAccept)) {
throw new BadCredentialsException("Bad credentials")
throw new BadCredentialsException("Bad credentials")
}

new User(username, password, true, true, true, true, NO_ROLES);
Expand Down

0 comments on commit ac848c7

Please sign in to comment.