1   package com.trendmicro.grid.acl.l0;
2   
3   import javax.xml.bind.annotation.*;
4   import javax.xml.ws.WebFault;
5   import java.util.Arrays;
6   import java.util.List;
7   
8   /**
9    * Defines the exception to throw if the logged in user has insufficient privileges.
10   *
11   * @author Juergen_Kellerer, 2010-04-26
12   * @version 1.0
13   */
14  @XmlAccessorType(XmlAccessType.FIELD)
15  @XmlType(namespace = Level0Constants.NAMESPACE)
16  @XmlRootElement(namespace = Level0Constants.NAMESPACE)
17  @WebFault(targetNamespace = Level0Constants.NAMESPACE)
18  public class InsufficientRightsException extends AuthenticationException {
19  
20  	private static final long serialVersionUID = -6186710714271668869L;
21  
22  	@XmlList
23  	@XmlAttribute
24  	private String[] requiredRoles;
25  
26  	@XmlList
27  	@XmlAttribute
28  	private String[] actualRoles;
29  
30  	public InsufficientRightsException() {
31  	}
32  
33  	public InsufficientRightsException(String message) {
34  		super(message);
35  	}
36  
37  	public InsufficientRightsException(String[] requiredRoles, String[] actualRoles) {
38  		super("AUTH01", String.format("Found actual user roles %s, whereas %s was expected.",
39  				Arrays.asList(actualRoles), Arrays.asList(requiredRoles)));
40  		this.requiredRoles = requiredRoles;
41  		this.actualRoles = actualRoles;
42  	}
43  
44  	public List<String> getRequiredRoles() {
45  		return Arrays.asList(requiredRoles);
46  	}
47  
48  	public List<String> getActualRoles() {
49  		return Arrays.asList(actualRoles);
50  	}
51  }