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

Commit

Permalink
Merge branch 'Openid-connect-new-OAuthPolicy-fields'
Browse files Browse the repository at this point in the history
  • Loading branch information
mrafiei committed Feb 10, 2017
2 parents 29be41e + 67ad654 commit 20b157e
Show file tree
Hide file tree
Showing 12 changed files with 968 additions and 6 deletions.
28 changes: 28 additions & 0 deletions api/src/main/java/com/stormpath/sdk/oauth/OAuthPolicies.java
@@ -0,0 +1,28 @@
/*
* Copyright 2013 Stormpath, 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.stormpath.sdk.oauth;

import com.stormpath.sdk.lang.Classes;

/**
* @since 1.6.0
*/
public final class OAuthPolicies {

public static OAuthPolicyOptions options() {
return (OAuthPolicyOptions) Classes.newInstance("com.stormpath.sdk.impl.oauth.DefaultOAuthPolicyOptions");
}
}
87 changes: 87 additions & 0 deletions api/src/main/java/com/stormpath/sdk/oauth/OAuthPolicy.java
Expand Up @@ -16,10 +16,15 @@
package com.stormpath.sdk.oauth;

import com.stormpath.sdk.application.Application;
import com.stormpath.sdk.oauth.openidconnect.Scope;
import com.stormpath.sdk.oauth.openidconnect.ScopeList;
import com.stormpath.sdk.resource.Resource;
import com.stormpath.sdk.resource.ResourceException;
import com.stormpath.sdk.resource.Saveable;
import com.stormpath.sdk.tenant.Tenant;

import java.util.Map;

/**
* An OAuthPolicy resource is used to configure different aspects of the OAuth tokens associated
* with an {@link Application Application}
Expand All @@ -42,6 +47,14 @@ public interface OAuthPolicy extends Resource, Saveable {
*/
String getRefreshTokenTtl();

/**
* Returns the Time To Live for the id tokens created for the parent {@link Application Application} expressed in a period of time format, for example: PT1H.
*
* @return the String representation of the Time To Live for the id tokens created for the parent {@link Application Application}
* @since 1.6.0
*/
String getIdTokenTtl();

/**
* The href corresponding to the Endpoint for Access Tokens created for the parent {@link Application Application}
*
Expand Down Expand Up @@ -71,6 +84,80 @@ public interface OAuthPolicy extends Resource, Saveable {
*/
OAuthPolicy setRefreshTokenTtl(String refreshTokenTtl);

/**
* Sets the Time To Live for the id tokens created for the parent {@link Application Application} expressed in a period of time format, for example: PT1H.
*
* @return this instance for method chaining.
* @since 1.6.0
*/
OAuthPolicy setIdTokenTtl(String idTokenTtl);

/**
* Creates a new {@link Scope} assigned to this oauthPolicy in the Stormpath server and returns the created resource.
* The scope is used for openid connect flows.
*
* @param scope {@link Scope} pojo to hold necessary data to send to the back-end to create a {@link Scope}.
* @return the newly created {@link Scope}.
*
* @since 1.6.0
*/
Scope createScope(Scope scope) throws ResourceException;

/**
* Returns a paginated list of all the scopes that belong to the oAuthPolicy.
*
* @return a paginated list of all the oAuthPolicy's scopes.
*
* @since 1.6.0
*/
ScopeList getScopes();

/**
* Returns access token attribute mappings.
* <p>Open Id provider (OP) would enter any custom mappings used for their internal purposes in this map.
* Authorization server would then add all these mappings as part of the access token upon its generation.</p>
*
* @return access token attribute mappings.
*
* @since 1.6.0
*/
Map<String,String> getAccessTokenAttributeMap();

/**
* Sets access token attribute mappings to be inserted into access tokens.
*
* @param accessTokenAttributeMap access token attribute mappings to be inserted into access tokens
* <p>Open Id provider (OP) would enter any custom mappings used for their internal purposes in this map.
* Authorization server would then add all these mappings as part of the access token upon its generation.</p>
* @return this instance for method chaining.
*
* @since 1.6.0
*/
OAuthPolicy setAccessTokenAttributeMap(Map<String,String> accessTokenAttributeMap);

/**
* Returns id token attribute mappings.
* <p>Open Id provider (OP) would enter any custom mappings used for their internal purposes in this map.
* Authorization server would then add all these mappings as part of the id token upon its generation.</p>
*
* @return id token attribute mappings.
*
* @since 1.6.0
*/
Map<String,String> getIdTokenAttributeMap();

/**
* Sets id token attribute mappings to be inserted into id tokens.
*
* @param idTokenAttributeMap id token attribute mappings to be inserted into id tokens
* <p>Open Id provider (OP) would enter any custom mappings used for their internal purposes in this map.
* Authorization server would then add all these mappings as part of the id token upon its generation.</p>
* @return this instance for method chaining.
*
* @since 1.6.0
*/
OAuthPolicy setIdTokenAttributeMap(Map<String, String> idTokenAttributeMap);

