messed up

This commit is contained in:
Bill Burke 2015-11-24 17:19:55 -05:00
parent 980a1eca5e
commit bba781beee
3 changed files with 8 additions and 51 deletions

View file

@ -1,43 +0,0 @@
package org.keycloak.adapters.saml;
import org.keycloak.adapters.spi.AuthenticationError;
import org.keycloak.dom.saml.v2.protocol.StatusResponseType;
import org.keycloak.dom.saml.v2.protocol.StatusType;
/**
* Object that describes the SAML error that happened.
*
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
* @version $Revision: 1 $
*/
public class SamlAuthenticationError implements AuthenticationError {
public static enum Reason {
EXTRACTION_FAILURE,
INVALID_SIGNATURE,
ERROR_STATUS
}
private Reason reason;
private StatusResponseType status;
public SamlAuthenticationError(Reason reason) {
this.reason = reason;
}
public SamlAuthenticationError(Reason reason, StatusResponseType status) {
this.reason = reason;
this.status = status;
}
public SamlAuthenticationError(StatusResponseType statusType) {
this.status = statusType;
}
public Reason getReason() {
return reason;
}
public StatusResponseType getStatus() {
return status;
}
}

View file

@ -218,7 +218,7 @@ public abstract class SamlAuthenticator {
challenge = new AuthChallenge() { challenge = new AuthChallenge() {
@Override @Override
public boolean challenge(HttpFacade exchange) { public boolean challenge(HttpFacade exchange) {
SamlAuthenticationError error = new SamlAuthenticationError(SamlAuthenticationError.Reason.INVALID_SIGNATURE); SamlAuthError error = new SamlAuthError(SamlAuthError.Reason.INVALID_SIGNATURE);
exchange.getRequest().setError(error); exchange.getRequest().setError(error);
exchange.getResponse().sendError(403); exchange.getResponse().sendError(403);
return true; return true;
@ -258,7 +258,7 @@ public abstract class SamlAuthenticator {
challenge = new AuthChallenge() { challenge = new AuthChallenge() {
@Override @Override
public boolean challenge(HttpFacade exchange) { public boolean challenge(HttpFacade exchange) {
SamlAuthenticationError error = new SamlAuthenticationError(SamlAuthenticationError.Reason.ERROR_STATUS, statusResponse); SamlAuthError error = new SamlAuthError(SamlAuthError.Reason.ERROR_STATUS, statusResponse);
exchange.getRequest().setError(error); exchange.getRequest().setError(error);
exchange.getResponse().sendError(403); exchange.getResponse().sendError(403);
return true; return true;
@ -299,7 +299,7 @@ public abstract class SamlAuthenticator {
challenge = new AuthChallenge() { challenge = new AuthChallenge() {
@Override @Override
public boolean challenge(HttpFacade exchange) { public boolean challenge(HttpFacade exchange) {
SamlAuthenticationError error = new SamlAuthenticationError(SamlAuthenticationError.Reason.EXTRACTION_FAILURE); SamlAuthError error = new SamlAuthError(SamlAuthError.Reason.EXTRACTION_FAILURE);
exchange.getRequest().setError(error); exchange.getRequest().setError(error);
exchange.getResponse().sendError(403); exchange.getResponse().sendError(403);
return true; return true;

View file

@ -3,7 +3,7 @@ package org.keycloak.testsuite.keycloaksaml;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.junit.Assert; import org.junit.Assert;
import org.junit.rules.ExternalResource; import org.junit.rules.ExternalResource;
import org.keycloak.adapters.saml.SamlAuthenticationError; import org.keycloak.adapters.saml.SamlAuthError;
import org.keycloak.adapters.saml.SamlPrincipal; import org.keycloak.adapters.saml.SamlPrincipal;
import org.keycloak.admin.client.Keycloak; import org.keycloak.admin.client.Keycloak;
import org.keycloak.admin.client.resource.RealmResource; import org.keycloak.admin.client.resource.RealmResource;
@ -121,8 +121,8 @@ public class SamlAdapterTestStrategy extends ExternalResource {
Assert.assertTrue(errorPage.contains("Error Page")); Assert.assertTrue(errorPage.contains("Error Page"));
client.close(); client.close();
Assert.assertNotNull(ErrorServlet.authError); Assert.assertNotNull(ErrorServlet.authError);
SamlAuthenticationError error = (SamlAuthenticationError)ErrorServlet.authError; SamlAuthError error = (SamlAuthError)ErrorServlet.authError;
Assert.assertEquals(SamlAuthenticationError.Reason.ERROR_STATUS, error.getReason()); Assert.assertEquals(SamlAuthError.Reason.ERROR_STATUS, error.getReason());
Assert.assertNotNull(error.getStatus()); Assert.assertNotNull(error.getStatus());
ErrorServlet.authError = null; ErrorServlet.authError = null;
@ -404,8 +404,8 @@ public class SamlAdapterTestStrategy extends ExternalResource {
assertEquals(driver.getCurrentUrl(), APP_SERVER_BASE_URL + "/bad-realm-sales-post-sig/"); assertEquals(driver.getCurrentUrl(), APP_SERVER_BASE_URL + "/bad-realm-sales-post-sig/");
System.out.println(driver.getPageSource()); System.out.println(driver.getPageSource());
Assert.assertNotNull(ErrorServlet.authError); Assert.assertNotNull(ErrorServlet.authError);
SamlAuthenticationError error = (SamlAuthenticationError)ErrorServlet.authError; SamlAuthError error = (SamlAuthError)ErrorServlet.authError;
Assert.assertEquals(SamlAuthenticationError.Reason.INVALID_SIGNATURE, error.getReason()); Assert.assertEquals(SamlAuthError.Reason.INVALID_SIGNATURE, error.getReason());
ErrorServlet.authError = null; ErrorServlet.authError = null;
} }