From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository. --- .../security/auth/login/AccountException.java | 64 +++++ .../auth/login/AccountExpiredException.java | 64 +++++ .../auth/login/AccountLockedException.java | 64 +++++ .../auth/login/AccountNotFoundException.java | 64 +++++ .../security/auth/login/AppConfigurationEntry.java | 143 +++++++++++ .../javax/security/auth/login/Configuration.java | 121 ++++++++++ .../security/auth/login/CredentialException.java | 64 +++++ .../auth/login/CredentialExpiredException.java | 64 +++++ .../auth/login/CredentialNotFoundException.java | 65 +++++ .../security/auth/login/FailedLoginException.java | 63 +++++ .../javax/security/auth/login/LoginContext.java | 265 +++++++++++++++++++++ .../javax/security/auth/login/LoginException.java | 65 +++++ .../security/auth/login/NullConfiguration.java | 62 +++++ .../javax/security/auth/login/package.html | 46 ++++ 14 files changed, 1214 insertions(+) create mode 100644 libjava/classpath/javax/security/auth/login/AccountException.java create mode 100644 libjava/classpath/javax/security/auth/login/AccountExpiredException.java create mode 100644 libjava/classpath/javax/security/auth/login/AccountLockedException.java create mode 100644 libjava/classpath/javax/security/auth/login/AccountNotFoundException.java create mode 100644 libjava/classpath/javax/security/auth/login/AppConfigurationEntry.java create mode 100644 libjava/classpath/javax/security/auth/login/Configuration.java create mode 100644 libjava/classpath/javax/security/auth/login/CredentialException.java create mode 100644 libjava/classpath/javax/security/auth/login/CredentialExpiredException.java create mode 100644 libjava/classpath/javax/security/auth/login/CredentialNotFoundException.java create mode 100644 libjava/classpath/javax/security/auth/login/FailedLoginException.java create mode 100644 libjava/classpath/javax/security/auth/login/LoginContext.java create mode 100644 libjava/classpath/javax/security/auth/login/LoginException.java create mode 100644 libjava/classpath/javax/security/auth/login/NullConfiguration.java create mode 100644 libjava/classpath/javax/security/auth/login/package.html (limited to 'libjava/classpath/javax/security/auth/login') diff --git a/libjava/classpath/javax/security/auth/login/AccountException.java b/libjava/classpath/javax/security/auth/login/AccountException.java new file mode 100644 index 000000000..32f739a31 --- /dev/null +++ b/libjava/classpath/javax/security/auth/login/AccountException.java @@ -0,0 +1,64 @@ +/* AccountException.java -- generic account exception + Copyright (C) 2005 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath 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, or (at your option) +any later version. + +GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.security.auth.login; + +/** + * This is the base class for various account-related exceptions. + * @since 1.5 + */ +public class AccountException extends LoginException +{ + private static final long serialVersionUID = -2112878680072211787L; + + /** + * Create a new exception object. + */ + public AccountException() + { + } + + /** + * Create a new exception with the indicated detail message. + * @param message the detail message + */ + public AccountException(String message) + { + super(message); + } +} diff --git a/libjava/classpath/javax/security/auth/login/AccountExpiredException.java b/libjava/classpath/javax/security/auth/login/AccountExpiredException.java new file mode 100644 index 000000000..c2b61c6e0 --- /dev/null +++ b/libjava/classpath/javax/security/auth/login/AccountExpiredException.java @@ -0,0 +1,64 @@ +/* AccountExpiredException.java + Copyright (C) 2004 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath 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, or (at your option) +any later version. + +GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.security.auth.login; + +/** + * An exception that signals that an attempt was made to login to an account + * that has expired. + */ +public class AccountExpiredException extends AccountException +{ + + // Constant. + // ------------------------------------------------------------------------- + + private static final long serialVersionUID = -6064064890162661560L; + + // Constructors. + // ------------------------------------------------------------------------- + + public AccountExpiredException() + { + } + + public AccountExpiredException (String message) + { + super (message); + } +} diff --git a/libjava/classpath/javax/security/auth/login/AccountLockedException.java b/libjava/classpath/javax/security/auth/login/AccountLockedException.java new file mode 100644 index 000000000..bcb8b4f8d --- /dev/null +++ b/libjava/classpath/javax/security/auth/login/AccountLockedException.java @@ -0,0 +1,64 @@ +/* AccountLockedException.java -- exception indicating locked account + Copyright (C) 2005 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath 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, or (at your option) +any later version. + +GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.security.auth.login; + +/** + * An exception indicating that an account is locked. + * @since 1.5 + */ +public class AccountLockedException extends AccountException +{ + private static final long serialVersionUID = 8280345554014066334L; + + /** + * Create a new exception object. + */ + public AccountLockedException() + { + } + + /** + * Create a new exception with the indicated detail message. + * @param message the detail message + */ + public AccountLockedException(String message) + { + super(message); + } +} diff --git a/libjava/classpath/javax/security/auth/login/AccountNotFoundException.java b/libjava/classpath/javax/security/auth/login/AccountNotFoundException.java new file mode 100644 index 000000000..e74ca0163 --- /dev/null +++ b/libjava/classpath/javax/security/auth/login/AccountNotFoundException.java @@ -0,0 +1,64 @@ +/* AccountNotFoundException.java -- exception indicating account not found + Copyright (C) 2005 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath 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, or (at your option) +any later version. + +GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.security.auth.login; + +/** + * An exception indicating that an account was not found. + * @since 1.5 + */ +public class AccountNotFoundException extends AccountException +{ + private static final long serialVersionUID = 1498349563916294614L; + + /** + * Create a new exception object. + */ + public AccountNotFoundException() + { + } + + /** + * Create a new exception with the given detail message. + * @param message the detail message + */ + public AccountNotFoundException(String message) + { + super(message); + } +} diff --git a/libjava/classpath/javax/security/auth/login/AppConfigurationEntry.java b/libjava/classpath/javax/security/auth/login/AppConfigurationEntry.java new file mode 100644 index 000000000..044c9105b --- /dev/null +++ b/libjava/classpath/javax/security/auth/login/AppConfigurationEntry.java @@ -0,0 +1,143 @@ +/* AppConfigurationEntry.java + Copyright (C) 2004, 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath 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, or (at your option) +any later version. + +GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.security.auth.login; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +public class AppConfigurationEntry +{ + // Fields. + // ------------------------------------------------------------------------- + + private final String loginModuleName; + private final LoginModuleControlFlag controlFlag; + private final Map options; + + // Constructor. + // ------------------------------------------------------------------------- + + public AppConfigurationEntry (final String loginModuleName, + final LoginModuleControlFlag controlFlag, + final Map options) + { + if (loginModuleName == null || loginModuleName.length() == 0) + throw new IllegalArgumentException ("module name cannot be null nor empty"); + + if (LoginModuleControlFlag.OPTIONAL != controlFlag && + LoginModuleControlFlag.REQUIRED != controlFlag && + LoginModuleControlFlag.REQUISITE != controlFlag && + LoginModuleControlFlag.SUFFICIENT != controlFlag) + throw new IllegalArgumentException ("invalid controlFlag"); + + if (options == null) + throw new IllegalArgumentException ("options cannot be null"); + + this.loginModuleName = loginModuleName; + this.controlFlag = controlFlag; + this.options = Collections.unmodifiableMap (new HashMap (options)); + } + + // Instance methods. + // ------------------------------------------------------------------------- + + public LoginModuleControlFlag getControlFlag() + { + return controlFlag; + } + + public String getLoginModuleName() + { + return loginModuleName; + } + + public Map getOptions() + { + return options; + } + + // Object methods ---------------------------------------------------------- + + public String toString() + { + + return loginModuleName + "\t" + + String.valueOf(controlFlag) + "\t" + + String.valueOf(options); + } + + // Inner class. + // ------------------------------------------------------------------------- + + public static class LoginModuleControlFlag + { + + // Constants. + // ----------------------------------------------------------------------- + + public static final LoginModuleControlFlag OPTIONAL = new LoginModuleControlFlag(); + public static final LoginModuleControlFlag REQUIRED = new LoginModuleControlFlag(); + public static final LoginModuleControlFlag REQUISITE = new LoginModuleControlFlag(); + public static final LoginModuleControlFlag SUFFICIENT = new LoginModuleControlFlag(); + + // Constructor. + // ----------------------------------------------------------------------- + + private LoginModuleControlFlag() + { + } + + // Instance methods. + // ----------------------------------------------------------------------- + + public String toString() + { + if (this == LoginModuleControlFlag.REQUIRED) + return "REQUIRED"; + if (this == LoginModuleControlFlag.REQUISITE) + return "REQUISITE"; + if (this == LoginModuleControlFlag.SUFFICIENT) + return "SUFFICIENT"; + if (this == LoginModuleControlFlag.OPTIONAL) + return "OPTIONAL"; + return "???"; + } + } +} diff --git a/libjava/classpath/javax/security/auth/login/Configuration.java b/libjava/classpath/javax/security/auth/login/Configuration.java new file mode 100644 index 000000000..fe56f8a59 --- /dev/null +++ b/libjava/classpath/javax/security/auth/login/Configuration.java @@ -0,0 +1,121 @@ +/* Configuration.java + Copyright (C) 2004, 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath 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, or (at your option) +any later version. + +GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.security.auth.login; + +import gnu.javax.security.auth.login.GnuConfiguration; + +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.security.Security; + +import javax.security.auth.AuthPermission; + +public abstract class Configuration +{ + // Fields. + // ------------------------------------------------------------------------- + + private static Configuration config; + + // Constructors. + // ------------------------------------------------------------------------- + + protected Configuration() + { + } + + // Class methods. + // ------------------------------------------------------------------------- + + public static synchronized Configuration getConfiguration() + { + SecurityManager sm = System.getSecurityManager(); + if (sm != null) + sm.checkPermission (new AuthPermission ("getLoginConfiguration")); + return getConfig(); + } + + public static synchronized void setConfiguration (Configuration config) + { + SecurityManager sm = System.getSecurityManager(); + if (sm != null) + sm.checkPermission (new AuthPermission ("setLoginConfiguration")); + Configuration.config = config; + } + + // Abstract methods. + // ------------------------------------------------------------------------- + + public abstract AppConfigurationEntry[] getAppConfigurationEntry (String applicationName); + + public abstract void refresh(); + + // Package-private methods. + // ------------------------------------------------------------------------- + + /** + * Get the current configuration, bypassing security checks. + */ + static Configuration getConfig() + { + if (config == null) + { + String conf = (String) AccessController.doPrivileged + (new PrivilegedAction() + { + public Object run() + { + return Security.getProperty ("login.configuration.provider"); + } + }); + try + { + if (conf != null) + config = (Configuration) Class.forName (conf).newInstance(); + else + config = new GnuConfiguration(); + } + catch (Exception x) + { + config = new GnuConfiguration(); + } + } + return config; + } +} diff --git a/libjava/classpath/javax/security/auth/login/CredentialException.java b/libjava/classpath/javax/security/auth/login/CredentialException.java new file mode 100644 index 000000000..980adde9e --- /dev/null +++ b/libjava/classpath/javax/security/auth/login/CredentialException.java @@ -0,0 +1,64 @@ +/* CredentialException.java -- generic credential exception + Copyright (C) 2005 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath 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, or (at your option) +any later version. + +GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.security.auth.login; + +/** + * This is the base class for various credential-related exceptions. + * @since 1.5 + */ +public class CredentialException extends LoginException +{ + private static final long serialVersionUID = -4772893876810601859L; + + /** + * Create a new exception object. + */ + public CredentialException() + { + } + + /** + * Create a new exception with the given detail message. + * @param message the detail message + */ + public CredentialException(String message) + { + super(message); + } +} diff --git a/libjava/classpath/javax/security/auth/login/CredentialExpiredException.java b/libjava/classpath/javax/security/auth/login/CredentialExpiredException.java new file mode 100644 index 000000000..9827a3d86 --- /dev/null +++ b/libjava/classpath/javax/security/auth/login/CredentialExpiredException.java @@ -0,0 +1,64 @@ +/* CredentialExpiredException.java + Copyright (C) 2004 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath 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, or (at your option) +any later version. + +GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.security.auth.login; + +/** + * An exception that signals an attempt to login with a credential that + * has expired. + */ +public class CredentialExpiredException extends CredentialException +{ + + // Constant. + // ------------------------------------------------------------------------- + + private static final long serialVersionUID = -5344739593859737937L; + + // Constructors. + // ------------------------------------------------------------------------- + + public CredentialExpiredException() + { + } + + public CredentialExpiredException (String message) + { + super (message); + } +} diff --git a/libjava/classpath/javax/security/auth/login/CredentialNotFoundException.java b/libjava/classpath/javax/security/auth/login/CredentialNotFoundException.java new file mode 100644 index 000000000..08ac115e3 --- /dev/null +++ b/libjava/classpath/javax/security/auth/login/CredentialNotFoundException.java @@ -0,0 +1,65 @@ +/* CredentialNotFoundException.java -- exception thrown when credentials + expire + Copyright (C) 2005 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath 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, or (at your option) +any later version. + +GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.security.auth.login; + +/** + * An exception that indicates that a credential was not found. + * @since 1.5 + */ +public class CredentialNotFoundException extends CredentialException +{ + private static final long serialVersionUID = -7779934467214319475L; + + /** + * Create a new exception. + */ + public CredentialNotFoundException() + { + } + + /** + * Create a new exception with the given detail message. + * @param message the detail message + */ + public CredentialNotFoundException(String message) + { + super(message); + } +} diff --git a/libjava/classpath/javax/security/auth/login/FailedLoginException.java b/libjava/classpath/javax/security/auth/login/FailedLoginException.java new file mode 100644 index 000000000..db975fbdd --- /dev/null +++ b/libjava/classpath/javax/security/auth/login/FailedLoginException.java @@ -0,0 +1,63 @@ +/* FailedLoginException.java + Copyright (C) 2004 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath 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, or (at your option) +any later version. + +GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.security.auth.login; + +/** + * An exception that signals that an attempt to login was unsuccessful. + */ +public class FailedLoginException extends LoginException +{ + + // Constant. + // ------------------------------------------------------------------------- + + private static final long serialVersionUID = 802556922354616286L; + + // Constructors. + // ------------------------------------------------------------------------- + + public FailedLoginException() + { + } + + public FailedLoginException (String message) + { + super (message); + } +} diff --git a/libjava/classpath/javax/security/auth/login/LoginContext.java b/libjava/classpath/javax/security/auth/login/LoginContext.java new file mode 100644 index 000000000..b2e4b97b6 --- /dev/null +++ b/libjava/classpath/javax/security/auth/login/LoginContext.java @@ -0,0 +1,265 @@ +/* LoginContext.java + Copyright (C) 2004, 2006 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath 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, or (at your option) +any later version. + +GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.security.auth.login; + +import gnu.java.security.action.GetSecurityPropertyAction; + +import java.security.AccessController; + +import java.util.HashMap; +import java.util.Map; + +import javax.security.auth.Subject; +import javax.security.auth.callback.CallbackHandler; +import javax.security.auth.spi.LoginModule; + +public class LoginContext +{ + + private static final String OTHER = "other"; + + private final String name; + private final CallbackHandler cbHandler; + private final Subject subject; + private final AppConfigurationEntry[] entries; + private final LoginModule[] modules; + private final Map sharedState; + + public LoginContext (final String name) throws LoginException + { + this (name, new Subject(), defaultHandler()); + } + + public LoginContext (final String name, final CallbackHandler cbHandler) + throws LoginException + { + this (name, new Subject(), cbHandler); + } + + public LoginContext (final String name, final Subject subject) + throws LoginException + { + this (name, subject, defaultHandler()); + } + + public LoginContext (final String name, final Subject subject, + final CallbackHandler cbHandler) + throws LoginException + { + this (name, subject, cbHandler, null); + } + + /** @since 1.5 */ + public LoginContext (final String name, final Subject subject, + final CallbackHandler cbHandler, + Configuration config) + throws LoginException + { + this.name = name; + this.subject = subject; + this.cbHandler = cbHandler; + if (config == null) + config = Configuration.getConfig(); + AppConfigurationEntry[] entries = config.getAppConfigurationEntry (name); + if (entries == null) + entries = config.getAppConfigurationEntry (OTHER); + if (entries == null) + throw new LoginException ("no configured modules for application " + + name); + this.entries = entries; + modules = new LoginModule[entries.length]; + sharedState = new HashMap(); + for (int i = 0; i < entries.length; i++) + modules[i] = lookupModule (entries[i], subject, sharedState); + } + + /** + * Returns the authenticated subject, or the parameter passed to one + * of the constructors. null is returned if the previous + * login attempt failed and there was no subject provided. + * + * @return The subject, or null. + */ + public Subject getSubject() + { + return subject; + } + + /** + * Logs a subject in, using all login modules configured for this + * application. This method will call the {@link LoginModule#login()} + * method of each module configured for this application, stopping + * if a REQUISITE module fails or if a SUFFICIENT module succeeds. If + * the overall login attempt fails, a {@link LoginException} will be + * thrown. + * + * @throws LoginException If logging in fails. + */ + public void login() throws LoginException + { + boolean failure = false; + for (int i = 0; i < modules.length; i++) + { + try + { + boolean result = modules[i].login(); + if (!result) + { + if (entries[i].getControlFlag() == + AppConfigurationEntry.LoginModuleControlFlag.REQUISITE) + throw new LoginException ("REQUISITE module " + entries[i].getLoginModuleName() + + " failed"); + else if (entries[i].getControlFlag() == + AppConfigurationEntry.LoginModuleControlFlag.REQUIRED) + failure = true; + } + else + { + if (entries[i].getControlFlag() == + AppConfigurationEntry.LoginModuleControlFlag.SUFFICIENT) + break; + } + } + catch (LoginException le) + { + if (entries[i].getControlFlag() != + AppConfigurationEntry.LoginModuleControlFlag.REQUISITE) + continue; + for (int j = 0; j < modules.length; j++) + modules[i].abort(); + throw le; + } + } + if (failure) + throw new LoginException ("not all REQUIRED modules succeeded"); + + for (int i = 0; i < modules.length; i++) + modules[i].commit(); + } + + /** + * Logs a subject out, cleaning up any state that may be in memory. + * + * @throws LoginException If logging out fails. + */ + public void logout() throws LoginException + { + for (int i = 0; i < modules.length; i++) + modules[i].logout(); + } + + // Own methods. + + /** + * Fetch the default callback handler, based on the + * auth.login.defaultCallbackHandler property, or null if it is not + * set. + */ + private static CallbackHandler defaultHandler() + { + GetSecurityPropertyAction act = + new GetSecurityPropertyAction ("auth.login.defaultCallbackHandler"); + String classname = (String) AccessController.doPrivileged (act); + if (classname != null) + { + try + { + return (CallbackHandler) Class.forName (classname).newInstance(); + } + catch (ClassNotFoundException cnfe) + { + return null; + } + catch (ClassCastException cce) + { + return null; + } + catch (IllegalAccessException iae) + { + return null; + } + catch (InstantiationException ie) + { + return null; + } + } + return null; + } + + private LoginModule lookupModule (AppConfigurationEntry entry, + Subject subject, Map sharedState) + throws LoginException + { + LoginModule module = null; + Exception cause = null; + try + { + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + Class c = Class.forName(entry.getLoginModuleName(), true, cl); + module = (LoginModule) c.newInstance(); + } + catch (ClassNotFoundException cnfe) + { + cause = cnfe; + } + catch (ClassCastException cce) + { + cause = cce; + } + catch (IllegalAccessException iae) + { + cause = iae; + } + catch (InstantiationException ie) + { + cause = ie; + } + + if (cause != null) + { + LoginException le = new LoginException ("could not load module " + + entry.getLoginModuleName()); + le.initCause (cause); + throw le; + } + + module.initialize (subject, cbHandler, sharedState, entry.getOptions()); + return module; + } +} diff --git a/libjava/classpath/javax/security/auth/login/LoginException.java b/libjava/classpath/javax/security/auth/login/LoginException.java new file mode 100644 index 000000000..46ec33aed --- /dev/null +++ b/libjava/classpath/javax/security/auth/login/LoginException.java @@ -0,0 +1,65 @@ +/* LoginException.java + Copyright (C) 2004 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath 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, or (at your option) +any later version. + +GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.security.auth.login; + +import java.security.GeneralSecurityException; + +/** + * A general exception during authentication and authorization. + */ +public class LoginException extends GeneralSecurityException +{ + + // Constant. + // ------------------------------------------------------------------------- + + private static final long serialVersionUID = -4679091624035232488L; + + // Constructors. + // ------------------------------------------------------------------------- + + public LoginException() + { + } + + public LoginException (String message) + { + super (message); + } +} diff --git a/libjava/classpath/javax/security/auth/login/NullConfiguration.java b/libjava/classpath/javax/security/auth/login/NullConfiguration.java new file mode 100644 index 000000000..a3f0c9943 --- /dev/null +++ b/libjava/classpath/javax/security/auth/login/NullConfiguration.java @@ -0,0 +1,62 @@ +/* NullConfiguration.java -- no-op default login configuration. + Copyright (C) 2004 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath 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, or (at your option) +any later version. + +GNU Classpath 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 GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package javax.security.auth.login; + +final class NullConfiguration extends Configuration +{ + + // Contructor. + // ------------------------------------------------------------------------- + + NullConfiguration() + { + } + + // Instance methods. + // ------------------------------------------------------------------------- + + public AppConfigurationEntry[] getAppConfigurationEntry (String applicationName) + { + return null; + } + + public void refresh() + { + } +} diff --git a/libjava/classpath/javax/security/auth/login/package.html b/libjava/classpath/javax/security/auth/login/package.html new file mode 100644 index 000000000..dcb7710cc --- /dev/null +++ b/libjava/classpath/javax/security/auth/login/package.html @@ -0,0 +1,46 @@ + + + + +GNU Classpath - javax.security.auth.login + + +

+ + + -- cgit v1.2.3