<commit_before>package aaf.fr.foundation

import org.apache.commons.lang.builder.EqualsBuilder
import org.apache.commons.lang.builder.HashCodeBuilder

import grails.plugins.federatedgrails.Role

/**
 * @author <NAME>
 */
class SPSSODescriptor extends SSODescriptor {
	static auditable = true

 	boolean authnRequestsSigned
 	boolean wantAssertionsSigned
  boolean forceAttributesInFilter = false

	ServiceDescription serviceDescription

 	static belongsTo = [entityDescriptor:EntityDescriptor]

	static hasMany = [
		assertionConsumerServices: AssertionConsumerService,
		attributeConsumingServices: AttributeConsumingService,
		discoveryResponseServices: DiscoveryResponseService,
		serviceCategories: ServiceCategory
	]

	static constraints = {
		attributeConsumingServices(nullable: true)
		serviceDescription(nullable:false)
 	}

	public String toString() {	"spssodescriptor:[id:$id, displayName: $displayName]" }

	public boolean functioning() {
		( !archived && active && approved && entityDescriptor.functioning() )
	}

	public boolean equals(Object obj) {
		if( this.is(obj) ) return true
		if ( obj == null ) return false
		if ( !obj.instanceOf(SPSSODescriptor) ) return false

		SPSSODescriptor rhs = (SPSSODescriptor) obj
		return new EqualsBuilder()
			.append(this.id, rhs.id)
			.append(this.displayName, rhs.displayName)
			.append(this.organization, rhs.organization)
			.isEquals()
	}

	public int hashCode() {
		// hard-coded, randomly chosen, non-zero, odd number different for each class
		return new HashCodeBuilder(43, 129).
		toHashCode();
	}

	def structureAsJson() {
		def adminRole = Role.findByName("descriptor-${this.id}-administrators")

		def json = new groovy.json.JsonBuilder()
		json {
		  fr_id this.id
		  display_name this.displayName
		  description this.description ?: ''
		  organization { id this.organization.id
		  							 name this.organization.displayName }

		  information {
		  	catalogue_publish serviceDescription.publish
		  	public_url serviceDescription.connectURL ?: ''
		  	logo_url serviceDescription.logoURL ?: ''
		  	further_info serviceDescription.furtherInfo ?: ''
		  	provides serviceDescription.provides ?: ''
		  	benefits serviceDescription.benefits ?: ''
		  	audience serviceDescription.audience ?: ''
		  	restrictions serviceDescription.restrictions ?: ''
		  	accessing serviceDescription.accessing ?: ''
		  	support serviceDescription.support ?: ''
		  	maintenance serviceDescription.maintenance ?: ''
		  }

		  categories serviceCategories.collect { [id: it.id, name: it.name] }

		  contacts this.contacts.collect { [id: it.id, type: [id: it.type.id, name: it.type.name]] }
		  monitors this.monitors.collect { [id: it.id, type: [id: it.type.id, name: it.type.name], url: it.url, node: it.node, enabled: it.enabled, check_period: it.checkPeriod] }

		  active this.active
		  archived this.archived
		  approved this.approved
		  functioning this.functioning()
		  reporting this.reporting
		  date_created this.dateCreated
		  last_updated this.lastUpdated
		  administrators adminRole?.subjects.collect { [id: it.id, principal: it.sharedToken] }
			saml {
				entity entityDescriptor.entityID
				authnrequests_signed authnRequestsSigned
				assertions_signed wantAssertionsSigned
				always_render_attributes_in_filter forceAttributesInFilter
				attribute_consuming_services attributeConsumingServices.collect { [id: it.id, is_default: it.isDefault, approved: it.approved,
																			names: it.serviceNames,
																			descriptions: it.serviceDescriptions,
																			attributes: it.requestedAttributes.collect { [id:it.base.id, name: it.base.name,
																									reason: it.reasoning, is_required: it.isRequired,  approved: it.approved
																									] }
																			]}
				assertion_consumer_services assertionConsumerServices.collect { [id: it.id, location: it.location, binding: [id: it.binding.id, uri: it.binding.uri], functioning: it.functioning(), index: it.index, is_default: it.isDefault ]}
      	discovery_response_services discoveryResponseServices.collect { [id: it.id, location: it.location, binding: [id: it.binding.id, uri: it.binding.uri], functioning: it.functioning(), index: it.index, is_default: it.isDefault ]}
				sso_descriptor super.structureAsJson()
			}
		}

		json.content
	}
}
<commit_msg>Export values for specified attributes<commit_after>package aaf.fr.foundation

import org.apache.commons.lang.builder.EqualsBuilder
import org.apache.commons.lang.builder.HashCodeBuilder

