Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OKTA-289663: Add IdP Integration Tests #409

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
b346c49
initial commit
arvindkrishnakumar-okta Jun 10, 2020
ea1cb16
updated IdpIT test
arvindkrishnakumar-okta Jun 10, 2020
b76f78f
Merge branch 'dev_openapi_v2.0.0_major_rel' into okta-289663-add-idp-…
arvindkrishnakumar-okta Jun 11, 2020
0bc1131
review ready
arvindkrishnakumar-okta Jun 11, 2020
7d9dcaf
Merge branch 'dev_openapi_v2.0.0_major_rel' into okta-289663-add-idp-…
arvindkrishnakumar-okta Jun 17, 2020
8b2823b
review comments addressed
arvindkrishnakumar-okta Jun 18, 2020
9655d16
Merge branch 'dev_openapi_v2.0.0_major_rel' into okta-289663-add-idp-…
arvindkrishnakumar-okta Jun 18, 2020
40f8ed8
refactored per review comments
arvindkrishnakumar-okta Jun 19, 2020
8c9fbf4
Merge branch 'dev_openapi_v2.0.0_major_rel' into okta-289663-add-idp-…
arvindkrishnakumar-okta Jun 19, 2020
b538993
added google Idp test
arvindkrishnakumar-okta Jun 19, 2020
b3ef49e
added idp builders for microsoft, facebook, linkedin
arvindkrishnakumar-okta Jun 23, 2020
d9e0a97
Merge branch 'dev_openapi_v2.0.0_major_rel' into okta-289663-add-idp-…
arvindkrishnakumar-okta Jun 24, 2020
6ef9766
review comments addressed
arvindkrishnakumar-okta Jun 25, 2020
9c5e2ea
included missing licence header
arvindkrishnakumar-okta Jun 25, 2020
0931691
cleanup unused imports
arvindkrishnakumar-okta Jun 25, 2020
d21dbb3
review comments addressed
arvindkrishnakumar-okta Jun 26, 2020
58449e9
review comments addressed
arvindkrishnakumar-okta Jun 26, 2020
2f0a245
Merge branch 'dev_openapi_v2.0.0_major_rel' into okta-289663-add-idp-…
arvindkrishnakumar-okta Jun 29, 2020
03509cf
refactored per review comments
arvindkrishnakumar-okta Jun 29, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* 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.identity.provider;

import com.okta.sdk.client.Client;
import com.okta.sdk.resource.policy.PolicySubjectMatchType;

import java.util.List;

