Commit 4db3685e authored by Misagh Moayyed's avatar Misagh Moayyed
Browse files

Merge pull request #1167 from Unicon/checkstyle-naming

Update/Remove deprecated/useless components
parents 30f6efa3 cde50f4a
......@@ -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>
......
......@@ -23,7 +23,7 @@ import org.jasig.cas.authentication.AuthenticationException;
import org.jasig.cas.authentication.Credential;
import org.jasig.cas.authentication.principal.Service;
import org.jasig.cas.logout.LogoutRequest;
import org.jasig.cas.ticket.TicketException;
import org.jasig.cas.ticket.AbstractTicketException;
import org.jasig.cas.ticket.InvalidTicketException;
import org.jasig.cas.ticket.ServiceTicket;
import org.jasig.cas.ticket.Ticket;
......@@ -66,10 +66,10 @@ public interface CentralAuthenticationService {
* @return Non-null ticket-granting ticket identifier.
*
* @throws AuthenticationException on errors authenticating the credentials
* @throws org.jasig.cas.ticket.TicketException if ticket cannot be created
* @throws AbstractTicketException if ticket cannot be created
*/
TicketGrantingTicket createTicketGrantingTicket(@NotNull Credential... credentials)
throws AuthenticationException, TicketException;
throws AuthenticationException, AbstractTicketException;
/**
......@@ -111,9 +111,9 @@ public interface CentralAuthenticationService {
*
* @return Non-null service ticket identifier.
*
* @throws org.jasig.cas.ticket.TicketException if the ticket could not be created.
* @throws AbstractTicketException if the ticket could not be created.
*/
ServiceTicket grantServiceTicket(@NotNull String ticketGrantingTicketId, @NotNull Service service) throws TicketException;
ServiceTicket grantServiceTicket(@NotNull String ticketGrantingTicketId, @NotNull Service service) throws AbstractTicketException;
/**
* Grant a {@link org.jasig.cas.ticket.ServiceTicket} that may be used to access the given service
......@@ -133,11 +133,11 @@ public interface CentralAuthenticationService {
* @return Non-null service ticket identifier.
*
* @throws AuthenticationException on errors authenticating the credentials
* @throws org.jasig.cas.ticket.TicketException if the ticket could not be created.
* @throws AbstractTicketException if the ticket could not be created.
*/
ServiceTicket grantServiceTicket(
@NotNull final String ticketGrantingTicketId, @NotNull final Service service, final Credential... credentials)
throws AuthenticationException, TicketException;
throws AuthenticationException, AbstractTicketException;
/**
* Validate a ServiceTicket for a particular Service.
......@@ -147,9 +147,9 @@ public interface CentralAuthenticationService {
*
* @return Non-null ticket validation assertion.
*
* @throws org.jasig.cas.ticket.TicketException if there was an error validating the ticket.
* @throws AbstractTicketException if there was an error validating the ticket.
*/
Assertion validateServiceTicket(@NotNull final String serviceTicketId, @NotNull final Service service) throws TicketException;
Assertion validateServiceTicket(@NotNull final String serviceTicketId, @NotNull final Service service) throws AbstractTicketException;
/**
* Destroy a TicketGrantingTicket and perform back channel logout. This has the effect of invalidating any
......@@ -173,8 +173,8 @@ public interface CentralAuthenticationService {
* that proxy authentication.
*
* @throws AuthenticationException on errors authenticating the credentials
* @throws org.jasig.cas.ticket.TicketException if there was an error creating the ticket
* @throws AbstractTicketException if there was an error creating the ticket
*/
TicketGrantingTicket delegateTicketGrantingTicket(@NotNull final String serviceTicketId, @NotNull final Credential... credentials)
throws AuthenticationException, TicketException;
throws AuthenticationException, AbstractTicketException;
}
......@@ -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,6 +18,7 @@
*/
package org.jasig.cas.authentication;
import javax.validation.constraints.NotNull;
/**
......@@ -27,7 +28,6 @@ import javax.validation.constraints.NotNull;
*
* @author Misagh Moayyed
* see org.jasig.cas.authentication.handler.AuthenticationException
* @see org.jasig.cas.ticket.TicketException
* @since 4.0.0
*/
public abstract class RootCasException extends Exception {
......
......@@ -21,14 +21,12 @@ package org.jasig.cas.ticket;
import org.jasig.cas.authentication.RootCasException;
/**
* Generic ticket exception. Top of the TicketException hierarchy.
* Generic ticket exception. Top of the AbstractTicketException hierarchy.
*
* @author Scott Battaglia
* @since 3.0.0
* @deprecated As of 4.1, the class is required to note its abstractness in the name and will be renamed in the future.
* @since 4.2.0
*/
@Deprecated
public abstract class TicketException extends RootCasException {
public abstract class AbstractTicketException extends RootCasException {
private static final long serialVersionUID = -5128676415951733624L;
/**
......@@ -37,7 +35,7 @@ public abstract class TicketException extends RootCasException {
* @param code the code
* @param throwable the throwable
*/
public TicketException(final String code, final Throwable throwable) {
public AbstractTicketException(final String code, final Throwable throwable) {
super(code, throwable);
}
......@@ -46,7 +44,7 @@ public abstract class TicketException extends RootCasException {
*
* @param code the code
*/
public TicketException(final String code) {
public AbstractTicketException(final String code) {
super(code);
}
......@@ -56,7 +54,7 @@ public abstract class TicketException extends RootCasException {
* @param code the code
* @param msg the msg
*/
public TicketException(final String code, final String msg) {
public AbstractTicketException(final String code, final String msg) {
super(code, msg);
}
}
......@@ -19,12 +19,12 @@
package org.jasig.cas.ticket;
/**
* TicketException to alert that a Ticket was not found or that it is expired.
* AbstractTicketException to alert that a Ticket was not found or that it is expired.
*
* @author Scott Battaglia
* @since 3.0.0
*/
public class InvalidTicketException extends TicketException {
public class InvalidTicketException extends AbstractTicketException {
private static final long serialVersionUID = 9141891414482490L;
......
......@@ -21,25 +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.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;
......@@ -48,12 +46,12 @@ 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;
import org.jasig.cas.ticket.Ticket;
import org.jasig.cas.ticket.TicketCreationException;
import org.jasig.cas.ticket.TicketException;
import org.jasig.cas.ticket.TicketGrantingTicket;
import org.jasig.cas.ticket.TicketGrantingTicketImpl;
import org.jasig.cas.ticket.UnrecognizableServiceForServiceTicketValidationException;
......@@ -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;
......@@ -248,7 +247,7 @@ public final class CentralAuthenticationServiceImpl implements CentralAuthentica
public ServiceTicket grantServiceTicket(
final String ticketGrantingTicketId,
final Service service, final Credential... credentials)
throws AuthenticationException, TicketException {
throws AuthenticationException, AbstractTicketException {
final TicketGrantingTicket ticketGrantingTicket = getTicket(ticketGrantingTicketId, TicketGrantingTicket.class);
final RegisteredService registeredService = this.servicesManager.findServiceBy(service);
......@@ -377,7 +376,7 @@ public final class CentralAuthenticationServiceImpl implements CentralAuthentica
@Counted(name="GRANT_SERVICE_TICKET_COUNTER", monotonic=true)
@Override
public ServiceTicket grantServiceTicket(final String ticketGrantingTicketId,
final Service service) throws TicketException {
final Service service) throws AbstractTicketException {
try {
return this.grantServiceTicket(ticketGrantingTicketId, service, (Credential[]) null);
} catch (final AuthenticationException e) {
......@@ -394,7 +393,7 @@ public final class CentralAuthenticationServiceImpl implements CentralAuthentica
@Counted(name="GRANT_PROXY_GRANTING_TICKET_COUNTER", monotonic=true)
@Override
public TicketGrantingTicket delegateTicketGrantingTicket(final String serviceTicketId, final Credential... credentials)
throws AuthenticationException, TicketException {
throws AuthenticationException, AbstractTicketException {
final ServiceTicket serviceTicket = this.serviceTicketRegistry.getTicket(serviceTicketId, ServiceTicket.class);
......@@ -434,7 +433,7 @@ public final class CentralAuthenticationServiceImpl implements CentralAuthentica
@Metered(name="VALIDATE_SERVICE_TICKET_METER")
@Counted(name="VALIDATE_SERVICE_TICKET_COUNTER", monotonic=true)
@Override
public Assertion validateServiceTicket(final String serviceTicketId, final Service service) throws TicketException {
public Assertion validateServiceTicket(final String serviceTicketId, final Service service) throws AbstractTicketException {
final RegisteredService registeredService = this.servicesManager.findServiceBy(service);
verifyRegisteredServiceProperties(registeredService, service);
......@@ -497,7 +496,7 @@ public final class CentralAuthenticationServiceImpl implements CentralAuthentica
@Counted(name="CREATE_TICKET_GRANTING_TICKET_COUNTER", monotonic=true)
@Override
public TicketGrantingTicket createTicketGrantingTicket(final Credential... credentials)
throws AuthenticationException, TicketException {
throws AuthenticationException, AbstractTicketException {
final Set<Credential> sanitizedCredentials = sanitizeCredentials(credentials);
if (!sanitizedCredentials.isEmpty()) {
......@@ -580,17 +579,6 @@ public final class CentralAuthenticationServiceImpl implements CentralAuthentica
this.serviceTicketExpirationPolicy = serviceTicketExpirationPolicy;
}
/**
* @deprecated
* Sets persistent id generator.
*
* @param persistentIdGenerator the persistent id generator
*/
@Deprecated
public void setPersistentIdGenerator(final PersistentIdGenerator persistentIdGenerator) {
logger.warn("setPersistentIdGenerator() is deprecated and no longer available. Consider "
+ "configuring the an attribute provider for service definitions.");
}
/**
* Sets principal factory to create principal objects.
......@@ -608,10 +596,10 @@ public final class CentralAuthenticationServiceImpl implements CentralAuthentica
* @param ticket the ticket
* @param context the context
* @return the authentication satisfied by policy
* @throws org.jasig.cas.ticket.TicketException the ticket exception
* @throws AbstractTicketException the ticket exception
*/
private Authentication getAuthenticationSatisfiedByPolicy(
final TicketGrantingTicket ticket, final ServiceContext context) throws TicketException {
final TicketGrantingTicket ticket, final ServiceContext context) throws AbstractTicketException {
final ContextualAuthenticationPolicy<ServiceContext> policy =
serviceContextAuthenticationPolicyFactory.createPolicy(context);
......
......@@ -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;
......@@ -52,19 +51,6 @@ public final class TicketOrCredentialPrincipalResolver implements PrincipalResol
@NotNull
private final CentralAuthenticationService centralAuthenticationService;
/**
* Instantiates a new ticket or credential principal resolver.
*
* @deprecated As of 4.1 access to the registry is no longer relevant
* Consider using alternative constructors instead.
* @param ticketRegistry the ticket registry
*/
@Deprecated
public TicketOrCredentialPrincipalResolver(final TicketRegistry ticketRegistry) {
LOGGER.warn("The constructor is deprecated and will be removed. Consider an alternate constructor");
this.centralAuthenticationService = null;
}
/**
* Instantiates a new Ticket or credential principal resolver.
*
......
......@@ -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();
}
}
}
/*
* Licensed to Apereo under one or more contributor license
* agreements. See the NOTICE file distributed with this work
* for additional information regarding copyright ownership.
* Apereo licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a
* copy of the License at the following location:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jasig.cas.authentication.handler;
import org.jasig.cas.authentication.RootCasException;
import javax.validation.constraints.NotNull;
/**
* The most generic type of authentication exception that one can catch if not
* sure what specific implementation will be thrown. Top of the tree of all
* other AuthenticationExceptions.
*
* @author Scott Battaglia
* @since 3.0.0
* @deprecated As of 4.1, the class is required to note its abstractness in the name and will be renamed in the future.
*/
@Deprecated
public abstract class AuthenticationException extends RootCasException {
/** Serializable ID. */
private static final long serialVersionUID = 3906648604830611762L;
private static final String DEFAULT_TYPE = "error";
/** The error type that provides additional info about the nature of the exception cause. **/
private final String type;
/**
* Instantiates a new authentication exception.
*
* @param code the code
*/
public AuthenticationException(final String code) {
this(code, "", DEFAULT_TYPE);
}
/**
* Instantiates a new authentication exception.
*
* @param code the code
* @param msg the msg
*/
public AuthenticationException(final String code, final String msg) {
this(code, msg, DEFAULT_TYPE);
}
/**
* @param type The type of the error message that caused the exception to be thrown. By default,
* all errors are considered of <code>error</code>.
* @param code the exception code
* @param msg the error message
*/
public AuthenticationException(final String code, final String msg, @NotNull final String type) {
super(code, msg);
this.type = type;
}
/**
* @param code the exception code
* @param throwable the exception that originally caused the authentication failure
*/
public AuthenticationException(final String code, final Throwable throwable) {
super(code, throwable);
this.type = DEFAULT_TYPE;
}
/**