/**
* Returns the {@link Application Application} associated to this {@link OAuthPolicy OAuthPolicy}
*
Expand Down
54 changes: 54 additions & 0 deletions api/src/main/java/com/stormpath/sdk/oauth/OAuthPolicyOptions.java
@@ -0,0 +1,54 @@
/*
* Copyright 2017 Stormpath, 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.stormpath.sdk.oauth;

import com.stormpath.sdk.query.Options;

/**
* @since 1.6.0
*/
public interface OAuthPolicyOptions<T> extends Options {

/**
* Ensures that when retrieving an OAuthPolicy, the OAuthPolicy's assigned {@link OAuthPolicy#getScopes()} scopes}
* are also retrieved in the same request. This enhances performance by leveraging a single request
* to retrieve multiple related resources you know you will use.
*
* @return this instance for method chaining.
*/
T withScopes();

/**
* Ensures that when retrieving an OAuthPolicy, the OAuthPolicy's assigned {@link OAuthPolicy#getScopes()} scopes}
* are also retrieved in the same request. This enhances performance by leveraging a single request
* to retrieve multiple related resources you know you will use.
*
* @param limit defines the maximum quantity of items to be retrieved when expanding this Collection Resource. Min:1, Max: 100. The default value is 25.
* @return this instance for method chaining.
*/
T withScopes(int limit);

/**
* Ensures that when retrieving an OAuthPolicy, the OAuthPolicy's assigned {@link OAuthPolicy#getScopes()} scopes}
* are also retrieved in the same request. This enhances performance by leveraging a single request
* to retrieve multiple related resources you know you will use.
*
* @param limit defines the maximum quantity of items to be retrieved when expanding this Collection Resource. Min:1, Max: 100. The default value is 25.
* @param offset the zero-based starting index in the entire collection of the first item to return. Default is 0
* @return this instance for method chaining.
*/
T withScopes(int limit, int offset);
}
108 changes: 108 additions & 0 deletions api/src/main/java/com/stormpath/sdk/oauth/openidconnect/Scope.java
@@ -0,0 +1,108 @@
/*
* Copyright 2017 Stormpath, 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.stormpath.sdk.oauth.openidconnect;

import com.stormpath.sdk.oauth.OAuthPolicy;
import com.stormpath.sdk.resource.Auditable;
import com.stormpath.sdk.resource.Deletable;
import com.stormpath.sdk.resource.Resource;
import com.stormpath.sdk.resource.Saveable;

import java.util.Map;

/**
* A Scope resource is used to configure different openid connect scopes
* with an {@link OAuthPolicy OAuthPolicy}
*
* @since 1.6.0
*/
public interface Scope extends Resource, Saveable, Deletable, Auditable {
/**
* Returns the scope's name.
*
* @return the scope's name.
*/
String getName();

/**
* Sets the scope's name.
* @param name the scope's name.
*
* @return this instance for method chaining.
*/
Scope setName(String name);

/**
* Returns the scope's friendly name.
*
* @return the scope's friendly name.
*/
String getFriendlyName();

/**
* Sets the scope's friendly name.
*
* @param name the scope's friendly name.
* @return this instance for method chaining.
*/
Scope setFriendlyName(String name);

/**
* Returns the scope's description.
*
* @return the scope's description.
*/
String getDescription();

/**
* Sets the scope's description.
* @param description the scope's description.
*
* @return this instance for method chaining.
*/
Scope setDescription(String description);


/**
* Returns the scope's attribute mappings.
*
* @return the scope's attribute mappings.
*/
Map<String, String> getAttributeMappings();

/**
* Sets the scope's attribute mappings.
* @param attributeMappings the scope's attribute mappings.
*
* @return this instance for method chaining.
*/
Scope setAttributeMappings(Map<String, String> attributeMappings);

/**
* Returns the {@link OAuthPolicy} associated with this scope.
*
* @return the {@link OAuthPolicy} associated with this scope.
*/
OAuthPolicy getOAuthPolicy();

/**
* Sets the {@link OAuthPolicy} associated with this scope.
* @param oAuthPolicy the {@link OAuthPolicy} associated with this scope.
*
* @return this instance for method chaining.
*/
Scope setOAuthPolicy(OAuthPolicy oAuthPolicy);
}
@@ -0,0 +1,26 @@
/*
* Copyright 2017 Stormpath, 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.stormpath.sdk.oauth.openidconnect;

import com.stormpath.sdk.resource.CollectionResource;

/**
* A {@link CollectionResource} containing {@link Scope} instances.
*
* @since 1.6.0
*/
public interface ScopeList extends CollectionResource<Scope> {
}

0 comments on commit 20b157e

Please sign in to comment.