In this example the Moria2-enabled service retrieves the previously
requested (through initiateAuthentication
; see separate
Java/Axis example)
attributes from Moria2.
The session ID (here hardcoded as
MDA3AAABAU2f8til3qYaexoDNWirZ94ozBGVyVgF8xN2cAKy1XKMP9dvGZe4YR-7Lg3lOIJtvft4O7E
)
sent as parameter is the substring session included in the URL
http://www.service.org/?STARTID=sessionSTOPID
initiateAuthentication
example when the
user is redirected back to the service after successful authentication.
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("service_username"); call.setPassword("service_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("serviceTicket", new QName("http://www.w3.org/2001/XMLSchema", "string"), String.class, ParameterMode.IN); final Object[] parameters = {"MDA3AAABAU2f8til3qYaexoDNWirZ94ozBGVyVgF8xN2cAKy1XKMP9dvGZe4YR-7Lg3lOIJtvft4O7E"}; final Object returnedAttributes = call.invoke(new QName("http://localhost:8080/moria/v2_1/Authentication"), "getUserAttributes"), parameters); final Attribute convertedAttributes = (Attribute[]) returnedAttributes;
The above code assumes that Moria2 is deployed locally.