mirror of
				https://github.com/gyurix1968/guacamole-client.git
				synced 2025-10-31 09:03:21 +00:00 
			
		
		
		
	GUACAMOLE-103: Implement common redirect form field.
This commit is contained in:
		| @@ -45,51 +45,51 @@ public class Field { | ||||
|         /** | ||||
|          * A text field, accepting arbitrary values. | ||||
|          */ | ||||
|         public static String TEXT = "TEXT"; | ||||
|         public static final String TEXT = "TEXT"; | ||||
|  | ||||
|         /** | ||||
|          * An email address field. This field type generally behaves | ||||
|          * identically to arbitrary text fields, but has semantic differences. | ||||
|          */ | ||||
|         public static String EMAIL = "EMAIL"; | ||||
|         public static final String EMAIL = "EMAIL"; | ||||
|  | ||||
|         /** | ||||
|          * A username field. This field type generally behaves identically to | ||||
|          * arbitrary text fields, but has semantic differences. | ||||
|          */ | ||||
|         public static String USERNAME = "USERNAME"; | ||||
|         public static final String USERNAME = "USERNAME"; | ||||
|  | ||||
|         /** | ||||
|          * A password field, whose value is sensitive and must be hidden. | ||||
|          */ | ||||
|         public static String PASSWORD = "PASSWORD"; | ||||
|         public static final String PASSWORD = "PASSWORD"; | ||||
|  | ||||
|         /** | ||||
|          * A numeric field, whose value must contain only digits. | ||||
|          */ | ||||
|         public static String NUMERIC = "NUMERIC"; | ||||
|         public static final String NUMERIC = "NUMERIC"; | ||||
|  | ||||
|         /** | ||||
|          * A boolean field, whose value is either blank or "true". | ||||
|          */ | ||||
|         public static String BOOLEAN = "BOOLEAN"; | ||||
|         public static final String BOOLEAN = "BOOLEAN"; | ||||
|  | ||||
|         /** | ||||
|          * An enumerated field, whose legal values are fully enumerated by a | ||||
|          * provided, finite list. | ||||
|          */ | ||||
|         public static String ENUM = "ENUM"; | ||||
|         public static final String ENUM = "ENUM"; | ||||
|  | ||||
|         /** | ||||
|          * A text field that can span more than one line. | ||||
|          */ | ||||
|         public static String MULTILINE = "MULTILINE"; | ||||
|         public static final String MULTILINE = "MULTILINE"; | ||||
|  | ||||
|         /** | ||||
|          * A time zone field whose legal values are only valid time zone IDs, | ||||
|          * as dictated by Java within TimeZone.getAvailableIDs(). | ||||
|          */ | ||||
|         public static String TIMEZONE = "TIMEZONE"; | ||||
|         public static final String TIMEZONE = "TIMEZONE"; | ||||
|  | ||||
|         /** | ||||
|          * Field type which allows selection of languages. The languages | ||||
| @@ -97,31 +97,37 @@ public class Field { | ||||
|          * application. Legal values are valid language IDs, as dictated by | ||||
|          * the filenames of Guacamole's available translations. | ||||
|          */ | ||||
|         public static String LANGUAGE = "LANGUAGE"; | ||||
|         public static final String LANGUAGE = "LANGUAGE"; | ||||
|  | ||||
|         /** | ||||
|          * A date field whose legal values conform to the pattern "YYYY-MM-DD", | ||||
|          * zero-padded. | ||||
|          */ | ||||
|         public static String DATE = "DATE"; | ||||
|         public static final String DATE = "DATE"; | ||||
|  | ||||
|         /** | ||||
|          * A time field whose legal values conform to the pattern "HH:MM:SS", | ||||
|          * zero-padded, 24-hour. | ||||
|          */ | ||||
|         public static String TIME = "TIME"; | ||||
|         public static final String TIME = "TIME"; | ||||
|  | ||||
|         /** | ||||
|          * An HTTP query parameter which is expected to be embedded in the URL | ||||
|          * given to a user. | ||||
|          */ | ||||
|         public static String QUERY_PARAMETER = "QUERY_PARAMETER"; | ||||
|         public static final String QUERY_PARAMETER = "QUERY_PARAMETER"; | ||||
|  | ||||
|         /** | ||||
|          * A color scheme accepted by the Guacamole server terminal emulator | ||||
|          * and protocols which leverage it. | ||||
|          */ | ||||
|         public static String TERMINAL_COLOR_SCHEME = "TERMINAL_COLOR_SCHEME"; | ||||
|         public static final String TERMINAL_COLOR_SCHEME = "TERMINAL_COLOR_SCHEME"; | ||||
|          | ||||
|         /** | ||||
|          * A redirect field whose value is an encoded URL to which the user | ||||
|          * will be redirected. | ||||
|          */ | ||||
|         public static final String REDIRECT = "REDIRECT"; | ||||
|  | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -0,0 +1,86 @@ | ||||
| /* | ||||
|  * 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.form; | ||||
|  | ||||
| import java.net.URI; | ||||
|  | ||||
| /** | ||||
|  * A Guacamole field that redirects a user to another page. | ||||
|  */ | ||||
| public class RedirectField extends Field { | ||||
|  | ||||
|     /** | ||||
|      * The encoded URL of the redirect. | ||||
|      */ | ||||
|     private final URI redirectUrl; | ||||
|      | ||||
|     /** | ||||
|      * The message that will be displayed for the user during the redirect | ||||
|      * process.  This will be processed through Guacamole's translation system. | ||||
|      */ | ||||
|     private final String redirectMsg; | ||||
|  | ||||
|     /** | ||||
|      * Creates a new field which facilitates redirection of the user | ||||
|      * to another page. | ||||
|      * | ||||
|      * @param name | ||||
|      *     The name of this field. | ||||
|      *  | ||||
|      * @param redirectUrl | ||||
|      *     The URL to which the user should be redirected. | ||||
|      *  | ||||
|      * @param redirectMsg | ||||
|      *     The message to display during the redirect, which will be processed | ||||
|      *     through Guacamole's translation system. | ||||
|      */ | ||||
|     public RedirectField(String name, URI redirectUrl, String redirectMsg) { | ||||
|  | ||||
|         // Init base field properties | ||||
|         super(name, Field.Type.REDIRECT); | ||||
|  | ||||
|         // Store the URL to which the user will be redirected. | ||||
|         this.redirectUrl = redirectUrl; | ||||
|         this.redirectMsg = redirectMsg; | ||||
|  | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Returns the URL of the redirect. | ||||
|      *  | ||||
|      * @return | ||||
|      *     The URL of the redirect. | ||||
|      */ | ||||
|     public String getRedirectUrl() { | ||||
|         return redirectUrl.toString(); | ||||
|     } | ||||
|      | ||||
|     /** | ||||
|      * Returns the message that will be displayed for the user while the | ||||
|      * redirect takes place. | ||||
|      *  | ||||
|      * @return | ||||
|      *     The message to display for the user. | ||||
|      */ | ||||
|     public String getRedirectMsg() { | ||||
|         return redirectMsg; | ||||
|     } | ||||
|  | ||||
| } | ||||
		Reference in New Issue
	
	Block a user