Skip to content

Commit

Permalink
Fix for identity-3171 to populate AttributeServiceIndex correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
ChamaraPhilipsuom committed Jul 6, 2015
1 parent 38eeb8a commit 1bab7a5
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public boolean addRelyingPartyServiceProvider(SAMLSSOServiceProviderDTO serviceP
serviceProviderDO.setDoSignResponse(serviceProviderDTO.isDoSignResponse());
serviceProviderDO.setDoSignAssertions(serviceProviderDTO.isDoSignAssertions());
serviceProviderDO.setNameIdClaimUri(serviceProviderDTO.getNameIdClaimUri());
serviceProviderDO.setEnableAttributesByDefault(serviceProviderDTO.isEnableAttributesByDefault());


if (serviceProviderDTO.getNameIDFormat() == null) {
serviceProviderDTO.setNameIDFormat(NameIdentifier.EMAIL);
Expand All @@ -96,8 +96,13 @@ public boolean addRelyingPartyServiceProvider(SAMLSSOServiceProviderDTO serviceP
} else {
serviceProviderDO.setAttributeConsumingServiceIndex(Integer.toString(IdentityUtil.getRandomInteger()));
}
serviceProviderDO.setEnableAttributesByDefault(serviceProviderDTO.isEnableAttributesByDefault());
} else {
serviceProviderDO.setAttributeConsumingServiceIndex("");
if (serviceProviderDO.isEnableAttributesByDefault()) {
log.warn("Enable Attribute Profile must be selected to activate it by default. EnableAttributesByDefault will be disabled.");
}
serviceProviderDO.setEnableAttributesByDefault(false);
}

if (serviceProviderDTO.getRequestedAudiences() != null && serviceProviderDTO.getRequestedAudiences().length != 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,6 @@ public SAMLSSORespDTO process(SAMLSSOAuthnReqDTO authnReqDTO, String sessionId,
SAMLSSOConstants.StatusCodes.REQUESTOR_ERROR, msg);
}

if (serviceProviderConfigs.isEnableAttributesByDefault() && serviceProviderConfigs.getAttributeConsumingServiceIndex() != null) {
authnReqDTO.setAttributeConsumingServiceIndex(Integer
.parseInt(serviceProviderConfigs
.getAttributeConsumingServiceIndex()));
}

// reading the service provider configs
populateServiceProviderConfigs(serviceProviderConfigs, authnReqDTO);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,7 @@ public static boolean validateXMLSignature(RequestAbstractType request, String a
throw new IdentityException("Illegal access to class: "
+ IdentityUtil.getProperty("SSOService.SAMLSSOSigner"), e);
} catch (Exception e) {
if(log.isDebugEnabled()){
if (log.isDebugEnabled()) {
log.debug("Error while validating XML signature.", e);
}
}
Expand Down Expand Up @@ -930,25 +930,35 @@ public static Map<String, String> getAttributes(SAMLSSOAuthnReqDTO authnReqDTO)
} catch (IdentityException e) {
request = (AuthnRequestImpl) SAMLSSOUtil.unmarshall(SAMLSSOUtil
.decodeForPost(authnReqDTO.getRequestMessageString()));
if(log.isDebugEnabled()){
if (log.isDebugEnabled()) {
log.debug("Error while decoding authentication request.", e);
}
}

if (request.getAttributeConsumingServiceIndex() == null) {
if (authnReqDTO.getAttributeConsumingServiceIndex() != 0) {
index = authnReqDTO.getAttributeConsumingServiceIndex();
spDO.setAttributeConsumingServiceIndex(String.valueOf(index));
//SP has not provide a AttributeConsumingServiceIndex in the authnReqDTO
if (StringUtils.isNotBlank(spDO.getAttributeConsumingServiceIndex())) {
if (spDO.isEnableAttributesByDefault()) {
index = Integer.parseInt(spDO.getAttributeConsumingServiceIndex());
} else {
return null;
}
} else {
return null; // not requesting for attributes
return null;
}
} else {
//SP has provide a AttributeConsumingServiceIndex in the authnReqDTO
index = request.getAttributeConsumingServiceIndex();
}
} else {
index = authnReqDTO.getAttributeConsumingServiceIndex();
if (index != 0) {
spDO.setAttributeConsumingServiceIndex(String.valueOf(index));
if (StringUtils.isNotBlank(spDO.getAttributeConsumingServiceIndex())) {
if (spDO.isEnableAttributesByDefault()) {
index = Integer.parseInt(spDO.getAttributeConsumingServiceIndex());
} else {
return null;
}
} else {
return null;
}

}
Expand Down Expand Up @@ -1134,7 +1144,7 @@ private static String normalizeUrlEncoding(String text) {
normalized.append(percentCode);
} catch (UnsupportedEncodingException e) {
normalized.append(percentCode);
if(log.isDebugEnabled()){
if (log.isDebugEnabled()) {
log.debug("Unsupported Encoding exception while decoding percent code.", e);
}
}
Expand Down

0 comments on commit 1bab7a5

Please sign in to comment.