Issue #2106 Correct connection password logic, fix test code

Change-Id: I6f7f91542c324ac63214da5e231ab3f267b90f25

Former-commit-id: 509418e05c [formerly e1fb1488c9] [formerly 509418e05c [formerly e1fb1488c9] [formerly 6cb4800e24 [formerly e1098a65c04a230590b8460b3da1d12b1046b9b5]]]
Former-commit-id: 6cb4800e24
Former-commit-id: d364dc9554 [formerly 57be281cb4]
Former-commit-id: ae0ad86a89
This commit is contained in:
Dustin Johnson 2013-06-17 09:24:07 -05:00
parent 0df3686a47
commit 86d55a558e
7 changed files with 30 additions and 29 deletions

View file

@ -44,6 +44,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
* Jun 28, 2012 819 djohnson Remove proxy information.
* Jul 24, 2012 955 djohnson Add copy constructor.
* Jun 11, 2013 1763 dhladky Added Encryption type
* Jun 17, 2013 2106 djohnson Check for encryption to not be null, getPassword() must be left alone for dynamic serialize.
*
* </pre>
*
@ -107,7 +108,11 @@ public class Connection implements ISerializableObject, Serializable {
}
public String getPassword() {
if (password != null) {
return password;
}
public String getUnencryptedPassword() {
if (password != null && encryption != null) {
return encryption.decrypt(password);
}
@ -121,21 +126,13 @@ public class Connection implements ISerializableObject, Serializable {
@XmlEnum
public enum Encryption {
// will have a map of these eventually
CLEAR(Encryption.CLEAR_VALUE);
CLEAR;
private static final String CLEAR_VALUE = "CLEAR";
private final String displayString;
private Encryption(String displayString) {
this.displayString = displayString;
}
// clear text for now so nothing happens here
public String decrypt(String password) {
return password;
}
}
public Encryption getEncryption() {

View file

@ -24,6 +24,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
* ------------ ---------- ----------- --------------------------
* May 12, 2013 753 dhladky created.
* May 31, 2013 1763 dhladky refined.
* Jun 17, 2013 2106 djohnson Use getUnencryptedPassword().
*
* </pre>
*
@ -54,7 +55,7 @@ public class WfsConnectionUtil {
http.setCredentials(uri.getHost(), uri.getPort(),
provider.getName(), conn.getUserName(),
conn.getPassword());
conn.getUnencryptedPassword());
}
get.setURI(uri);

View file

@ -53,6 +53,7 @@ import com.raytheon.uf.common.util.ProxiedJettyServer;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jun 11, 2013 1763 dhladky Initial creation
* Jun 17, 2013 2106 djohnson Use unencrypted password getter.
*
* </pre>
*
@ -101,7 +102,6 @@ public class HttpProxiedClientValidCredentialsTest {
@Test
public void testHttpsConnectionWithValidCredentials() {
int expectedCode = 200;
int actualCode = 200;
String xmlResponse;
HttpClient http = null;
@ -146,12 +146,13 @@ public class HttpProxiedClientValidCredentialsTest {
if (conn1 != null && conn1.getUserName() != null
&& conn1.getPassword() != null) {
final String unencryptedPassword = conn1.getUnencryptedPassword();
http.setCredentials(uri.getHost(), uri.getPort(),
provider.getName(), conn1.getUserName(),
conn1.getPassword());
unencryptedPassword);
System.out.println("Credentials set! " + conn1.getUserName()
+ " " + conn1.getPassword());
+ " " + unencryptedPassword);
}
get.setURI(uri);
@ -160,10 +161,9 @@ public class HttpProxiedClientValidCredentialsTest {
xmlResponse = new String(response.data);
System.out.println(xmlResponse);
assertEquals(expectedCode, response.code);
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
assertEquals(expectedCode, actualCode);
}
}

View file

@ -19,6 +19,8 @@
**/
package com.raytheon.uf.common.comm;
import org.junit.Ignore;
/**
* Http constants
*
@ -28,22 +30,19 @@ package com.raytheon.uf.common.comm;
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* June 11, 2013 1763 dhladky Initial creation
* Jun 11, 2013 1763 dhladky Initial creation
* Jun 17, 2013 2106 djohnson Use username/password from HttpTestConstants.
*
* </pre>
*
* @author dhladky
* @version 1.0
*/
public class HttpProxyTestConstants {
@Ignore
public class HttpProxyTestConstants extends HttpTestConstants {
public static final int HTTPS_PORT = 8888;
public static final String USERNAME = "user";
public static final String PASSWD = "password";
public static final String REALM = "MADISOGC";
public static final String CONTEXT = "wfs";

View file

@ -19,6 +19,8 @@
**/
package com.raytheon.uf.common.comm;
import org.junit.Ignore;
/**
* Test implementation.
*
@ -35,7 +37,7 @@ package com.raytheon.uf.common.comm;
* @author mpduff
* @version 1.0
*/
@Ignore
public class TestProxyHttpsConfiguration implements IHttpsConfiguration {
/*

View file

@ -19,6 +19,8 @@
**/
package com.raytheon.uf.common.comm;
import org.junit.Ignore;
/**
* Test Https credentials handler. Returns valid credentials for HttpClient Test
* Cases.
@ -36,7 +38,7 @@ package com.raytheon.uf.common.comm;
* @author mpduff
* @version 1.0
*/
@Ignore
public class TestHttpsCredentialsHandler implements IHttpsCredentialsHandler {
@Override

View file

@ -41,7 +41,7 @@ public class TestProxyHttpsCredentialsHandler implements IHttpsCredentialsHandle
@Override
public String[] getCredentials(String message) {
return new String[] { HttpProxyTestConstants.USERNAME,
HttpProxyTestConstants.PASSWD };
return new String[] { HttpTestConstants.USERNAME,
HttpTestConstants.PASSWD };
}
}