updated to reflect that proxy retriever is injected into TicketValidator and not SecurityContext

This commit is contained in:
Scott Battaglia 2006-10-03 13:07:30 +00:00
parent 7a608c2e4f
commit ad9521f139
6 changed files with 11 additions and 59 deletions

View File

@ -8,7 +8,6 @@ package org.jasig.cas.client.integration.uportal;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jasig.cas.authentication.principal.Service;
import org.jasig.cas.client.proxy.ProxyRetriever;
import org.jasig.cas.client.validation.TicketValidator;
import org.jasig.portal.security.ISecurityContextFactory;
import org.jasig.portal.security.InitialSecurityContextFactory;
@ -31,11 +30,6 @@ public abstract class AbstractCasSecurityContextFactory extends
*/
public static final String CONST_CAS_TICKET_VALIDATOR = "casTicketValidator";
/**
* Spring Bean ID for the Proxy Retriever.
*/
public static final String CONST_CAS_PROXY_RETRIEVER = "casProxyRetriever";
/**
* Spring Bean ID for the Service.
*/
@ -57,12 +51,6 @@ public abstract class AbstractCasSecurityContextFactory extends
*/
protected final TicketValidator ticketValidator;
/**
* The ProxyRetriever referenced by the constant
* <code>CONST_CAS_PROXY_RETRIEVER</code>.
*/
protected final ProxyRetriever proxyRetriever;
/**
* The Service referenced by the constant <code>CONST_CAS_SERVICE</code>.
*/
@ -76,18 +64,7 @@ public abstract class AbstractCasSecurityContextFactory extends
public AbstractCasSecurityContextFactory() {
this.ticketValidator = (TicketValidator) PortalApplicationContextFacade
.getPortalApplicationContext().getBean(CONST_CAS_TICKET_VALIDATOR);
if (PortalApplicationContextFacade.getPortalApplicationContext()
.containsBean(CONST_CAS_PROXY_RETRIEVER)) {
this.proxyRetriever = (ProxyRetriever) PortalApplicationContextFacade
.getPortalApplicationContext().getBean(
CONST_CAS_PROXY_RETRIEVER);
} else {
this.proxyRetriever = null;
log
.warn("No Proxy Retriever found in PortalApplicationFacade. No Proxying capabilities will be provided by CAS.");
}
this.service = (Service) PortalApplicationContextFacade
.getPortalApplicationContext().getBean(CONST_CAS_SERVICE);
}
}

View File

