forked from keycloak/keycloak
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
KEYCLOAK-14189 Client Policy : Basics
- Loading branch information
Showing
62 changed files
with
3,657 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...er-spi-private/src/main/java/org/keycloak/services/clientpolicy/ClientPolicyProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright 2020 Red Hat, Inc. and/or its affiliates | ||
* and other contributors as indicated by the @author tags. | ||
* | ||
* 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 org.keycloak.services.clientpolicy; | ||
|
||
import java.util.List; | ||
|
||
import org.keycloak.provider.Provider; | ||
import org.keycloak.services.clientpolicy.condition.ClientPolicyConditionProvider; | ||
import org.keycloak.services.clientpolicy.executor.ClientPolicyExecutorProvider; | ||
|
||
/** | ||
* Provides Client Policy which accommodates several Conditions and Executors. | ||
*/ | ||
public interface ClientPolicyProvider extends Provider { | ||
|
||
/** | ||
* returns the list of conditions which this provider accommodates. | ||
* | ||
* @return list of conditions | ||
*/ | ||
List<ClientPolicyConditionProvider> getConditions(); | ||
|
||
/** | ||
* returns the list of executors which this provider accommodates. | ||
* | ||
* @return list of executors | ||
*/ | ||
List<ClientPolicyExecutorProvider> getExecutors(); | ||
|
||
String getName(); | ||
|
||
String getProviderId(); | ||
} |
23 changes: 23 additions & 0 deletions
23
...private/src/main/java/org/keycloak/services/clientpolicy/ClientPolicyProviderFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright 2020 Red Hat, Inc. and/or its affiliates | ||
* and other contributors as indicated by the @author tags. | ||
* | ||
* 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 org.keycloak.services.clientpolicy; | ||
|
||
import org.keycloak.component.ComponentFactory; | ||
|
||
public interface ClientPolicyProviderFactory extends ComponentFactory<ClientPolicyProvider, ClientPolicyProvider> { | ||
} |
46 changes: 46 additions & 0 deletions
46
server-spi-private/src/main/java/org/keycloak/services/clientpolicy/ClientPolicySpi.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright 2020 Red Hat, Inc. and/or its affiliates | ||
* and other contributors as indicated by the @author tags. | ||
* | ||
* 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 org.keycloak.services.clientpolicy; | ||
|
||
import org.keycloak.provider.Provider; | ||
import org.keycloak.provider.ProviderFactory; | ||
import org.keycloak.provider.Spi; | ||
|
||
public class ClientPolicySpi implements Spi { | ||
|
||
@Override | ||
public boolean isInternal() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "client-policy"; | ||
} | ||
|
||
@Override | ||
public Class<? extends Provider> getProviderClass() { | ||
return ClientPolicyProvider.class; | ||
} | ||
|
||
@Override | ||
public Class<? extends ProviderFactory> getProviderFactoryClass() { | ||
return ClientPolicyProviderFactory.class; | ||
} | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
server-spi-private/src/main/java/org/keycloak/services/clientpolicy/ClientPolicyVote.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright 2020 Red Hat, Inc. and/or its affiliates | ||
* and other contributors as indicated by the @author tags. | ||
* | ||
* 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 org.keycloak.services.clientpolicy; | ||
|
||
public enum ClientPolicyVote { | ||
YES, | ||
NO, | ||
ABSTAIN | ||
} |
54 changes: 54 additions & 0 deletions
54
...main/java/org/keycloak/services/clientpolicy/condition/ClientPolicyConditionProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright 2020 Red Hat, Inc. and/or its affiliates | ||
* and other contributors as indicated by the @author tags. | ||
* | ||
* 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 org.keycloak.services.clientpolicy.condition; | ||
|
||
import org.keycloak.provider.Provider; | ||
import org.keycloak.services.clientpolicy.ClientPolicyContext; | ||
import org.keycloak.services.clientpolicy.ClientPolicyEvent; | ||
import org.keycloak.services.clientpolicy.ClientPolicyException; | ||
import org.keycloak.services.clientpolicy.ClientPolicyVote; | ||
|
||
/** | ||
* This condition determines to which client a {@link ClientPolicyProvider} is adopted. | ||
* The condition can be evaluated on the events defined in {@link ClientPolicyEvent}. | ||
* It is sufficient for the implementer of this condition to implement methods in which they are interested | ||
* and {@link isEvaluatedOnEvent} method. | ||
*/ | ||
public interface ClientPolicyConditionProvider extends Provider { | ||
|
||
@Override | ||
default void close() { | ||
} | ||
|
||
/** | ||
* returns ABSTAIN if this condition is not evaluated due to its nature. | ||
* returns YES if the client satisfies this condition on the event defined in {@link ClientPolicyEvent}. | ||
* If not, returns NO. | ||
* | ||
* @param context - the context of the event. | ||
* @return returns ABSTAIN if this condition is not evaluated due to its nature. | ||
* @throws {@link ClientPolicyException} - thrown if the condition is not evaluated in its nature on the event specified by context. | ||
*/ | ||
default ClientPolicyVote applyPolicy(ClientPolicyContext context) throws ClientPolicyException { | ||
return ClientPolicyVote.ABSTAIN; | ||
} | ||
|
||
String getName(); | ||
|
||
String getProviderId(); | ||
} |
23 changes: 23 additions & 0 deletions
23
...va/org/keycloak/services/clientpolicy/condition/ClientPolicyConditionProviderFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright 2020 Red Hat, Inc. and/or its affiliates | ||
* and other contributors as indicated by the @author tags. | ||
* | ||
* 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 org.keycloak.services.clientpolicy.condition; | ||
|
||
import org.keycloak.component.ComponentFactory; | ||
|
||
public interface ClientPolicyConditionProviderFactory extends ComponentFactory<ClientPolicyConditionProvider, ClientPolicyConditionProvider> { | ||
} |
46 changes: 46 additions & 0 deletions
46
.../src/main/java/org/keycloak/services/clientpolicy/condition/ClientPolicyConditionSpi.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright 2020 Red Hat, Inc. and/or its affiliates | ||
* and other contributors as indicated by the @author tags. | ||
* | ||
* 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 org.keycloak.services.clientpolicy.condition; | ||
|
||
import org.keycloak.provider.Provider; | ||
import org.keycloak.provider.ProviderFactory; | ||
import org.keycloak.provider.Spi; | ||
|
||
public class ClientPolicyConditionSpi implements Spi { | ||
|
||
@Override | ||
public boolean isInternal() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "client-policy-condition"; | ||
} | ||
|
||
@Override | ||
public Class<? extends Provider> getProviderClass() { | ||
return ClientPolicyConditionProvider.class; | ||
} | ||
|
||
@Override | ||
public Class<? extends ProviderFactory> getProviderFactoryClass() { | ||
return ClientPolicyConditionProviderFactory.class; | ||
} | ||
|
||
} |
49 changes: 49 additions & 0 deletions
49
...c/main/java/org/keycloak/services/clientpolicy/executor/ClientPolicyExecutorProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright 2020 Red Hat, Inc. and/or its affiliates | ||
* and other contributors as indicated by the @author tags. | ||
* | ||
* 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 org.keycloak.services.clientpolicy.executor; | ||
|
||
import org.keycloak.provider.Provider; | ||
import org.keycloak.services.clientpolicy.ClientPolicyException; | ||
import org.keycloak.services.clientpolicy.ClientPolicyContext; | ||
import org.keycloak.services.clientpolicy.ClientPolicyEvent; | ||
|
||
/** | ||
* This executor specifies what action is executed on the client to which {@link ClientPolicyProvider} is adopted. | ||
* The executor can be executed on the events defined in {@link ClientPolicyEvent}. | ||
* It is sufficient for the implementer of this executor to implement methods in which they are interested | ||
* and {@link isEvaluatedOnEvent} method. | ||
*/ | ||
public interface ClientPolicyExecutorProvider extends Provider { | ||
|
||
@Override | ||
default void close() { | ||
} | ||
|
||
/** | ||
* execute actions against the client on the event defined in {@link ClientPolicyEvent}. | ||
* | ||
* @param context - the context of the event. | ||
* @throws {@link ClientPolicyException} - if something wrong happens when execution actions. | ||
*/ | ||
default void executeOnEvent(ClientPolicyContext context) throws ClientPolicyException { | ||
} | ||
|
||
String getName(); | ||
|
||
String getProviderId(); | ||
} |
23 changes: 23 additions & 0 deletions
23
...java/org/keycloak/services/clientpolicy/executor/ClientPolicyExecutorProviderFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright 2020 Red Hat, Inc. and/or its affiliates | ||
* and other contributors as indicated by the @author tags. | ||
* | ||
* 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 org.keycloak.services.clientpolicy.executor; | ||
|
||
import org.keycloak.component.ComponentFactory; | ||
|
||
public interface ClientPolicyExecutorProviderFactory extends ComponentFactory<ClientPolicyExecutorProvider, ClientPolicyExecutorProvider> { | ||
} |
Oops, something went wrong.