001: /*
002: * JOSSO: Java Open Single Sign-On
003: *
004: * Copyright 2004-2008, Atricore, Inc.
005: *
006: * This is free software; you can redistribute it and/or modify it
007: * under the terms of the GNU Lesser General Public License as
008: * published by the Free Software Foundation; either version 2.1 of
009: * the License, or (at your option) any later version.
010: *
011: * This software is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this software; if not, write to the Free
018: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
019: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
020: */
021: package org.josso.gateway;
022:
023: import org.josso.auth.Credential;
024: import org.josso.auth.exceptions.SSOAuthenticationException;
025: import org.josso.gateway.identity.SSORole;
026: import org.josso.gateway.identity.SSOUser;
027: import org.josso.gateway.session.SSOSession;
028: import org.josso.gateway.session.exceptions.NoSuchSessionException;
029: import org.josso.gateway.assertion.AuthenticationAssertion;
030:
031: /**
032: * SSO Gateway service interface.
033: *
034: * @author <a href="mailto:sgonzalez@josso.org">Sebastian Gonzalez Oyuela</a>
035: * @version $Id: SSOGateway.java 508 2008-02-18 13:32:29Z sgonzalez $
036: */
037: public interface SSOGateway {
038:
039: /**
040: * Login a user into the SSO infrastructure.
041: *
042: * @param credentials that proof user identity.
043: * @param scheme the authentication scheme name to be used for
044: * logging in the user.
045: * @param ctx the external context used during method execution
046: *
047: * @return the user information after login.
048: *
049: * @throws SSOException if an error occurs.
050: * @throws SSOAuthenticationException if user identity cannot be confirmed.
051: */
052: SSOSession login(Credential[] credentials, String scheme,
053: SSOContext ctx) throws SSOException,
054: SSOAuthenticationException;
055:
056: /**
057: * Create an authentication assertion based on the supplied credentials. If assertion is successful a new session
058: * is created for the subject which can be referenced through the corresponding assertion identifier.
059: *
060: * @param credentials that proof user identity.
061: * @param scheme the authentication scheme name to be used for
062: * logging in the user.
063: * @param ctx the external context used during method execution
064: *
065: * @return the user information after login.
066: *
067: * @throws SSOException if an error occurs.
068: * @throws SSOAuthenticationException if user identity cannot be confirmed.
069: */
070: AuthenticationAssertion assertIdentity(Credential[] credentials,
071: String scheme, SSOContext ctx) throws SSOException,
072: SSOAuthenticationException;
073:
074: /**
075: * Create an authentication assertion from a previous existing and valid one.
076: *
077: * @param sessionId SSO session identifier for the session to be bound to the new assertion.
078: * @return
079: * @throws SSOException
080: */
081: AuthenticationAssertion assertIdentity(String sessionId)
082: throws SSOException;
083:
084: /**
085: * Builds the supplied user credentials for the
086: * supplied Authentication Scheme.
087: */
088: Credential newCredential(String schemeName, String name,
089: Object value) throws SSOAuthenticationException;
090:
091: /**
092: * Obtains the principal name from the given credentials using the
093: * supplied Authentication Scheme.
094: */
095: String getPrincipalName(String schemeName, Credential[] creds)
096: throws SSOAuthenticationException;
097:
098: /**
099: * Logout a user from the SSO infrastructure.
100: *
101: * @param ctx the external context used during method execution
102: *
103: * @throws SSOException if an error occurs.
104: *
105: */
106: void logout(SSOContext ctx) throws SSOException;
107:
108: /**
109: * Finds a user based on session id, the user has to be logged in the SSO infrastructure.
110: * @param sessionId
111: *
112: * @throws SSOException if user was not logged in the SSO.
113: */
114: SSOUser findUserInSession(String sessionId) throws SSOException;
115:
116: /**
117: * List user's roles base on user's name.
118: *
119: * @param username
120: *
121: * @throws SSOException
122: */
123: SSORole[] findRolesByUsername(String username) throws SSOException;
124:
125: /**
126: * Finds a session given its id.
127: */
128: SSOSession findSession(String jossoSessionId) throws SSOException,
129: NoSuchSessionException;
130:
131: /**
132: * Initializes this gateway.
133: */
134: void initialize();
135:
136: /**
137: * Destroys this instance, free all resources.
138: */
139: void destroy();
140:
141: /**
142: * @return true if the gateway was already initialized.
143: */
144: boolean isInitialized();
145:
146: }
|