using System; using System.Collections.Generic; using System.Text; using RemoteSearchClient.RemoteSearchService; using System.Xml; namespace RemoteSearchClient { class RemoteSearchHelper { public static PersonSearchInstructionsType createRemoteSearchRequest() { PersonSearchInstructionsType remoteSearch_request = new PersonSearchInstructionsType(); PersonSearchInstructionsTypeSearchCriteria searchCriteria = new PersonSearchInstructionsTypeSearchCriteria(); // Last name SearchCriterionTextType lastName = new SearchCriterionTextType(); lastName.Value = "smith"; lastName.match = SearchCriterionTextTypeMatch.startswith; searchCriteria.personLastName = lastName; // Birthday SearchCriterionDateType birthDate = new SearchCriterionDateType(); MinOrMaxDateType minOrMaxDate = new MinOrMaxDateType(); minOrMaxDate.dd = "02"; minOrMaxDate.mm = "02"; minOrMaxDate.yyyy = "1981"; minOrMaxDate.match = MinOrMaxYearTypeMatch.onOrBefore; birthDate.Item = minOrMaxDate; searchCriteria.personBirthDate = birthDate; // Activity Date SearchCriterionDateType activityDate = new SearchCriterionDateType(); BeginDateType beginDate = new BeginDateType(); beginDate.yyyy = "2007"; beginDate.mm = "04"; beginDate.dd = "05"; beginDate.match = BeginYearTypeMatch.onOrAfter; EndDateType endDate = new EndDateType(); endDate.yyyy = "2008"; endDate.mm = "08"; endDate.dd ="18"; endDate.match = EndYearTypeMatch.onOrBefore; DateRangeType dateRange = new DateRangeType(); dateRange.Item = beginDate; dateRange.Item1 = endDate; activityDate.Item = dateRange; searchCriteria.activityDate = activityDate; remoteSearch_request.searchCriteria = searchCriteria; // Source source source = new source(); source.enumVal = sourceEnumVal.LAW_ENFORCEMENT; remoteSearch_request.sources = new source[]{source}; // Submitter Or SubmitterGroup Criteria SubmitterCriterionTypeSubmitterGroup submitterGroup = new SubmitterCriterionTypeSubmitterGroup(); submitterGroup.submitterGroupURI = "http://wijis.wisconsin.gov/names/operatorGroups/states/Wisconsin/counties/Sauk/"; remoteSearch_request.submitters = new object[]{submitterGroup}; remoteSearch_request.searchProfile = SearchProfileURIAbbrev.Person; // Sort By (personLastName/personBirthDate/activityDate/recordHolderCaption) PersonSearchInstructionsTypeSortItem sortItem = new PersonSearchInstructionsTypeSortItem(); sortItem.descending = false; sortItem.Value = "personLastName"; remoteSearch_request.sortBy = new PersonSearchInstructionsTypeSortItem[]{sortItem}; return remoteSearch_request; } public static ResponseType createSamlAssertion() //throws ParserConfigurationException { // Create a new DOM builder and Document //builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); //document = builder.newDocument(); ResponseType samlAssertion = new ResponseType(); /* * Issuer */ NameIDType issuer = new NameIDType(); issuer.Value = "http://wijis.wisconsin.gov/names/operators/Bayside/"; AssertionType assertion = new AssertionType(); assertion.Issuer = issuer; samlAssertion.Issuer = issuer; /* * Condition, notBefore and notOnOrAfter */ ConditionsType condition = new ConditionsType(); condition.NotBefore = new DateTime(2008,8,9); condition.NotBeforeSpecified = true; condition.NotOnOrAfter = new DateTime(2008,12,9); condition.NotOnOrAfterSpecified = true; assertion.Conditions = condition; /* * Attributes - names */ AttributeStatementType attributeStatementType = new AttributeStatementType(); // givenName AttributeType givenName = createAttribute("givenName", new String[] { "Jim" }); // surName AttributeType surName = createAttribute("sn", new String[] { "Smith" }); // middleName AttributeType middleName = createAttribute( "middleName", new String[] { "L" }); /* * Attribute Organization */ AttributeType organization = createAttribute("o", new String[] { "http://wijis.wisconsin.gov/names/operators/Bayside/VillageOfBaysidePD/" }); /* * Unique ID */ AttributeType uniqueID = createAttribute("http://wijis.wisconsin.gov/RemoteSearch/attributes/UniqueId", new String[] { "Rs7vLrXPw0imWzzESLfG08==" }); /* * Sensitivity Privileges */ AttributeType sensitivity = createAttribute( "gov:wi:wijis:saml:attribute:SensitivityPrivilege", new String[] { "JUV", "OPEN", "SX" }); attributeStatementType.Items = new AttributeType[] { givenName, surName, middleName, organization, uniqueID, sensitivity }; //attributeStatementType.Items = new AttributeType[] { givenName }; assertion.Items = new StatementAbstractType[] { attributeStatementType }; samlAssertion.Items = new AssertionType[] { assertion }; return samlAssertion; } private static AttributeType createAttribute( string attributeName, String[] values) { AttributeType attribute = new AttributeType(); attribute.Name = attributeName; attribute.AttributeValue = new Object[values.Length]; for (int i = 0; i < values.Length; i++) { //String value = values[i]; //XmlDocument document = new XmlDocument(); //XmlElement element = document.CreateElement("saml:AttributeValue", "urn:oasis:names:tc:SAML:2.0:assertion"); //element.InnerText = value; //attribute.AttributeValue[i] = element; String value = values[i]; attribute.AttributeValue[i] = value; } return attribute; } } }