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

updated deprecated config

parent 70937430
......@@ -34,11 +34,14 @@
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
</dependency>
</dependencies>
<properties>
......
......@@ -18,13 +18,13 @@
*/
package org.jasig.cas.authentication;
import org.jasig.cas.authentication.principal.Principal;
import org.joda.time.DateTime;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.jasig.cas.authentication.principal.Principal;
/**
* <p>
* The Authentication object represents a successful authentication request. It
......@@ -61,7 +61,7 @@ public interface Authentication extends Serializable {
*
* @return the date/time the authentication occurred.
*/
Date getAuthenticationDate();
DateTime getAuthenticationDate();
/**
* Attributes of the authentication (not the Principal).
......
......@@ -20,9 +20,9 @@
package org.jasig.cas.authentication;
import org.jasig.cas.authentication.principal.Principal;
import org.joda.time.DateTime;
import java.io.Serializable;
import java.util.Date;
import java.util.Map;
/**
......@@ -92,7 +92,7 @@ public interface AuthenticationBuilder extends Serializable {
*
* @return This builder instance.
*/
AuthenticationBuilder setAuthenticationDate(Date d);
AuthenticationBuilder setAuthenticationDate(DateTime d);
/**
* Creates an immutable authentication instance from builder data.
......
......@@ -18,7 +18,6 @@
*/
package org.jasig.cas.authentication;
import org.jasig.cas.ticket.AbstractTicketException;
import javax.validation.constraints.NotNull;
......@@ -29,7 +28,6 @@ import javax.validation.constraints.NotNull;
*
* @author Misagh Moayyed
* see org.jasig.cas.authentication.handler.AuthenticationException
* @see AbstractTicketException
* @since 4.0.0
*/
public abstract class RootCasException extends Exception {
......
......@@ -21,26 +21,23 @@ package org.jasig.cas;
import com.codahale.metrics.annotation.Counted;
import com.codahale.metrics.annotation.Metered;
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.jasig.cas.authentication.AcceptAnyAuthenticationPolicyFactory;
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.AuthenticationManager;
import org.jasig.cas.authentication.ContextualAuthenticationPolicy;
import org.jasig.cas.authentication.ContextualAuthenticationPolicyFactory;
import org.jasig.cas.authentication.Credential;
import org.jasig.cas.authentication.DefaultAuthenticationBuilder;
import org.jasig.cas.authentication.MixedPrincipalException;
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.PrincipalFactory;
import org.jasig.cas.authentication.principal.Service;
import org.jasig.cas.logout.LogoutManager;
import org.jasig.cas.logout.LogoutRequest;
import org.jasig.cas.services.AttributeReleasePolicy;
import org.jasig.cas.services.RegisteredService;
import org.jasig.cas.services.ServiceContext;
......@@ -49,6 +46,7 @@ import org.jasig.cas.services.UnauthorizedProxyingException;
import org.jasig.cas.services.UnauthorizedServiceException;
import org.jasig.cas.services.UnauthorizedServiceForPrincipalException;
import org.jasig.cas.services.UnauthorizedSsoServiceException;
import org.jasig.cas.ticket.AbstractTicketException;
import org.jasig.cas.ticket.ExpirationPolicy;
import org.jasig.cas.ticket.InvalidTicketException;
import org.jasig.cas.ticket.ServiceTicket;
......@@ -63,6 +61,7 @@ import org.jasig.cas.util.DefaultUniqueTicketIdGenerator;
import org.jasig.cas.util.UniqueTicketIdGenerator;
import org.jasig.cas.validation.Assertion;
import org.jasig.cas.validation.ImmutableAssertion;
import org.jasig.inspektr.audit.annotation.Audit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.Assert;
......
......@@ -18,7 +18,6 @@
*/
package org.jasig.cas.audit.spi;
import org.jasig.inspektr.common.spi.PrincipalResolver;
import org.aspectj.lang.JoinPoint;
import org.jasig.cas.CentralAuthenticationService;
import org.jasig.cas.authentication.Credential;
......@@ -26,8 +25,8 @@ import org.jasig.cas.ticket.InvalidTicketException;
import org.jasig.cas.ticket.ServiceTicket;
import org.jasig.cas.ticket.Ticket;
import org.jasig.cas.ticket.TicketGrantingTicket;
import org.jasig.cas.ticket.registry.TicketRegistry;
import org.jasig.cas.util.AopUtils;
import org.jasig.inspektr.common.spi.PrincipalResolver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.core.Authentication;
......
......@@ -23,7 +23,6 @@ import org.joda.time.DateTime;
import org.springframework.util.Assert;
import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
......@@ -88,8 +87,8 @@ public class DefaultAuthenticationBuilder implements AuthenticationBuilder {
* @return This builder instance.
*/
@Override
public AuthenticationBuilder setAuthenticationDate(final Date d) {
this.authenticationDate = new DateTime(d);
public AuthenticationBuilder setAuthenticationDate(final DateTime d) {
this.authenticationDate = d;
return this;
}
......
......@@ -25,7 +25,6 @@ import org.joda.time.DateTime;
import org.springframework.util.Assert;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;
......@@ -45,7 +44,7 @@ public final class ImmutableAuthentication implements Authentication {
private static final long serialVersionUID = 3206127526058061391L;
/** Authentication date stamp. */
private final long authenticationDate;
private final DateTime authenticationDate;
/** List of metadata about credentials presented at authentication. */
private final List<CredentialMetaData> credentials;
......@@ -64,7 +63,7 @@ public final class ImmutableAuthentication implements Authentication {
/** No-arg constructor for serialization support. */
private ImmutableAuthentication() {
this.authenticationDate = 0;
this.authenticationDate = null;
this.credentials = null;
this.principal = null;
this.attributes = null;
......@@ -97,7 +96,7 @@ public final class ImmutableAuthentication implements Authentication {
Assert.notEmpty(credentials, "Credential cannot be empty");
Assert.notEmpty(successes, "Successes cannot be empty");
this.authenticationDate = date.toDate().getTime();
this.authenticationDate = date;
this.credentials = credentials;
this.principal = principal;
this.attributes = attributes.isEmpty() ? null : attributes;
......@@ -110,8 +109,9 @@ public final class ImmutableAuthentication implements Authentication {
return this.principal;
}
public Date getAuthenticationDate() {
return new ImmutableDate(this.authenticationDate);
@Override
public DateTime getAuthenticationDate() {
return authenticationDate;
}
@Override
......@@ -159,7 +159,7 @@ public final class ImmutableAuthentication implements Authentication {
builder.append(this.principal, other.getPrincipal());
builder.append(this.credentials, other.getCredentials());
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.failures), other.getFailures());
return builder.isEquals();
......@@ -180,54 +180,4 @@ public final class ImmutableAuthentication implements Authentication {
}
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 @@
*/
package org.jasig.cas.services;
import org.jasig.inspektr.audit.annotation.Audit;
import org.jasig.cas.authentication.principal.Service;
import org.jasig.inspektr.audit.annotation.Audit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.transaction.annotation.Transactional;
......@@ -27,7 +27,6 @@ import org.springframework.transaction.annotation.Transactional;
import javax.validation.constraints.NotNull;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.TreeSet;
import java.util.concurrent.ConcurrentHashMap;
......
......@@ -20,7 +20,6 @@ package org.jasig.cas.ticket.registry.support;
import org.apache.commons.collections4.Predicate;
import org.jasig.cas.CentralAuthenticationService;
import org.jasig.cas.logout.LogoutManager;
import org.jasig.cas.ticket.ServiceTicket;
import org.jasig.cas.ticket.Ticket;
import org.jasig.cas.ticket.TicketGrantingTicket;
......
......@@ -39,14 +39,10 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.DisposableBean;
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.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.RejectedExecutionException;
/**
......
......@@ -23,6 +23,7 @@ import org.jasig.cas.authentication.RememberMeCredential;
import org.jasig.cas.authentication.principal.Principal;
import org.jasig.cas.authentication.principal.Service;
import org.jasig.cas.validation.Assertion;
import org.joda.time.DateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
......@@ -186,7 +186,7 @@ public abstract class AbstractCasView extends AbstractView {
* @return the authentication date
* @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();
}
......@@ -207,7 +207,7 @@ public abstract class AbstractCasView extends AbstractView {
* @return the chained authentications
*/
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 List<Authentication> chainedAuthentications = assertion.getChainedAuthentications();
......
......@@ -49,6 +49,7 @@ import org.jasig.cas.ticket.registry.TicketRegistry;
import org.jasig.cas.util.DefaultUniqueTicketIdGenerator;
import org.jasig.cas.util.UniqueTicketIdGenerator;
import org.jasig.cas.validation.Assertion;
import org.joda.time.DateTime;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentMatcher;
......@@ -56,7 +57,6 @@ import org.mockito.ArgumentMatcher;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -104,7 +104,7 @@ public class CentralAuthenticationServiceImplWithMockitoTests {
@Before
public void prepareNewCAS() {
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 Map<String, HandlerResult> successes = new HashMap<>();
successes.put("handler1", new DefaultHandlerResult(mock(AuthenticationHandler.class), metadata));
......
......@@ -62,12 +62,7 @@ public class ImmutableAuthenticationTests {
attributes,
successes,
failures);
try {
auth.getAuthenticationDate().setTime(100);
fail("Should have failed");
} catch (final RuntimeException e) {
logger.debug("Setting authenticate date/time failed correctly");
}
try {
auth.getCredentials().add(new BasicCredentialMetaData(new UsernamePasswordCredential()));
fail("Should have failed");
......
......@@ -18,24 +18,21 @@
*/
package org.jasig.cas.ticket.registry;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
import java.util.concurrent.TimeUnit;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import net.spy.memcached.AddrUtil;
import net.spy.memcached.MemcachedClient;
import net.spy.memcached.MemcachedClientIF;
import org.jasig.cas.ticket.ServiceTicket;
import org.jasig.cas.ticket.Ticket;
import org.jasig.cas.ticket.TicketGrantingTicket;
import org.jasig.cas.ticket.registry.encrypt.AbstractCrypticTicketRegistry;
import org.springframework.beans.factory.DisposableBean;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
/**
* Key-value ticket registry implementation that stores tickets in memcached keyed on the ticket ID.
*
......
......@@ -18,25 +18,8 @@
*/
package org.jasig.cas.ticket.registry.support.kryo;
import static org.junit.Assert.assertEquals;
import java.net.MalformedURLException;
import java.net.URL;
import java.security.GeneralSecurityException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.security.auth.login.AccountNotFoundException;
import javax.security.auth.login.FailedLoginException;
import javax.validation.constraints.NotNull;
import com.esotericsoftware.kryo.Serializer;
import com.esotericsoftware.kryo.serializers.FieldSerializer;
import net.spy.memcached.CachedData;
import org.apache.commons.collections4.map.ListOrderedMap;
import org.apache.commons.lang3.builder.HashCodeBuilder;
......@@ -44,11 +27,11 @@ import org.jasig.cas.TestUtils;
import org.jasig.cas.authentication.AcceptUsersAuthenticationHandler;
import org.jasig.cas.authentication.Authentication;
import org.jasig.cas.authentication.AuthenticationBuilder;
import org.jasig.cas.authentication.DefaultAuthenticationBuilder;
import org.jasig.cas.authentication.AuthenticationHandler;
import org.jasig.cas.authentication.BasicCredentialMetaData;
import org.jasig.cas.authentication.Credential;
import org.jasig.cas.authentication.CredentialMetaData;
import org.jasig.cas.authentication.DefaultAuthenticationBuilder;
import org.jasig.cas.authentication.DefaultHandlerResult;
import org.jasig.cas.authentication.HttpBasedServiceCredential;
import org.jasig.cas.authentication.PreventedException;
......@@ -63,10 +46,26 @@ import org.jasig.cas.ticket.ServiceTicket;
import org.jasig.cas.ticket.TicketGrantingTicket;
import org.jasig.cas.ticket.TicketGrantingTicketImpl;
import org.jasig.cas.ticket.support.NeverExpiresExpirationPolicy;
import org.joda.time.DateTime;
import org.junit.Test;
import com.esotericsoftware.kryo.Serializer;
import com.esotericsoftware.kryo.serializers.FieldSerializer;
import javax.security.auth.login.AccountNotFoundException;
import javax.security.auth.login.FailedLoginException;
import javax.validation.constraints.NotNull;
import java.net.MalformedURLException;
import java.net.URL;
import java.security.GeneralSecurityException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import static org.junit.Assert.*;
/**
* Unit test for {@link KryoTranscoder} class.
......@@ -112,7 +111,7 @@ public class KryoTranscoderTests {
new DefaultPrincipalFactory()
.createPrincipal("user", Collections.unmodifiableMap(this.principalAttributes)));
bldr.setAttributes(Collections.unmodifiableMap(this.principalAttributes));
bldr.setAuthenticationDate(new Date());
bldr.setAuthenticationDate(new DateTime());
bldr.addCredential(new BasicCredentialMetaData(userPassCredential));
bldr.addFailure("error", AccountNotFoundException.class);
bldr.addSuccess("authn", new DefaultHandlerResult(
......@@ -324,9 +323,9 @@ public class KryoTranscoderTests {
MockTicketGrantingTicket(final String id, final Credential credential, final Map<String, Object> principalAttributes) {
this.id = id;
final CredentialMetaData credentialMetaData = new BasicCredentialMetaData(credential);
final DefaultAuthenticationBuilder builder = new DefaultAuthenticationBuilder();
final AuthenticationBuilder builder = new DefaultAuthenticationBuilder();
builder.setPrincipal(this.principalFactory.createPrincipal(USERNAME, principalAttributes));
builder.setAuthenticationDate(new Date());
builder.setAuthenticationDate(new DateTime());
builder.addCredential(credentialMetaData);
builder.addAttribute(RememberMeCredential.AUTHENTICATION_ATTRIBUTE_REMEMBER_ME, Boolean.TRUE);
final AuthenticationHandler handler = new MockAuthenticationHandler();
......
......@@ -26,7 +26,6 @@ import org.jasig.cas.authentication.handler.support.AbstractUsernamePasswordAuth
import javax.security.auth.login.FailedLoginException;
import javax.validation.constraints.NotNull;
import java.security.GeneralSecurityException;
import java.util.List;
import java.util.Set;
/**
......
......@@ -82,7 +82,7 @@ public final class Saml10SuccessResponseView extends AbstractSaml10ResponseView
SamlAuthenticationMetaDataPopulator.ATTRIBUTE_AUTHENTICATION_METHOD);
final AuthenticationStatement authnStatement = this.samlObjectBuilder.newAuthenticationStatement(
authentication.getAuthenticationDate(), authenticationMethod, getPrincipal(model).getId());
authentication.getAuthenticationDate().toDate(), authenticationMethod, getPrincipal(model).getId());
final Assertion assertion = this.samlObjectBuilder.newAssertion(authnStatement, this.issuer, issuedAt,
this.samlObjectBuilder.generateSecureRandomId());
......
......@@ -25,9 +25,7 @@ import org.jasig.cas.authentication.DefaultHandlerResult;
import org.jasig.cas.authentication.HandlerResult;
import org.jasig.cas.authentication.PreventedException;
import org.jasig.cas.authentication.handler.support.AbstractPreAndPostProcessingAuthenticationHandler;
import org.jasig.cas.authentication.principal.DefaultPrincipalFactory;
import org.jasig.cas.authentication.principal.Principal;
import org.jasig.cas.authentication.principal.SimplePrincipal;
import org.jasig.cas.support.spnego.authentication.principal.SpnegoCredential;
import javax.security.auth.login.FailedLoginException;
......
......@@ -25,9 +25,7 @@ import org.jasig.cas.authentication.DefaultHandlerResult;
import org.jasig.cas.authentication.HandlerResult;
import org.jasig.cas.authentication.PreventedException;
import org.jasig.cas.authentication.handler.support.AbstractPreAndPostProcessingAuthenticationHandler;
import org.jasig.cas.authentication.principal.DefaultPrincipalFactory;
import org.jasig.cas.authentication.principal.Principal;
import org.jasig.cas.authentication.principal.SimplePrincipal;
import org.jasig.cas.support.spnego.authentication.principal.SpnegoCredential;
import javax.security.auth.login.FailedLoginException;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment