mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-07 13:41:21 +00:00
GUACAMOLE-197: Convert state to Hex string to avoid encoding issues.
This commit is contained in:
@@ -21,8 +21,10 @@ package org.apache.guacamole.auth.radius;
|
|||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Provider;
|
import com.google.inject.Provider;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.xml.bind.DatatypeConverter;
|
||||||
import org.apache.guacamole.auth.radius.user.AuthenticatedUser;
|
import org.apache.guacamole.auth.radius.user.AuthenticatedUser;
|
||||||
import org.apache.guacamole.auth.radius.form.RadiusChallengeResponseField;
|
import org.apache.guacamole.auth.radius.form.RadiusChallengeResponseField;
|
||||||
import org.apache.guacamole.auth.radius.form.RadiusStateField;
|
import org.apache.guacamole.auth.radius.form.RadiusStateField;
|
||||||
@@ -97,7 +99,7 @@ public class AuthenticationProviderService {
|
|||||||
|
|
||||||
// We have the required attributes - convert to strings and then generate the additional login box/field
|
// We have the required attributes - convert to strings and then generate the additional login box/field
|
||||||
String replyMsg = replyAttr.toString();
|
String replyMsg = replyAttr.toString();
|
||||||
String radiusState = new String(stateAttr.getValue().getBytes());
|
String radiusState = javax.xml.bind.DatatypeConverter.printHexBinary(stateAttr.getValue().getBytes());
|
||||||
Field radiusResponseField = new RadiusChallengeResponseField(replyMsg);
|
Field radiusResponseField = new RadiusChallengeResponseField(replyMsg);
|
||||||
Field radiusStateField = new RadiusStateField(radiusState);
|
Field radiusStateField = new RadiusStateField(radiusState);
|
||||||
|
|
||||||
@@ -155,9 +157,10 @@ public class AuthenticationProviderService {
|
|||||||
// This is a response to a previous challenge, authenticate with that.
|
// This is a response to a previous challenge, authenticate with that.
|
||||||
else {
|
else {
|
||||||
try {
|
try {
|
||||||
|
byte[] stateBytes = javax.xml.bind.DatatypeConverter.parseHexBinary(request.getParameter(RadiusStateField.PARAMETER_NAME));
|
||||||
radPack = radiusService.sendChallengeResponse(credentials.getUsername(),
|
radPack = radiusService.sendChallengeResponse(credentials.getUsername(),
|
||||||
challengeResponse,
|
challengeResponse,
|
||||||
request.getParameter(RadiusStateField.PARAMETER_NAME));
|
stateBytes);
|
||||||
}
|
}
|
||||||
catch (GuacamoleException e) {
|
catch (GuacamoleException e) {
|
||||||
logger.error("Cannot configure RADIUS server: {}", e.getMessage());
|
logger.error("Cannot configure RADIUS server: {}", e.getMessage());
|
||||||
|
@@ -187,7 +187,7 @@ public class RadiusConnectionService {
|
|||||||
* @throws GuacamoleException
|
* @throws GuacamoleException
|
||||||
* If an error occurs while talking to the server.
|
* If an error occurs while talking to the server.
|
||||||
*/
|
*/
|
||||||
public RadiusPacket authenticate(String username, String secret, String state)
|
public RadiusPacket authenticate(String username, String secret, byte[] state)
|
||||||
throws GuacamoleException {
|
throws GuacamoleException {
|
||||||
|
|
||||||
// If a username wasn't passed, we quit
|
// If a username wasn't passed, we quit
|
||||||
@@ -219,7 +219,7 @@ public class RadiusConnectionService {
|
|||||||
try {
|
try {
|
||||||
AttributeList radAttrs = new AttributeList();
|
AttributeList radAttrs = new AttributeList();
|
||||||
radAttrs.add(new Attr_UserName(username));
|
radAttrs.add(new Attr_UserName(username));
|
||||||
if (state != null && !state.isEmpty())
|
if (state != null && state.length > 0)
|
||||||
radAttrs.add(new Attr_State(state));
|
radAttrs.add(new Attr_State(state));
|
||||||
radAttrs.add(new Attr_UserPassword(secret));
|
radAttrs.add(new Attr_UserPassword(secret));
|
||||||
radAttrs.add(new Attr_CleartextPassword(secret));
|
radAttrs.add(new Attr_CleartextPassword(secret));
|
||||||
@@ -282,7 +282,7 @@ public class RadiusConnectionService {
|
|||||||
* @throws GuacamoleException
|
* @throws GuacamoleException
|
||||||
* If an error is encountered trying to talk to the RADIUS server.
|
* If an error is encountered trying to talk to the RADIUS server.
|
||||||
*/
|
*/
|
||||||
public RadiusPacket sendChallengeResponse(String username, String response, String state)
|
public RadiusPacket sendChallengeResponse(String username, String response, byte[] state)
|
||||||
throws GuacamoleException {
|
throws GuacamoleException {
|
||||||
|
|
||||||
if (username == null || username.isEmpty()) {
|
if (username == null || username.isEmpty()) {
|
||||||
@@ -290,7 +290,7 @@ public class RadiusConnectionService {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state == null || state.isEmpty()) {
|
if (state == null || state.length < 1) {
|
||||||
logger.error("Challenge/response to RADIUS requires a prior state.");
|
logger.error("Challenge/response to RADIUS requires a prior state.");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user