mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17: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.form.CASTicketField;
|
||||||
import org.apache.guacamole.auth.cas.ticket.TicketValidationService;
|
import org.apache.guacamole.auth.cas.ticket.TicketValidationService;
|
||||||
import org.apache.guacamole.auth.cas.user.CASAuthenticatedUser;
|
import org.apache.guacamole.auth.cas.user.CASAuthenticatedUser;
|
||||||
|
import org.apache.guacamole.language.TranslatableMessage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service providing convenience functions for the CAS AuthenticationProvider
|
* Service providing convenience functions for the CAS AuthenticationProvider
|
||||||
@@ -100,7 +101,7 @@ public class AuthenticationProviderService {
|
|||||||
new CASTicketField(
|
new CASTicketField(
|
||||||
confService.getAuthorizationEndpoint(),
|
confService.getAuthorizationEndpoint(),
|
||||||
confService.getRedirectURI(),
|
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 java.net.URI;
|
||||||
import javax.ws.rs.core.UriBuilder;
|
import javax.ws.rs.core.UriBuilder;
|
||||||
import org.apache.guacamole.form.RedirectField;
|
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
|
* The URI that the CAS service should redirect to upon successful
|
||||||
* authentication.
|
* authentication.
|
||||||
*
|
*
|
||||||
* @param redirectMsg
|
* @param redirectMessage
|
||||||
* The message that will be displayed for the user while the redirect
|
* The message that will be displayed for the user while the redirect
|
||||||
* is processed. This will be processed through Guacamole's translation
|
* is processed. This will be processed through Guacamole's translation
|
||||||
* system.
|
* system.
|
||||||
*/
|
*/
|
||||||
public CASTicketField(URI authorizationEndpoint, URI redirectURI,
|
public CASTicketField(URI authorizationEndpoint, URI redirectURI,
|
||||||
String redirectMsg) {
|
TranslatableMessage redirectMessage) {
|
||||||
|
|
||||||
super(PARAMETER_NAME, UriBuilder.fromUri(authorizationEndpoint)
|
super(PARAMETER_NAME, UriBuilder.fromUri(authorizationEndpoint)
|
||||||
.path(CAS_LOGIN_URI)
|
.path(CAS_LOGIN_URI)
|
||||||
.queryParam("service", redirectURI)
|
.queryParam("service", redirectURI)
|
||||||
.build(),
|
.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.auth.openid.user.AuthenticatedUser;
|
||||||
import org.apache.guacamole.GuacamoleException;
|
import org.apache.guacamole.GuacamoleException;
|
||||||
import org.apache.guacamole.form.Field;
|
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;
|
||||||
import org.apache.guacamole.net.auth.credentials.CredentialsInfo;
|
import org.apache.guacamole.net.auth.credentials.CredentialsInfo;
|
||||||
import org.apache.guacamole.net.auth.credentials.GuacamoleInvalidCredentialsException;
|
import org.apache.guacamole.net.auth.credentials.GuacamoleInvalidCredentialsException;
|
||||||
@@ -122,7 +123,7 @@ public class AuthenticationProviderService {
|
|||||||
confService.getClientID(),
|
confService.getClientID(),
|
||||||
confService.getRedirectURI(),
|
confService.getRedirectURI(),
|
||||||
nonceService.generate(confService.getMaxNonceValidity() * 60000L),
|
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 java.net.URI;
|
||||||
import javax.ws.rs.core.UriBuilder;
|
import javax.ws.rs.core.UriBuilder;
|
||||||
import org.apache.guacamole.form.RedirectField;
|
import org.apache.guacamole.form.RedirectField;
|
||||||
|
import org.apache.guacamole.language.TranslatableMessage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Field definition which represents the token returned by an OpenID Connect
|
* 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
|
* A random string unique to this request. To defend against replay
|
||||||
* attacks, this value must cease being valid after its first use.
|
* 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
|
* The message that will be displayed to the user during redirect. This
|
||||||
* will be processed through Guacamole's translation system.
|
* will be processed through Guacamole's translation system.
|
||||||
*/
|
*/
|
||||||
public TokenField(URI authorizationEndpoint, String scope,
|
public TokenField(URI authorizationEndpoint, String scope,
|
||||||
String clientID, URI redirectURI, String nonce,
|
String clientID, URI redirectURI, String nonce,
|
||||||
String redirectMsg) {
|
TranslatableMessage redirectMessage) {
|
||||||
|
|
||||||
super(PARAMETER_NAME, UriBuilder.fromUri(authorizationEndpoint)
|
super(PARAMETER_NAME, UriBuilder.fromUri(authorizationEndpoint)
|
||||||
.queryParam("scope", scope)
|
.queryParam("scope", scope)
|
||||||
@@ -79,7 +80,7 @@ public class TokenField extends RedirectField {
|
|||||||
.queryParam("redirect_uri", redirectURI)
|
.queryParam("redirect_uri", redirectURI)
|
||||||
.queryParam("nonce", nonce)
|
.queryParam("nonce", nonce)
|
||||||
.build(),
|
.build(),
|
||||||
redirectMsg);
|
redirectMessage);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -20,22 +20,25 @@
|
|||||||
package org.apache.guacamole.form;
|
package org.apache.guacamole.form;
|
||||||
|
|
||||||
import java.net.URI;
|
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.
|
* 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;
|
private final URI redirectUrl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The message that will be displayed for the user during the redirect
|
* The translatable message that should be displayed for the user while the
|
||||||
* process. This will be processed through Guacamole's translation system.
|
* browser redirects.
|
||||||
*/
|
*/
|
||||||
private final String redirectMsg;
|
private final TranslatableMessage redirectMessage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new field which facilitates redirection of the user
|
* Creates a new field which facilitates redirection of the user
|
||||||
@@ -47,40 +50,37 @@ public class RedirectField extends Field {
|
|||||||
* @param redirectUrl
|
* @param redirectUrl
|
||||||
* The URL to which the user should be redirected.
|
* The URL to which the user should be redirected.
|
||||||
*
|
*
|
||||||
* @param redirectMsg
|
* @param redirectMessage
|
||||||
* The message to display during the redirect, which will be processed
|
* The translatable message that should be displayed for the user while
|
||||||
* through Guacamole's translation system.
|
* the browser redirects.
|
||||||
*/
|
*/
|
||||||
public RedirectField(String name, URI redirectUrl, String redirectMsg) {
|
public RedirectField(String name, URI redirectUrl,
|
||||||
|
TranslatableMessage redirectMessage) {
|
||||||
|
|
||||||
// Init base field properties
|
// Init base field properties
|
||||||
super(name, Field.Type.REDIRECT);
|
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.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
|
* @return
|
||||||
* The URL of the redirect.
|
* The URL to which the user should be redirected.
|
||||||
*/
|
*/
|
||||||
public String getRedirectUrl() {
|
public String getRedirectUrl() {
|
||||||
return redirectUrl.toString();
|
return redirectUrl.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Returns the message that will be displayed for the user while the
|
public TranslatableMessage getTranslatableMessage() {
|
||||||
* redirect takes place.
|
return redirectMessage;
|
||||||
*
|
|
||||||
* @return
|
|
||||||
* The message to display for the user.
|
|
||||||
*/
|
|
||||||
public String getRedirectMsg() {
|
|
||||||
return redirectMsg;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -29,15 +29,4 @@ angular.module('form').controller('redirectFieldController', ['$scope','$window'
|
|||||||
*/
|
*/
|
||||||
$window.location.href = $scope.field.redirectUrl;
|
$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-container">
|
||||||
<div class="redirect-field">
|
<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>
|
||||||
</div>
|
</div>
|
Reference in New Issue
Block a user