Skip to content

Commit 5ff3f3f

Browse files
author
Joerg Huber
committed
Various changes due to refactoring of Authentication Approach.
1 parent 561e967 commit 5ff3f3f

5 files changed

Lines changed: 67 additions & 43 deletions

File tree

SIF3InfraREST/sif3InfraCommon/src/main/java/sif3/infra/common/env/mgr/DirectProviderEnvironmentManager.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,9 @@ public boolean removeEnvironmentBySessionToken(String sessionToken, boolean perm
422422
@Override
423423
public String toString()
424424
{
425-
return "DirectProviderEnvironmentManager [sessions=" + this.sessions + "]";
425+
return "DirectProviderEnvironmentManager [adapterFileNameWithoutExt="
426+
+ adapterFileNameWithoutExt + ", sessions=" + sessions
427+
+ ", secTokenSession=" + secTokenSession + "]";
426428
}
427429

428430
/*---------------------*/

SIF3InfraREST/sif3InfraCommon/src/main/java/sif3/infra/common/env/ops/DirectProviderEnvStoreOps.java

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,26 @@
2121
import java.util.Date;
2222
import java.util.List;
2323

24+
import au.com.systemic.framework.utils.StringUtils;
2425
import sif3.common.CommonConstants;
2526
import sif3.common.CommonConstants.AdapterType;
2627
import sif3.common.exception.PersistenceException;
2728
import sif3.common.model.EnvironmentKey;
28-
import sif3.common.model.AuthenticationInfo.AuthenticationMethod;
29+
import sif3.common.model.security.InternalSecurityServiceConstants;
2930
import sif3.common.model.security.TokenInfo;
3031
import sif3.common.persist.model.AppEnvironmentTemplate;
32+
import sif3.common.persist.model.ExternalSecurityService;
3133
import sif3.common.persist.model.SIF3Session;
3234
import sif3.common.persist.service.AppEnvironmentService;
3335
import sif3.common.persist.service.SIF3SessionService;
36+
import sif3.common.security.SecurityServiceFactory;
3437
import sif3.common.utils.UUIDGenerator;
3538
import sif3.infra.common.env.types.ConsumerEnvironment;
3639
import sif3.infra.common.env.types.ProviderEnvironment;
3740
import sif3.infra.common.model.EnvironmentType;
3841
import sif3.infra.common.model.EnvironmentTypeType;
3942
import sif3.infra.common.model.InfrastructureServiceType;
4043
import sif3.infra.common.model.InfrastructureServicesType;
41-
import au.com.systemic.framework.utils.StringUtils;
4244

4345
/**
4446
* This class implements operations required by a direct environment provider. They are quite distinct and therefore warrant having its own
@@ -420,11 +422,11 @@ public SIF3Session createSession(EnvironmentType inputEnv, TokenInfo tokenInfo,
420422
// Maybe the authentication method has changed, too.
421423
if (StringUtils.notEmpty(appEnvTemplate.getAuthMethod()))
422424
{
423-
environment.setAuthenticationMethod(appEnvTemplate.getAuthMethod());
425+
environment.setAuthenticationMethod(getAuthXMLValue(appEnvTemplate.getAuthMethod()));
424426
}
425427
else if (StringUtils.isEmpty(environment.getAuthenticationMethod())) // if empty in env.xml set to Basic
426428
{
427-
environment.setAuthenticationMethod(AuthenticationMethod.Basic.name());
429+
environment.setAuthenticationMethod(InternalSecurityServiceConstants.BASIC_GENERIC_SECURITY.getXmlValue());
428430
}
429431

430432
// Set Authentication Method is sif3 Session.
@@ -525,11 +527,11 @@ private void updateSessionInfo(SIF3Session sif3Session, ProviderEnvironment envI
525527
// Maybe the authentication method has changed, too.
526528
if (StringUtils.notEmpty(appEnvTemplate.getAuthMethod()))
527529
{
528-
environment.setAuthenticationMethod(appEnvTemplate.getAuthMethod());
530+
environment.setAuthenticationMethod(getAuthXMLValue(appEnvTemplate.getAuthMethod()));
529531
}
530532
else // assume Basic
531533
{
532-
environment.setAuthenticationMethod(AuthenticationMethod.Basic.name());
534+
environment.setAuthenticationMethod(InternalSecurityServiceConstants.BASIC_GENERIC_SECURITY.getXmlValue());
533535
}
534536

535537
// Set authentication method it in the session.
@@ -636,4 +638,24 @@ private void reloadServiceInfo(EnvironmentType environment, EnvironmentType temp
636638
{
637639
environment.setProvisionedZones(templEnv.getProvisionedZones());
638640
}
641+
642+
private String getAuthXMLValue(String authMethod)
643+
{
644+
if (StringUtils.notEmpty(authMethod))
645+
{
646+
ExternalSecurityService securityService = SecurityServiceFactory.getSecurityService(authMethod, CommonConstants.AdapterType.ENVIRONMENT_PROVIDER);
647+
if (securityService != null)
648+
{
649+
return securityService.getXmlValue();
650+
}
651+
else // default to Basic
652+
{
653+
return InternalSecurityServiceConstants.BASIC_GENERIC_SECURITY.getXmlValue();
654+
}
655+
}
656+
else // assume Basic
657+
{
658+
return InternalSecurityServiceConstants.BASIC_GENERIC_SECURITY.getXmlValue();
659+
}
660+
}
639661
}

SIF3InfraREST/sif3InfraCommon/src/main/java/sif3/infra/common/env/types/AdapterEnvironmentStore.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@
3131
import au.com.systemic.framework.utils.StringUtils;
3232
import sif3.common.CommonConstants;
3333
import sif3.common.CommonConstants.AdapterType;
34+
import sif3.common.CommonConstants.AuthenticationType;
3435
import sif3.common.CommonConstants.QueuePollingType;
3536
import sif3.common.CommonConstants.QueueStrategy;
3637
import sif3.common.header.HeaderProperties;
3738
import sif3.common.header.HeaderValues.UpdateType;
38-
import sif3.common.model.AuthenticationInfo.AuthenticationMethod;
3939
import sif3.common.utils.FileAndFolderUtils;
4040
import sif3.infra.common.env.types.EnvironmentInfo.EnvironmentType;
4141

@@ -423,7 +423,7 @@ private boolean loadConsumerInfo(AdvancedProperties props, ConsumerEnvironment e
423423
}
424424

425425
// Authentication Method
426-
envInfo.setAuthMethod(adapterProperties.getPropertyAsString("env.authentication.method", AuthenticationMethod.Basic.name()));
426+
envInfo.setAuthMethod(adapterProperties.getPropertyAsString("env.authentication.method", AuthenticationType.Basic.name()));
427427

428428
envInfo.getEnvironmentKey().setUserToken(props.getPropertyAsString("env.userToken", null));
429429
envInfo.getEnvironmentKey().setInstanceID(props.getPropertyAsString("env.instanceID", null));
@@ -486,7 +486,7 @@ private boolean loadProviderInfo(AdvancedProperties props, ProviderEnvironment e
486486
}
487487

488488
// Authentication Method
489-
envInfo.setAuthMethod(adapterProperties.getPropertyAsString("env.authentication.method", AuthenticationMethod.Basic.name()));
489+
envInfo.setAuthMethod(adapterProperties.getPropertyAsString("env.authentication.method", AuthenticationType.Basic.name()));
490490

491491
envInfo.setTemplateXMLFileName(props.getPropertyAsString("env.xml.file.name", null));
492492
if (StringUtils.isEmpty(envInfo.getTemplateXMLFileName()))
@@ -544,7 +544,7 @@ private boolean loadProviderInfo(AdvancedProperties props, ProviderEnvironment e
544544
envInfo.setAutoCreateEnvironment(props.getPropertyAsBool("env.allow.autoCreate", false));
545545

546546
// Authentication Method
547-
envInfo.setAccessTokenAuthMethod(adapterProperties.getPropertyAsString("adapter.default.accessToken.authentication.method", AuthenticationMethod.Bearer.name()));
547+
envInfo.setAccessTokenAuthMethod(adapterProperties.getPropertyAsString("adapter.default.accessToken.authentication.method", AuthenticationType.Basic.name()));
548548

549549
// Allow access_token or URL
550550
envInfo.setAllowAuthOnURL(adapterProperties.getPropertyAsBool("adapter.authTokenOnURL.allowed", false));

SIF3InfraREST/sif3InfraCommon/src/main/java/sif3/infra/common/env/types/EnvironmentInfo.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import javax.ws.rs.core.MediaType;
2626

2727
import sif3.common.CommonConstants.AdapterType;
28-
import sif3.common.model.AuthenticationInfo.AuthenticationMethod;
28+
import sif3.common.CommonConstants.AuthenticationType;
2929
import sif3.common.model.EnvironmentKey;
3030
import sif3.infra.common.env.types.ConsumerEnvironment.ConnectorName;
3131

@@ -53,7 +53,7 @@ public enum EnvironmentType {DIRECT, BROKERED};
5353
private AdapterType adapterType = null;
5454
private boolean checkACL = true;
5555
private EnvironmentType environmentType = null;
56-
private AuthenticationMethod authMethod = AuthenticationMethod.Basic;
56+
private String authMethod = AuthenticationType.Basic.name();
5757
private boolean removeEnvOnShutdown = false;
5858
private String adapterName = null; ; // consumerName
5959
private EnvironmentKey environmentKey = new EnvironmentKey();
@@ -197,28 +197,28 @@ public void setCheckACL(boolean checkACL)
197197
this.checkACL = checkACL;
198198
}
199199

200-
public AuthenticationMethod getAuthMethod()
200+
public String getAuthMethod()
201201
{
202202
return this.authMethod;
203203
}
204204

205-
public void setAuthMethod(AuthenticationMethod authMethod)
205+
public void setAuthMethod(String authMethod)
206206
{
207207
this.authMethod = authMethod;
208208
}
209209

210-
// authMethod: Valid values are what is listed in AuthenticationUtils.AuthenticationMethod (case sensitive!!!)
211-
public void setAuthMethod(String authMethod)
212-
{
213-
try
214-
{
215-
this.authMethod = AuthenticationMethod.valueOf(authMethod);
216-
}
217-
catch (Exception ex)
218-
{
219-
this.authMethod = AuthenticationMethod.Basic;
220-
}
221-
}
210+
// // authMethod: Valid values are what is listed in AuthenticationUtils.AuthenticationMethod (case sensitive!!!)
211+
// public void setAuthMethod(String authMethod)
212+
// {
213+
// try
214+
// {
215+
// this.authMethod = AuthenticationMethod.valueOf(authMethod);
216+
// }
217+
// catch (Exception ex)
218+
// {
219+
// this.authMethod = AuthenticationMethod.Basic;
220+
// }
221+
// }
222222

223223
public MediaType getMediaType()
224224
{

SIF3InfraREST/sif3InfraCommon/src/main/java/sif3/infra/common/env/types/ProviderEnvironment.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020

2121
import java.net.URI;
2222

23+
import sif3.common.CommonConstants.AuthenticationType;
2324
import sif3.common.header.HeaderProperties;
2425
import sif3.common.header.HeaderValues.UpdateType;
25-
import sif3.common.model.AuthenticationInfo.AuthenticationMethod;
2626

2727
/**
2828
* This class represents a provider environment. This is a more complex class than a consumer environment as it has to validate a
@@ -42,7 +42,7 @@ public class ProviderEnvironment extends EnvironmentInfo
4242
private boolean eventsSupported = false;
4343
private UpdateType defaultUpdateType = UpdateType.FULL; // Default value for update events.
4444
private boolean autoCreateEnvironment = false;
45-
private AuthenticationMethod accessTokenAuthMethod = AuthenticationMethod.Bearer; // Default Auth Method if accessToken is used.
45+
private String accessTokenAuthMethod = AuthenticationType.Basic.name(); // Default Auth Method if accessToken is used.
4646
private boolean allowAuthOnURL = false;
4747
private HeaderProperties customResponseHeaders = new HeaderProperties();
4848

@@ -158,28 +158,28 @@ public void setAutoCreateEnvironment(boolean autoCreateEnvironment)
158158
this.autoCreateEnvironment = autoCreateEnvironment;
159159
}
160160

161-
public AuthenticationMethod getAccessTokenAuthMethod()
161+
public String getAccessTokenAuthMethod()
162162
{
163163
return accessTokenAuthMethod;
164164
}
165165

166-
public void setAccessTokenAuthMethod(AuthenticationMethod accessTokenAuthMethod)
166+
public void setAccessTokenAuthMethod(String accessTokenAuthMethod)
167167
{
168168
this.accessTokenAuthMethod = accessTokenAuthMethod;
169169
}
170170

171-
// authMethod for accessToken: Valid values are what is listed in AuthenticationUtils.AuthenticationMethod (case sensitive!!!)
172-
public void setAccessTokenAuthMethod(String accessTokenAuthMethod)
173-
{
174-
try
175-
{
176-
this.accessTokenAuthMethod = AuthenticationMethod.valueOf(accessTokenAuthMethod);
177-
}
178-
catch (Exception ex)
179-
{
180-
this.accessTokenAuthMethod = AuthenticationMethod.Bearer;
181-
}
182-
}
171+
// // authMethod for accessToken: Valid values are what is listed in AuthenticationUtils.AuthenticationMethod (case sensitive!!!)
172+
// public void setAccessTokenAuthMethod(String accessTokenAuthMethod)
173+
// {
174+
// try
175+
// {
176+
// this.accessTokenAuthMethod = AuthenticationMethod.valueOf(accessTokenAuthMethod);
177+
// }
178+
// catch (Exception ex)
179+
// {
180+
// this.accessTokenAuthMethod = AuthenticationMethod.Bearer;
181+
// }
182+
// }
183183

184184
public boolean getAllowAuthOnURL()
185185
{

0 commit comments

Comments
 (0)