Changeset 788


Ignore:
Timestamp:
05/12/11 19:06:48 (8 years ago)
Author:
philsmart
Message:
 
Location:
raptor-information-model/trunk/src
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • raptor-information-model/trunk/src/main/java/uk/ac/cardiff/model/event/AuthenticationEvent.java

    r784 r788  
    2323/** 
    2424 * @author philsmart 
    25  *  
     25 * 
    2626 */ 
    2727public class AuthenticationEvent extends Event { 
     
    2929    private String authenticationType; 
    3030    private String principalName; 
    31      
     31 
    3232    /** This is fixed to a principal expansion */ 
    3333    private PrincipalInformation principalInformation; 
    34      
    35      
     34 
     35 
    3636    public AuthenticationEvent(){ 
    3737        super(); 
    3838    } 
    39      
     39 
    4040    /** 
    4141     * Copy constructor 
    42      *  
     42     * 
    4343     * @param event 
    4444     */ 
    45     public AuthenticationEvent(AuthenticationEvent event){ 
     45    protected AuthenticationEvent(AuthenticationEvent event){ 
    4646        super(event); 
    4747        this.authenticationType = event.getAuthenticationType(); 
    4848        this.principalName = event.getPrincipalName(); 
    49         this.principalInformation = new PrincipalInformation(event.getPrincipalInformation()); 
    50          
     49        if (event.getPrincipalInformation()!=null){ 
     50            this.principalInformation = new PrincipalInformation(event.getPrincipalInformation()); 
     51        } 
     52 
     53    } 
     54 
     55    /** 
     56     * Copy method. Alternative to clone. 
     57     */ 
     58    public AuthenticationEvent copy(){ 
     59        return new AuthenticationEvent(this); 
    5160    } 
    5261 
  • raptor-information-model/trunk/src/main/java/uk/ac/cardiff/model/event/Event.aegis.xml

    r614 r788  
    77                <property name="eventTime" ignore="true"/> 
    88                <property name="persistantId" ignore="true"/> 
     9                <property name="eventTimeMillis" ignore="true"/> 
    910        </mapping> 
    1011</mappings> 
  • raptor-information-model/trunk/src/main/java/uk/ac/cardiff/model/event/Event.java

    r784 r788  
    4444    private int resourceIdCategory; 
    4545 
    46      
     46 
    4747    public Event(){ 
    48          
     48 
    4949    } 
    50      
     50 
    5151    /** A Copy constructor */ 
    5252    public Event(Event event){ 
     
    6161        this.resourceIdCategory = event.getResourceIdCategory(); 
    6262    } 
    63      
     63 
     64    public Event copy(){ 
     65        return new Event(this); 
     66    } 
     67 
    6468    public static Event newInstance() { 
    6569        return new Event(); 
    6670      } 
    67      
    68      
     71 
     72 
    6973    public void setEventTime(DateTime eventTime) { 
    7074        this.eventTime = eventTime; 
     
    183187        return serviceId; 
    184188    } 
    185      
     189 
    186190 
    187191    public String toString() { 
  • raptor-information-model/trunk/src/main/java/uk/ac/cardiff/model/event/EzproxyAuthenticationEvent.java

    r784 r788  
    1818    private String requesterIp; 
    1919    private String sessionId; 
    20      
     20 
    2121    public EzproxyAuthenticationEvent(){ 
    2222        super(); 
    2323    } 
    24      
    25     public EzproxyAuthenticationEvent(EzproxyAuthenticationEvent event){ 
     24 
     25    protected EzproxyAuthenticationEvent(EzproxyAuthenticationEvent event){ 
    2626        super(event); 
    2727        this.requesterIp = event.getRequesterIp(); 
    2828        this.sessionId = event.getSessionId(); 
     29    } 
     30 
     31    /** 
     32     * Copy method. Alternative to clone. 
     33     */ 
     34    public EzproxyAuthenticationEvent copy(){ 
     35        return new EzproxyAuthenticationEvent(this); 
    2936    } 
    3037 
  • raptor-information-model/trunk/src/main/java/uk/ac/cardiff/model/event/EzproxyProxyEvent.java

    r784 r788  
    1414 
    1515    private String sessionId; 
    16      
     16 
    1717    public EzproxyProxyEvent(){ 
    1818        super(); 
    1919    } 
    20      
     20 
    2121    /** 
    2222     * Copy constructor 
    23      *  
     23     * 
    2424     * @param event 
    2525     */ 
    26     public EzproxyProxyEvent(EzproxyProxyEvent event){ 
     26    protected EzproxyProxyEvent(EzproxyProxyEvent event){ 
    2727        super(event); 
    2828        this.sessionId = event.getSessionId(); 
     29    } 
     30 
     31    /** 
     32     * Copy method. Alternative to clone. 
     33     */ 
     34    public EzproxyProxyEvent copy(){ 
     35        return new EzproxyProxyEvent(this); 
    2936    } 
    3037 
  • raptor-information-model/trunk/src/main/java/uk/ac/cardiff/model/event/OpenathenslaAuthenticationEvent.java

    r784 r788  
    1515        super(); 
    1616    } 
    17      
     17 
     18    /** 
     19     * Copy constructor. 
     20     * 
     21     * @param event 
     22     */ 
    1823    public OpenathenslaAuthenticationEvent(OpenathenslaAuthenticationEvent event){ 
    1924        super(event); 
    2025        this.requesterIP = event.getRequesterIP(); 
    2126    } 
    22      
     27 
     28    /** 
     29     * Copy method. Alternative to clone. 
     30     */ 
     31    public OpenathenslaAuthenticationEvent copy(){ 
     32        return new OpenathenslaAuthenticationEvent(this); 
     33    } 
     34 
     35 
    2336    public void setRequesterIP(String requesterIP) { 
    2437        this.requesterIP = requesterIP; 
  • raptor-information-model/trunk/src/main/java/uk/ac/cardiff/model/event/ProxyEvent.java

    r784 r788  
    1818    private DateTime responseTime; 
    1919    private String requesterIp; 
    20      
     20 
    2121    public ProxyEvent(){ 
    2222        super(); 
    2323    } 
    24      
     24 
    2525    /** 
    2626     * Copy constructor 
     
    3434        this.responseTime = event.getResponseTime(); 
    3535        this.requesterIp = event.getRequesterIp(); 
     36    } 
     37 
     38    /** 
     39     * Copy method. Alternative to clone. 
     40     */ 
     41    public ProxyEvent cop(){ 
     42        return new ProxyEvent(this); 
    3643    } 
    3744 
     
    5865        this.responseTime = responseTime; 
    5966    } 
    60      
     67 
    6168    /** 
    6269     * Get response time, using a defensive copy 
    63      *  
     70     * 
    6471     * @return 
    6572     */ 
  • raptor-information-model/trunk/src/main/java/uk/ac/cardiff/model/event/ShibbolethIdpAuthenticationEvent.java

    r784 r788  
    1919public class ShibbolethIdpAuthenticationEvent extends AuthenticationEvent{ 
    2020 
    21         private String requestPath; 
    2221        private String requestId; 
    2322        private String messageProfileId; 
     
    2928        private String[] releasedAttributes; 
    3029 
    31          
     30 
    3231        public ShibbolethIdpAuthenticationEvent(){ 
    3332            super(); 
    3433        } 
    35          
     34 
    3635        public static ShibbolethIdpAuthenticationEvent newInstance() { 
    3736            return new ShibbolethIdpAuthenticationEvent(); 
    3837          } 
    3938 
    40         /**  
    41          * Copy constructor  
    42          *  
     39        /** 
     40         * Copy constructor 
     41         * 
    4342         * @param event 
    4443         */ 
    45         public ShibbolethIdpAuthenticationEvent(ShibbolethIdpAuthenticationEvent event){ 
     44        protected ShibbolethIdpAuthenticationEvent(ShibbolethIdpAuthenticationEvent event){ 
    4645            super (event); 
    47             this.requestPath = event.getRequestPath(); 
    4846            this.requestId = event.getRequestId(); 
    4947            this.messageProfileId = event.getMessageProfileId(); 
     
    5250            this.requestBinding = event.getRequestBinding(); 
    5351            this.nameIdentifier = event.getNameIdentifier(); 
    54              
     52 
    5553            //shallow copy is OK here, as a new array is created with immutable objects (String). 
    5654            this.assertionId = event.getAssertionId().clone(); 
     
    5856        } 
    5957 
    60         public void setRequestPath(String requestPath) { 
    61                 this.requestPath = requestPath; 
    62         } 
    63         public String getRequestPath() { 
    64                 return requestPath; 
    65         } 
     58            /** 
     59             * Copy method. Alternative to clone. 
     60             */ 
     61         public ShibbolethIdpAuthenticationEvent copy(){ 
     62              return new ShibbolethIdpAuthenticationEvent(this); 
     63         } 
    6664 
    6765        public void setResponseBinding(String responseBinding) { 
     
    137135              EqualsUtil.areEqual(this.getServiceHost(), that.getServiceHost()) && 
    138136              EqualsUtil.areEqual(this.getRequestId(), that.getRequestId()) && 
    139               EqualsUtil.areEqual(this.getRequestPath(), that.getRequestPath()) && 
    140137              EqualsUtil.areEqual(this.getResponseBinding(), that.getResponseBinding()) && 
    141138              EqualsUtil.areEqual(this.getResourceHost(), that.getResourceHost()) && 
     
    185182            hash = HashCodeUtil.hash(hash,getServiceHost()); 
    186183            hash = HashCodeUtil.hash(hash,getRequestId()); 
    187             hash = HashCodeUtil.hash(hash,getRequestPath()); 
    188184            hash = HashCodeUtil.hash(hash,getResponseBinding()); 
    189185            hash = HashCodeUtil.hash(hash,getResourceHost()); 
  • raptor-information-model/trunk/src/main/java/uk/ac/cardiff/model/event/event.hbm.xml

    r781 r788  
    6868 
    6969 
    70                 <property name="requestPath" column="requestPath" type="string" /> 
    7170                <property name="requestId" column="requestID" type="string" /> 
    7271                <property name="messageProfileId" column="messageProfileId" 
  • raptor-information-model/trunk/src/test/java/uk/ac/cardiff/model/event/ShibbolethEntryTest.java

    r784 r788  
    3737        entry.setServiceHost("https://abc.cardiff.ac.uk/sp/shibboleth"); 
    3838        entry.setRequestId(""); 
    39         entry.setRequestPath(""); 
    4039        entry.setResponseBinding("urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"); 
    4140        entry.setResourceHost("https://idp.cardiff.ac.uk/shibboleth"); 
     
    5453        equalEntry.setServiceHost("https://abc.cardiff.ac.uk/sp/shibboleth"); 
    5554        equalEntry.setRequestId(""); 
    56         equalEntry.setRequestPath(""); 
    5755        equalEntry.setResponseBinding("urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"); 
    5856        equalEntry.setResourceHost("https://idp.cardiff.ac.uk/shibboleth"); 
     
    8280        entry.setServiceHost("https://abc.cardiff.ac.uk/sp/shibboleth"); 
    8381        entry.setRequestId(""); 
    84         entry.setRequestPath(""); 
    8582        entry.setResponseBinding("urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"); 
    8683        entry.setResourceHost("https://idp.cardiff.ac.uk/shibboleth"); 
     
    9996        equalEntry.setServiceHost("https://abc.cardiff.ac.uk/sp/shibboleth"); 
    10097        equalEntry.setRequestId(""); 
    101         equalEntry.setRequestPath(""); 
    10298        equalEntry.setResponseBinding("urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"); 
    10399        equalEntry.setResourceHost("https://idp.cardiff.ac.uk/shibboleth"); 
     
    127123        entry.setServiceHost("https://abc.cardiff.ac.uk/sp/shibboleth"); 
    128124        entry.setRequestId(""); 
    129         entry.setRequestPath(""); 
    130125        entry.setResponseBinding("urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"); 
    131126        entry.setResourceHost("https://idp.cardiff.ac.uk/shibboleth"); 
     
    144139        equalEntry.setServiceHost("https://abc.cardiff.ac.uk/sp/shibboleth"); 
    145140        equalEntry.setRequestId(""); 
    146         equalEntry.setRequestPath(""); 
    147141        equalEntry.setResponseBinding("urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"); 
    148142        equalEntry.setResourceHost("https://idp.cardiff.ac.uk/shibboleth"); 
     
    154148 
    155149    } 
    156      
    157     @Test 
    158     public void testConstructorCopy(){ 
     150 
     151    @Test 
     152    public void testConstructorCopyChangesDoNotEffectOriginal(){ 
    159153        ShibbolethIdpAuthenticationEvent entry = new ShibbolethIdpAuthenticationEvent(); 
    160154        entry.setAuthenticationType("urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport"); 
     
    169163        entry.setServiceHost("https://abc.cardiff.ac.uk/sp/shibboleth"); 
    170164        entry.setRequestId(""); 
    171         entry.setRequestPath(""); 
    172165        entry.setResponseBinding("urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"); 
    173166        entry.setResourceHost("https://idp.cardiff.ac.uk/shibboleth"); 
     
    180173        entry.setPrincipalInformation(principle); 
    181174        entry.setResourceId("http://raptor.test"); 
    182          
     175        entry.setResourceIdCategory(1); 
     176 
    183177        System.out.println("testConstructorCopy:First Event :"+entry); 
    184178        int hashBefore = entry.getHashCode(); 
    185179 
    186180 
    187         ShibbolethIdpAuthenticationEvent copy =  new ShibbolethIdpAuthenticationEvent(entry); 
     181        ShibbolethIdpAuthenticationEvent copy =  entry.copy(); 
    188182        copy.setAuthenticationType("urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport-new"); 
    189183        eventTime ="20111117T184343"; 
     
    197191        copy.setServiceHost("https://abc.cardiff.ac.uk/sp/shibboleth-new"); 
    198192        copy.setRequestId("new"); 
    199         copy.setRequestPath("new"); 
    200193        copy.setResponseBinding("urn:oasis:names:tc:SAML:2.0:bindings:HTTP-SOAP-new"); 
    201194        copy.setResourceHost("https://idp.cardiff.ac.uk/shibboleth-new"); 
     
    206199        copy.setPrincipalInformation(principleCopy); 
    207200        copy.setResourceId("http://raptor.test.new"); 
    208  
    209          
     201        copy.setResourceIdCategory(2); 
     202 
     203 
    210204        System.out.println("testConstructorCopy:Copied Event:"+copy); 
    211205        System.out.println("testConstructorCopy:First After :"+entry); 
    212          
     206 
    213207        System.out.println("testConstructorCopy:First:Shibboleth Event, First Instance has hash ["+hashBefore+"], " + 
    214208                "Copy has Hash ["+copy.getHashCode()+"], First after copy has hash ["+entry.getHashCode()+"], first and firts after copy" + 
    215209                                "should be equal ["+(hashBefore==entry.getHashCode())+"]"); 
    216          
     210 
    217211        assertTrue(hashBefore==entry.getHashCode()); 
    218212    } 
    219      
     213 
    220214    /** 
    221215     * Test that a copy produces the same object 
     
    235229        entry.setServiceHost("https://abc.cardiff.ac.uk/sp/shibboleth"); 
    236230        entry.setRequestId(""); 
    237         entry.setRequestPath(""); 
    238231        entry.setResponseBinding("urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"); 
    239232        entry.setResourceHost("https://idp.cardiff.ac.uk/shibboleth"); 
     
    246239        entry.setPrincipalInformation(principle); 
    247240        entry.setResourceId("http://raptor.test"); 
    248          
    249  
    250  
    251         ShibbolethIdpAuthenticationEvent copy = new ShibbolethIdpAuthenticationEvent(entry); 
     241 
     242 
     243 
     244        ShibbolethIdpAuthenticationEvent copy = entry.copy(); 
    252245        copy.setAuthenticationType("urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport"); 
    253246        eventTime ="20101117T184343"; 
     
    261254        copy.setServiceHost("https://abc.cardiff.ac.uk/sp/shibboleth"); 
    262255        copy.setRequestId(""); 
    263         copy.setRequestPath(""); 
    264256        copy.setResponseBinding("urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"); 
    265257        copy.setResourceHost("https://idp.cardiff.ac.uk/shibboleth"); 
     
    270262        entry.setPrincipalInformation(principleCopy); 
    271263        entry.setResourceId("http://raptor.test"); 
    272          
     264 
    273265        System.out.println("testShibConstructorCopyEquals:Shibboleth Event, First Instance has hash ["+entry.getHashCode()+"], " + 
    274266                        "Copy has Hash ["+copy.getHashCode()+"], are equal ["+(entry.getHashCode()==copy.getHashCode())+"]"); 
Note: See TracChangeset for help on using the changeset viewer.