proxyAuthentication Java/Axis Example

Using a proxy ticket (here MDA3AAABAVwaUL6fRITMT0eux25M*s2yHbgbhQ3pWf8V8qWpYsaBfMFx-h0dafwwM7OgzxU4blCDgcY supplied by the parent Moria2-enabled service (through getProxyTicket, see separate Java/Axis example), the subservice request an authentication confirmation for the user belonging to the authentication session pointed to by the proxy ticket. In addition, the subservice requests the attribute eduPersonAffiliation.

The SOAP implementation used in this example is Axis.

import javax.xml.namespace.QName;
import no.feide.moria.webservices.v2_0.Attribute;
import org.apache.axis.client.Call;
import org.apache.axis.encoding.ser.VectorDeserializerFactory;
import org.apache.axis.encoding.ser.VectorSerializerFactory;

...

Call call = new Call("http://localhost:8080/moria/v2_1/Authentication?WSDL");
call.setUsername("subservice_username");
call.setPassword("subservice_password");
final QName attributeQName = new QName("https://login.feide.no/moria/v2_1/Authentication", 
                                       "Attribute");
call.setReturnType(attributeQName);
VectorSerializerFactory serializer = new VectorSerializerFactory(Attribute.class, 
                                                                 attributeQName);
VectorDeserializerFactory deserializer = new VectorDeserializerFactory(Attribute.class,
                                                                       attributeQName);
call.registerTypeMapping(Attribute.class, 
                         attributeQName, 
                         serializer, 
                         deserializer);
call.addParameter("attributes", 
                  new QName("http://www.w3.org/2001/XMLSchema", "string[]"), 
                  String[].class, 
                  ParameterMode.IN);
call.addParameter("proxyTicket", 
                  new QName("http://www.w3.org/2001/XMLSchema", "string"), 
                  String.class, 
                  ParameterMode.IN);
final Object[] parameters = { ["eduPersonAffiliation"],
                              "MDA3AAABAVwaUL6fRITMT0eux25M*s2yHbgbhQ3pWf8V8qWpYsaBfMFx-h0dafwwM7OgzxU4blCDgcY" };
final Object returnedAttributes = call.invoke(new QName("http://localhost:8080/moria/v2_1/Authentication", "proxyAuthentication"),
                                              parameters);
final Attribute convertedAttributes = (Attribute[]) returnedAttributes;

The above code assumes that Moria2 is deployed locally.