Commit cb6c7598 authored by Misagh Moayyed's avatar Misagh Moayyed
Browse files

updated deprecated config

parent 70937430
...@@ -34,11 +34,14 @@ ...@@ -34,11 +34,14 @@
<groupId>org.apache.commons</groupId> <groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId> <artifactId>commons-collections4</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.commons</groupId> <groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId> <artifactId>commons-lang3</artifactId>
</dependency> </dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
</dependency>
</dependencies> </dependencies>
<properties> <properties>
......
...@@ -18,13 +18,13 @@ ...@@ -18,13 +18,13 @@
*/ */
package org.jasig.cas.authentication; package org.jasig.cas.authentication;
import org.jasig.cas.authentication.principal.Principal;
import org.joda.time.DateTime;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.jasig.cas.authentication.principal.Principal;
/** /**
* <p> * <p>
* The Authentication object represents a successful authentication request. It * The Authentication object represents a successful authentication request. It
...@@ -61,7 +61,7 @@ public interface Authentication extends Serializable { ...@@ -61,7 +61,7 @@ public interface Authentication extends Serializable {
* *
* @return the date/time the authentication occurred. * @return the date/time the authentication occurred.
*/ */
Date getAuthenticationDate(); DateTime getAuthenticationDate();
/** /**
* Attributes of the authentication (not the Principal). * Attributes of the authentication (not the Principal).
......
...@@ -20,9 +20,9 @@ ...@@ -20,9 +20,9 @@
package org.jasig.cas.authentication; package org.jasig.cas.authentication;
import org.jasig.cas.authentication.principal.Principal; import org.jasig.cas.authentication.principal.Principal;
import org.joda.time.DateTime;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date;
import java.util.Map; import java.util.Map;
/** /**
...@@ -92,7 +92,7 @@ public interface AuthenticationBuilder extends Serializable { ...@@ -92,7 +92,7 @@ public interface AuthenticationBuilder extends Serializable {
* *
* @return This builder instance. * @return This builder instance.
*/ */
AuthenticationBuilder setAuthenticationDate(Date d); AuthenticationBuilder setAuthenticationDate(DateTime d);
/** /**
* Creates an immutable authentication instance from builder data. * Creates an immutable authentication instance from builder data.
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
*/ */
package org.jasig.cas.authentication; package org.jasig.cas.authentication;
import org.jasig.cas.ticket.AbstractTicketException;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
...@@ -29,7 +28,6 @@ import javax.validation.constraints.NotNull; ...@@ -29,7 +28,6 @@ import javax.validation.constraints.NotNull;
* *
* @author Misagh Moayyed * @author Misagh Moayyed
* see org.jasig.cas.authentication.handler.AuthenticationException * see org.jasig.cas.authentication.handler.AuthenticationException
* @see AbstractTicketException
* @since 4.0.0 * @since 4.0.0
*/ */
public abstract class RootCasException extends Exception { public abstract class RootCasException extends Exception {
......
...@@ -21,26 +21,23 @@ package org.jasig.cas; ...@@ -21,26 +21,23 @@ package org.jasig.cas;
import com.codahale.metrics.annotation.Counted; import com.codahale.metrics.annotation.Counted;
import com.codahale.metrics.annotation.Metered; import com.codahale.metrics.annotation.Metered;
import com.codahale.metrics.annotation.Timed; import com.codahale.metrics.annotation.Timed;
import org.jasig.cas.authentication.AuthenticationBuilder;
import org.jasig.cas.logout.LogoutRequest;
import org.jasig.cas.ticket.AbstractTicketException;
import org.jasig.inspektr.audit.annotation.Audit;
import org.apache.commons.collections4.Predicate; import org.apache.commons.collections4.Predicate;
import org.jasig.cas.authentication.AcceptAnyAuthenticationPolicyFactory; import org.jasig.cas.authentication.AcceptAnyAuthenticationPolicyFactory;
import org.jasig.cas.authentication.Authentication; import org.jasig.cas.authentication.Authentication;
import org.jasig.cas.authentication.DefaultAuthenticationBuilder; import org.jasig.cas.authentication.AuthenticationBuilder;
import org.jasig.cas.authentication.AuthenticationException; import org.jasig.cas.authentication.AuthenticationException;
import org.jasig.cas.authentication.AuthenticationManager; import org.jasig.cas.authentication.AuthenticationManager;
import org.jasig.cas.authentication.ContextualAuthenticationPolicy; import org.jasig.cas.authentication.ContextualAuthenticationPolicy;
import org.jasig.cas.authentication.ContextualAuthenticationPolicyFactory; import org.jasig.cas.authentication.ContextualAuthenticationPolicyFactory;
import org.jasig.cas.authentication.Credential; import org.jasig.cas.authentication.Credential;
import org.jasig.cas.authentication.DefaultAuthenticationBuilder;
import org.jasig.cas.authentication.MixedPrincipalException; import org.jasig.cas.authentication.MixedPrincipalException;
import org.jasig.cas.authentication.principal.DefaultPrincipalFactory; import org.jasig.cas.authentication.principal.DefaultPrincipalFactory;
import org.jasig.cas.authentication.principal.PersistentIdGenerator;
import org.jasig.cas.authentication.principal.Principal; import org.jasig.cas.authentication.principal.Principal;
import org.jasig.cas.authentication.principal.PrincipalFactory; import org.jasig.cas.authentication.principal.PrincipalFactory;
import org.jasig.cas.authentication.principal.Service; import org.jasig.cas.authentication.principal.Service;
import org.jasig.cas.logout.LogoutManager; import org.jasig.cas.logout.LogoutManager;
import org.jasig.cas.logout.LogoutRequest;
import org.jasig.cas.services.AttributeReleasePolicy; import org.jasig.cas.services.AttributeReleasePolicy;
import org.jasig.cas.services.RegisteredService; import org.jasig.cas.services.RegisteredService;
import org.jasig.cas.services.ServiceContext; import org.jasig.cas.services.ServiceContext;
...@@ -49,6 +46,7 @@ import org.jasig.cas.services.UnauthorizedProxyingException; ...@@ -49,6 +46,7 @@ import org.jasig.cas.services.UnauthorizedProxyingException;
import org.jasig.cas.services.UnauthorizedServiceException; import org.jasig.cas.services.UnauthorizedServiceException;
import org.jasig.cas.services.UnauthorizedServiceForPrincipalException; import org.jasig.cas.services.UnauthorizedServiceForPrincipalException;
import org.jasig.cas.services.UnauthorizedSsoServiceException; import org.jasig.cas.services.UnauthorizedSsoServiceException;
import org.jasig.cas.ticket.AbstractTicketException;
import org.jasig.cas.ticket.ExpirationPolicy; import org.jasig.cas.ticket.ExpirationPolicy;
import org.jasig.cas.ticket.InvalidTicketException; import org.jasig.cas.ticket.InvalidTicketException;
import org.jasig.cas.ticket.ServiceTicket; import org.jasig.cas.ticket.ServiceTicket;
...@@ -63,6 +61,7 @@ import org.jasig.cas.util.DefaultUniqueTicketIdGenerator; ...@@ -63,6 +61,7 @@ import org.jasig.cas.util.DefaultUniqueTicketIdGenerator;
import org.jasig.cas.util.UniqueTicketIdGenerator; import org.jasig.cas.util.UniqueTicketIdGenerator;
import org.jasig.cas.validation.Assertion; import org.jasig.cas.validation.Assertion;
import org.jasig.cas.validation.ImmutableAssertion; import org.jasig.cas.validation.ImmutableAssertion;
import org.jasig.inspektr.audit.annotation.Audit;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.util.Assert; import org.springframework.util.Assert;
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
*/ */
package org.jasig.cas.audit.spi; package org.jasig.cas.audit.spi;
import org.jasig.inspektr.common.spi.PrincipalResolver;
import org.aspectj.lang.JoinPoint; import org.aspectj.lang.JoinPoint;
import org.jasig.cas.CentralAuthenticationService; import org.jasig.cas.CentralAuthenticationService;
import org.jasig.cas.authentication.Credential; import org.jasig.cas.authentication.Credential;
...@@ -26,8 +25,8 @@ import org.jasig.cas.ticket.InvalidTicketException; ...@@ -26,8 +25,8 @@ import org.jasig.cas.ticket.InvalidTicketException;
import org.jasig.cas.ticket.ServiceTicket; import org.jasig.cas.ticket.ServiceTicket;
import org.jasig.cas.ticket.Ticket; import org.jasig.cas.ticket.Ticket;
import org.jasig.cas.ticket.TicketGrantingTicket; import org.jasig.cas.ticket.TicketGrantingTicket;
import org.jasig.cas.ticket.registry.TicketRegistry;
import org.jasig.cas.util.AopUtils; import org.jasig.cas.util.AopUtils;
import org.jasig.inspektr.common.spi.PrincipalResolver;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.security.core.Authentication; import org.springframework.security.core.Authentication;
......
...@@ -23,7 +23,6 @@ import org.joda.time.DateTime; ...@@ -23,7 +23,6 @@ import org.joda.time.DateTime;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -88,8 +87,8 @@ public class DefaultAuthenticationBuilder implements AuthenticationBuilder { ...@@ -88,8 +87,8 @@ public class DefaultAuthenticationBuilder implements AuthenticationBuilder {
* @return This builder instance. * @return This builder instance.
*/ */
@Override @Override
public AuthenticationBuilder setAuthenticationDate(final Date d) { public AuthenticationBuilder setAuthenticationDate(final DateTime d) {
this.authenticationDate = new DateTime(d); this.authenticationDate = d;
return this; return this;
} }
......
...@@ -25,7 +25,6 @@ import org.joda.time.DateTime; ...@@ -25,7 +25,6 @@ import org.joda.time.DateTime;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import java.util.Collections; import java.util.Collections;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -45,7 +44,7 @@ public final class ImmutableAuthentication implements Authentication { ...@@ -45,7 +44,7 @@ public final class ImmutableAuthentication implements Authentication {
private static final long serialVersionUID = 3206127526058061391L; private static final long serialVersionUID = 3206127526058061391L;
/** Authentication date stamp. */ /** Authentication date stamp. */
private final long authenticationDate; private final DateTime authenticationDate;
/** List of metadata about credentials presented at authentication. */ /** List of metadata about credentials presented at authentication. */
private final List<CredentialMetaData> credentials; private final List<CredentialMetaData> credentials;
...@@ -64,7 +63,7 @@ public final class ImmutableAuthentication implements Authentication { ...@@ -64,7 +63,7 @@ public final class ImmutableAuthentication implements Authentication {
/** No-arg constructor for serialization support. */ /** No-arg constructor for serialization support. */
private ImmutableAuthentication() { private ImmutableAuthentication() {
this.authenticationDate = 0; this.authenticationDate = null;
this.credentials = null; this.credentials = null;
this.principal = null; this.principal = null;
this.attributes = null; this.attributes = null;
...@@ -97,7 +96,7 @@ public final class ImmutableAuthentication implements Authentication { ...@@ -97,7 +96,7 @@ public final class ImmutableAuthentication implements Authentication {
Assert.notEmpty(credentials, "Credential cannot be empty"); Assert.notEmpty(credentials, "Credential cannot be empty");
Assert.notEmpty(successes, "Successes cannot be empty"); Assert.notEmpty(successes, "Successes cannot be empty");
this.authenticationDate = date.toDate().getTime(); this.authenticationDate = date;
this.credentials = credentials; this.credentials = credentials;
this.principal = principal; this.principal = principal;
this.attributes = attributes.isEmpty() ? null : attributes; this.attributes = attributes.isEmpty() ? null : attributes;
...@@ -110,8 +109,9 @@ public final class ImmutableAuthentication implements Authentication { ...@@ -110,8 +109,9 @@ public final class ImmutableAuthentication implements Authentication {
return this.principal; return this.principal;
} }
public Date getAuthenticationDate() { @Override
return new ImmutableDate(this.authenticationDate); public DateTime getAuthenticationDate() {
return authenticationDate;
} }
@Override @Override
...@@ -159,7 +159,7 @@ public final class ImmutableAuthentication implements Authentication { ...@@ -159,7 +159,7 @@ public final class ImmutableAuthentication implements Authentication {
builder.append(this.principal, other.getPrincipal()); builder.append(this.principal, other.getPrincipal());
builder.append(this.credentials, other.getCredentials()); builder.append(this.credentials, other.getCredentials());
builder.append(this.successes, other.getSuccesses()); builder.append(this.successes, other.getSuccesses());
builder.append(this.authenticationDate, other.getAuthenticationDate().getTime()); builder.append(this.authenticationDate, other.getAuthenticationDate());
builder.append(wrap(this.attributes), other.getAttributes()); builder.append(wrap(this.attributes), other.getAttributes());
builder.append(wrap(this.failures), other.getFailures()); builder.append(wrap(this.failures), other.getFailures());
return builder.isEquals(); return builder.isEquals();
...@@ -180,54 +180,4 @@ public final class ImmutableAuthentication implements Authentication { ...@@ -180,54 +180,4 @@ public final class ImmutableAuthentication implements Authentication {
} }
return Collections.emptyMap(); return Collections.emptyMap();
} }
/**
* Immutable date implementation that throws {@link UnsupportedOperationException} for setter methods.
*/
private static final class ImmutableDate extends Date {
private static final long serialVersionUID = 6275827030191703183L;
/** No-arg constructor for serialization support. */
private ImmutableDate() {}
/**
* Creates a new instance with the given epoch time in milliseconds.
*
* @param instant Milliseconds since the Unix epoch.
*/
ImmutableDate(final long instant) {
super(instant);
}
@Override
public void setYear(final int year) {
throw new UnsupportedOperationException();
}
@Override
public void setDate(final int date) {
throw new UnsupportedOperationException();
}
@Override
public void setHours(final int hours) {
throw new UnsupportedOperationException();
}
@Override
public void setMinutes(final int minutes) {
throw new UnsupportedOperationException();
}
@Override
public void setSeconds(final int seconds) {
throw new UnsupportedOperationException();
}
@Override
public void setTime(final long time) {
throw new UnsupportedOperationException();
}
}
} }
...@@ -18,8 +18,8 @@ ...@@ -18,8 +18,8 @@
*/ */
package org.jasig.cas.services; package org.jasig.cas.services;
import org.jasig.inspektr.audit.annotation.Audit;
import org.jasig.cas.authentication.principal.Service; import org.jasig.cas.authentication.principal.Service;
import org.jasig.inspektr.audit.annotation.Audit;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -27,7 +27,6 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -27,7 +27,6 @@ import org.springframework.transaction.annotation.Transactional;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.List;
import java.util.TreeSet; import java.util.TreeSet;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
......
...@@ -20,7 +20,6 @@ package org.jasig.cas.ticket.registry.support; ...@@ -20,7 +20,6 @@ package org.jasig.cas.ticket.registry.support;
import org.apache.commons.collections4.Predicate; import org.apache.commons.collections4.Predicate;
import org.jasig.cas.CentralAuthenticationService; import org.jasig.cas.CentralAuthenticationService;
import org.jasig.cas.logout.LogoutManager;
import org.jasig.cas.ticket.ServiceTicket; import org.jasig.cas.ticket.ServiceTicket;
import org.jasig.cas.ticket.Ticket; import org.jasig.cas.ticket.Ticket;
import org.jasig.cas.ticket.TicketGrantingTicket; import org.jasig.cas.ticket.TicketGrantingTicket;
......
...@@ -39,14 +39,10 @@ import org.slf4j.LoggerFactory; ...@@ -39,14 +39,10 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.DisposableBean;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLSocketFactory;
import javax.validation.constraints.NotNull;
import java.io.Serializable; import java.io.Serializable;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.util.List; import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.RejectedExecutionException;
/** /**
......
...@@ -23,6 +23,7 @@ import org.jasig.cas.authentication.RememberMeCredential; ...@@ -23,6 +23,7 @@ import org.jasig.cas.authentication.RememberMeCredential;
import org.jasig.cas.authentication.principal.Principal; import org.jasig.cas.authentication.principal.Principal;
import org.jasig.cas.authentication.principal.Service; import org.jasig.cas.authentication.principal.Service;
import org.jasig.cas.validation.Assertion; import org.jasig.cas.validation.Assertion;
import org.joda.time.DateTime;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.web.servlet.view.AbstractView; import org.springframework.web.servlet.view.AbstractView;
...@@ -30,7 +31,6 @@ import org.springframework.web.servlet.view.AbstractView; ...@@ -30,7 +31,6 @@ import org.springframework.web.servlet.view.AbstractView;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Date;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
...@@ -186,7 +186,7 @@ public abstract class AbstractCasView extends AbstractView { ...@@ -186,7 +186,7 @@ public abstract class AbstractCasView extends AbstractView {
* @return the authentication date * @return the authentication date
* @since 4.1.0 * @since 4.1.0
*/ */
protected final Date getAuthenticationDate(final Map<String, Object> model) { protected final DateTime getAuthenticationDate(final Map<String, Object> model) {
return getPrimaryAuthenticationFrom(model).getAuthenticationDate(); return getPrimaryAuthenticationFrom(model).getAuthenticationDate();
} }
...@@ -207,7 +207,7 @@ public abstract class AbstractCasView extends AbstractView { ...@@ -207,7 +207,7 @@ public abstract class AbstractCasView extends AbstractView {
* @return the chained authentications * @return the chained authentications
*/ */
protected final Collection<Authentication> getChainedAuthentications(final Map<String, Object> model) { protected final Collection<Authentication> getChainedAuthentications(final Map<String, Object> model) {
final List<Authentication> chainedAuthenticationsToReturn = new ArrayList<>(); final Collection<Authentication> chainedAuthenticationsToReturn = new ArrayList<>();
final Assertion assertion = getAssertionFrom(model); final Assertion assertion = getAssertionFrom(model);
final List<Authentication> chainedAuthentications = assertion.getChainedAuthentications(); final List<Authentication> chainedAuthentications = assertion.getChainedAuthentications();
......
...@@ -49,6 +49,7 @@ import org.jasig.cas.ticket.registry.TicketRegistry; ...@@ -49,6 +49,7 @@ import org.jasig.cas.ticket.registry.TicketRegistry;
import org.jasig.cas.util.DefaultUniqueTicketIdGenerator; import org.jasig.cas.util.DefaultUniqueTicketIdGenerator;
import org.jasig.cas.util.UniqueTicketIdGenerator; import org.jasig.cas.util.UniqueTicketIdGenerator;
import org.jasig.cas.validation.Assertion; import org.jasig.cas.validation.Assertion;
import org.joda.time.DateTime;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.mockito.ArgumentMatcher; import org.mockito.ArgumentMatcher;
...@@ -56,7 +57,6 @@ import org.mockito.ArgumentMatcher; ...@@ -56,7 +57,6 @@ import org.mockito.ArgumentMatcher;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -104,7 +104,7 @@ public class CentralAuthenticationServiceImplWithMockitoTests { ...@@ -104,7 +104,7 @@ public class CentralAuthenticationServiceImplWithMockitoTests {
@Before @Before
public void prepareNewCAS() { public void prepareNewCAS() {
this.authentication = mock(Authentication.class); this.authentication = mock(Authentication.class);
when(this.authentication.getAuthenticationDate()).thenReturn(new Date()); when(this.authentication.getAuthenticationDate()).thenReturn(DateTime.now());
final CredentialMetaData metadata = new BasicCredentialMetaData(TestUtils.getCredentialsWithSameUsernameAndPassword("principal")); final CredentialMetaData metadata = new BasicCredentialMetaData(TestUtils.getCredentialsWithSameUsernameAndPassword("principal"));
final Map<String, HandlerResult> successes = new HashMap<>(); final Map<String, HandlerResult> successes = new HashMap<>();
successes.put("handler1", new DefaultHandlerResult(mock(AuthenticationHandler.class), metadata)); successes.put("handler1", new DefaultHandlerResult(mock(AuthenticationHandler.class), metadata));
......
...@@ -62,12 +62,7 @@ public class ImmutableAuthenticationTests { ...@@ -62,12 +62,7 @@ public class ImmutableAuthenticationTests {
attributes, attributes,
successes, successes,
failures); failures);
try {
auth.getAuthenticationDate().setTime(100);
fail("Should have failed");
} catch (final RuntimeException e) {
logger.debug("Setting authenticate date/time failed correctly");
}
try { try {
auth.getCredentials().add(new BasicCredentialMetaData(new UsernamePasswordCredential())); auth.getCredentials().add(new BasicCredentialMetaData(new UsernamePasswordCredential()));
fail("Should have failed"); fail("Should have failed");
......
...@@ -18,24 +18,21 @@ ...@@ -18,24 +18,21 @@
*/ */
package org.jasig.cas.ticket.registry;