Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
3 changed files
with
53 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,44 @@ | ||
package hudson.plugins.active_directory; | ||
|
||
import com.google.common.collect.ImmutableList; | ||
import hudson.util.FlushProofOutputStream; | ||
import org.acegisecurity.AuthenticationException; | ||
|
||
import java.io.PrintStream; | ||
import java.io.PrintWriter; | ||
import java.util.Collection; | ||
import java.util.List; | ||
|
||
/** | ||
* {@link AuthenticationException} that supports multiple nested causes. | ||
* | ||
* @author Kohsuke Kawaguchi | ||
*/ | ||
public class MultiCauseBadCredentialsException extends AuthenticationException { | ||
private final List<Throwable> causes; | ||
|
||
public MultiCauseBadCredentialsException(String msg, Collection<? extends Throwable> causes) { | ||
super(msg); | ||
this.causes = ImmutableList.copyOf(causes); | ||
} | ||
|
||
@Override | ||
public void printStackTrace(PrintStream s) { | ||
PrintWriter w = new PrintWriter(new FlushProofOutputStream(s)); | ||
printStackTrace(w); | ||
w.flush(); | ||
} | ||
|
||
@Override | ||
public void printStackTrace(PrintWriter s) { | ||
synchronized (s) { | ||
super.printStackTrace(s); | ||
|
||
for (int i = 0; i < causes.size(); i++) { | ||
Throwable cause = causes.get(i); | ||
s.format("Cause #%s: ", i + 1); | ||
cause.printStackTrace(s); | ||
} | ||
} | ||
} | ||
} |