mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 05:07:41 +00:00
GUACAMOLE-103: Move to using Translatable for redirect message; clean up comments.
This commit is contained in:
@@ -33,6 +33,7 @@ import org.apache.guacamole.auth.cas.conf.ConfigurationService;
|
||||
import org.apache.guacamole.auth.cas.form.CASTicketField;
|
||||
import org.apache.guacamole.auth.cas.ticket.TicketValidationService;
|
||||
import org.apache.guacamole.auth.cas.user.CASAuthenticatedUser;
|
||||
import org.apache.guacamole.language.TranslatableMessage;
|
||||
|
||||
/**
|
||||
* Service providing convenience functions for the CAS AuthenticationProvider
|
||||
@@ -100,7 +101,7 @@ public class AuthenticationProviderService {
|
||||
new CASTicketField(
|
||||
confService.getAuthorizationEndpoint(),
|
||||
confService.getRedirectURI(),
|
||||
"LOGIN.INFO_CAS_REDIRECT_PENDING"
|
||||
new TranslatableMessage("LOGIN.INFO_CAS_REDIRECT_PENDING")
|
||||
)
|
||||
|
||||
}))
|
||||
|
@@ -22,6 +22,7 @@ package org.apache.guacamole.auth.cas.form;
|
||||
import java.net.URI;
|
||||
import javax.ws.rs.core.UriBuilder;
|
||||
import org.apache.guacamole.form.RedirectField;
|
||||
import org.apache.guacamole.language.TranslatableMessage;
|
||||
|
||||
|
||||
/**
|
||||
@@ -58,19 +59,19 @@ public class CASTicketField extends RedirectField {
|
||||
* The URI that the CAS service should redirect to upon successful
|
||||
* authentication.
|
||||
*
|
||||
* @param redirectMsg
|
||||
* @param redirectMessage
|
||||
* The message that will be displayed for the user while the redirect
|
||||
* is processed. This will be processed through Guacamole's translation
|
||||
* system.
|
||||
*/
|
||||
public CASTicketField(URI authorizationEndpoint, URI redirectURI,
|
||||
String redirectMsg) {
|
||||
TranslatableMessage redirectMessage) {
|
||||
|
||||
super(PARAMETER_NAME, UriBuilder.fromUri(authorizationEndpoint)
|
||||
.path(CAS_LOGIN_URI)
|
||||
.queryParam("service", redirectURI)
|
||||
.build(),
|
||||
redirectMsg);
|
||||
redirectMessage);
|
||||
|
||||
}
|
||||
|
||||
|
@@ -30,6 +30,7 @@ import org.apache.guacamole.auth.openid.token.TokenValidationService;
|
||||
import org.apache.guacamole.auth.openid.user.AuthenticatedUser;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.form.Field;
|
||||
import org.apache.guacamole.language.TranslatableMessage;
|
||||
import org.apache.guacamole.net.auth.Credentials;
|
||||
import org.apache.guacamole.net.auth.credentials.CredentialsInfo;
|
||||
import org.apache.guacamole.net.auth.credentials.GuacamoleInvalidCredentialsException;
|
||||
@@ -122,7 +123,7 @@ public class AuthenticationProviderService {
|
||||
confService.getClientID(),
|
||||
confService.getRedirectURI(),
|
||||
nonceService.generate(confService.getMaxNonceValidity() * 60000L),
|
||||
"LOGIN.INFO_OID_PENDING_REDIRECT"
|
||||
new TranslatableMessage("LOGIN.INFO_OID_PENDING_REDIRECT")
|
||||
)
|
||||
|
||||
}))
|
||||
|
@@ -22,6 +22,7 @@ package org.apache.guacamole.auth.openid.form;
|
||||
import java.net.URI;
|
||||
import javax.ws.rs.core.UriBuilder;
|
||||
import org.apache.guacamole.form.RedirectField;
|
||||
import org.apache.guacamole.language.TranslatableMessage;
|
||||
|
||||
/**
|
||||
* Field definition which represents the token returned by an OpenID Connect
|
||||
@@ -64,13 +65,13 @@ public class TokenField extends RedirectField {
|
||||
* A random string unique to this request. To defend against replay
|
||||
* attacks, this value must cease being valid after its first use.
|
||||
*
|
||||
* @param redirectMsg
|
||||
* @param redirectMessage
|
||||
* The message that will be displayed to the user during redirect. This
|
||||
* will be processed through Guacamole's translation system.
|
||||
*/
|
||||
public TokenField(URI authorizationEndpoint, String scope,
|
||||
String clientID, URI redirectURI, String nonce,
|
||||
String redirectMsg) {
|
||||
TranslatableMessage redirectMessage) {
|
||||
|
||||
super(PARAMETER_NAME, UriBuilder.fromUri(authorizationEndpoint)
|
||||
.queryParam("scope", scope)
|
||||
@@ -79,7 +80,7 @@ public class TokenField extends RedirectField {
|
||||
.queryParam("redirect_uri", redirectURI)
|
||||
.queryParam("nonce", nonce)
|
||||
.build(),
|
||||
redirectMsg);
|
||||
redirectMessage);
|
||||
|
||||
}
|
||||
|
||||
|
@@ -20,22 +20,25 @@
|
||||
package org.apache.guacamole.form;
|
||||
|
||||
import java.net.URI;
|
||||
import org.apache.guacamole.language.Translatable;
|
||||
import org.apache.guacamole.language.TranslatableMessage;
|
||||
|
||||
/**
|
||||
* A Guacamole field that redirects a user to another page.
|
||||
*/
|
||||
public class RedirectField extends Field {
|
||||
public class RedirectField extends Field implements Translatable {
|
||||
|
||||
/**
|
||||
* The encoded URL of the redirect.
|
||||
* The URL to which the user should be redirected. The URL should be
|
||||
* encoded
|
||||
*/
|
||||
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.
|
||||
* The translatable message that should be displayed for the user while the
|
||||
* browser redirects.
|
||||
*/
|
||||
private final String redirectMsg;
|
||||
private final TranslatableMessage redirectMessage;
|
||||
|
||||
/**
|
||||
* Creates a new field which facilitates redirection of the user
|
||||
@@ -47,40 +50,37 @@ public class RedirectField extends 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.
|
||||
* @param redirectMessage
|
||||
* The translatable message that should be displayed for the user while
|
||||
* the browser redirects.
|
||||
*/
|
||||
public RedirectField(String name, URI redirectUrl, String redirectMsg) {
|
||||
public RedirectField(String name, URI redirectUrl,
|
||||
TranslatableMessage redirectMessage) {
|
||||
|
||||
// Init base field properties
|
||||
super(name, Field.Type.REDIRECT);
|
||||
|
||||
// Store the URL to which the user will be redirected.
|
||||
// Store the URL to which the user will be redirected
|
||||
this.redirectUrl = redirectUrl;
|
||||
this.redirectMsg = redirectMsg;
|
||||
|
||||
// Store the message that will be displayed for the user during redirect
|
||||
this.redirectMessage = redirectMessage;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the URL of the redirect.
|
||||
* Returns the URL to which the user should be redirected.
|
||||
*
|
||||
* @return
|
||||
* The URL of the redirect.
|
||||
* The URL to which the user should be redirected.
|
||||
*/
|
||||
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;
|
||||
@Override
|
||||
public TranslatableMessage getTranslatableMessage() {
|
||||
return redirectMessage;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -29,15 +29,4 @@ angular.module('form').controller('redirectFieldController', ['$scope','$window'
|
||||
*/
|
||||
$window.location.href = $scope.field.redirectUrl;
|
||||
|
||||
/**
|
||||
* Return the text that should be displayed to the user while the redirect
|
||||
* is taking place.
|
||||
*
|
||||
* @return {String}
|
||||
* The text to display for the user during the redirect.
|
||||
*/
|
||||
$scope.getRedirectMsg = function getRedirctMsg() {
|
||||
return $scope.field.redirectMsg;
|
||||
};
|
||||
|
||||
}]);
|
||||
|
@@ -1,5 +1,8 @@
|
||||
<div class="redirect-field-container">
|
||||
<div class="redirect-field">
|
||||
<p>{{ getRedirectMsg() | translate }}</p>
|
||||
<p ng-show="field.translatableMessage"
|
||||
translate="{{field.translatableMessage.key}}"
|
||||
translate-values="{{field.translatableMessage.variables}}">
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
Reference in New Issue
Block a user