public interface IdentityProviderBuilder<T extends IdentityProviderBuilder> {

T setName(String name);

T setClientId(String clientId);

T setClientSecret(String clientSecret);

T setScopes(List<String> scopes);

T setMaxClockSkew(Integer maxClockSkew);

T setUserName(String userName);

T setMatchType(PolicySubjectMatchType policySubjectMatchType);

T setIsProfileMaster(Boolean isProfileMaster);

T isProfileMaster(Boolean isProfileMaster);

IdentityProvider buildAndCreate(Client client);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* 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.identity.provider;

import com.okta.commons.lang.Classes;

public class IdentityProviderBuilders {

public static OIDCIdentityProviderBuilder oidc() {
return Classes.newInstance("com.okta.sdk.impl.resource.identity.provider.DefaultOIDCIdentityProviderBuilder");
}

public static IdentityProviderBuilder google() {
return Classes.newInstance("com.okta.sdk.impl.resource.identity.provider.DefaultGoogleIdentityProviderBuilder");
}

public static IdentityProviderBuilder facebook() {
return Classes.newInstance("com.okta.sdk.impl.resource.identity.provider.DefaultFacebookIdentityProviderBuilder");
}

public static IdentityProviderBuilder microsoft() {
return Classes.newInstance("com.okta.sdk.impl.resource.identity.provider.DefaultMicrosoftIdentityProviderBuilder");
}

public static IdentityProviderBuilder linkedin() {
return Classes.newInstance("com.okta.sdk.impl.resource.identity.provider.DefaultLinkedInIdentityProviderBuilder");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* 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.identity.provider;

import com.okta.sdk.resource.policy.PolicySubjectMatchType;

public interface OIDCIdentityProviderBuilder extends IdentityProviderBuilder<OIDCIdentityProviderBuilder> {

OIDCIdentityProviderBuilder setIssuerMode(IdentityProvider.IssuerModeEnum issuerMode);

OIDCIdentityProviderBuilder setRequestSignatureAlgorithm(String requestSignatureAlgorithm);

OIDCIdentityProviderBuilder setRequestSignatureScope(ProtocolAlgorithmTypeSignature.ScopeEnum requestSignatureScope);

OIDCIdentityProviderBuilder setResponseSignatureAlgorithm(String responseSignatureAlgorithm);

OIDCIdentityProviderBuilder setResponseSignatureScope(ProtocolAlgorithmTypeSignature.ScopeEnum responseSignatureScope);

OIDCIdentityProviderBuilder setAcsEndpointBinding(ProtocolEndpoint.BindingEnum acsEndpointBinding);

OIDCIdentityProviderBuilder setAcsEndpointType(ProtocolEndpoint.TypeEnum acsEndpointType);

OIDCIdentityProviderBuilder setAuthorizationEndpointBinding(ProtocolEndpoint.BindingEnum authorizationEndpointBinding);

OIDCIdentityProviderBuilder setAuthorizationEndpointUrl(String authorizationEndpointUrl);

OIDCIdentityProviderBuilder setTokenEndpointBinding(ProtocolEndpoint.BindingEnum tokenEndpointBinding);

OIDCIdentityProviderBuilder setTokenEndpointUrl(String tokenEndpointUrl);

OIDCIdentityProviderBuilder setUserInfoEndpointBinding(ProtocolEndpoint.BindingEnum userInfoEndpointBinding);

OIDCIdentityProviderBuilder setUserInfoEndpointUrl(String userInfoEndpointUrl);

OIDCIdentityProviderBuilder setJwksEndpointBinding(ProtocolEndpoint.BindingEnum jwksEndpointBinding);

OIDCIdentityProviderBuilder setJwksEndpointUrl(String jwksEndpointUrl);

OIDCIdentityProviderBuilder setIssuerUrl(String issuerUrl);

OIDCIdentityProviderBuilder setUserName(String userName);

OIDCIdentityProviderBuilder setMatchType(PolicySubjectMatchType matchType);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* 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.impl.resource.identity.provider;

import com.okta.sdk.client.Client;
import com.okta.sdk.resource.identity.provider.IdentityProvider;
import com.okta.sdk.resource.identity.provider.IdentityProviderCredentials;
import com.okta.sdk.resource.identity.provider.IdentityProviderCredentialsClient;
import com.okta.sdk.resource.identity.provider.Protocol;
import com.okta.sdk.resource.identity.provider.Provisioning;
import com.okta.sdk.resource.identity.provider.ProvisioningConditions;
import com.okta.sdk.resource.identity.provider.ProvisioningDeprovisionedCondition;
import com.okta.sdk.resource.identity.provider.ProvisioningGroups;
import com.okta.sdk.resource.identity.provider.ProvisioningSuspendedCondition;
import com.okta.sdk.resource.policy.IdentityProviderPolicy;
import com.okta.sdk.resource.policy.PolicyAccountLink;
import com.okta.sdk.resource.policy.PolicySubject;
import com.okta.sdk.resource.policy.PolicyUserNameTemplate;

public class DefaultFacebookIdentityProviderBuilder extends DefaultIdentityProviderBuilder {

@Override
public IdentityProvider buildAndCreate(Client client) {

IdentityProvider createdIdp = client.createIdentityProvider(client.instantiate(IdentityProvider.class)
.setType(IdentityProvider.TypeEnum.FACEBOOK)
.setName(name)
.setProtocol(client.instantiate(Protocol.class)
.setType(Protocol.TypeEnum.OAUTH2)
.setScopes(scopes)
.setCredentials(client.instantiate(IdentityProviderCredentials.class)
.setClient(client.instantiate(IdentityProviderCredentialsClient.class)
.setClientId(clientId)
.setClientSecret(clientSecret))))
.setPolicy(client.instantiate(IdentityProviderPolicy.class)
.setProvisioning(client.instantiate(Provisioning.class)
.setAction(Provisioning.ActionEnum.AUTO)
.setProfileMaster(isProfileMaster)
.setGroups(client.instantiate(ProvisioningGroups.class)
.setAction(ProvisioningGroups.ActionEnum.NONE))
.setConditions(client.instantiate(ProvisioningConditions.class)
.setDeprovisioned(client.instantiate(ProvisioningDeprovisionedCondition.class)
.setAction(ProvisioningDeprovisionedCondition.ActionEnum.NONE))
.setSuspended(client.instantiate(ProvisioningSuspendedCondition.class)
.setAction(ProvisioningSuspendedCondition.ActionEnum.NONE))))
.setAccountLink(client.instantiate(PolicyAccountLink.class)
.setFilter(null)
.setAction(PolicyAccountLink.ActionEnum.AUTO))
.setSubject(client.instantiate(PolicySubject.class)
.setUserNameTemplate(client.instantiate(PolicyUserNameTemplate.class)
.setTemplate(userName))
.setMatchType(matchType))
.setMaxClockSkew(maxClockSkew)));
arvindkrishnakumar-okta marked this conversation as resolved.
Show resolved Hide resolved

return createdIdp;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* 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.impl.resource.identity.provider;

import com.okta.sdk.client.Client;
import com.okta.sdk.resource.identity.provider.IdentityProvider;
import com.okta.sdk.resource.identity.provider.IdentityProviderCredentials;
import com.okta.sdk.resource.identity.provider.IdentityProviderCredentialsClient;
import com.okta.sdk.resource.identity.provider.Protocol;
import com.okta.sdk.resource.identity.provider.Provisioning;
import com.okta.sdk.resource.identity.provider.ProvisioningConditions;
import com.okta.sdk.resource.identity.provider.ProvisioningDeprovisionedCondition;
import com.okta.sdk.resource.identity.provider.ProvisioningGroups;
import com.okta.sdk.resource.identity.provider.ProvisioningSuspendedCondition;
import com.okta.sdk.resource.policy.IdentityProviderPolicy;
import com.okta.sdk.resource.policy.PolicyAccountLink;
import com.okta.sdk.resource.policy.PolicySubject;
import com.okta.sdk.resource.policy.PolicyUserNameTemplate;

public class DefaultGoogleIdentityProviderBuilder extends DefaultIdentityProviderBuilder {

@Override
public IdentityProvider buildAndCreate(Client client) {

return client.createIdentityProvider(client.instantiate(IdentityProvider.class)
.setType(IdentityProvider.TypeEnum.GOOGLE)
.setName(name)
.setProtocol(client.instantiate(Protocol.class)
.setType(Protocol.TypeEnum.OIDC)
.setScopes(scopes)
.setCredentials(client.instantiate(IdentityProviderCredentials.class)
.setClient(client.instantiate(IdentityProviderCredentialsClient.class)
.setClientId(clientId)
.setClientSecret(clientSecret))))
.setPolicy(client.instantiate(IdentityProviderPolicy.class)
.setProvisioning(client.instantiate(Provisioning.class)
.setAction(Provisioning.ActionEnum.AUTO)
.setProfileMaster(isProfileMaster)
.setGroups(client.instantiate(ProvisioningGroups.class)
.setAction(ProvisioningGroups.ActionEnum.NONE))
.setConditions(client.instantiate(ProvisioningConditions.class)
.setDeprovisioned(client.instantiate(ProvisioningDeprovisionedCondition.class)
.setAction(ProvisioningDeprovisionedCondition.ActionEnum.NONE))
.setSuspended(client.instantiate(ProvisioningSuspendedCondition.class)
.setAction(ProvisioningSuspendedCondition.ActionEnum.NONE))))
.setAccountLink(client.instantiate(PolicyAccountLink.class)
.setFilter(null)
.setAction(PolicyAccountLink.ActionEnum.AUTO))
.setSubject(client.instantiate(PolicySubject.class)
.setUserNameTemplate(client.instantiate(PolicyUserNameTemplate.class)
.setTemplate(userName))
.setMatchType(matchType))
.setMaxClockSkew(maxClockSkew)));
arvindkrishnakumar-okta marked this conversation as resolved.
Show resolved Hide resolved
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*
* 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.impl.resource.identity.provider;

import com.okta.sdk.client.Client;
import com.okta.sdk.resource.identity.provider.IdentityProvider;
import com.okta.sdk.resource.identity.provider.IdentityProviderBuilder;
import com.okta.sdk.resource.policy.PolicySubjectMatchType;

import java.util.List;

@SuppressWarnings("rawtypes")
public class DefaultIdentityProviderBuilder<T extends IdentityProviderBuilder> implements IdentityProviderBuilder<T> {

protected String name;
protected String clientId;
protected String clientSecret;
protected List<String> scopes;
protected Integer maxClockSkew;
protected String userName;
protected PolicySubjectMatchType matchType;
protected Boolean isProfileMaster;

@Override
public T setName(String name) {
this.name = name;
return self();
}

@Override
public T setClientId(String clientId) {
this.clientId = clientId;
return self();
}

@Override
public T setClientSecret(String clientSecret) {
this.clientSecret = clientSecret;
return self();
}

@Override
public T setScopes(List<String> scopes) {
this.scopes = scopes;
return self();
}

@Override
public T setMaxClockSkew(Integer maxClockSkew) {
this.maxClockSkew = maxClockSkew;
return self();
}

@Override
public T setUserName(String userName) {
this.userName = userName;
return self();
}

@Override
public T setMatchType(PolicySubjectMatchType matchType) {
this.matchType = matchType;
return self();
}

@Override
public T setIsProfileMaster(Boolean isProfileMaster) {
this.isProfileMaster = isProfileMaster;
return self();
}

@Override
public T isProfileMaster(Boolean isProfileMaster) {
return setIsProfileMaster(isProfileMaster);
}

@Override
public IdentityProvider buildAndCreate(Client client) {
return client.createIdentityProvider(client.instantiate(IdentityProvider.class));
}

@SuppressWarnings("unchecked")
protected T self() {
return (T) this;
}
}
Loading