Skip to content

Commit

Permalink
adds builders for Policy and its types, PolicyRule and types, GroupRu…
Browse files Browse the repository at this point in the history
…le. Edited IT to use these builders. (#355)

* adds builders for Policy and PasswordPolicy.

* adds builders for Policy and PasswordPolicy.

* adds builders for Policy and PasswordPolicy.

* Allow for PolicyBuilder to be extendable

* Correcting year in the License and changes to fix CI job failures

* Correcting year in the License and changes to fix CI job failures

* adds builders for Policy and PasswordPolicy.

* adds builders for Policy and PasswordPolicy.

* Allow for PolicyBuilder to be extendable

* Correcting year in the License and changes to fix CI job failures

* Added builders for OktaSignOnPolicy, PolicyRules, GroupRule, edited IT to use these builders

* Minor edits to fix CI job failure

* Minor edits to fix CI job failure

* Correcting License header.

* Correcting License header.

* Update integration-tests/src/test/groovy/com/okta/sdk/tests/it/ApplicationsIT.groovy

Co-authored-by: Brian Demers <brian.demers@gmail.com>

Co-authored-by: Jeyadev Asokan <jeyadev_asokan@baxter.com>
Co-authored-by: Brian Demers <bdemers@apache.org>
Co-authored-by: Arvind Krishnakumar <61501885+arvindkrishnakumar-okta@users.noreply.github.com>
Co-authored-by: Brian Demers <brian.demers@gmail.com>
  • Loading branch information
5 people authored Jun 30, 2020
1 parent 4e3c3bc commit 83edb78
Show file tree
Hide file tree
Showing 27 changed files with 2,305 additions and 254 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright 2020-Present Okta, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.okta.sdk.resource.group.rule;

import com.okta.commons.lang.Classes;
import com.okta.sdk.client.Client;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public interface GroupRuleBuilder {

static GroupRuleBuilder instance(){ return Classes.newInstance("com.okta.sdk.impl.resource.DefaultGroupRuleBuilder");}

GroupRuleBuilder setName(String name);

GroupRuleBuilder setType(String type);

GroupRuleBuilder setAllGroupsValid(Boolean allGroupsValid);

GroupRuleBuilder setAssignUserToGroups(List<String> assignUserToGroups);

default GroupRuleBuilder setGroups(String... groupIds) {
return setGroups(Arrays.stream(groupIds).collect(Collectors.toList()));
}

GroupRuleBuilder setGroups(List<String> groupIds);

GroupRuleBuilder addGroup(String groupId);

default GroupRuleBuilder setUsers(String... userIds) {
return setUsers(Arrays.stream(userIds).collect(Collectors.toList()));
}

GroupRuleBuilder setUsers(List<String> userIds);

GroupRuleBuilder addUser(String userId);

GroupRuleBuilder setGroupRuleExpressionType(String groupRuleExpressionType);

GroupRuleBuilder setGroupRuleExpressionValue(String groupRuleExpressionValue);

GroupRule buildAndCreate(Client client);


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright 2020-Present Okta, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.okta.sdk.resource.policy;

import com.okta.commons.lang.Classes;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public interface OktaSignOnPolicyBuilder extends PolicyBuilder<OktaSignOnPolicyBuilder> {

static OktaSignOnPolicyBuilder instance() {
return Classes.newInstance("com.okta.sdk.impl.resource.DefaultOktaSignOnPolicyBuilder");
}

default OktaSignOnPolicyBuilder setGroups(String... groupIds) {
return setGroups(Arrays.stream(groupIds).collect(Collectors.toList()));
}

OktaSignOnPolicyBuilder setGroups(List<String> groupIds);

OktaSignOnPolicyBuilder addGroup(String groupId);

default OktaSignOnPolicyBuilder setUsers(String... userIds) {
return setGroups(Arrays.stream(userIds).collect(Collectors.toList()));
}

OktaSignOnPolicyBuilder setUsers(List<String> userIds);

OktaSignOnPolicyBuilder addUser(String userId);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
* Copyright 2020-Present Okta, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.okta.sdk.resource.policy;

import com.okta.commons.lang.Classes;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public interface PasswordPolicyBuilder extends PolicyBuilder<PasswordPolicyBuilder> {

static PasswordPolicyBuilder instance() {
return Classes.newInstance("com.okta.sdk.impl.resource.DefaultPasswordPolicyBuilder");
}

PasswordPolicyBuilder setAuthProvider(PasswordPolicyAuthenticationProviderCondition.ProviderEnum provider);

default PasswordPolicyBuilder setGroups(String... groupIds) {
return setGroups(Arrays.stream(groupIds).collect(Collectors.toList()));
}

PasswordPolicyBuilder setGroups(List<String> groupIds);

PasswordPolicyBuilder addGroup(String groupId);

default PasswordPolicyBuilder setUsers(String... userIds) {
return setGroups(Arrays.stream(userIds).collect(Collectors.toList()));
}

PasswordPolicyBuilder setUsers(List<String> userIds);

PasswordPolicyBuilder addUser(String userId);

PasswordPolicyBuilder setExcludePasswordDictionary(Boolean excludePasswordDictionary);

PasswordPolicyBuilder setExcludeUserNameInPassword(Boolean excludeUserNameInPassword);

PasswordPolicyBuilder setMinPasswordLength(Integer minPasswordLength);

PasswordPolicyBuilder setMinLowerCase(Integer minLowerCase);

PasswordPolicyBuilder setMinUpperCase(Integer minUpperCase);

PasswordPolicyBuilder setMinNumbers(Integer minNumbers);

PasswordPolicyBuilder setMinSymbols(Integer minSymbols);

PasswordPolicyBuilder setSkipUnlock(Boolean skipUnlock);

PasswordPolicyBuilder setPasswordExpireWarnDays(Integer pwdExpireWarnDays);

PasswordPolicyBuilder setPasswordHistoryCount(Integer pwdHistoryCount);

PasswordPolicyBuilder setPasswordMaxAgeDays(Integer pwdMaxAgeDays);

PasswordPolicyBuilder setPasswordMinMinutes(Integer pwdMinMinutes);

PasswordPolicyBuilder setPasswordAutoUnlockMinutes(Integer pwdAutoUnlockMinutes);

PasswordPolicyBuilder setPasswordMaxAttempts(Integer pwdMaxAttempts);

PasswordPolicyBuilder setShowLockoutFailures(Boolean showLockoutFailures);

PasswordPolicyBuilder setPasswordRecoveryOktaCall(PasswordPolicyRecoveryFactorSettings.StatusEnum pwdRecoveryOktaCall);

PasswordPolicyBuilder setPasswordRecoveryOktaSMS(PasswordPolicyRecoveryFactorSettings.StatusEnum pwdRecoveryOktaSMS);

PasswordPolicyBuilder setPasswordPolicyRecoveryEmailStatus(PasswordPolicyRecoveryFactorSettings.StatusEnum status);

PasswordPolicyBuilder setPasswordRecoveryTokenLifeMinutes(Integer pwdRecoveryTokenLifeMinutes);
}
40 changes: 40 additions & 0 deletions api/src/main/java/com/okta/sdk/resource/policy/PolicyBuilder.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright 2020-Present Okta, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.okta.sdk.resource.policy;

import com.okta.commons.lang.Classes;
import com.okta.sdk.client.Client;


public interface PolicyBuilder<T extends PolicyBuilder> {

static PolicyBuilder<PolicyBuilder> instance() {
return Classes.newInstance("com.okta.sdk.impl.resource.DefaultPolicyBuilder");
}

T setName(String name);

T setDescription(String description);

T setType(PolicyType policyType);

T setPriority(Integer priority);

T setStatus(Policy.StatusEnum status);

Policy buildAndCreate(Client client);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright 2020-Present Okta, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.okta.sdk.resource.policy.rule;

import com.okta.commons.lang.Classes;
import com.okta.sdk.resource.policy.PasswordPolicyRuleAction;
import com.okta.sdk.resource.policy.PolicyNetworkCondition;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public interface PasswordPolicyRuleBuilder extends PolicyRuleBuilder<PasswordPolicyRuleBuilder> {

static PasswordPolicyRuleBuilder instance(){
return Classes.newInstance("com.okta.sdk.impl.resource.DefaultPasswordPolicyRuleBuilder");
}

PasswordPolicyRuleBuilder setName(String name);

PasswordPolicyRuleBuilder setNetworkConnection(PolicyNetworkCondition.ConnectionEnum connection);

default PasswordPolicyRuleBuilder setUsers(String... userIds) {
return setUsers(Arrays.stream(userIds).collect(Collectors.toList()));
}

PasswordPolicyRuleBuilder setUsers(List<String> userIds);

PasswordPolicyRuleBuilder addUser(String userId);

default PasswordPolicyRuleBuilder setGroups(String... groupIds) {
return setGroups(Arrays.stream(groupIds).collect(Collectors.toList()));
}

PasswordPolicyRuleBuilder setGroups(List<String> groupIds);

PasswordPolicyRuleBuilder addGroup(String groupId);

PasswordPolicyRuleBuilder setSelfServiceUnlockAccess(PasswordPolicyRuleAction.AccessEnum unlockAccess);

PasswordPolicyRuleBuilder setSelfServicePasswordResetAccess(PasswordPolicyRuleAction.AccessEnum passwordResetAccess);

PasswordPolicyRuleBuilder setPasswordChangeAccess(PasswordPolicyRuleAction.AccessEnum passwordChangeAccess);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright 2020-Present Okta, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.okta.sdk.resource.policy.rule;

import com.okta.commons.lang.Classes;
import com.okta.sdk.client.Client;
import com.okta.sdk.resource.policy.Policy;
import com.okta.sdk.resource.policy.PolicyRule;

public interface PolicyRuleBuilder<T extends PolicyRuleBuilder> {

static PolicyRuleBuilder<PolicyRuleBuilder> instance(){
return Classes.newInstance("com.okta.sdk.impl.resource.DefaultPolicyRuleBuilder");
}

T setId(String id);

T setPriority(Integer priority);

T setStatus(PolicyRule.StatusEnum status);

T setType(PolicyRule.TypeEnum type);

PolicyRule buildAndCreate(Client client, Policy policy);

}
Loading

0 comments on commit 83edb78

Please sign in to comment.