Skip to content
This repository was archived by the owner on Dec 12, 2018. It is now read-only.

Commit 2e51a57

Browse files
committed
AM-3581 - fix based on review comments
1 parent 7163d93 commit 2e51a57

9 files changed

Lines changed: 48 additions & 38 deletions

File tree

api/src/main/java/com/stormpath/sdk/provider/social/SocialUserInfoMappingRules.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015 Stormpath, Inc.
2+
* Copyright 2016 Stormpath, Inc.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,51 @@
11
package com.stormpath.sdk.provider.social;
22

3-
import com.stormpath.sdk.saml.AttributeStatementMappingRules;
4-
53
import java.util.Set;
64

75
/**
8-
* A rule that indicates how a SAML Attribute Statement should populate one or more Stormpath Account field values. By
9-
* creating rules, you configure which SAML Attribute values should be copied to Stormpath Account field values.
10-
* <p>{@code AttributeStatementMappingRule}s are immutable. If you want to change the mapping rules for Accounts in a
11-
* particular SAML Directory, you must remove and add new {@code AttributeStatementMappingRule} instances to the
12-
* Directory Provider's {@link AttributeStatementMappingRules} instance.
6+
* A rule that indicates how a userInfo attribute from a Social Provider should populate one or more Stormpath Account field values. By
7+
* creating rules, you configure which userInfo attribute values from the Social Provider should be copied to Stormpath Account field values.
8+
* <p>{@code UserInfoMappingRule}s are immutable. If you want to change the mapping rules for Accounts in a
9+
* particular Social Directory, you must remove and add new {@code UserInfoMappingRule} instances to the
10+
* Directory Provider's {@link UserInfoMappingRules} instance.
1311
*
1412
* <h4>How does it work?</h4>
15-
* <p>Each {@code AttributeStatementMappingRule} has a {@code name} and a collection of Stormpath account
13+
* <p>Each {@code UserInfoMappingRule} has a {@code name} and a collection of Stormpath account
1614
* {@link #getAccountAttributes() attribute names}.</p>
17-
* <p>When a SAML Attribute Statement is encountered, every SAML Attribute with a matching name will have its value
18-
* copied to the corresponding specified Stormpath account fields.</p>
15+
* <p>When a userInfo attribute from a Social Provider is encountered, every userInfo attribute from the Social Provider
16+
* with a matching name will have its value copied to the corresponding specified Stormpath account fields.</p>
1917
*
2018
* <h5>Example</h5>
2119
* <p>For example, assume that a mapping rule's {@code name} is {@code foo}, and the rule's
2220
* {@link #getAccountAttributes() accountAttributes} collection contains the Stormpath Account field names
2321
* of {@code givenName} and {@code surname}.</p>
24-
* <p>If an Attribute Statement named {@code foo} is encountered on login to have a value of {@code bar}, then
22+
* <p>If a userInfo attribute named {@code foo} is encountered on login to have a value of {@code bar}, then
2523
* {@code bar} will automatically be copied to the specified Stormpath Account fields for that user. This user would
2624
* then automatically have a {@code givenName} of {@code bar} and a {@code surname} of {@code bar}.</p>
2725
*
28-
* @since 1.0.RC8
26+
* @since 1.3.0
2927
*/
3028
public interface UserInfoMappingRule {
3129

3230
/**
33-
* Returns the SAML Attribute name, that when encountered, should have its value applied as Account field values.
34-
* When this name is encountered when processing a SAML Attribute Statement, its associated value will be set as the
35-
* value for all Stormpath Account field names specified in the
31+
* Returns the UserInfo attribute name for a Social Provider, that when encountered, should have its value applied
32+
* as Account field values.
33+
* When this name is encountered when processing UserInfo from a Social Provider, its associated value will be set
34+
* as the value for all Stormpath Account field names specified in the
3635
* {@link #getAccountAttributes() accountAttributes} collection.
3736
*
38-
* @return SAML Attribute name, that when encountered, should have its value set on the
37+
* @return UserInfo attribute name, that when encountered, should have its value set on the
3938
* {@link #getAccountAttributes() specified} Account fields.
4039
*/
4140
String getName();
4241

4342
/**
4443
* Returns the Stormpath account fields that should be updated when encountering {@link #getName() named}
45-
* SAML Attribute name. If discovered, that SAML Attribute value will be set on all of the Stormpath account
44+
* UserInfo attribute name. If discovered, that UserInfo attribute value will be set on all of the Stormpath account
4645
* fields named in this collection.
4746
*
4847
* @return the Stormpath account fields that should be updated when encountering {@link #getName() named}
49-
* SAML Attribute name.
48+
* UserInfo attribute name.
5049
*/
5150
Set<String> getAccountAttributes();
5251
}

