Changeset 1204


Ignore:
Timestamp:
12/04/11 23:05:16 (9 years ago)
Author:
philsmart
Message:
 
Location:
raptor-information-model/trunk
Files:
4 added
9 edited

Legend:

Unmodified
Added
Removed
  • raptor-information-model/trunk/pom.xml

    r1147 r1204  
    1919 
    2020                </dependency> 
    21                 <dependency> 
    22                         <groupId>junit</groupId> 
    23                         <artifactId>junit</artifactId> 
    24                         <version>4.8.2</version> 
    25                 </dependency> 
     21 
    2622        <dependency> 
    2723            <groupId>ch.qos.logback</groupId> 
     
    2925            <version>0.9.27</version> 
    3026            <scope>provided</scope> 
     27        </dependency> 
     28        <dependency> 
     29                <groupId>org.testng</groupId> 
     30                <artifactId>testng</artifactId> 
     31                <version>6.3.1</version> 
    3132        </dependency> 
    3233        </dependencies> 
  • raptor-information-model/trunk/src/main/java/uk/ac/cardiff/model/event/Event.java

    r1178 r1204  
    4848    private int eventId; 
    4949 
    50     /** The service id. */ 
     50    /** The service id. This is the service that serves the event. */ 
    5151    private String serviceId; 
    5252 
     
    5454    private String eventType; 
    5555 
    56     /** The service host. */ 
     56    /** The hostname of the service that provided this event. */ 
    5757    private String serviceHost; 
    5858 
    59     /** The resource host. */ 
     59    /** The hostname of the resource you are using. */ 
    6060    private String resourceHost; 
    6161 
    62     /** The resource id. */ 
     62    /** The resource id. This is the resource you are using. */ 
    6363    private String resourceId; 
    6464 
  • raptor-information-model/trunk/src/main/java/uk/ac/cardiff/model/event/event.hbm.xml

    r1143 r1204  
    3434 
    3535                --><property name="serviceHost" type="string" update="true" 
    36                         insert="true" column="serviceHost" not-null="false" index="requesthost_i" /> 
     36                        insert="true" column="serviceHost" not-null="false" index="requesthost_i" length="400" /> 
    3737                <property name="resourceHost" type="string" update="true" 
    3838                        insert="true" column="resourceHost" not-null="false" /> 
     
    9090                <property name="requestBinding" column="requestBinding" type="string" /> 
    9191                <property name="releasedAttributes" column="releasedAttributes" 
    92                         type="uk.ac.cardiff.model.hibernate.types.CommaDelimStringToListUserType" /> 
     92                        type="uk.ac.cardiff.model.hibernate.types.CommaDelimStringToListUserType" length="400"/> 
    9393                <property name="assertionId" column="assertionId" 
    9494                        type="uk.ac.cardiff.model.hibernate.types.CommaDelimStringToListUserType" /> 
  • raptor-information-model/trunk/src/main/java/uk/ac/cardiff/model/wsmodel/Capabilities.java

    r1172 r1204  
    55 
    66import java.io.Serializable; 
     7import java.util.Date; 
    78import java.util.List; 
    89 
     
    2627    private List<StatisticalUnitInformation> statisticalServices; 
    2728 
    28     /** Any error message that occurs during processing. */ 
     29    /** Any error message that occurs during processing the attached MUAs capabilities. */ 
    2930    private String errorMessage; 
    3031 
    31     /** If an error occured during processing. */ 
     32    /** If an error occured during processing the attached MUAs capabilities. */ 
    3233    private boolean error; 
    3334 
     
    4445    private long numberOfEntries; 
    4546 
     47    /** The date of the latest event in the attached MUA. */ 
     48    private Date latestEventTime; 
     49 
     50    /** The date of the earliest event in the attached MUA. */ 
     51    private Date earliestEventTime; 
     52 
     53    /** A list of event types and how many events are stored for each type in the attached MUA. */ 
     54    private List<EventTypeInformation> eventsPerType; 
     55 
     56    /** The version of the attached mua */ 
     57    private String muaVersion; 
     58 
    4659    /** 
    4760     * Sets the statistical services. 
     
    197210    } 
    198211 
     212    /** 
     213     * @param latestEventTime 
     214     *            the latestEventTime to set 
     215     */ 
     216    public void setLatestEventTime(Date latestEventTime) { 
     217        this.latestEventTime = latestEventTime; 
     218    } 
     219 
     220    /** 
     221     * @return the latestEventTime 
     222     */ 
     223    public Date getLatestEventTime() { 
     224        return latestEventTime; 
     225    } 
     226 
     227    /** 
     228     * @param earliestEventTime 
     229     *            the earliestEventTime to set 
     230     */ 
     231    public void setEarliestEventTime(Date earliestEventTime) { 
     232        this.earliestEventTime = earliestEventTime; 
     233    } 
     234 
     235    /** 
     236     * @return the earliestEventTime 
     237     */ 
     238    public Date getEarliestEventTime() { 
     239        return earliestEventTime; 
     240    } 
     241 
     242    /** 
     243     * @param eventsPerType 
     244     *            the eventsPerType to set 
     245     */ 
     246    public void setEventsPerType(List<EventTypeInformation> eventsPerType) { 
     247        this.eventsPerType = eventsPerType; 
     248    } 
     249 
     250    /** 
     251     * @return the eventsPerType 
     252     */ 
     253    public List<EventTypeInformation> getEventsPerType() { 
     254        return eventsPerType; 
     255    } 
     256 
     257    /** 
     258     * @param muaVersion the muaVersion to set 
     259     */ 
     260    public void setMuaVersion(String muaVersion) { 
     261        this.muaVersion = muaVersion; 
     262    } 
     263 
     264    /** 
     265     * @return the muaVersion 
     266     */ 
     267    public String getMuaVersion() { 
     268        return muaVersion; 
     269    } 
     270 
    199271} 
  • raptor-information-model/trunk/src/main/java/uk/ac/cardiff/model/wsmodel/MethodParameter.java

    r1172 r1204  
    1212 * The Class MethodParameter. 
    1313 *  
    14  * @author philsmart 
    1514 */ 
    1615public class MethodParameter implements Serializable { 
     
    3534    private ParameterType parameterType; 
    3635 
    37     /** friendly name of the parameter, for the benefit of the view. */ 
     36    /** friendly name of the parameter. */ 
    3837    private String parameterName; 
    3938 
    40     /** value of the parameter. */ 
    41     private String value; 
     39    /** Generic value of the parameter. */ 
     40    private Object value; 
     41 
     42    /** 
     43     * The class type of the value object, used by the view component to understand the value to set. Stored as a string for remoting. 
     44     */ 
     45    private String valueType; 
    4246 
    4347    /** 
     
    4751     *            the new value 
    4852     */ 
    49     public void setValue(String value) { 
     53    public void setValue(Object value) { 
    5054        this.value = value; 
     55    } 
     56 
     57    /** 
     58     * Gets the value assuming the type, throws an error if the value does not equal the type. 
     59     *  
     60     * @param requiredType 
     61     *            the class that needs to match with <code>value</code>. 
     62     */ 
     63    public <T> T getValue(Class<T> requiredType) throws MethodParameterNotOfRequiredTypeException { 
     64        if (requiredType.isAssignableFrom(value.getClass())) { 
     65            return (T) value; 
     66        } else { 
     67            throw new MethodParameterNotOfRequiredTypeException(parameterName, requiredType, value.getClass()); 
     68        } 
     69 
    5170    } 
    5271 
     
    5675     * @return the value 
    5776     */ 
    58     public String getValue() { 
     77    public Object getValue() { 
    5978        return value; 
    6079    } 
     
    98117    } 
    99118 
     119    /** 
     120     * @param valueType 
     121     *            the valueType to set 
     122     */ 
     123    public void setValueType(String valueType) { 
     124        this.valueType = valueType; 
     125    } 
     126 
     127    /** 
     128     * @return the valueType 
     129     */ 
     130    public String getValueType() { 
     131        return valueType; 
     132    } 
     133 
    100134} 
  • raptor-information-model/trunk/src/main/java/uk/ac/cardiff/model/wsmodel/ProcessorInformation.java

    r1076 r1204  
    22 
    33import java.io.Serializable; 
     4import java.util.List; 
    45 
     6/** 
     7 * Used to encapsulate processor information for sending between MUA and Web. Related closely to the MUA only {@link ProcessorTemplate}. 
     8 *  
     9 */ 
    510public class ProcessorInformation implements Serializable { 
    611 
     
    813    private static final long serialVersionUID = 3004339123572624352L; 
    914 
    10     /** Bean name of the processor */ 
    11     private String beanName; 
     15    /** canoncial name of the class type of this processor. Not a class type due to ageis binding. **/ 
     16    private String processorClass; 
    1217 
    13     /** Name (fully qualified) of this processors class **/ 
    14     private String className; 
     18    private String friendlyName; 
     19 
     20    private List<MethodParameter> methodParameters; 
    1521 
    1622    /** 
    17      * @param beanName 
    18      *            the beanName to set 
     23     * @param methodParameters 
     24     *            the methodParameters to set 
    1925     */ 
    20     public void setBeanName(String beanName) { 
    21         this.beanName = beanName; 
     26    public void setMethodParameters(List<MethodParameter> methodParameters) { 
     27        this.methodParameters = methodParameters; 
    2228    } 
    2329 
    2430    /** 
    25      * @return the beanName 
     31     * @return the methodParameters 
    2632     */ 
    27     public String getBeanName() { 
    28         return beanName; 
     33    public List<MethodParameter> getMethodParameters() { 
     34        return methodParameters; 
    2935    } 
    3036 
    3137    /** 
    32      * @param className 
    33      *            the className to set 
     38     * @param processorClass 
     39     *            the processorClass to set 
    3440     */ 
    35     public void setClassName(String className) { 
    36         this.className = className; 
     41    public void setProcessorClass(String processorClass) { 
     42        this.processorClass = processorClass; 
    3743    } 
    3844 
    3945    /** 
    40      * @return the className 
     46     * @return the processorClass 
    4147     */ 
    42     public String getClassName() { 
    43         return className; 
     48    public String getProcessorClass() { 
     49        return processorClass; 
     50    } 
     51 
     52    /** 
     53     * @param friendlyName 
     54     *            the friendlyName to set 
     55     */ 
     56    public void setFriendlyName(String friendlyName) { 
     57        this.friendlyName = friendlyName; 
     58    } 
     59 
     60    /** 
     61     * @return the friendlyName 
     62     */ 
     63    public String getFriendlyName() { 
     64        return friendlyName; 
    4465    } 
    4566 
  • raptor-information-model/trunk/src/main/java/uk/ac/cardiff/model/wsmodel/StatisticalUnitInformation.java

    r1076 r1204  
    4343 
    4444    /** 
    45      * human consumable output method for array of preprocessors 
    46      *  
    47      * @return 
    48      */ 
    49     public String getPreProcessorsAsString() { 
    50         StringBuilder output = new StringBuilder(); 
    51         if (preprocessors == null) 
    52             return output.toString(); 
    53         int count = 0; 
    54         for (ProcessorInformation preprocessor : preprocessors) { 
    55             output.append(preprocessor.getBeanName()); 
    56             if (count < preprocessors.size() - 1) 
    57                 output.append(", "); 
    58             count++; 
    59         } 
    60         return output.toString(); 
    61     } 
    62  
    63     /** 
    64      * human consumable output method for array of postprocessors 
    65      *  
    66      * @return 
    67      */ 
    68     public String getPostProcessorsAsString() { 
    69         StringBuilder output = new StringBuilder(); 
    70         if (preprocessors == null) 
    71             return output.toString(); 
    72         int count = 0; 
    73         for (ProcessorInformation postprocessor : postprocessors) { 
    74             output.append(postprocessor.getBeanName()); 
    75             if (count < postprocessors.size() - 1) 
    76                 output.append(", "); 
    77             count++; 
    78         } 
    79         return output.toString(); 
    80     } 
    81  
    82     /** 
    8345     * @param preprocessors 
    8446     *            the preprocessors to set 
     
    10062     */ 
    10163    public void setPostprocessors(List<ProcessorInformation> postprocessors) { 
    102         for (ProcessorInformation processor : postprocessors) { 
    103             log.debug("Post processor {} added", processor.getBeanName()); 
    104  
    105         } 
    10664        this.postprocessors = postprocessors; 
    10765    } 
  • raptor-information-model/trunk/src/main/java/uk/ac/cardiff/model/wsmodel/SuggestionValues.java

    r1178 r1204  
    2626 
    2727    /** The possible post processors. */ 
    28     private List<Suggestion> possiblePostProcessors; 
     28    private List<ProcessorInformation> possiblePostProcessors; 
    2929 
    3030    /** 
     
    122122 
    123123    /** 
    124      * Sets the possible post processors. 
    125      *  
    126      * @param possiblePostProcessors 
    127      *            the possiblePostProcessors to set 
     124     * @param possiblePostProcessors the possiblePostProcessors to set 
    128125     */ 
    129     public void setPossiblePostProcessors(List<Suggestion> possiblePostProcessors) { 
     126    public void setPossiblePostProcessors(List<ProcessorInformation> possiblePostProcessors) { 
    130127        this.possiblePostProcessors = possiblePostProcessors; 
    131128    } 
    132129 
    133130    /** 
    134      * Gets the possible post processors. 
    135      *  
    136131     * @return the possiblePostProcessors 
    137132     */ 
    138     public List<Suggestion> getPossiblePostProcessors() { 
     133    public List<ProcessorInformation> getPossiblePostProcessors() { 
    139134        return possiblePostProcessors; 
    140135    } 
    141136 
    142     /** 
    143      * Gets the possible post processor values list. 
    144      *  
    145      * @return the possible post processor values list 
    146      */ 
    147     public ArrayList<String> getPossiblePostProcessorValuesList() { 
    148         ArrayList<String> fields = new ArrayList<String>(); 
    149         if (possiblePostProcessors == null) 
    150             return fields; 
    151         for (Suggestion entry : possiblePostProcessors) { 
    152             fields.add(entry.getValue()); 
    153         } 
    154         return fields; 
    155     } 
    156  
    157137} 
  • raptor-information-model/trunk/src/test/java/uk/ac/cardiff/model/event/ShibbolethEntryTest.java

    r788 r1204  
    44package uk.ac.cardiff.model.event; 
    55 
    6  
    7 import static org.junit.Assert.assertTrue; 
    8  
    9 import org.hibernate.mapping.PrimaryKey; 
    106import org.joda.time.DateTime; 
    117import org.joda.time.format.DateTimeFormat; 
    128import org.joda.time.format.DateTimeFormatter; 
    13 import org.junit.Test; 
    14  
    15 import uk.ac.cardiff.model.event.ShibbolethIdpAuthenticationEvent; 
     9import org.testng.Assert; 
     10import org.testng.annotations.Test; 
     11 
    1612import uk.ac.cardiff.model.event.auxiliary.PrincipalInformation; 
    17  
    1813 
    1914/** 
    2015 * @author philsmart 
    21  * 
     16 *  
    2217 */ 
    2318public class ShibbolethEntryTest { 
    2419 
    2520    @Test 
    26     public void testHashCodeEqual(){ 
    27         ShibbolethIdpAuthenticationEvent entry = new ShibbolethIdpAuthenticationEvent(); 
    28         entry.setAuthenticationType("urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport"); 
    29         String eventTime ="20101117T184343"; 
    30         DateTimeFormatter dtf = DateTimeFormat.forPattern("yyyyMMdd'T'HHmmss"); 
    31         DateTime dt = dtf.parseDateTime(eventTime); 
    32         entry.setEventTime(dt); 
    33         entry.setMessageProfileId("urn:mace:shibboleth:2.0:profiles:saml2:sso"); 
    34         entry.setPrincipalName("scmps2"); 
    35         entry.setRequestBinding("urn:mace:shibboleth:1.0:profiles:AuthnRequest"); 
    36         entry.setReleasedAttributes(new String[]{"eduPersonScopedAffiliation","eduPersonEntitlement"}); 
    37         entry.setServiceHost("https://abc.cardiff.ac.uk/sp/shibboleth"); 
    38         entry.setRequestId(""); 
    39         entry.setResponseBinding("urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"); 
    40         entry.setResourceHost("https://idp.cardiff.ac.uk/shibboleth"); 
    41  
    42  
    43         ShibbolethIdpAuthenticationEvent equalEntry = new ShibbolethIdpAuthenticationEvent(); 
    44         equalEntry.setAuthenticationType("urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport"); 
    45         eventTime ="20101117T184343"; 
    46         dtf = DateTimeFormat.forPattern("yyyyMMdd'T'HHmmss"); 
    47         dt = dtf.parseDateTime(eventTime); 
    48         equalEntry.setEventTime(dt); 
    49         equalEntry.setMessageProfileId("urn:mace:shibboleth:2.0:profiles:saml2:sso"); 
    50         equalEntry.setPrincipalName("scmps2"); 
    51         equalEntry.setRequestBinding("urn:mace:shibboleth:1.0:profiles:AuthnRequest"); 
    52         equalEntry.setReleasedAttributes(new String[]{"eduPersonScopedAffiliation","eduPersonEntitlement"}); 
    53         equalEntry.setServiceHost("https://abc.cardiff.ac.uk/sp/shibboleth"); 
    54         equalEntry.setRequestId(""); 
    55         equalEntry.setResponseBinding("urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"); 
    56         equalEntry.setResourceHost("https://idp.cardiff.ac.uk/shibboleth"); 
    57  
    58         System.out.println("testHashCodeEqual: Entry One Hash ["+entry.hashCode()+"] : Entry Two Hash ["+equalEntry.hashCode()+"] : Are Equal: "+entry.equals(equalEntry)); 
    59  
    60         assertTrue(entry.equals(equalEntry)); 
    61  
     21    public void testHashCodeEqual() { 
     22        ShibbolethIdpAuthenticationEvent entry = new ShibbolethIdpAuthenticationEvent(); 
     23        entry.setAuthenticationType("urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport"); 
     24        String eventTime = "20101117T184343"; 
     25        DateTimeFormatter dtf = DateTimeFormat.forPattern("yyyyMMdd'T'HHmmss"); 
     26        DateTime dt = dtf.parseDateTime(eventTime); 
     27        entry.setEventTime(dt); 
     28        entry.setMessageProfileId("urn:mace:shibboleth:2.0:profiles:saml2:sso"); 
     29        entry.setPrincipalName("scmps2"); 
     30        entry.setRequestBinding("urn:mace:shibboleth:1.0:profiles:AuthnRequest"); 
     31        entry.setReleasedAttributes(new String[] { "eduPersonScopedAffiliation", "eduPersonEntitlement" }); 
     32        entry.setServiceHost("https://abc.cardiff.ac.uk/sp/shibboleth"); 
     33        entry.setRequestId(""); 
     34        entry.setResponseBinding("urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"); 
     35        entry.setResourceHost("https://idp.cardiff.ac.uk/shibboleth"); 
     36 
     37        ShibbolethIdpAuthenticationEvent equalEntry = new ShibbolethIdpAuthenticationEvent(); 
     38        equalEntry.setAuthenticationType("urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport"); 
     39        eventTime = "20101117T184343"; 
     40        dtf = DateTimeFormat.forPattern("yyyyMMdd'T'HHmmss"); 
     41        dt = dtf.parseDateTime(eventTime); 
     42        equalEntry.setEventTime(dt); 
     43        equalEntry.setMessageProfileId("urn:mace:shibboleth:2.0:profiles:saml2:sso"); 
     44        equalEntry.setPrincipalName("scmps2"); 
     45        equalEntry.setRequestBinding("urn:mace:shibboleth:1.0:profiles:AuthnRequest"); 
     46        equalEntry.setReleasedAttributes(new String[] { "eduPersonScopedAffiliation", "eduPersonEntitlement" }); 
     47        equalEntry.setServiceHost("https://abc.cardiff.ac.uk/sp/shibboleth"); 
     48        equalEntry.setRequestId(""); 
     49        equalEntry.setResponseBinding("urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"); 
     50        equalEntry.setResourceHost("https://idp.cardiff.ac.uk/shibboleth"); 
     51 
     52        System.out.println("testHashCodeEqual: Entry One Hash [" + entry.hashCode() + "] : Entry Two Hash [" + equalEntry.hashCode() + "] : Are Equal: " + entry.equals(equalEntry)); 
     53 
     54        Assert.assertTrue(entry.equals(equalEntry)); 
    6255 
    6356    } 
     
    6760     */ 
    6861    @Test 
    69     public void testHashCodeNotEqualDate(){ 
    70         ShibbolethIdpAuthenticationEvent entry = new ShibbolethIdpAuthenticationEvent(); 
    71         entry.setAuthenticationType("urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport"); 
    72         String eventTime ="20101117T184343"; 
    73         DateTimeFormatter dtf = DateTimeFormat.forPattern("yyyyMMdd'T'HHmmss"); 
    74         DateTime dt = dtf.parseDateTime(eventTime); 
    75         entry.setEventTime(dt); 
    76         entry.setMessageProfileId("urn:mace:shibboleth:2.0:profiles:saml2:sso"); 
    77         entry.setPrincipalName("scmps2"); 
    78         entry.setRequestBinding("urn:mace:shibboleth:1.0:profiles:AuthnRequest"); 
    79         entry.setReleasedAttributes(new String[]{"eduPersonScopedAffiliation","eduPersonEntitlement"}); 
    80         entry.setServiceHost("https://abc.cardiff.ac.uk/sp/shibboleth"); 
    81         entry.setRequestId(""); 
    82         entry.setResponseBinding("urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"); 
    83         entry.setResourceHost("https://idp.cardiff.ac.uk/shibboleth"); 
    84  
    85  
    86         ShibbolethIdpAuthenticationEvent equalEntry = new ShibbolethIdpAuthenticationEvent(); 
    87         equalEntry.setAuthenticationType("urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport"); 
    88         eventTime ="20101117T184342"; //changed 3 to 2 at the end 
    89         dtf = DateTimeFormat.forPattern("yyyyMMdd'T'HHmmss"); 
    90         dt = dtf.parseDateTime(eventTime); 
    91         equalEntry.setEventTime(dt); 
    92         equalEntry.setMessageProfileId("urn:mace:shibboleth:2.0:profiles:saml2:sso"); 
    93         equalEntry.setPrincipalName("scmps2"); 
    94         equalEntry.setRequestBinding("urn:mace:shibboleth:1.0:profiles:AuthnRequest"); 
    95         equalEntry.setReleasedAttributes(new String[]{"eduPersonScopedAffiliation","eduPersonEntitlement"}); 
    96         equalEntry.setServiceHost("https://abc.cardiff.ac.uk/sp/shibboleth"); 
    97         equalEntry.setRequestId(""); 
    98         equalEntry.setResponseBinding("urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"); 
    99         equalEntry.setResourceHost("https://idp.cardiff.ac.uk/shibboleth"); 
    100  
    101         System.out.println("testHashCodeNotEqualDate: Entry One Hash ["+entry.hashCode()+"] : Entry Two Hash ["+equalEntry.hashCode()+"] : Are Equal: "+entry.equals(equalEntry)); 
    102  
    103         assertTrue(!entry.equals(equalEntry)); 
    104  
     62    public void testHashCodeNotEqualDate() { 
     63        ShibbolethIdpAuthenticationEvent entry = new ShibbolethIdpAuthenticationEvent(); 
     64        entry.setAuthenticationType("urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport"); 
     65        String eventTime = "20101117T184343"; 
     66        DateTimeFormatter dtf = DateTimeFormat.forPattern("yyyyMMdd'T'HHmmss"); 
     67        DateTime dt = dtf.parseDateTime(eventTime); 
     68        entry.setEventTime(dt); 
     69        entry.setMessageProfileId("urn:mace:shibboleth:2.0:profiles:saml2:sso"); 
     70        entry.setPrincipalName("scmps2"); 
     71        entry.setRequestBinding("urn:mace:shibboleth:1.0:profiles:AuthnRequest"); 
     72        entry.setReleasedAttributes(new String[] { "eduPersonScopedAffiliation", "eduPersonEntitlement" }); 
     73        entry.setServiceHost("https://abc.cardiff.ac.uk/sp/shibboleth"); 
     74        entry.setRequestId(""); 
     75        entry.setResponseBinding("urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"); 
     76        entry.setResourceHost("https://idp.cardiff.ac.uk/shibboleth"); 
     77 
     78        ShibbolethIdpAuthenticationEvent equalEntry = new ShibbolethIdpAuthenticationEvent(); 
     79        equalEntry.setAuthenticationType("urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport"); 
     80        eventTime = "20101117T184342"; // changed 3 to 2 at the end 
     81        dtf = DateTimeFormat.forPattern("yyyyMMdd'T'HHmmss"); 
     82        dt = dtf.parseDateTime(eventTime); 
     83        equalEntry.setEventTime(dt); 
     84        equalEntry.setMessageProfileId("urn:mace:shibboleth:2.0:profiles:saml2:sso"); 
     85        equalEntry.setPrincipalName("scmps2"); 
     86        equalEntry.setRequestBinding("urn:mace:shibboleth:1.0:profiles:AuthnRequest"); 
     87        equalEntry.setReleasedAttributes(new String[] { "eduPersonScopedAffiliation", "eduPersonEntitlement" }); 
     88        equalEntry.setServiceHost("https://abc.cardiff.ac.uk/sp/shibboleth"); 
     89        equalEntry.setRequestId(""); 
     90        equalEntry.setResponseBinding("urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"); 
     91        equalEntry.setResourceHost("https://idp.cardiff.ac.uk/shibboleth"); 
     92 
     93        System.out.println("testHashCodeNotEqualDate: Entry One Hash [" + entry.hashCode() + "] : Entry Two Hash [" + equalEntry.hashCode() + "] : Are Equal: " + entry.equals(equalEntry)); 
     94 
     95        Assert.assertTrue(!entry.equals(equalEntry)); 
    10596 
    10697    } 
     
    110101     */ 
    111102    @Test 
    112     public void testHashCodeNotEqualReleasedAttributes(){ 
    113         ShibbolethIdpAuthenticationEvent entry = new ShibbolethIdpAuthenticationEvent(); 
    114         entry.setAuthenticationType("urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport"); 
    115         String eventTime ="20101117T184343"; 
    116         DateTimeFormatter dtf = DateTimeFormat.forPattern("yyyyMMdd'T'HHmmss"); 
    117         DateTime dt = dtf.parseDateTime(eventTime); 
    118         entry.setEventTime(dt); 
    119         entry.setMessageProfileId("urn:mace:shibboleth:2.0:profiles:saml2:sso"); 
    120         entry.setPrincipalName("scmps2"); 
    121         entry.setRequestBinding("urn:mace:shibboleth:1.0:profiles:AuthnRequest"); 
    122         entry.setReleasedAttributes(new String[]{"eduPersonScopedAffiliation","eduPersonEntitlement"}); 
    123         entry.setServiceHost("https://abc.cardiff.ac.uk/sp/shibboleth"); 
    124         entry.setRequestId(""); 
    125         entry.setResponseBinding("urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"); 
    126         entry.setResourceHost("https://idp.cardiff.ac.uk/shibboleth"); 
    127  
    128  
    129         ShibbolethIdpAuthenticationEvent equalEntry = new ShibbolethIdpAuthenticationEvent(); 
    130         equalEntry.setAuthenticationType("urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport"); 
    131         eventTime ="20101117T184343"; 
    132         dtf = DateTimeFormat.forPattern("yyyyMMdd'T'HHmmss"); 
    133         dt = dtf.parseDateTime(eventTime); 
    134         equalEntry.setEventTime(dt); 
    135         equalEntry.setMessageProfileId("urn:mace:shibboleth:2.0:profiles:saml2:sso"); 
    136         equalEntry.setPrincipalName("scmps2"); 
    137         equalEntry.setRequestBinding("urn:mace:shibboleth:1.0:profiles:AuthnRequest"); 
    138         equalEntry.setReleasedAttributes(new String[]{"eduPersonScopedAffiliation"}); //removed eduPersonEntitlement 
    139         equalEntry.setServiceHost("https://abc.cardiff.ac.uk/sp/shibboleth"); 
    140         equalEntry.setRequestId(""); 
    141         equalEntry.setResponseBinding("urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"); 
    142         equalEntry.setResourceHost("https://idp.cardiff.ac.uk/shibboleth"); 
    143  
    144         System.out.println("testHashCodeNotEqualReleasedAttributes: Entry One Hash ["+entry.hashCode()+"] : Entry Two Hash ["+equalEntry.hashCode()+"] : Are Equal: "+entry.equals(equalEntry)); 
    145  
    146         assertTrue(!entry.equals(equalEntry)); 
    147  
    148  
    149     } 
    150  
    151     @Test 
    152     public void testConstructorCopyChangesDoNotEffectOriginal(){ 
    153         ShibbolethIdpAuthenticationEvent entry = new ShibbolethIdpAuthenticationEvent(); 
    154         entry.setAuthenticationType("urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport"); 
    155         String eventTime ="20101117T184343"; 
    156         DateTimeFormatter dtf = DateTimeFormat.forPattern("yyyyMMdd'T'HHmmss"); 
    157         DateTime dt = dtf.parseDateTime(eventTime); 
    158         entry.setEventTime(dt); 
    159         entry.setMessageProfileId("urn:mace:shibboleth:2.0:profiles:saml2:sso"); 
    160         entry.setPrincipalName("scmps2"); 
    161         entry.setRequestBinding("urn:mace:shibboleth:1.0:profiles:AuthnRequest"); 
    162         entry.setReleasedAttributes(new String[]{"eduPersonScopedAffiliation","eduPersonEntitlement"}); 
    163         entry.setServiceHost("https://abc.cardiff.ac.uk/sp/shibboleth"); 
    164         entry.setRequestId(""); 
    165         entry.setResponseBinding("urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"); 
    166         entry.setResourceHost("https://idp.cardiff.ac.uk/shibboleth"); 
    167         entry.setAssertionId(new String[]{"1"}); 
     103    public void testHashCodeNotEqualReleasedAttributes() { 
     104        ShibbolethIdpAuthenticationEvent entry = new ShibbolethIdpAuthenticationEvent(); 
     105        entry.setAuthenticationType("urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport"); 
     106        String eventTime = "20101117T184343"; 
     107        DateTimeFormatter dtf = DateTimeFormat.forPattern("yyyyMMdd'T'HHmmss"); 
     108        DateTime dt = dtf.parseDateTime(eventTime); 
     109        entry.setEventTime(dt); 
     110        entry.setMessageProfileId("urn:mace:shibboleth:2.0:profiles:saml2:sso"); 
     111        entry.setPrincipalName("scmps2"); 
     112        entry.setRequestBinding("urn:mace:shibboleth:1.0:profiles:AuthnRequest"); 
     113        entry.setReleasedAttributes(new String[] { "eduPersonScopedAffiliation", "eduPersonEntitlement" }); 
     114        entry.setServiceHost("https://abc.cardiff.ac.uk/sp/shibboleth"); 
     115        entry.setRequestId(""); 
     116        entry.setResponseBinding("urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"); 
     117        entry.setResourceHost("https://idp.cardiff.ac.uk/shibboleth"); 
     118 
     119        ShibbolethIdpAuthenticationEvent equalEntry = new ShibbolethIdpAuthenticationEvent(); 
     120        equalEntry.setAuthenticationType("urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport"); 
     121        eventTime = "20101117T184343"; 
     122        dtf = DateTimeFormat.forPattern("yyyyMMdd'T'HHmmss"); 
     123        dt = dtf.parseDateTime(eventTime); 
     124        equalEntry.setEventTime(dt); 
     125        equalEntry.setMessageProfileId("urn:mace:shibboleth:2.0:profiles:saml2:sso"); 
     126        equalEntry.setPrincipalName("scmps2"); 
     127        equalEntry.setRequestBinding("urn:mace:shibboleth:1.0:profiles:AuthnRequest"); 
     128        equalEntry.setReleasedAttributes(new String[] { "eduPersonScopedAffiliation" }); // removed eduPersonEntitlement 
     129        equalEntry.setServiceHost("https://abc.cardiff.ac.uk/sp/shibboleth"); 
     130        equalEntry.setRequestId(""); 
     131        equalEntry.setResponseBinding("urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"); 
     132        equalEntry.setResourceHost("https://idp.cardiff.ac.uk/shibboleth"); 
     133 
     134        System.out.println("testHashCodeNotEqualReleasedAttributes: Entry One Hash [" + entry.hashCode() + "] : Entry Two Hash [" + equalEntry.hashCode() + "] : Are Equal: " 
     135                + entry.equals(equalEntry)); 
     136 
     137        Assert.assertTrue(!entry.equals(equalEntry)); 
     138 
     139    } 
     140 
     141    @Test 
     142    public void testConstructorCopyChangesDoNotEffectOriginal() { 
     143        ShibbolethIdpAuthenticationEvent entry = new ShibbolethIdpAuthenticationEvent(); 
     144        entry.setAuthenticationType("urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport"); 
     145        String eventTime = "20101117T184343"; 
     146        DateTimeFormatter dtf = DateTimeFormat.forPattern("yyyyMMdd'T'HHmmss"); 
     147        DateTime dt = dtf.parseDateTime(eventTime); 
     148        entry.setEventTime(dt); 
     149        entry.setMessageProfileId("urn:mace:shibboleth:2.0:profiles:saml2:sso"); 
     150        entry.setPrincipalName("scmps2"); 
     151        entry.setRequestBinding("urn:mace:shibboleth:1.0:profiles:AuthnRequest"); 
     152        entry.setReleasedAttributes(new String[] { "eduPersonScopedAffiliation", "eduPersonEntitlement" }); 
     153        entry.setServiceHost("https://abc.cardiff.ac.uk/sp/shibboleth"); 
     154        entry.setRequestId(""); 
     155        entry.setResponseBinding("urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"); 
     156        entry.setResourceHost("https://idp.cardiff.ac.uk/shibboleth"); 
     157        entry.setAssertionId(new String[] { "1" }); 
    168158        entry.setEventId(100); 
    169159        entry.setNameIdentifier("name1"); 
     
    175165        entry.setResourceIdCategory(1); 
    176166 
    177         System.out.println("testConstructorCopy:First Event :"+entry); 
     167        System.out.println("testConstructorCopy:First Event :" + entry); 
    178168        int hashBefore = entry.getHashCode(); 
    179169 
    180  
    181         ShibbolethIdpAuthenticationEvent copy =  entry.copy(); 
     170        ShibbolethIdpAuthenticationEvent copy = entry.copy(); 
    182171        copy.setAuthenticationType("urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport-new"); 
    183         eventTime ="20111117T184343"; 
     172        eventTime = "20111117T184343"; 
    184173        dtf = DateTimeFormat.forPattern("yyyyMMdd'T'HHmmss"); 
    185174        dt = dtf.parseDateTime(eventTime); 
     
    188177        copy.setPrincipalName("new"); 
    189178        copy.setRequestBinding("urn:mace:shibboleth:1.0:profiles:AuthnRequest-new"); 
    190         copy.setReleasedAttributes(new String[]{"eduPersonScopedAffiliation"}); //removed eduPersonEntitlement 
     179        copy.setReleasedAttributes(new String[] { "eduPersonScopedAffiliation" }); // removed eduPersonEntitlement 
    191180        copy.setServiceHost("https://abc.cardiff.ac.uk/sp/shibboleth-new"); 
    192181        copy.setRequestId("new"); 
    193182        copy.setResponseBinding("urn:oasis:names:tc:SAML:2.0:bindings:HTTP-SOAP-new"); 
    194183        copy.setResourceHost("https://idp.cardiff.ac.uk/shibboleth-new"); 
    195         copy.setAssertionId(new String[]{"1","4"}); 
     184        copy.setAssertionId(new String[] { "1", "4" }); 
    196185        copy.setEventId(300); 
    197186        copy.setNameIdentifier("new"); 
     
    201190        copy.setResourceIdCategory(2); 
    202191 
    203  
    204         System.out.println("testConstructorCopy:Copied Event:"+copy); 
    205         System.out.println("testConstructorCopy:First After :"+entry); 
    206  
    207         System.out.println("testConstructorCopy:First:Shibboleth Event, First Instance has hash ["+hashBefore+"], " + 
    208                 "Copy has Hash ["+copy.getHashCode()+"], First after copy has hash ["+entry.getHashCode()+"], first and firts after copy" + 
    209                                 "should be equal ["+(hashBefore==entry.getHashCode())+"]"); 
    210  
    211         assertTrue(hashBefore==entry.getHashCode()); 
     192        System.out.println("testConstructorCopy:Copied Event:" + copy); 
     193        System.out.println("testConstructorCopy:First After :" + entry); 
     194 
     195        System.out.println("testConstructorCopy:First:Shibboleth Event, First Instance has hash [" + hashBefore + "], " + "Copy has Hash [" + copy.getHashCode() + "], First after copy has hash [" 
     196                + entry.getHashCode() + "], first and firts after copy" + "should be equal [" + (hashBefore == entry.getHashCode()) + "]"); 
     197 
     198        Assert.assertTrue(hashBefore == entry.getHashCode()); 
    212199    } 
    213200 
     
    216203     */ 
    217204    @Test 
    218     public void testShibConstructorCopyEquals(){ 
    219         ShibbolethIdpAuthenticationEvent entry = new ShibbolethIdpAuthenticationEvent(); 
    220         entry.setAuthenticationType("urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport"); 
    221         String eventTime ="20101117T184343"; 
    222         DateTimeFormatter dtf = DateTimeFormat.forPattern("yyyyMMdd'T'HHmmss"); 
    223         DateTime dt = dtf.parseDateTime(eventTime); 
    224         entry.setEventTime(dt); 
    225         entry.setMessageProfileId("urn:mace:shibboleth:2.0:profiles:saml2:sso"); 
    226         entry.setPrincipalName("scmps2"); 
    227         entry.setRequestBinding("urn:mace:shibboleth:1.0:profiles:AuthnRequest"); 
    228         entry.setReleasedAttributes(new String[]{"eduPersonScopedAffiliation","eduPersonEntitlement"}); 
    229         entry.setServiceHost("https://abc.cardiff.ac.uk/sp/shibboleth"); 
    230         entry.setRequestId(""); 
    231         entry.setResponseBinding("urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"); 
    232         entry.setResourceHost("https://idp.cardiff.ac.uk/shibboleth"); 
    233         entry.setAssertionId(new String[]{"1"}); 
     205    public void testShibConstructorCopyEquals() { 
     206        ShibbolethIdpAuthenticationEvent entry = new ShibbolethIdpAuthenticationEvent(); 
     207        entry.setAuthenticationType("urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport"); 
     208        String eventTime = "20101117T184343"; 
     209        DateTimeFormatter dtf = DateTimeFormat.forPattern("yyyyMMdd'T'HHmmss"); 
     210        DateTime dt = dtf.parseDateTime(eventTime); 
     211        entry.setEventTime(dt); 
     212        entry.setMessageProfileId("urn:mace:shibboleth:2.0:profiles:saml2:sso"); 
     213        entry.setPrincipalName("scmps2"); 
     214        entry.setRequestBinding("urn:mace:shibboleth:1.0:profiles:AuthnRequest"); 
     215        entry.setReleasedAttributes(new String[] { "eduPersonScopedAffiliation", "eduPersonEntitlement" }); 
     216        entry.setServiceHost("https://abc.cardiff.ac.uk/sp/shibboleth"); 
     217        entry.setRequestId(""); 
     218        entry.setResponseBinding("urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"); 
     219        entry.setResourceHost("https://idp.cardiff.ac.uk/shibboleth"); 
     220        entry.setAssertionId(new String[] { "1" }); 
    234221        entry.setEventId(100); 
    235222        entry.setNameIdentifier("name1"); 
     
    240227        entry.setResourceId("http://raptor.test"); 
    241228 
    242  
    243  
    244229        ShibbolethIdpAuthenticationEvent copy = entry.copy(); 
    245230        copy.setAuthenticationType("urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport"); 
    246         eventTime ="20101117T184343"; 
     231        eventTime = "20101117T184343"; 
    247232        dtf = DateTimeFormat.forPattern("yyyyMMdd'T'HHmmss"); 
    248233        dt = dtf.parseDateTime(eventTime); 
     
    251236        copy.setPrincipalName("scmps2"); 
    252237        copy.setRequestBinding("urn:mace:shibboleth:1.0:profiles:AuthnRequest"); 
    253         copy.setReleasedAttributes(new String[]{"eduPersonScopedAffiliation","eduPersonEntitlement"}); //removed eduPersonEntitlement 
     238        copy.setReleasedAttributes(new String[] { "eduPersonScopedAffiliation", "eduPersonEntitlement" }); // removed eduPersonEntitlement 
    254239        copy.setServiceHost("https://abc.cardiff.ac.uk/sp/shibboleth"); 
    255240        copy.setRequestId(""); 
    256241        copy.setResponseBinding("urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"); 
    257242        copy.setResourceHost("https://idp.cardiff.ac.uk/shibboleth"); 
    258         entry.setAssertionId(new String[]{"1"}); 
     243        entry.setAssertionId(new String[] { "1" }); 
    259244        entry.setEventId(100); 
    260245        entry.setNameIdentifier("name1"); 
     
    263248        entry.setResourceId("http://raptor.test"); 
    264249 
    265         System.out.println("testShibConstructorCopyEquals:Shibboleth Event, First Instance has hash ["+entry.getHashCode()+"], " + 
    266                         "Copy has Hash ["+copy.getHashCode()+"], are equal ["+(entry.getHashCode()==copy.getHashCode())+"]"); 
    267  
    268         assertTrue(entry.getHashCode()==copy.getHashCode()); 
     250        System.out.println("testShibConstructorCopyEquals:Shibboleth Event, First Instance has hash [" + entry.getHashCode() + "], " + "Copy has Hash [" + copy.getHashCode() + "], are equal [" 
     251                + (entry.getHashCode() == copy.getHashCode()) + "]"); 
     252 
     253        Assert.assertTrue(entry.getHashCode() == copy.getHashCode()); 
    269254    } 
    270255 
Note: See TracChangeset for help on using the changeset viewer.