Problem in Logout request for Post binding

rahul sharma rahulsharma.bbiet at gmail.com
Wed Jan 15 13:03:33 EST 2020


Hi, I have implemented single sign-on in my project recently usinf OpenSAML
V3.3. I implemented the sign-on and its working but now I need to implement
the Single Logout feature. I have created a logout request but Could not
find any help to send this logout request using the post binding.

My logout request is -  
private LogoutRequest prepareLogoutRequest(String username, String
sessionIndex) {
        LogoutRequest logoutRequest = new
LogoutRequestBuilder().buildObject();

        DateTime issueInstant = new DateTime();

        Issuer issuer = new IssuerBuilder().buildObject();
        issuer.setValue(SAMLConfiguration.spEntityId());

        NameID nameId = new NameIDBuilder().buildObject();
       
nameId.setFormat("urn:oasis:names:tc:SAML:2.0:nameid-format:entity");
        nameId.setValue(username);

        SessionIndex sessionIndexElement = new
SessionIndexBuilder().buildObject();
        sessionIndexElement.setSessionIndex(sessionIndex);

        //  sets the mandatory attributes of a SAML 2.0 Request
        logoutRequest.setID(newId());
        logoutRequest.setIssueInstant(issueInstant);

        logoutRequest.setDestination(idpEndpoint.getLocation());
        //  time at which the request expires, after which the recipient may
discard the message
        logoutRequest.setNotOnOrAfter(new DateTime(issueInstant.getMillis()
+ (5 * 60 * 1000)));
        logoutRequest.setIssuer(issuer);
        logoutRequest.setNameID(nameId);
        logoutRequest.getSessionIndexes().add(sessionIndexElement);
        //  indicates the reason for the logout
        logoutRequest.setReason("Single Logout");

        return logoutRequest;
    }

Now I don't know what to do next to post my logout request to the IDP.
I tried the code below to send the request but no luck

final MessageContext<SAMLObject> mc = new MessageContext<SAMLObject>();
            mc.setMessage(logoutRequest);

try {
                final HTTPPostEncoder pe = new HTTPPostEncoder();
                pe.setHttpServletResponse(response);
                pe.setMessageContext(mc);
                pe.initialize();
                pe.prepareContext();
                pe.encode();
            } catch (final MessageEncodingException |
ComponentInitializationException e) {
                logger.warn("SAML2Request generation failed: {}",
e.getMessage(), e);
            }

*This is the error I got *- SAML2Request generation failed: VelocityEngine
must be supplied 
net.shibboleth.utilities.java.support.component.ComponentInitializationException:
VelocityEngine must be supplied
	at
org.opensaml.saml.saml2.binding.encoding.impl.HTTPPostEncoder.doInitialize(HTTPPostEncoder.java:128)
~[opensaml-saml-impl-3.3.0.jar:na]
	at
net.shibboleth.utilities.java.support.component.AbstractInitializableComponent.initialize(AbstractInitializableComponent.java:61)
~[java-support-7.3.0.jar:na]
	at
com.ixonos.idcs.mup.servlet.IDPLogoutServlet.service(IDPLogoutServlet.java:111)
~[classes/:na]
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
[tomcat-embed-core-7.0.47.jar:7.0.47]
	at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
[tomcat-embed-core-7.0.47.jar:7.0.47]
	at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
[tomcat-embed-core-7.0.47.jar:7.0.47]
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
[tomcat-embed-core-7.0.47.jar:7.0.47]
	at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
[tomcat-embed-core-7.0.47.jar:7.0.47]
	at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
[tomcat-embed-core-7.0.47.jar:7.0.47]
	at com.ixonos.mup.profile.SessionFilter.doFilter(SessionFilter.java:99)
[mup-1.3.11-SNAPSHOT.jar:na]
	at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
[tomcat-embed-core-7.0.47.jar:7.0.47]
	at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
[tomcat-embed-core-7.0.47.jar:7.0.47]




Please help me to achieve this task. Thanks in advance!



--
Sent from: https://shibboleth.1660669.n2.nabble.com/Shibboleth-Developers-f1660781.html


More information about the dev mailing list