Skip to content

Commit b8a2c8f

Browse files
sgramponeanaiberta
authored andcommitted
Quality fixes
(cherry picked from commit 762423c)
1 parent 248188c commit b8a2c8f

File tree

5 files changed

+21
-80
lines changed

5 files changed

+21
-80
lines changed

gamsaml/src/main/java/com/genexus/saml/Crypt.java

Lines changed: 0 additions & 14 deletions
This file was deleted.

gamsaml/src/main/java/com/genexus/saml/GXExternalObject.java

Lines changed: 0 additions & 37 deletions
This file was deleted.

gamsaml/src/main/java/com/genexus/saml/GamSamlProperties.java

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@
1111
public class GamSamlProperties {
1212
public static final ILogger logger = LogManager.getLogger(GamSamlProperties.class);
1313
private static GamSamlProperties instance = null;
14-
private Properties generalPropsProperties = null;
15-
private Properties attPropsProperties = null;
14+
private Properties generalProperties;
15+
private Properties attPropsProperties;
1616
private static String state = "";
1717

1818
private GamSamlProperties() {
19+
generalProperties = null;
20+
attPropsProperties = null;
1921
}
2022

2123
public static GamSamlProperties getInstance() {
@@ -26,32 +28,23 @@ public static GamSamlProperties getInstance() {
2628
}
2729

2830
public void init(String instate) {
29-
logger.debug("[init] - state = " + instate);
30-
generalPropsProperties = null;
31-
if (instate == null || instate.isEmpty()) {
32-
logger.debug("[init] - state state == null or empty");
33-
state = "";
34-
logger.debug("[init] sale if ");
35-
36-
} else {
31+
if (!(instate == null || instate.isEmpty())) {
3732
state = instate;
3833
logger.debug("[init] - state != null");
39-
// if state is there inicialize from GAM
4034
try {
41-
generalPropsProperties = loadPropsFromGAM(instate);
35+
generalProperties = load(instate);
4236
} catch (Exception e) {
4337
logger.error("[init] ", e);
4438
}
4539
}
4640
}
4741

48-
public void updatePropsFromGAM(String state) {
49-
logger.debug("[init] - updatePropsFromGAM = " + state);
50-
generalPropsProperties = null;
42+
43+
public void update(String state) {
5144
try {
52-
generalPropsProperties = loadPropsFromGAM(state);
45+
generalProperties = load(state);
5346
} catch (Exception e) {
54-
logger.error("[] updatePropsFromGAM " , e);
47+
logger.error("update " , e);
5548
}
5649
}
5750

@@ -121,7 +114,7 @@ public static String getKeyStPathCredential() {
121114
public static String getKeyStPwdCredential() {
122115
String cryptPass = GamSamlProperties.getInstance().getGeneralProperty(
123116
"KeyStPwdCredential");
124-
String ret = Crypt.Decrypt(cryptPass);
117+
String ret = com.genexus.util.Encryption.decrypt64(cryptPass, getKeyCrypt());
125118
logger.debug("[getKeyStPwdCredential] " + "Gets getKeyStPwdCredential: " + ret);
126119

127120
return ret;
@@ -152,7 +145,8 @@ public static String getKeyStPathTrustSt() {
152145
public static String getKeyStPwdTrustSt() {
153146
String cryptPass = GamSamlProperties.getInstance().getGeneralProperty(
154147
"KeyStorePwdTrustCred");
155-
String ret = Crypt.Decrypt(cryptPass);
148+
//String ret = Crypt.Decrypt(cryptPass);
149+
String ret = com.genexus.util.Encryption.decrypt64(cryptPass, getKeyCrypt());
156150
logger.debug("[getKeyStPwdTrustSt] " + "Gets KeyStorePwdTrustCred: " + cryptPass);
157151
return ret;
158152
}
@@ -177,7 +171,7 @@ public static String getKeyStorePwdTrustCred() {
177171
String cryptPass = GamSamlProperties.getInstance().getGeneralProperty(
178172
"KeyStorePwdTrustCred");
179173
logger.debug("[getKeyStorePwdTrustCred] " + "cryptPass: " + cryptPass);
180-
String ret = Crypt.Decrypt(cryptPass);
174+
String ret = com.genexus.util.Encryption.decrypt64(cryptPass, getKeyCrypt());
181175
logger.debug("[getKeyStorePwdTrustCred] " + "Gets KeyStorePwdTrustCred: " + ret);
182176
return ret;
183177
}
@@ -213,10 +207,8 @@ public static String getPathCancelServletSSO() {
213207

214208
public static String getCriteriaKey() {
215209
String cryptPass = GamSamlProperties.getInstance().getGeneralProperty("CriteriaKey");
216-
217-
String ret = Crypt.Decrypt(cryptPass);
210+
String ret = com.genexus.util.Encryption.decrypt64(cryptPass, getKeyCrypt());
218211
logger.debug("[getCriteriaKey] " + "Gets getCriteriaKey: " + ret);
219-
220212
return ret;
221213
}
222214

@@ -300,7 +292,7 @@ public static String getState() {
300292
}
301293

302294
private String getGeneralProperty(String prop) {
303-
return getPropertyValue(generalPropsProperties, prop);
295+
return getPropertyValue(generalProperties, prop);
304296
}
305297

306298
private String getAttProperty(String prop) {
@@ -315,7 +307,7 @@ public String getPropertyValue(Properties config, String prop) {
315307
}
316308
}
317309

318-
public Properties loadPropsFromGAM(String state) throws Exception {
310+
public Properties load(String state) throws Exception {
319311
logger.debug("[loadPropsFromGAM] start");
320312
Properties config = new Properties();
321313
String[] resultString = new String[1];
@@ -337,10 +329,10 @@ public Properties loadPropsFromGAM(String state) throws Exception {
337329
return config;
338330
}
339331

340-
public void saveConfigFile(String result) throws Exception {
332+
public void saveConfig(String result) throws Exception {
341333
Properties config = new Properties();
342334
config.load(new StringReader(result));
343-
generalPropsProperties = config;
335+
generalProperties = config;
344336
logger.debug("[saveConfigFile] config: " + config.toString());
345337
}
346338
}

gamsaml/src/main/java/com/genexus/saml/SamlReceiver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public Assertion getSAMLAssertion(String responseMessage) throws GamSamlExceptio
6868
String result = resultString[0].trim();
6969
logger.debug("[getSAMLAssertion] result: " + result);
7070
try {
71-
GamSamlProperties.getInstance().saveConfigFile(result);
71+
GamSamlProperties.getInstance().saveConfig(result);
7272
} catch (Exception e) {
7373
logger.error("[getSAMLAssertion] ", e);
7474
}

gamsaml/src/main/java/com/genexus/saml/servlet/Logout.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public void doPost(HttpServletRequest request, HttpServletResponse response) thr
123123
NameID nameId = req.getNameID();
124124
String externalToken = nameId.getFormat() + "," + nameId.getValue()+"::" + sessionIndex;;
125125
stateParm = "Token="+ externalToken;
126-
props.updatePropsFromGAM(stateParm);
126+
props.update(stateParm);
127127

128128
boolean isValid = receiver.validateSignature(req);
129129

0 commit comments

Comments
 (0)