api/src/main/java/com/stormpath/sdk/provider/social/UserInfoMappingRuleBuilder.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015 Stormpath, Inc.
2+
* Copyright 2016 Stormpath, Inc.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -33,18 +33,18 @@
3333
public interface UserInfoMappingRuleBuilder {
3434

3535
/**
36-
* Sets the SAML Attribute name, that when encountered, should have its value applied as Account field values.
37-
* When this name is encountered when processing a SAML Attribute Statement, its associated value will be set as the
36+
* Sets the UserInfo attribute name, that when encountered, should have its value applied as Account field values.
37+
* When this name is encountered when processing UserInfo from a Social Provider, its associated value will be set as the
3838
* value for all Stormpath Account field names specified in the
3939
* {@link UserInfoMappingRule#getAccountAttributes() accountAttributes} collection.
4040
*
41-
* @param name the SAML Attribute name that when encountered, should have its value applied as Account field values.
41+
* @param name the UserInfo attribute name that when encountered, should have its value applied as Account field values.
4242
*/
4343
UserInfoMappingRuleBuilder setName(String name);
4444

4545
/**
4646
* Sets the Stormpath account fields that should be updated when encountering {@link UserInfoMappingRule#getName() named}
47-
* field from the userInfo provided by the social provider. If discovered, that SAML Attribute value will be set on
47+
* field from the userInfo provided by the social provider. If discovered, that UserInfo attribute value will be set on
4848
* all of the Stormpath account fields named in this collection.
4949
*
5050
* @param accountAttributes the account fields that should be updated when there's a match with a field name in userInfo
@@ -54,7 +54,7 @@ public interface UserInfoMappingRuleBuilder {
5454

5555
/**
5656
* Sets the Stormpath account fields that should be updated when encountering {@link UserInfoMappingRule#getName() named}
57-
* field from the userInfo provided by the social provider. If discovered, that SAML Attribute value will be set on
57+
* field from the userInfo provided by the social provider. If discovered, that UserInfo attribute value will be set on
5858
* all of the Stormpath account fields named in this collection.
5959
*
6060
* @param accountAttributes the account fields that should be updated when there's a match with a field name in userInfo

api/src/main/java/com/stormpath/sdk/provider/social/UserInfoMappingRules.java

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,34 @@
77

88
import java.util.List;
99

10+
/**
11+
* A collection of rules that indicates how a userInfo attribute from a Social Provider should populate one or more
12+
* Stormpath Account field values.
13+
* By creating rules, you configure which userInfo attribute values from the Social Provider should be copied to the
14+
* Stormpath Account field values.
15+
*
16+
* <p> Also see {@link UserInfoMappingRule} </p>
17+
*
18+
* @since 1.3.0
19+
*/
1020
public interface UserInfoMappingRules extends Resource, Saveable, Auditable {
1121

1222
/**
13-
* Specifies the Set of all {@link UserInfoMappingRule}s that indicate how SAML Attribute Statements should
14-
* populate one or more Stormpath Account field values after a successful SAML login.
23+
* Specifies the Set of all {@link UserInfoMappingRule}s that indicate how UserInfo attribute should
24+
* populate one or more Stormpath Account field values after a successful Social (provider) login.
1525
*
1626
* @param userInfoMappingRules the set of {@link UserInfoMappingRule userInfoMappingRules}s to build a Social provider.
1727
*
1828
* @return this instance for method chaining.
19-
* @since 1.3.0
2029
*/
2130
void setItems(List<UserInfoMappingRule> userInfoMappingRules);
2231

2332
/**
24-
* Returns the Set of all {@link UserInfoMappingRule}s that indicate how SAML Attribute Statements should
25-
* populate one or more Stormpath Account field values after a successful SAML login.
33+
* Returns the Set of all {@link UserInfoMappingRule}s that indicate how UserInfo attribute should
34+
* populate one or more Stormpath Account field values after a successful Social (provider) login.
2635
*
27-
* @return the Set of all {@link UserInfoMappingRule}s that indicate how SAML Attribute Statements should
28-
* populate one or more Stormpath Account field values after a successful SAML login.
29-
* @since 1.3.0
36+
* @return the Set of all {@link UserInfoMappingRule}s that indicate how UserInfo attribute should
37+
* populate one or more Stormpath Account field values after a successful Social (provider) login.
3038
*/
3139
List<UserInfoMappingRule> getItems();
3240
}

extensions/httpclient/src/test/groovy/com/stormpath/sdk/client/DirectoryIT.groovy

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ import org.testng.annotations.Test
4444
import java.lang.reflect.Field
4545
import java.util.concurrent.TimeUnit
4646

47-
import static org.testng.Assert.*
47+
import static org.testng.Assert.assertNull
48+
import static org.testng.Assert.assertTrue
49+
import static org.testng.Assert.fail
50+
4851
/**
4952
*
5053
* @since 0.8.1

impl/src/main/java/com/stormpath/sdk/impl/provider/DefaultFacebookCreateProviderRequestBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ protected CreateProviderRequest doBuild(Map<String, Object> map) {
3535
DefaultFacebookProvider provider = new DefaultFacebookProvider(null, map);
3636
provider.setClientId(super.clientId);
3737
provider.setClientSecret(super.clientSecret);
38-
if(super.userInfoMappingRules != null) {
38+
if (super.userInfoMappingRules != null) {
3939
provider.setUserInfoMappingRules(super.userInfoMappingRules);
4040
}
4141

impl/src/main/java/com/stormpath/sdk/impl/provider/DefaultGithubCreateProviderRequestBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ protected CreateProviderRequest doBuild(Map<String, Object> map) {
3535
DefaultGithubProvider provider = new DefaultGithubProvider(null, map);
3636
provider.setClientId(super.clientId);
3737
provider.setClientSecret(super.clientSecret);
38-
if(super.userInfoMappingRules != null) {
38+
if (super.userInfoMappingRules != null) {
3939
provider.setUserInfoMappingRules(super.userInfoMappingRules);
4040
}
4141
return new DefaultCreateProviderRequest(provider);

impl/src/main/java/com/stormpath/sdk/impl/provider/DefaultGoogleCreateProviderRequestBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ protected CreateProviderRequest doBuild(Map<String, Object> map) {
4848
provider.setClientId(super.clientId);
4949
provider.setClientSecret(super.clientSecret);
5050
provider.setRedirectUri(this.redirectUri);
51-
if(super.userInfoMappingRules != null) {
51+
if (super.userInfoMappingRules != null) {
5252
provider.setUserInfoMappingRules(super.userInfoMappingRules);
5353
}
5454
return new DefaultCreateProviderRequest(provider);

impl/src/main/java/com/stormpath/sdk/impl/provider/DefaultLinkedInCreateProviderRequestBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ protected CreateProviderRequest doBuild(Map<String, Object> map) {
4949
provider.setRedirectUri(redirectUri);
5050
}
5151

52-
if(super.userInfoMappingRules != null) {
52+
if (super.userInfoMappingRules != null) {
5353
provider.setUserInfoMappingRules(super.userInfoMappingRules);
5454
}
5555
return new DefaultCreateProviderRequest(provider);

0 commit comments

Comments
 (0)