Method: Crowd.add_attribute_principal

Defined in:
lib/crowd.rb

.add_attribute_principal(username, attributes) ⇒ Object

Add attribute to principal



245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
# File 'lib/crowd.rb', line 245

def self.add_attribute_principal(username, attributes)
  attributes.each do |key, val|
    response = authenticated_connection do
      if(val.class == Array)
        valArray = ArrayOfString.new(val)
      else
        valArray = ArrayOfString.new
        valArray << val
      end

      tuple = SOAPAttribute.new(key, valArray)
      arg = AddAttributeToPrincipal.new(@@application_token, username, tuple)
      
      server.addAttributeToPrincipal(arg)
    end

    case response
      when AddAttributeToPrincipalResponse
        # Burying it because this means it was successful
      when ObjectNotFoundException
        raise AuthenticationObjectNotFoundException
      else
        raise AuthenticationException, response
    end
  end
  
  true
end