summaryrefslogtreecommitdiffstats
path: root/java/coldfusion/src/CFLassoSingleLogout.java
blob: 588c97ddbe47da4e0c6d0b4e2947491a5f102f0c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*
 * ColdFusionLasso -- ColdFusion bindings for Lasso library
 *
 * Copyright (C) 2004 Entr'ouvert
 * http://lasso.entrouvert.org
 *
 * Authors: Emmanuel Raviart <eraviart@entrouvert.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */


import com.entrouvert.lasso.AuthnRequest;
import com.entrouvert.lasso.Identity;
import com.entrouvert.lasso.lassoConstants;
import com.entrouvert.lasso.lasso;
import com.entrouvert.lasso.Logout;
import com.entrouvert.lasso.Server;
import com.entrouvert.lasso.Session;


public class CFLassoSingleLogout {
    /* A simple service provider single logout */

    protected Logout logout = null;
    protected Server server = null;

    public String idpProviderId = null;

    public void buildRequestMsg() {
	logout.buildRequestMsg();
    }

    public void configure(String metadataPath, String publicKeyPath, String privateKeyPath,
			  String idpProviderId, String idpMetadataPath, String idpPublicKeyPath) {
        server = new Server(metadataPath, publicKeyPath, privateKeyPath, null,
			    lassoConstants.signatureMethodRsaSha1);
	this.idpProviderId = idpProviderId;
        server.addProvider(idpMetadataPath, idpPublicKeyPath, null);
        logout = new Logout(server, lassoConstants.providerTypeSp);
    }

    public String getIdentityDump() {
	Identity identity = logout.getIdentity();
	if (identity != null)
	    return identity.dump();
	else
	    return null;
    }

    public String getMsgBody() {
	return logout.getMsgBody();
    }

    public String getMsgUrl() {
	return logout.getMsgUrl();
    }

    public String getNameIdentifier() {
	return logout.getNameIdentifier();
    }

    public String getSessionDump() {
	Session session = logout.getSession();
	if (session != null)
	    return session.dump();
	else
	    return null;
    }

    public void initRequest() {
	logout.initRequest(idpProviderId, lassoConstants.httpMethodAny);
    }

    public void processResponseMsg(String responseMsg) {
	logout.processResponseMsg(responseMsg, lassoConstants.httpMethodSoap);
    }

    public void setIdentityFromDump(String identityDump) {
	logout.setIdentityFromDump(identityDump);
    }

    public void setSessionFromDump(String sessionDump) {
	logout.setSessionFromDump(sessionDump);
    }
}