@ -6,7 +6,6 @@
package org.jasig.cas.client.integration.uportal;
import org.jasig.cas.authentication.principal.Service;
import org.jasig.cas.client.proxy.ProxyRetriever;
import org.jasig.cas.client.util.CommonUtils;
import org.jasig.cas.client.validation.Assertion;
import org.jasig.cas.client.validation.TicketValidator;
@ -35,11 +34,6 @@ public class CasSecurityContext extends ChainingSecurityContext implements
*/
private final TicketValidator ticketValidator;
/**
* Instance of ProxyRetriever to obtain proxy tickets.
*/
private final ProxyRetriever proxyRetriever;
/**
* Instance of Service representing uPortal instance.
*/
@ -55,27 +49,18 @@ public class CasSecurityContext extends ChainingSecurityContext implements
*
* @param ticketValidator the TicketValidator to validate tickets.
* @param service the Service representing the portal.
* @param proxyRetriever the ProxyRetriever to use to retrieve proxies.
*/
public CasSecurityContext(final TicketValidator ticketValidator, final Service service, final ProxyRetriever proxyRetriever
) {
public CasSecurityContext(final TicketValidator ticketValidator, final Service service) {
CommonUtils.assertNotNull(ticketValidator, "ticketValidator cannot be null.");
CommonUtils.assertNotNull(service, "service cannot be null.");
log.trace("Initalizing CasSecurityContext");
this.ticketValidator = ticketValidator;
this.service = service;
this.proxyRetriever = proxyRetriever;
}
public final String getProxyTicket(final Service targetService) {
if (this.proxyRetriever == null
|| CommonUtils.isEmpty(this.assertion.getProxyGrantingTicketId())) {
return null;
}
return this.proxyRetriever.getProxyTicketIdFor(this.assertion
.getProxyGrantingTicketId(), targetService);
return this.assertion.getProxyTicketFor(targetService);
}
public final int getAuthType() {

View File

@ -31,7 +31,6 @@ public final class CasSecurityContextFactory extends AbstractCasSecurityContextF
public ISecurityContext getSecurityContext() {
log
.trace("Returning CasSecurityContext from CasSecurityContextFactory.");
return new CasSecurityContext(this.ticketValidator, this.service, this.proxyRetriever
);
return new CasSecurityContext(this.ticketValidator, this.service);
}
}

View File

@ -6,7 +6,6 @@
package org.jasig.cas.client.integration.uportal;
import org.jasig.cas.authentication.principal.Service;
import org.jasig.cas.client.proxy.ProxyRetriever;
import org.jasig.cas.client.validation.TicketValidator;
/**
@ -32,12 +31,10 @@ public final class ThreadLocalAwareCasSecurityContext extends
*
* @param ticketValidator the Ticket Validator.
* @param service the Service instance representing this uPortal instance.
* @param proxyRetriever the object used to retrieve proxies.
*/
public ThreadLocalAwareCasSecurityContext(
final TicketValidator ticketValidator, final Service service,
final ProxyRetriever proxyRetriever) {
super(ticketValidator, service, proxyRetriever);
final TicketValidator ticketValidator, final Service service) {
super(ticketValidator, service);
}
protected Service getService() {

View File

@ -19,6 +19,6 @@ public final class ThreadLocalAwareCasSecurityContextFactory extends
public ISecurityContext getSecurityContext() {
return new ThreadLocalAwareCasSecurityContext(this.ticketValidator,
this.service, this.proxyRetriever);
this.service);
}
}

View File

@ -4,7 +4,6 @@ import junit.framework.TestCase;
import org.jasig.cas.authentication.principal.Service;
import org.jasig.cas.authentication.principal.SimplePrincipal;
import org.jasig.cas.authentication.principal.SimpleService;
import org.jasig.cas.client.proxy.ProxyRetriever;
import org.jasig.cas.client.validation.Assertion;
import org.jasig.cas.client.validation.AssertionImpl;
import org.jasig.cas.client.validation.TicketValidator;
@ -27,9 +26,9 @@ public final class CasSecurityContextTests extends TestCase {
this.context = new CasSecurityContext(new TicketValidator() {
public Assertion validate(String ticketId, Service service) throws ValidationException {
return new AssertionImpl(new SimplePrincipal("test"), new HashMap(), null);
return new AssertionImpl(new SimplePrincipal("test"), new HashMap());
}
}, new SimpleService("test"), null);
}, new SimpleService("test"));
this.context.getOpaqueCredentialsInstance().setCredentials("ticket");
}
@ -45,14 +44,9 @@ public final class CasSecurityContextTests extends TestCase {
this.context = new CasSecurityContext(new TicketValidator() {
public Assertion validate(String ticketId, Service service) throws ValidationException {
return new AssertionImpl(new SimplePrincipal("test"), new HashMap(), "test");
return new AssertionImpl(new SimplePrincipal("test"), new HashMap());
}
}, new SimpleService("test"), new ProxyRetriever() {
public String getProxyTicketIdFor(String proxyGrantingTicketId, Service targetService) {
return "test";
}
});
}, new SimpleService("test"));
this.context.getOpaqueCredentialsInstance().setCredentials("ticket");
this.context.authenticate();
assertEquals("test", this.context.getProxyTicket(new SimpleService("test")));
@ -65,7 +59,7 @@ public final class CasSecurityContextTests extends TestCase {
public Assertion validate(String ticketId, Service service) throws ValidationException {
throw new ValidationException("test");
}
}, new SimpleService("test"), null);
}, new SimpleService("test"));
this.context.getOpaqueCredentialsInstance().setCredentials("ticket");
try {