Skip to content

Commit

Permalink
[SP-6612] Backport of PDI-20206 - Spoon PDI Client: User Unable to co…
Browse files Browse the repository at this point in the history
…nnect to repository if password has special character and Server is configured to use LDAP (10.2 Suite)

This reverts commit 90e8229.
  • Loading branch information
smmribeiro committed Oct 4, 2024
1 parent 751ff41 commit d285eaf
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 28 deletions.
12 changes: 1 addition & 11 deletions assemblies/pentaho-war/src/main/webapp/jsp/PUCLogin.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -332,14 +332,6 @@
}
function getUserDataForLogin(loginForm) {
var username = loginForm.find("#j_username").val();
var password = loginForm.find("#j_password").val();
return "j_username="+encodeURIComponent(username)+"&j_password=ENC:"+window.btoa( encodeURIComponent(password) );
}
function doLogin() {
// if we have a valid session and we attempt to login on top of it, the server
Expand All @@ -358,13 +350,11 @@
var userState = '';
<% } %>
var userData = getUserDataForLogin($("#login"));
jQuery.ajax({
type: "POST",
url: "j_spring_security_check",
dataType: "text",
data: userData,
data: $("#login").serialize(),
error:function (xhr, ajaxOptions, thrownError){
if (xhr.status == 404) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@

package org.pentaho.platform.repository2.userroledao.jackrabbit.security;

import com.google.gwt.user.server.Base64Utils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.Validate;
import org.apache.jackrabbit.core.security.authentication.CryptedSimpleCredentials;
import org.pentaho.platform.engine.security.messages.Messages;
Expand All @@ -30,7 +28,6 @@
import org.springframework.security.crypto.password.PasswordEncoder;

import javax.jcr.SimpleCredentials;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;

Expand Down Expand Up @@ -82,27 +79,14 @@ public boolean isPasswordValid( final String encPass, final String rawPass, fina
return false;
}
try {
char[] decodedPassword = decodePassword( rawPass );
char[] decodedPassword = URLDecoder.decode( rawPass, StandardCharsets.UTF_8.name() ).toCharArray();
CryptedSimpleCredentials credentials = new CryptedSimpleCredentials( "dummyUser", encPass );
return credentials.matches( new SimpleCredentials( "dummyUser", decodedPassword ) );
} catch ( Exception e ) {
throw new RuntimeException( e );
}
}

private static char[] decodePassword( String rawPass ) {
try {
if ( !StringUtils.isEmpty( rawPass ) && rawPass.startsWith( "ENC:" ) ) {
String password = new String( Base64Utils.fromBase64( rawPass.substring( 4 ) ), StandardCharsets.UTF_8 );
return URLDecoder.decode( password.replace( "+", "%2B" ), StandardCharsets.UTF_8.name() ).toCharArray();
} else {
return rawPass.toCharArray();
}
} catch ( UnsupportedEncodingException e ) {
return rawPass.toCharArray();
}
}

@Override public String encode( CharSequence charSequence ) {
return this.encodePassword( charSequence.toString(), null );
}
Expand Down

0 comments on commit d285eaf

Please sign in to comment.