import grails.plugins.federatedgrails.Role

/**
 * @author <NAME>
 */
class SPSSODescriptor extends SSODescriptor {
	static auditable = true

 	boolean authnRequestsSigned
 	boolean wantAssertionsSigned
  boolean forceAttributesInFilter = false

	ServiceDescription serviceDescription

 	static belongsTo = [entityDescriptor:EntityDescriptor]

	static hasMany = [
		assertionConsumerServices: AssertionConsumerService,
		attributeConsumingServices: AttributeConsumingService,
		discoveryResponseServices: DiscoveryResponseService,
		serviceCategories: ServiceCategory
	]

	static constraints = {
		attributeConsumingServices(nullable: true)
		serviceDescription(nullable:false)
 	}

	public String toString() {	"spssodescriptor:[id:$id, displayName: $displayName]" }

	public boolean functioning() {
		( !archived && active && approved && entityDescriptor.functioning() )
	}

	public boolean equals(Object obj) {
		if( this.is(obj) ) return true
		if ( obj == null ) return false
		if ( !obj.instanceOf(SPSSODescriptor) ) return false

		SPSSODescriptor rhs = (SPSSODescriptor) obj
		return new EqualsBuilder()
			.append(this.id, rhs.id)
			.append(this.displayName, rhs.displayName)
			.append(this.organization, rhs.organization)
			.isEquals()
	}

	public int hashCode() {
		// hard-coded, randomly chosen, non-zero, odd number different for each class
		return new HashCodeBuilder(43, 129).
		toHashCode();
	}

	def structureAsJson() {
		def adminRole = Role.findByName("descriptor-${this.id}-administrators")

		def json = new groovy.json.JsonBuilder()
		json {
		  fr_id this.id
		  display_name this.displayName
		  description this.description ?: ''
		  organization { id this.organization.id
		  							 name this.organization.displayName }

		  information {
		  	catalogue_publish serviceDescription.publish
		  	public_url serviceDescription.connectURL ?: ''
		  	logo_url serviceDescription.logoURL ?: ''
		  	further_info serviceDescription.furtherInfo ?: ''
		  	provides serviceDescription.provides ?: ''
		  	benefits serviceDescription.benefits ?: ''
		  	audience serviceDescription.audience ?: ''
		  	restrictions serviceDescription.restrictions ?: ''
		  	accessing serviceDescription.accessing ?: ''
		  	support serviceDescription.support ?: ''
		  	maintenance serviceDescription.maintenance ?: ''
		  }

		  categories serviceCategories.collect { [id: it.id, name: it.name] }

		  contacts this.contacts.collect { [id: it.id, type: [id: it.type.id, name: it.type.name]] }
		  monitors this.monitors.collect { [id: it.id, type: [id: it.type.id, name: it.type.name], url: it.url, node: it.node, enabled: it.enabled, check_period: it.checkPeriod] }

		  active this.active
		  archived this.archived
		  approved this.approved
		  functioning this.functioning()
		  reporting this.reporting
		  date_created this.dateCreated
		  last_updated this.lastUpdated
		  administrators adminRole?.subjects.collect { [id: it.id, principal: it.sharedToken] }
			saml {
				entity entityDescriptor.entityID
				authnrequests_signed authnRequestsSigned
				assertions_signed wantAssertionsSigned
				always_render_attributes_in_filter forceAttributesInFilter
				attribute_consuming_services attributeConsumingServices.collect { [id: it.id, is_default: it.isDefault, approved: it.approved,
																			names: it.serviceNames,
																			descriptions: it.serviceDescriptions,
																			attributes: it.requestedAttributes.collect { [id:it.base.id, name: it.base.name, specification: it.base.specificationRequired,
																									reason: it.reasoning, is_required: it.isRequired,  approved: it.approved,
																									values: it.values.collect { [value: it.value, approved: it.approved] }
																									] }
																			] }
				assertion_consumer_services assertionConsumerServices.collect { [id: it.id, location: it.location, binding: [id: it.binding.id, uri: it.binding.uri], functioning: it.functioning(), index: it.index, is_default: it.isDefault ]}
      	discovery_response_services discoveryResponseServices.collect { [id: it.id, location: it.location, binding: [id: it.binding.id, uri: it.binding.uri], functioning: it.functioning(), index: it.index, is_default: it.isDefault ]}
				sso_descriptor super.structureAsJson()
			}
		}

		json.content
	}
}

{'fraction_non_alphanumeric': 0.09910925696245348, 'fraction_numerical': 0.0011275228323373548, 'mean_word_length': 3.870950027457441, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6891570', 'n_tokens_mistral': 2971, 'n_tokens_neox': 2530, 'n_words': 554}