From 30591dcc2e197fb6acc74636aac747ad478473b1 Mon Sep 17 00:00:00 2001 From: Virtually Nick Date: Sun, 11 Aug 2019 14:25:15 -0400 Subject: [PATCH] GUACAMOLE-769: Use standard password field for RADIUS challenge. --- .../radius/AuthenticationProviderService.java | 8 ++- .../form/RadiusChallengeResponseField.java | 68 ------------------- 2 files changed, 5 insertions(+), 71 deletions(-) delete mode 100644 extensions/guacamole-auth-radius/src/main/java/org/apache/guacamole/auth/radius/form/RadiusChallengeResponseField.java diff --git a/extensions/guacamole-auth-radius/src/main/java/org/apache/guacamole/auth/radius/AuthenticationProviderService.java b/extensions/guacamole-auth-radius/src/main/java/org/apache/guacamole/auth/radius/AuthenticationProviderService.java index d44205b8d..94a462663 100644 --- a/extensions/guacamole-auth-radius/src/main/java/org/apache/guacamole/auth/radius/AuthenticationProviderService.java +++ b/extensions/guacamole-auth-radius/src/main/java/org/apache/guacamole/auth/radius/AuthenticationProviderService.java @@ -26,7 +26,6 @@ import java.util.Arrays; import javax.servlet.http.HttpServletRequest; import org.apache.guacamole.auth.radius.user.AuthenticatedUser; import org.apache.guacamole.auth.radius.form.GuacamoleRadiusChallenge; -import org.apache.guacamole.auth.radius.form.RadiusChallengeResponseField; import org.apache.guacamole.auth.radius.form.RadiusStateField; import org.apache.guacamole.GuacamoleException; import org.apache.guacamole.form.Field; @@ -43,6 +42,7 @@ import net.jradius.packet.AccessAccept; import net.jradius.packet.AccessChallenge; import net.jradius.packet.AccessReject; import net.jradius.packet.attribute.RadiusAttribute; +import org.apache.guacamole.form.PasswordField; /** * Service providing convenience functions for the RADIUS AuthenticationProvider @@ -54,6 +54,8 @@ public class AuthenticationProviderService { * Logger for this class. */ private final Logger logger = LoggerFactory.getLogger(AuthenticationProviderService.class); + + private static final String CHALLENGE_RESPONSE_PARAM = "radisuChallenge"; /** * Service for creating and managing connections to RADIUS servers. @@ -103,7 +105,7 @@ public class AuthenticationProviderService { logger.debug("Received challenge: {}", replyAttr.toString()); String replyMsg = replyAttr.toString().split(" = ", 2)[1]; String radiusState = BaseEncoding.base16().encode(stateAttr.getValue().getBytes()); - Field radiusResponseField = new RadiusChallengeResponseField(replyMsg); + Field radiusResponseField = new PasswordField(CHALLENGE_RESPONSE_PARAM); Field radiusStateField = new RadiusStateField(radiusState); // Return the GuacamoleRadiusChallenge object that has the state @@ -141,7 +143,7 @@ public class AuthenticationProviderService { // Grab HTTP request object and a response to a challenge. HttpServletRequest request = credentials.getRequest(); - String challengeResponse = request.getParameter(RadiusChallengeResponseField.PARAMETER_NAME); + String challengeResponse = request.getParameter(CHALLENGE_RESPONSE_PARAM); // RadiusPacket object to store response from server. RadiusPacket radPack; diff --git a/extensions/guacamole-auth-radius/src/main/java/org/apache/guacamole/auth/radius/form/RadiusChallengeResponseField.java b/extensions/guacamole-auth-radius/src/main/java/org/apache/guacamole/auth/radius/form/RadiusChallengeResponseField.java deleted file mode 100644 index 32ceb90de..000000000 --- a/extensions/guacamole-auth-radius/src/main/java/org/apache/guacamole/auth/radius/form/RadiusChallengeResponseField.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.apache.guacamole.auth.radius.form; - -import org.apache.guacamole.form.Field; - -/** - * A form used to prompt the user for additional information when - * the RADIUS server sends a challenge back to the user with a reply - * message. - */ -public class RadiusChallengeResponseField extends Field { - - /** - * The field returned by the RADIUS challenge/response. - */ - public static final String PARAMETER_NAME = "guac-radius-challenge-response"; - - /** - * The type of field to initialize for the challenge/response. - */ - private static final String RADIUS_FIELD_TYPE = "GUAC_RADIUS_CHALLENGE_RESPONSE"; - - /** - * The message the RADIUS server sent back in the challenge. - */ - private final String challenge; - - /** - * Initialize the field with the challenge sent back by the RADIUS server. - * - * @param challenge - * The challenge message sent back by the RADIUS server. - */ - public RadiusChallengeResponseField(String challenge) { - super(PARAMETER_NAME, RADIUS_FIELD_TYPE); - this.challenge = challenge; - - } - - /** - * Get the challenge sent by the RADIUS server. - * - * @return - * A String that indicates the challenge returned - * by the RADIUS server. - */ - public String getChallenge() { - return challenge; - } -}