mirror of
https://github.com/octoleo/plantuml.git
synced 2025-01-03 07:12:29 +00:00
wip
This commit is contained in:
parent
df9f6cbfb1
commit
1e69806f44
@ -35,25 +35,6 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml.security;
|
||||
|
||||
import net.sourceforge.plantuml.OptionFlags;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.json.Json;
|
||||
import net.sourceforge.plantuml.json.JsonValue;
|
||||
import net.sourceforge.plantuml.security.authentication.SecurityAccessInterceptor;
|
||||
import net.sourceforge.plantuml.security.authentication.SecurityAuthentication;
|
||||
import net.sourceforge.plantuml.security.authentication.SecurityAuthorizeManager;
|
||||
import net.sourceforge.plantuml.security.authentication.SecurityCredentials;
|
||||
import net.sourceforge.plantuml.security.authentication.SecurityDefaultNoopAccessInterceptor;
|
||||
import net.sourceforge.plantuml.security.authentication.SecurityDefaultNoopAuthorizeManager;
|
||||
import net.sourceforge.plantuml.security.authentication.basicauth.BasicAuthAccessInterceptor;
|
||||
import net.sourceforge.plantuml.security.authentication.basicauth.BasicAuthAuthorizeManager;
|
||||
import net.sourceforge.plantuml.security.authentication.oauth.OAuth2AccessInterceptor;
|
||||
import net.sourceforge.plantuml.security.authentication.oauth.OAuth2ClientAccessAuthorizeManager;
|
||||
import net.sourceforge.plantuml.security.authentication.oauth.OAuth2ResourceOwnerAccessAuthorizeManager;
|
||||
import net.sourceforge.plantuml.security.authentication.token.TokenAuthAccessInterceptor;
|
||||
import net.sourceforge.plantuml.security.authentication.token.TokenAuthAuthorizeManager;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
import java.awt.Image;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.BufferedReader;
|
||||
@ -74,6 +55,26 @@ import java.util.List;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
|
||||
import net.sourceforge.plantuml.Log;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.json.Json;
|
||||
import net.sourceforge.plantuml.json.JsonValue;
|
||||
import net.sourceforge.plantuml.security.authentication.SecurityAccessInterceptor;
|
||||
import net.sourceforge.plantuml.security.authentication.SecurityAuthentication;
|
||||
import net.sourceforge.plantuml.security.authentication.SecurityAuthorizeManager;
|
||||
import net.sourceforge.plantuml.security.authentication.SecurityCredentials;
|
||||
import net.sourceforge.plantuml.security.authentication.SecurityDefaultNoopAccessInterceptor;
|
||||
import net.sourceforge.plantuml.security.authentication.SecurityDefaultNoopAuthorizeManager;
|
||||
import net.sourceforge.plantuml.security.authentication.basicauth.BasicAuthAccessInterceptor;
|
||||
import net.sourceforge.plantuml.security.authentication.basicauth.BasicAuthAuthorizeManager;
|
||||
import net.sourceforge.plantuml.security.authentication.oauth.OAuth2AccessInterceptor;
|
||||
import net.sourceforge.plantuml.security.authentication.oauth.OAuth2ClientAccessAuthorizeManager;
|
||||
import net.sourceforge.plantuml.security.authentication.oauth.OAuth2ResourceOwnerAccessAuthorizeManager;
|
||||
import net.sourceforge.plantuml.security.authentication.token.TokenAuthAccessInterceptor;
|
||||
import net.sourceforge.plantuml.security.authentication.token.TokenAuthAuthorizeManager;
|
||||
|
||||
public class SecurityUtils {
|
||||
|
||||
/**
|
||||
@ -160,9 +161,9 @@ public class SecurityUtils {
|
||||
static private SecurityProfile current = null;
|
||||
|
||||
public static synchronized SecurityProfile getSecurityProfile() {
|
||||
if (current == null) {
|
||||
if (current == null)
|
||||
current = SecurityProfile.init();
|
||||
}
|
||||
|
||||
return current;
|
||||
}
|
||||
|
||||
@ -183,9 +184,9 @@ public class SecurityUtils {
|
||||
|
||||
public static String getenv(String name) {
|
||||
final String env = System.getProperty(name);
|
||||
if (StringUtils.isNotEmpty(env)) {
|
||||
if (StringUtils.isNotEmpty(env))
|
||||
return env;
|
||||
}
|
||||
|
||||
return System.getenv(name);
|
||||
}
|
||||
|
||||
@ -220,13 +221,13 @@ public class SecurityUtils {
|
||||
paths = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(paths);
|
||||
final StringTokenizer st = new StringTokenizer(paths, System.getProperty("path.separator"));
|
||||
while (st.hasMoreTokens()) {
|
||||
final String tmp = st.nextToken();
|
||||
try {
|
||||
final SFile f = new SFile(st.nextToken()).getCanonicalFile();
|
||||
if (f.isDirectory()) {
|
||||
final SFile f = new SFile(tmp).getCanonicalFile();
|
||||
if (f.isDirectory())
|
||||
result.add(f);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
Log.info("Cannot access to " + tmp + ". " + e);
|
||||
}
|
||||
}
|
||||
return Collections.unmodifiableList(result);
|
||||
@ -260,9 +261,9 @@ public class SecurityUtils {
|
||||
|
||||
public synchronized static BufferedImage readRasterImage(final ImageIcon imageIcon) {
|
||||
final Image tmpImage = imageIcon.getImage();
|
||||
if (imageIcon.getIconWidth() == -1) {
|
||||
if (imageIcon.getIconWidth() == -1)
|
||||
return null;
|
||||
}
|
||||
|
||||
final BufferedImage image = new BufferedImage(imageIcon.getIconWidth(), imageIcon.getIconHeight(),
|
||||
BufferedImage.TYPE_INT_ARGB);
|
||||
image.getGraphics().drawImage(tmpImage, 0, 0, null);
|
||||
|
@ -108,6 +108,7 @@ public class StyleLoader {
|
||||
}
|
||||
return internalIs;
|
||||
}
|
||||
|
||||
private void loadSkinInternal(final BlocLines lines) {
|
||||
for (Style newStyle : getDeclaredStyles(lines, styleBuilder))
|
||||
this.styleBuilder.loadInternal(newStyle.getSignature(), newStyle);
|
||||
|
@ -104,12 +104,12 @@ public class TikzGraphics {
|
||||
}
|
||||
|
||||
private String getColorName(Color c) {
|
||||
if (c.equals(Color.WHITE)) {
|
||||
if (c.equals(Color.WHITE))
|
||||
return "white";
|
||||
}
|
||||
if (c.equals(Color.BLACK)) {
|
||||
|
||||
if (c.equals(Color.BLACK))
|
||||
return "black";
|
||||
}
|
||||
|
||||
final String result = colornames.get(c);
|
||||
return Objects.requireNonNull(result);
|
||||
}
|
||||
@ -158,29 +158,28 @@ public class TikzGraphics {
|
||||
out(os, " }");
|
||||
out(os, "}");
|
||||
}
|
||||
for (Map.Entry<Color, String> ent : colornames.entrySet()) {
|
||||
for (Map.Entry<Color, String> ent : colornames.entrySet())
|
||||
out(os, definecolor(ent.getValue(), ent.getKey()));
|
||||
|
||||
}
|
||||
if (scale != 1) {
|
||||
if (scale != 1)
|
||||
out(os, "\\scalebox{" + format(scale) + "}{");
|
||||
}
|
||||
|
||||
out(os, "\\begin{tikzpicture}[yscale=-1");
|
||||
purgeStyles();
|
||||
for (String style : styles.keySet()) {
|
||||
for (String style : styles.keySet())
|
||||
out(os, "," + stylesID.get(style) + "/.style={" + style + "}");
|
||||
}
|
||||
|
||||
out(os, "]");
|
||||
for (String s : cmd) {
|
||||
for (String s : cmd)
|
||||
out(os, useStyle(s));
|
||||
}
|
||||
|
||||
out(os, "\\end{tikzpicture}");
|
||||
if (scale != 1) {
|
||||
if (scale != 1)
|
||||
out(os, "}");
|
||||
}
|
||||
if (withPreamble) {
|
||||
|
||||
if (withPreamble)
|
||||
out(os, "\\end{document}");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private String useStyle(String s) {
|
||||
@ -202,9 +201,9 @@ public class TikzGraphics {
|
||||
private void purgeStyles() {
|
||||
for (Iterator<Map.Entry<String, Integer>> it = styles.entrySet().iterator(); it.hasNext();) {
|
||||
final Map.Entry<String, Integer> ent = it.next();
|
||||
if (ent.getValue().intValue() == 1) {
|
||||
if (ent.getValue().intValue() == 1)
|
||||
it.remove();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -224,25 +223,25 @@ public class TikzGraphics {
|
||||
sb.append(";");
|
||||
} else {
|
||||
sb.append("\\node at " + couple(x, y) + "[draw, ");
|
||||
if (color != null) {
|
||||
if (color != null)
|
||||
sb.append("color=" + getColorName(color) + ",");
|
||||
}
|
||||
if (fillcolor != null) {
|
||||
|
||||
if (mustApplyFillColor()) {
|
||||
sb.append("fill=" + getColorName(fillcolor) + ",");
|
||||
if (color == null) {
|
||||
if (color == null)
|
||||
sb.append("color=" + getColorName(fillcolor) + ",");
|
||||
}
|
||||
|
||||
}
|
||||
sb.append("line width=" + thickness + "pt,");
|
||||
sb.append("below right,");
|
||||
sb.append("inner sep=2ex,");
|
||||
sb.append("minimum width=" + format(width) + "pt,");
|
||||
sb.append("minimum height=" + format(height) + "pt,");
|
||||
if (Url.isLatex(pendingUrl)) {
|
||||
if (Url.isLatex(pendingUrl))
|
||||
sb.append("hyperref node=" + extractInternalHref(pendingUrl));
|
||||
} else {
|
||||
else
|
||||
sb.append("href node=" + pendingUrl);
|
||||
}
|
||||
|
||||
sb.append("] ");
|
||||
sb.append(" {};");
|
||||
urlIgnoreText = true;
|
||||
@ -251,18 +250,18 @@ public class TikzGraphics {
|
||||
}
|
||||
|
||||
private String getAngleFromGradientPolicy() {
|
||||
if (this.gradientPolicy == '-') {
|
||||
if (this.gradientPolicy == '-')
|
||||
return "0";
|
||||
}
|
||||
if (this.gradientPolicy == '|') {
|
||||
|
||||
if (this.gradientPolicy == '|')
|
||||
return "90";
|
||||
}
|
||||
if (this.gradientPolicy == '/') {
|
||||
|
||||
if (this.gradientPolicy == '/')
|
||||
return "45";
|
||||
}
|
||||
if (this.gradientPolicy == '\\') {
|
||||
|
||||
if (this.gradientPolicy == '\\')
|
||||
return "135";
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
@ -288,25 +287,25 @@ public class TikzGraphics {
|
||||
}
|
||||
sb.append("]{");
|
||||
if (pendingUrl == null || urlIgnoreText) {
|
||||
if (underline) {
|
||||
if (underline)
|
||||
sb.append("\\underline{");
|
||||
}
|
||||
if (italic) {
|
||||
|
||||
if (italic)
|
||||
sb.append("\\textit{");
|
||||
}
|
||||
if (bold) {
|
||||
|
||||
if (bold)
|
||||
sb.append("\\textbf{");
|
||||
}
|
||||
|
||||
sb.append(protectText(text));
|
||||
if (bold) {
|
||||
if (bold)
|
||||
sb.append("}");
|
||||
}
|
||||
if (italic) {
|
||||
|
||||
if (italic)
|
||||
sb.append("}");
|
||||
}
|
||||
if (underline) {
|
||||
|
||||
if (underline)
|
||||
sb.append("}");
|
||||
}
|
||||
|
||||
} else {
|
||||
appendPendingUrl(sb);
|
||||
sb.append("{");
|
||||
@ -370,13 +369,13 @@ public class TikzGraphics {
|
||||
public void line(double x1, double y1, double x2, double y2) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append("\\draw[");
|
||||
if (color != null) {
|
||||
if (color != null)
|
||||
sb.append("color=" + getColorName(color) + ",");
|
||||
}
|
||||
|
||||
sb.append("line width=" + thickness + "pt");
|
||||
if (dash != null) {
|
||||
if (dash != null)
|
||||
sb.append(",dash pattern=" + dash);
|
||||
}
|
||||
|
||||
sb.append("] ");
|
||||
sb.append(couple(x1, y1));
|
||||
sb.append(" -- ");
|
||||
@ -438,14 +437,22 @@ public class TikzGraphics {
|
||||
sb.append("top color=" + getColorName(fillcolor) + ",");
|
||||
sb.append("bottom color=" + getColorName(fillcolorGradient2) + ",");
|
||||
sb.append("shading=axis,shading angle=" + getAngleFromGradientPolicy() + ",");
|
||||
} else if (fillcolor != null) {
|
||||
} else if (mustApplyFillColor()) {
|
||||
sb.append("fill=" + getColorName(fillcolor) + ",");
|
||||
if (color == null) {
|
||||
if (color == null)
|
||||
sb.append("color=" + getColorName(fillcolor) + ",");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private boolean mustApplyFillColor() {
|
||||
if (fillcolor == null)
|
||||
return false;
|
||||
if (fillcolor.getAlpha() == 0)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void rectangleRound(double x, double y, double width, double height, double r) {
|
||||
double[] points = new double[8 * 2];
|
||||
points[0] = x;
|
||||
@ -475,9 +482,9 @@ public class TikzGraphics {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
appendShadeOrDraw(sb);
|
||||
sb.append("line width=" + thickness + "pt");
|
||||
if (dash != null) {
|
||||
if (dash != null)
|
||||
sb.append(",dash pattern=" + dash);
|
||||
}
|
||||
|
||||
sb.append("] ");
|
||||
for (USegment seg : path) {
|
||||
final USegmentType type = seg.getSegmentType();
|
||||
@ -513,12 +520,12 @@ public class TikzGraphics {
|
||||
public void ellipse(double x, double y, double width, double height) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append("\\draw[");
|
||||
if (color != null) {
|
||||
if (color != null)
|
||||
sb.append("color=" + getColorName(color) + ",");
|
||||
}
|
||||
if (fillcolor != null) {
|
||||
|
||||
if (fillcolor != null)
|
||||
sb.append("fill=" + getColorName(fillcolor) + ",");
|
||||
}
|
||||
|
||||
sb.append("line width=" + thickness + "pt] " + couple(x, y) + " ellipse (" + format(width) + "pt and "
|
||||
+ format(height) + "pt);");
|
||||
addCommand(sb);
|
||||
@ -527,12 +534,12 @@ public class TikzGraphics {
|
||||
public void arc(double x, double y, int angleStart, int angleEnd, double radius) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append("\\draw[");
|
||||
if (color != null) {
|
||||
if (color != null)
|
||||
sb.append("color=" + getColorName(color) + ",");
|
||||
}
|
||||
if (fillcolor != null) {
|
||||
|
||||
if (fillcolor != null)
|
||||
sb.append("fill=" + getColorName(fillcolor) + ",");
|
||||
}
|
||||
|
||||
sb.append("line width=" + thickness + "pt] " + couple(x, y) + " arc (" + angleStart + ":" + angleEnd + ":"
|
||||
+ format(radius) + "pt);");
|
||||
addCommand(sb);
|
||||
@ -609,12 +616,12 @@ public class TikzGraphics {
|
||||
}
|
||||
|
||||
private void addColor(Color c) {
|
||||
if (c == null) {
|
||||
if (c == null)
|
||||
return;
|
||||
}
|
||||
if (colornames.containsKey(c)) {
|
||||
|
||||
if (colornames.containsKey(c))
|
||||
return;
|
||||
}
|
||||
|
||||
final String name = "plantucolor" + String.format("%04d", colornames.size());
|
||||
colornames.put(c, name);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user