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.auth.scheme;
022:
023: import org.josso.auth.Credential;
024: import org.josso.auth.CredentialProvider;
025: import org.josso.auth.CredentialStore;
026: import org.josso.auth.CredentialStoreKeyAdapter;
027: import org.josso.auth.exceptions.SSOAuthenticationException;
028:
029: import javax.security.auth.Subject;
030: import java.security.Principal;
031:
032: /**
033: * Represents any authentication scheme, like user&password, certificate, kerveros 5, etc.
034: * The authentication mechanism should be :
035: *
036: * 1. Initialize the AuthenticationScheme withe input credentials received from user.
037: * 2. Optionally get the principal name derived from input credentials.
038: * 3. Authenticate the user providing known or trusted credentials.
039: * 4. Confirm or cancel the authentication process.
040: * 5. Optinalliy get private / public credentials.
041: *
042: * Authentication schemes are cloneable, a first instance is used as a "prototype" to build new ones.
043: *
044: * @author <a href="mailto:sgonzalez@josso.org">Sebastian Gonzalez Oyuela</a>
045: * @version $Id: AuthenticationScheme.java 508 2008-02-18 13:32:29Z sgonzalez $
046: */
047:
048: public interface AuthenticationScheme extends CredentialProvider,
049: Cloneable {
050:
051: /**
052: * Obtains the Authentication Scheme name
053: */
054: String getName();
055:
056: /**
057: * Initializes this authentication scheme with the received credentials.
058: *
059: * @param inputCredentials the list of credentials used to authenticate the user, like username and password.
060: *
061: */
062: void initialize(Credential[] inputCredentials, Subject s);
063:
064: /**
065: * This method authenticates a user based on its credentials.
066: *
067: * @return The Principal associated with the user if the authentication success, null otherwise.
068: */
069: boolean authenticate() throws SSOAuthenticationException;
070:
071: /**
072: * Confirms the authentication process, populates the subject with Principal and credential information.
073: */
074: void confirm();
075:
076: /**
077: * Cancels the authentication process.
078: */
079: void cancel();
080:
081: /**
082: * This method returns the principal name derived from input credentials.
083: *
084: */
085: Principal getPrincipal();
086:
087: /**
088: * This method returns the principal name derived from provided credentials.
089: *
090: */
091: Principal getPrincipal(Credential[] credentials);
092:
093: /**
094: * Returns an array of private credentials that can be associated to a Subject by the authenticator.
095: *
096: */
097: Credential[] getPrivateCredentials();
098:
099: /**
100: * Returns an array of public credentials that can be associated to a Subject by the authenticator.
101: *
102: */
103: Credential[] getPublicCredentials();
104:
105: /**
106: * Setter for the CredentialStore used by the scheme to retrieve known credentials if necessary.
107: */
108: void setCredentialStore(CredentialStore cs);
109:
110: /**
111: * Setter for the CredentialStoreKeyAdapter used by the scheme to retrieve known credentials if necessary.
112: */
113: void setCredentialStoreKeyAdapter(CredentialStoreKeyAdapter a);
114:
115: /**
116: * All authenticatio schemes should be cloneable.
117: */
118: Object clone();
119:
120: }
|