8290975: Minor cleanup could be done in javax.security
Reviewed-by: wetmore, mullan
This commit is contained in:
parent
7db5abddd1
commit
08274e6fea
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -31,7 +31,7 @@ package javax.security.auth;
|
|||||||
* list; you either have the named permission or you don't.
|
* list; you either have the named permission or you don't.
|
||||||
*
|
*
|
||||||
* <p> The target name is the name of a security configuration parameter
|
* <p> The target name is the name of a security configuration parameter
|
||||||
* (see below). Currently the {@code AuthPermission} object is used to
|
* (see below). Currently, the {@code AuthPermission} object is used to
|
||||||
* guard access to the {@link Subject},
|
* guard access to the {@link Subject},
|
||||||
* {@link javax.security.auth.login.LoginContext}, and
|
* {@link javax.security.auth.login.LoginContext}, and
|
||||||
* {@link javax.security.auth.login.Configuration} objects.
|
* {@link javax.security.auth.login.Configuration} objects.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -50,7 +50,7 @@ public interface Destroyable {
|
|||||||
* @exception SecurityException if the caller does not have permission
|
* @exception SecurityException if the caller does not have permission
|
||||||
* to destroy this {@code Object}.
|
* to destroy this {@code Object}.
|
||||||
*/
|
*/
|
||||||
public default void destroy() throws DestroyFailedException {
|
default void destroy() throws DestroyFailedException {
|
||||||
throw new DestroyFailedException();
|
throw new DestroyFailedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ public interface Destroyable {
|
|||||||
* @return true if this {@code Object} has been destroyed,
|
* @return true if this {@code Object} has been destroyed,
|
||||||
* false otherwise.
|
* false otherwise.
|
||||||
*/
|
*/
|
||||||
public default boolean isDestroyed() {
|
default boolean isDestroyed() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,7 @@ public final class PrivateCredentialPermission extends Permission {
|
|||||||
/**
|
/**
|
||||||
* @serial
|
* @serial
|
||||||
*/
|
*/
|
||||||
private boolean testing = false;
|
private final boolean testing = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new {@code PrivateCredentialPermission}
|
* Create a new {@code PrivateCredentialPermission}
|
||||||
@ -269,11 +269,9 @@ public final class PrivateCredentialPermission extends Permission {
|
|||||||
if (obj == this)
|
if (obj == this)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (! (obj instanceof PrivateCredentialPermission))
|
if (! (obj instanceof PrivateCredentialPermission that))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
PrivateCredentialPermission that = (PrivateCredentialPermission)obj;
|
|
||||||
|
|
||||||
return (this.implies(that) && that.implies(this));
|
return (this.implies(that) && that.implies(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -316,8 +314,8 @@ public final class PrivateCredentialPermission extends Permission {
|
|||||||
|
|
||||||
ArrayList<CredOwner> pList = new ArrayList<>();
|
ArrayList<CredOwner> pList = new ArrayList<>();
|
||||||
StringTokenizer tokenizer = new StringTokenizer(name, " ", true);
|
StringTokenizer tokenizer = new StringTokenizer(name, " ", true);
|
||||||
String principalClass = null;
|
String principalClass;
|
||||||
String principalName = null;
|
String principalName;
|
||||||
|
|
||||||
if (testing)
|
if (testing)
|
||||||
System.out.println("whole name = " + name);
|
System.out.println("whole name = " + name);
|
||||||
@ -327,7 +325,7 @@ public final class PrivateCredentialPermission extends Permission {
|
|||||||
if (testing)
|
if (testing)
|
||||||
System.out.println("Credential Class = " + credentialClass);
|
System.out.println("Credential Class = " + credentialClass);
|
||||||
|
|
||||||
if (tokenizer.hasMoreTokens() == false) {
|
if (!tokenizer.hasMoreTokens()) {
|
||||||
MessageFormat form = new MessageFormat(ResourcesMgr.getString
|
MessageFormat form = new MessageFormat(ResourcesMgr.getString
|
||||||
("permission.name.name.syntax.invalid."));
|
("permission.name.name.syntax.invalid."));
|
||||||
Object[] source = {name};
|
Object[] source = {name};
|
||||||
@ -346,7 +344,7 @@ public final class PrivateCredentialPermission extends Permission {
|
|||||||
if (testing)
|
if (testing)
|
||||||
System.out.println(" Principal Class = " + principalClass);
|
System.out.println(" Principal Class = " + principalClass);
|
||||||
|
|
||||||
if (tokenizer.hasMoreTokens() == false) {
|
if (!tokenizer.hasMoreTokens()) {
|
||||||
MessageFormat form = new MessageFormat(ResourcesMgr.getString
|
MessageFormat form = new MessageFormat(ResourcesMgr.getString
|
||||||
("permission.name.name.syntax.invalid."));
|
("permission.name.name.syntax.invalid."));
|
||||||
Object[] source = {name};
|
Object[] source = {name};
|
||||||
@ -428,7 +426,7 @@ public final class PrivateCredentialPermission extends Permission {
|
|||||||
if (thisC.equals("*"))
|
if (thisC.equals("*"))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* XXX let's not enable this for now --
|
* XXX let's not enable this for now --
|
||||||
* if people want it, we'll enable it later
|
* if people want it, we'll enable it later
|
||||||
*/
|
*/
|
||||||
@ -533,7 +531,7 @@ public final class PrivateCredentialPermission extends Permission {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* XXX no code yet to support a.b.*
|
* XXX no code yet to support a.b.*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -25,20 +25,16 @@
|
|||||||
|
|
||||||
package javax.security.auth;
|
package javax.security.auth;
|
||||||
|
|
||||||
import java.util.*;
|
import java.io.IOException;
|
||||||
import java.io.*;
|
import java.io.ObjectInputStream;
|
||||||
|
import java.io.ObjectOutputStream;
|
||||||
|
import java.io.ObjectStreamField;
|
||||||
|
import java.security.*;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.security.AccessController;
|
import java.util.*;
|
||||||
import java.security.AccessControlContext;
|
|
||||||
import java.security.DomainCombiner;
|
|
||||||
import java.security.Principal;
|
|
||||||
import java.security.PrivilegedExceptionAction;
|
|
||||||
import java.security.PrivilegedActionException;
|
|
||||||
import java.security.ProtectionDomain;
|
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.CompletionException;
|
import java.util.concurrent.CompletionException;
|
||||||
|
|
||||||
import sun.security.action.GetBooleanAction;
|
|
||||||
import sun.security.util.ResourcesMgr;
|
import sun.security.util.ResourcesMgr;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -90,7 +86,7 @@ import sun.security.util.ResourcesMgr;
|
|||||||
* While the Principals associated with the {@code Subject} are serialized,
|
* While the Principals associated with the {@code Subject} are serialized,
|
||||||
* the credentials associated with the {@code Subject} are not.
|
* the credentials associated with the {@code Subject} are not.
|
||||||
* Note that the {@code java.security.Principal} class
|
* Note that the {@code java.security.Principal} class
|
||||||
* does not implement {@code Serializable}. Therefore all concrete
|
* does not implement {@code Serializable}. Therefore, all concrete
|
||||||
* {@code Principal} implementations associated with Subjects
|
* {@code Principal} implementations associated with Subjects
|
||||||
* must implement {@code Serializable}.
|
* must implement {@code Serializable}.
|
||||||
*
|
*
|
||||||
@ -752,7 +748,7 @@ public final class Subject implements java.io.Serializable {
|
|||||||
|
|
||||||
// always return an empty Set instead of null
|
// always return an empty Set instead of null
|
||||||
// so LoginModules can add to the Set if necessary
|
// so LoginModules can add to the Set if necessary
|
||||||
return new ClassSet<T>(PRINCIPAL_SET, c);
|
return new ClassSet<>(PRINCIPAL_SET, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -846,7 +842,7 @@ public final class Subject implements java.io.Serializable {
|
|||||||
|
|
||||||
// always return an empty Set instead of null
|
// always return an empty Set instead of null
|
||||||
// so LoginModules can add to the Set if necessary
|
// so LoginModules can add to the Set if necessary
|
||||||
return new ClassSet<T>(PUB_CREDENTIAL_SET, c);
|
return new ClassSet<>(PUB_CREDENTIAL_SET, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -890,7 +886,7 @@ public final class Subject implements java.io.Serializable {
|
|||||||
|
|
||||||
// always return an empty Set instead of null
|
// always return an empty Set instead of null
|
||||||
// so LoginModules can add to the Set if necessary
|
// so LoginModules can add to the Set if necessary
|
||||||
return new ClassSet<T>(PRIV_CREDENTIAL_SET, c);
|
return new ClassSet<>(PRIV_CREDENTIAL_SET, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -923,9 +919,7 @@ public final class Subject implements java.io.Serializable {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (o instanceof Subject) {
|
if (o instanceof final Subject that) {
|
||||||
|
|
||||||
final Subject that = (Subject)o;
|
|
||||||
|
|
||||||
// check the principal and credential sets
|
// check the principal and credential sets
|
||||||
Set<Principal> thatPrincipals;
|
Set<Principal> thatPrincipals;
|
||||||
@ -1180,7 +1174,7 @@ public final class Subject implements java.io.Serializable {
|
|||||||
SecureSet(Subject subject, int which) {
|
SecureSet(Subject subject, int which) {
|
||||||
this.subject = subject;
|
this.subject = subject;
|
||||||
this.which = which;
|
this.which = which;
|
||||||
this.elements = new LinkedList<E>();
|
this.elements = new LinkedList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
SecureSet(Subject subject, int which, LinkedList<E> list) {
|
SecureSet(Subject subject, int which, LinkedList<E> list) {
|
||||||
@ -1195,10 +1189,12 @@ public final class Subject implements java.io.Serializable {
|
|||||||
|
|
||||||
public Iterator<E> iterator() {
|
public Iterator<E> iterator() {
|
||||||
final LinkedList<E> list = elements;
|
final LinkedList<E> list = elements;
|
||||||
return new Iterator<E>() {
|
return new Iterator<>() {
|
||||||
ListIterator<E> i = list.listIterator(0);
|
final ListIterator<E> i = list.listIterator(0);
|
||||||
|
|
||||||
public boolean hasNext() {return i.hasNext();}
|
public boolean hasNext() {
|
||||||
|
return i.hasNext();
|
||||||
|
}
|
||||||
|
|
||||||
public E next() {
|
public E next() {
|
||||||
if (which != Subject.PRIV_CREDENTIAL_SET) {
|
if (which != Subject.PRIV_CREDENTIAL_SET) {
|
||||||
@ -1337,7 +1333,7 @@ public final class Subject implements java.io.Serializable {
|
|||||||
// For private credentials:
|
// For private credentials:
|
||||||
// If the caller does not have read permission
|
// If the caller does not have read permission
|
||||||
// for o.getClass(), we throw a SecurityException.
|
// for o.getClass(), we throw a SecurityException.
|
||||||
// Otherwise we check the private cred set to see whether
|
// Otherwise, we check the private cred set to see whether
|
||||||
// it contains the Object
|
// it contains the Object
|
||||||
|
|
||||||
SecurityManager sm = System.getSecurityManager();
|
SecurityManager sm = System.getSecurityManager();
|
||||||
@ -1472,7 +1468,7 @@ public final class Subject implements java.io.Serializable {
|
|||||||
// The next() method performs a security manager check
|
// The next() method performs a security manager check
|
||||||
// on each element in the SecureSet. If we make it all
|
// on each element in the SecureSet. If we make it all
|
||||||
// the way through we should be able to simply return
|
// the way through we should be able to simply return
|
||||||
// element's toArray results. Otherwise we'll let
|
// element's toArray results. Otherwise, we'll let
|
||||||
// the SecurityException pass up the call stack.
|
// the SecurityException pass up the call stack.
|
||||||
e.next();
|
e.next();
|
||||||
}
|
}
|
||||||
@ -1486,7 +1482,7 @@ public final class Subject implements java.io.Serializable {
|
|||||||
// The next() method performs a security manager check
|
// The next() method performs a security manager check
|
||||||
// on each element in the SecureSet. If we make it all
|
// on each element in the SecureSet. If we make it all
|
||||||
// the way through we should be able to simply return
|
// the way through we should be able to simply return
|
||||||
// element's toArray results. Otherwise we'll let
|
// element's toArray results. Otherwise, we'll let
|
||||||
// the SecurityException pass up the call stack.
|
// the SecurityException pass up the call stack.
|
||||||
e.next();
|
e.next();
|
||||||
}
|
}
|
||||||
@ -1586,14 +1582,14 @@ public final class Subject implements java.io.Serializable {
|
|||||||
*/
|
*/
|
||||||
private class ClassSet<T> extends AbstractSet<T> {
|
private class ClassSet<T> extends AbstractSet<T> {
|
||||||
|
|
||||||
private int which;
|
private final int which;
|
||||||
private Class<T> c;
|
private final Class<T> c;
|
||||||
private Set<T> set;
|
private final Set<T> set;
|
||||||
|
|
||||||
ClassSet(int which, Class<T> c) {
|
ClassSet(int which, Class<T> c) {
|
||||||
this.which = which;
|
this.which = which;
|
||||||
this.c = c;
|
this.c = c;
|
||||||
set = new HashSet<T>();
|
set = new HashSet<>();
|
||||||
|
|
||||||
switch (which) {
|
switch (which) {
|
||||||
case Subject.PRINCIPAL_SET:
|
case Subject.PRINCIPAL_SET:
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -70,7 +70,7 @@ public class ChoiceCallback implements Callback, java.io.Serializable {
|
|||||||
/**
|
/**
|
||||||
* Construct a {@code ChoiceCallback} with a prompt,
|
* Construct a {@code ChoiceCallback} with a prompt,
|
||||||
* a list of choices, a default choice, and a boolean specifying
|
* a list of choices, a default choice, and a boolean specifying
|
||||||
* whether or not multiple selections from the list of choices are allowed.
|
* whether multiple selections from the list of choices are allowed.
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param prompt the prompt used to describe the list of choices.
|
* @param prompt the prompt used to describe the list of choices.
|
||||||
@ -83,9 +83,8 @@ public class ChoiceCallback implements Callback, java.io.Serializable {
|
|||||||
* is represented as an index into the
|
* is represented as an index into the
|
||||||
* {@code choices} array.
|
* {@code choices} array.
|
||||||
*
|
*
|
||||||
* @param multipleSelectionsAllowed boolean specifying whether or
|
* @param multipleSelectionsAllowed boolean specifying whether multiple
|
||||||
* not multiple selections can be made from the
|
* selections can be made from the list of choices.
|
||||||
* list of choices.
|
|
||||||
*
|
*
|
||||||
* @exception IllegalArgumentException if {@code prompt} is null,
|
* @exception IllegalArgumentException if {@code prompt} is null,
|
||||||
* if {@code prompt} has a length of 0,
|
* if {@code prompt} has a length of 0,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -42,12 +42,12 @@ public class NameCallback implements Callback, java.io.Serializable {
|
|||||||
* @serial
|
* @serial
|
||||||
* @since 1.4
|
* @since 1.4
|
||||||
*/
|
*/
|
||||||
private String prompt;
|
private final String prompt;
|
||||||
/**
|
/**
|
||||||
* @serial
|
* @serial
|
||||||
* @since 1.4
|
* @since 1.4
|
||||||
*/
|
*/
|
||||||
private String defaultName;
|
private final String defaultName;
|
||||||
/**
|
/**
|
||||||
* @serial
|
* @serial
|
||||||
* @since 1.4
|
* @since 1.4
|
||||||
@ -66,6 +66,7 @@ public class NameCallback implements Callback, java.io.Serializable {
|
|||||||
if (prompt == null || prompt.isEmpty())
|
if (prompt == null || prompt.isEmpty())
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
this.prompt = prompt;
|
this.prompt = prompt;
|
||||||
|
this.defaultName = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -155,8 +155,6 @@ public class PasswordCallback implements Callback, java.io.Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static Runnable cleanerFor(char[] password) {
|
private static Runnable cleanerFor(char[] password) {
|
||||||
return () -> {
|
return () -> Arrays.fill(password, ' ');
|
||||||
Arrays.fill(password, ' ');
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -43,12 +43,12 @@ public class TextInputCallback implements Callback, java.io.Serializable {
|
|||||||
* @serial
|
* @serial
|
||||||
* @since 1.4
|
* @since 1.4
|
||||||
*/
|
*/
|
||||||
private String prompt;
|
private final String prompt;
|
||||||
/**
|
/**
|
||||||
* @serial
|
* @serial
|
||||||
* @since 1.4
|
* @since 1.4
|
||||||
*/
|
*/
|
||||||
private String defaultText;
|
private final String defaultText;
|
||||||
/**
|
/**
|
||||||
* @serial
|
* @serial
|
||||||
* @since 1.4
|
* @since 1.4
|
||||||
@ -67,6 +67,7 @@ public class TextInputCallback implements Callback, java.io.Serializable {
|
|||||||
if (prompt == null || prompt.isEmpty())
|
if (prompt == null || prompt.isEmpty())
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
this.prompt = prompt;
|
this.prompt = prompt;
|
||||||
|
this.defaultText = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -50,12 +50,12 @@ public class TextOutputCallback implements Callback, java.io.Serializable {
|
|||||||
* @serial
|
* @serial
|
||||||
* @since 1.4
|
* @since 1.4
|
||||||
*/
|
*/
|
||||||
private int messageType;
|
private final int messageType;
|
||||||
/**
|
/**
|
||||||
* @serial
|
* @serial
|
||||||
* @since 1.4
|
* @since 1.4
|
||||||
*/
|
*/
|
||||||
private String message;
|
private final String message;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a TextOutputCallback with a message type and message
|
* Construct a TextOutputCallback with a message type and message
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -40,7 +40,7 @@ public class UnsupportedCallbackException extends Exception {
|
|||||||
* @serial
|
* @serial
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("serial") // Not statically typed as Serializable
|
@SuppressWarnings("serial") // Not statically typed as Serializable
|
||||||
private Callback callback;
|
private final Callback callback;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs an {@code UnsupportedCallbackException}
|
* Constructs an {@code UnsupportedCallbackException}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -44,9 +44,9 @@ import java.util.Collections;
|
|||||||
*/
|
*/
|
||||||
public class AppConfigurationEntry {
|
public class AppConfigurationEntry {
|
||||||
|
|
||||||
private String loginModuleName;
|
private final String loginModuleName;
|
||||||
private LoginModuleControlFlag controlFlag;
|
private final LoginModuleControlFlag controlFlag;
|
||||||
private Map<String,?> options;
|
private final Map<String,?> options;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor for this class.
|
* Default constructor for this class.
|
||||||
@ -122,12 +122,12 @@ public class AppConfigurationEntry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class represents whether or not a {@code LoginModule}
|
* This class represents whether a {@code LoginModule}
|
||||||
* is REQUIRED, REQUISITE, SUFFICIENT or OPTIONAL.
|
* is REQUIRED, REQUISITE, SUFFICIENT or OPTIONAL.
|
||||||
*/
|
*/
|
||||||
public static class LoginModuleControlFlag {
|
public static class LoginModuleControlFlag {
|
||||||
|
|
||||||
private String controlFlag;
|
private final String controlFlag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Required {@code LoginModule}.
|
* Required {@code LoginModule}.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -321,7 +321,7 @@ public abstract class Configuration {
|
|||||||
* {@code jdk.security.provider.preferred}
|
* {@code jdk.security.provider.preferred}
|
||||||
* {@link Security#getProperty(String) Security} property to determine
|
* {@link Security#getProperty(String) Security} property to determine
|
||||||
* the preferred provider order for the specified algorithm. This
|
* the preferred provider order for the specified algorithm. This
|
||||||
* may be different than the order of providers returned by
|
* may be different from the order of providers returned by
|
||||||
* {@link Security#getProviders() Security.getProviders()}.
|
* {@link Security#getProviders() Security.getProviders()}.
|
||||||
*
|
*
|
||||||
* @param type the specified Configuration type. See the Configuration
|
* @param type the specified Configuration type. See the Configuration
|
||||||
@ -519,7 +519,7 @@ public abstract class Configuration {
|
|||||||
*
|
*
|
||||||
* <p> This Configuration instance will only have a Provider if it
|
* <p> This Configuration instance will only have a Provider if it
|
||||||
* was obtained via a call to {@code Configuration.getInstance}.
|
* was obtained via a call to {@code Configuration.getInstance}.
|
||||||
* Otherwise this method returns null.
|
* Otherwise, this method returns null.
|
||||||
*
|
*
|
||||||
* @return the Provider of this Configuration, or null.
|
* @return the Provider of this Configuration, or null.
|
||||||
*
|
*
|
||||||
@ -534,7 +534,7 @@ public abstract class Configuration {
|
|||||||
*
|
*
|
||||||
* <p> This Configuration instance will only have a type if it
|
* <p> This Configuration instance will only have a type if it
|
||||||
* was obtained via a call to {@code Configuration.getInstance}.
|
* was obtained via a call to {@code Configuration.getInstance}.
|
||||||
* Otherwise this method returns null.
|
* Otherwise, this method returns null.
|
||||||
*
|
*
|
||||||
* @return the type of this Configuration, or null.
|
* @return the type of this Configuration, or null.
|
||||||
*
|
*
|
||||||
@ -549,7 +549,7 @@ public abstract class Configuration {
|
|||||||
*
|
*
|
||||||
* <p> This Configuration instance will only have parameters if it
|
* <p> This Configuration instance will only have parameters if it
|
||||||
* was obtained via a call to {@code Configuration.getInstance}.
|
* was obtained via a call to {@code Configuration.getInstance}.
|
||||||
* Otherwise this method returns null.
|
* Otherwise, this method returns null.
|
||||||
*
|
*
|
||||||
* @return Configuration parameters, or null.
|
* @return Configuration parameters, or null.
|
||||||
*
|
*
|
||||||
@ -595,10 +595,10 @@ public abstract class Configuration {
|
|||||||
*/
|
*/
|
||||||
private static class ConfigDelegate extends Configuration {
|
private static class ConfigDelegate extends Configuration {
|
||||||
|
|
||||||
private ConfigurationSpi spi;
|
private final ConfigurationSpi spi;
|
||||||
private Provider p;
|
private final Provider p;
|
||||||
private String type;
|
private final String type;
|
||||||
private Configuration.Parameters params;
|
private final Configuration.Parameters params;
|
||||||
|
|
||||||
private ConfigDelegate(ConfigurationSpi spi, Provider p,
|
private ConfigDelegate(ConfigurationSpi spi, Provider p,
|
||||||
String type, Configuration.Parameters params) {
|
String type, Configuration.Parameters params) {
|
||||||
@ -628,5 +628,5 @@ public abstract class Configuration {
|
|||||||
*
|
*
|
||||||
* @since 1.6
|
* @since 1.6
|
||||||
*/
|
*/
|
||||||
public static interface Parameters { }
|
public interface Parameters { }
|
||||||
}
|
}
|
||||||
|
@ -208,7 +208,7 @@ public class LoginContext {
|
|||||||
private boolean subjectProvided = false;
|
private boolean subjectProvided = false;
|
||||||
private boolean loginSucceeded = false;
|
private boolean loginSucceeded = false;
|
||||||
private CallbackHandler callbackHandler;
|
private CallbackHandler callbackHandler;
|
||||||
private Map<String,?> state = new HashMap<String,Object>();
|
private final Map<String,?> state = new HashMap<>();
|
||||||
|
|
||||||
private Configuration config;
|
private Configuration config;
|
||||||
@SuppressWarnings("removal")
|
@SuppressWarnings("removal")
|
||||||
@ -658,8 +658,7 @@ public class LoginContext {
|
|||||||
clearState();
|
clearState();
|
||||||
|
|
||||||
// throw the exception
|
// throw the exception
|
||||||
LoginException error = (originalError != null) ? originalError : le;
|
throw (originalError != null) ? originalError : le;
|
||||||
throw error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -767,7 +766,7 @@ public class LoginContext {
|
|||||||
throw new AssertionError("Unknown method " + methodName);
|
throw new AssertionError("Unknown method " + methodName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status == true) {
|
if (status) {
|
||||||
|
|
||||||
// if SUFFICIENT, return if no prior REQUIRED errors
|
// if SUFFICIENT, return if no prior REQUIRED errors
|
||||||
if (!methodName.equals(ABORT_METHOD) &&
|
if (!methodName.equals(ABORT_METHOD) &&
|
||||||
@ -887,14 +886,14 @@ public class LoginContext {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// we went thru all the LoginModules.
|
// we went through all the LoginModules.
|
||||||
if (firstRequiredError != null) {
|
if (firstRequiredError != null) {
|
||||||
// a REQUIRED module failed -- return the error
|
// a REQUIRED module failed -- return the error
|
||||||
throwException(firstRequiredError, null);
|
throwException(firstRequiredError, null);
|
||||||
} else if (success == false && firstError != null) {
|
} else if (!success && firstError != null) {
|
||||||
// no module succeeded -- return the first error
|
// no module succeeded -- return the first error
|
||||||
throwException(firstError, null);
|
throwException(firstError, null);
|
||||||
} else if (success == false) {
|
} else if (!success) {
|
||||||
// no module succeeded -- all modules were IGNORED
|
// no module succeeded -- all modules were IGNORED
|
||||||
throwException(new LoginException
|
throwException(new LoginException
|
||||||
(ResourcesMgr.getString("Login.Failure.all.modules.ignored")),
|
(ResourcesMgr.getString("Login.Failure.all.modules.ignored")),
|
||||||
@ -903,7 +902,6 @@ public class LoginContext {
|
|||||||
// success
|
// success
|
||||||
|
|
||||||
clearState();
|
clearState();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -948,7 +946,7 @@ public class LoginContext {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* LoginModule information -
|
* LoginModule information -
|
||||||
* incapsulates Configuration info and actual module instances
|
* encapsulates Configuration info and actual module instances
|
||||||
*/
|
*/
|
||||||
private static class ModuleInfo {
|
private static class ModuleInfo {
|
||||||
AppConfigurationEntry entry;
|
AppConfigurationEntry entry;
|
||||||
|
@ -25,10 +25,10 @@
|
|||||||
|
|
||||||
package javax.security.auth.spi;
|
package javax.security.auth.spi;
|
||||||
|
|
||||||
import javax.security.auth.Subject;
|
|
||||||
import javax.security.auth.callback.*;
|
|
||||||
import javax.security.auth.login.*;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import javax.security.auth.Subject;
|
||||||
|
import javax.security.auth.callback.CallbackHandler;
|
||||||
|
import javax.security.auth.login.LoginException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p> Service-provider interface for authentication technology providers.
|
* <p> Service-provider interface for authentication technology providers.
|
||||||
@ -39,7 +39,7 @@ import java.util.Map;
|
|||||||
* authentication technology providers implement the
|
* authentication technology providers implement the
|
||||||
* {@code LoginModule} interface.
|
* {@code LoginModule} interface.
|
||||||
* A {@code Configuration} specifies the LoginModule(s)
|
* A {@code Configuration} specifies the LoginModule(s)
|
||||||
* to be used with a particular login application. Therefore different
|
* to be used with a particular login application. Therefore, different
|
||||||
* LoginModules can be plugged in under the application without
|
* LoginModules can be plugged in under the application without
|
||||||
* requiring any modifications to the application itself.
|
* requiring any modifications to the application itself.
|
||||||
*
|
*
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -91,7 +91,7 @@ public final class X500Principal implements Principal, java.io.Serializable {
|
|||||||
*
|
*
|
||||||
* NOTE: The constructor is package private. It is intended to be accessed
|
* NOTE: The constructor is package private. It is intended to be accessed
|
||||||
* using privileged reflection from classes in sun.security.*.
|
* using privileged reflection from classes in sun.security.*.
|
||||||
* Currently referenced from sun.security.x509.X500Name.asX500Principal().
|
* Currently, it is referenced from sun.security.x509.X500Name.asX500Principal().
|
||||||
*/
|
*/
|
||||||
X500Principal(X500Name x500Name) {
|
X500Principal(X500Name x500Name) {
|
||||||
thisX500Name = x500Name;
|
thisX500Name = x500Name;
|
||||||
@ -126,7 +126,7 @@ public final class X500Principal implements Principal, java.io.Serializable {
|
|||||||
* is improperly specified
|
* is improperly specified
|
||||||
*/
|
*/
|
||||||
public X500Principal(String name) {
|
public X500Principal(String name) {
|
||||||
this(name, Collections.<String, String>emptyMap());
|
this(name, Collections.emptyMap());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -288,7 +288,7 @@ public final class X500Principal implements Principal, java.io.Serializable {
|
|||||||
/**
|
/**
|
||||||
* Returns a string representation of the X.500 distinguished name
|
* Returns a string representation of the X.500 distinguished name
|
||||||
* using the specified format. Valid values for the format are
|
* using the specified format. Valid values for the format are
|
||||||
* "RFC1779", "RFC2253", and "CANONICAL" (case insensitive).
|
* "RFC1779", "RFC2253", and "CANONICAL" (case-insensitive).
|
||||||
*
|
*
|
||||||
* <p> If "RFC1779" is specified as the format,
|
* <p> If "RFC1779" is specified as the format,
|
||||||
* this method emits the attribute type keywords defined in
|
* this method emits the attribute type keywords defined in
|
||||||
@ -363,7 +363,7 @@ public final class X500Principal implements Principal, java.io.Serializable {
|
|||||||
/**
|
/**
|
||||||
* Returns a string representation of the X.500 distinguished name
|
* Returns a string representation of the X.500 distinguished name
|
||||||
* using the specified format. Valid values for the format are
|
* using the specified format. Valid values for the format are
|
||||||
* "RFC1779" and "RFC2253" (case insensitive). "CANONICAL" is not
|
* "RFC1779" and "RFC2253" (case-insensitive). "CANONICAL" is not
|
||||||
* permitted and an {@code IllegalArgumentException} will be thrown.
|
* permitted and an {@code IllegalArgumentException} will be thrown.
|
||||||
*
|
*
|
||||||
* <p>This method returns Strings in the format as specified in
|
* <p>This method returns Strings in the format as specified in
|
||||||
@ -461,10 +461,9 @@ public final class X500Principal implements Principal, java.io.Serializable {
|
|||||||
if (this == o) {
|
if (this == o) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (o instanceof X500Principal == false) {
|
if (!(o instanceof X500Principal other)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
X500Principal other = (X500Principal)o;
|
|
||||||
return this.thisX500Name.equals(other.thisX500Name);
|
return this.thisX500Name.equals(other.thisX500Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -27,17 +27,13 @@
|
|||||||
package javax.security.cert;
|
package javax.security.cert;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.lang.Class;
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.security.Security;
|
|
||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.security.AccessController;
|
import java.security.AccessController;
|
||||||
import java.security.Principal;
|
import java.security.Principal;
|
||||||
import java.security.PrivilegedAction;
|
import java.security.PrivilegedAction;
|
||||||
import java.security.PublicKey;
|
import java.security.Security;
|
||||||
import java.util.BitSet;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user