src/share/jaxws_classes/com/sun/tools/internal/ws/wscompile/AuthInfo.java

changeset 368
0989ad8c0860
parent 286
f50545b5e2f1
child 637
9c07ef4934dd
equal deleted inserted replaced
366:8c0b6bccfe47 368:0989ad8c0860
1 /* 1 /*
2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this 7 * published by the Free Software Foundation. Oracle designates this
26 package com.sun.tools.internal.ws.wscompile; 26 package com.sun.tools.internal.ws.wscompile;
27 27
28 import com.sun.istack.internal.NotNull; 28 import com.sun.istack.internal.NotNull;
29 29
30 import java.net.URL; 30 import java.net.URL;
31 import java.util.regex.Pattern;
31 32
32 /** 33 /**
33 * Represents authorization information needed by {@link com.sun.tools.internal.ws.wscompile.DefaultAuthenticator} to 34 * Represents authorization information needed by {@link com.sun.tools.internal.ws.wscompile.DefaultAuthenticator} to
34 * authenticate wsimport to access the wsdl. 35 * authenticate wsimport to access the wsdl.
35 * 36 *
37 */ 38 */
38 39
39 public final class AuthInfo { 40 public final class AuthInfo {
40 private final String user; 41 private final String user;
41 private final String password; 42 private final String password;
42 private final URL url; 43 private final Pattern urlPattern;
43 44
44 public AuthInfo(@NotNull URL url, @NotNull String user, @NotNull String password){ 45 public AuthInfo(@NotNull URL url, @NotNull String user, @NotNull String password) {
45 this.url = url; 46 String u = url.toExternalForm().replaceFirst("\\?", "\\\\?");
47 this.urlPattern = Pattern.compile(u.replace("*", ".*"), Pattern.CASE_INSENSITIVE);
46 this.user = user; 48 this.user = user;
47 this.password = password; 49 this.password = password;
48 } 50 }
49 51
50 public String getUser() { 52 public String getUser() {
57 59
58 /** 60 /**
59 * Returns if the requesting host and port are associated with this {@link AuthInfo} 61 * Returns if the requesting host and port are associated with this {@link AuthInfo}
60 */ 62 */
61 public boolean matchingHost(@NotNull URL requestingURL) { 63 public boolean matchingHost(@NotNull URL requestingURL) {
62 return requestingURL.equals(url); 64 return urlPattern.matcher(requestingURL.toExternalForm()).matches();
63 } 65 }
64 66
65 } 67 }

mercurial