parent
8033002675
commit
90ac40168d
@ -53,12 +53,6 @@ public enum Clause {
|
||||
ROLE,
|
||||
PRIVILEGE,
|
||||
|
||||
GRANT,
|
||||
GRANT_PRIVILEGE,
|
||||
|
||||
REVOKE,
|
||||
REVOKE_PRIVILEGE,
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Clauses used in a any type of statement to model constraint references
|
||||
// -------------------------------------------------------------------------
|
||||
@ -831,7 +825,7 @@ public enum Clause {
|
||||
TRUNCATE_TRUNCATE,
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Clauses that are used in an ALTER statement
|
||||
// Clauses that are used in DDL statements
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
@ -1256,6 +1250,20 @@ public enum Clause {
|
||||
*/
|
||||
DROP_SEQUENCE_SEQUENCE,
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Clauses that are used in access control statements
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
GRANT,
|
||||
GRANT_PRIVILEGE,
|
||||
GRANT_ON,
|
||||
GRANT_TO,
|
||||
|
||||
REVOKE,
|
||||
REVOKE_PRIVILEGE,
|
||||
REVOKE_ON,
|
||||
REVOKE_FROM,
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Other clauses
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@ -9487,6 +9487,46 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
@Support
|
||||
<R extends Record> TruncateIdentityStep<R> truncate(Table<R> table);
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX Access control
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Grant a privilege on a table to user or role.
|
||||
*/
|
||||
@Support
|
||||
GrantOnStep grant(Privilege privilege);
|
||||
|
||||
/**
|
||||
* Grant privileges on a table to user or role.
|
||||
*/
|
||||
@Support
|
||||
GrantOnStep grant(Privilege... privileges);
|
||||
|
||||
/**
|
||||
* Grant privileges on a table to user or role.
|
||||
*/
|
||||
@Support
|
||||
GrantOnStep grant(Collection<? extends Privilege> privileges);
|
||||
|
||||
/**
|
||||
* Revoke a privilege on table from user or role.
|
||||
*/
|
||||
@Support
|
||||
RevokeOnStep revoke(Privilege privilege);
|
||||
|
||||
/**
|
||||
* Revoke privileges on table from user or role.
|
||||
*/
|
||||
@Support
|
||||
RevokeOnStep revoke(Privilege... privileges);
|
||||
|
||||
/**
|
||||
* Revoke privileges on table from user or role.
|
||||
*/
|
||||
@Support
|
||||
RevokeOnStep revoke(Collection<? extends Privilege> privileges);
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX Other queries for identites and sequences
|
||||
// -------------------------------------------------------------------------
|
||||
@ -10840,32 +10880,4 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
*/
|
||||
@Support
|
||||
<R extends TableRecord<R>, T> int executeDelete(R record, Condition condition) throws DataAccessException;
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX Access control
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Grant privilege on a table to user or role.
|
||||
*/
|
||||
@Support
|
||||
GrantStepOn grant(Privilege privilege);
|
||||
|
||||
/**
|
||||
* Grant privileges on a table to user or role.
|
||||
*/
|
||||
@Support
|
||||
GrantStepOn grant(Collection<? extends Privilege> privileges);
|
||||
|
||||
/**
|
||||
* Revoke a privilege on table from user or role.
|
||||
*/
|
||||
@Support
|
||||
RevokeStepOn revoke(Privilege privilege);
|
||||
|
||||
/**
|
||||
* Revoke privileges on table from user or role.
|
||||
*/
|
||||
@Support
|
||||
RevokeStepOn revoke(Collection<? extends Privilege> privileges);
|
||||
}
|
||||
|
||||
@ -31,17 +31,17 @@
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package org.jooq;
|
||||
|
||||
/**
|
||||
* The preparation either a user or a role.
|
||||
* The final step in the creation of a <code>REVOKE</code> statement.
|
||||
*
|
||||
* @author Timur Shaidullin
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
public interface GrantStepTo extends Query {
|
||||
|
||||
Query to(User user);
|
||||
|
||||
Query to(Role role);
|
||||
public interface GrantFinalStep extends Query {
|
||||
}
|
||||
@ -31,19 +31,42 @@
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package org.jooq;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* The preparation a privilege.
|
||||
* The step in the creation of a <code>GRANT</code> statement where the
|
||||
* <code>ON</code> clause can be added.
|
||||
*
|
||||
* @author Timur Shaidullin
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
public interface RevokeFirstStep extends RevokeStepOn {
|
||||
public interface GrantOnStep {
|
||||
|
||||
RevokeStepOn revoke(Privilege privilege);
|
||||
/**
|
||||
* Grant a privilege on a table.
|
||||
*/
|
||||
@Support
|
||||
GrantToStep on(Table<?> table);
|
||||
|
||||
RevokeStepOn revoke(Collection<? extends Privilege> privileges);
|
||||
/**
|
||||
* Grant a privilege on a table.
|
||||
*/
|
||||
@Support
|
||||
GrantToStep on(Name table);
|
||||
|
||||
/**
|
||||
* Grant a privilege on a table.
|
||||
* <p>
|
||||
* <b>NOTE</b>: When inserting plain SQL into jOOQ objects, you must
|
||||
* guarantee syntax integrity. You may also create the possibility of
|
||||
* malicious SQL injection. Be sure to properly use bind variables and/or
|
||||
* escape literals when concatenated into SQL clauses!
|
||||
*/
|
||||
@PlainSQL
|
||||
@Support
|
||||
GrantToStep on(String table);
|
||||
}
|
||||
@ -31,19 +31,30 @@
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package org.jooq;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* The preparation a privilege.
|
||||
* The step in the creation of a <code>GRANT</code> statement where the
|
||||
* <code>TO</code> clause can be added.
|
||||
*
|
||||
* @author Timur Shaidullin
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
public interface GrantFirstStep extends GrantStepOn {
|
||||
public interface GrantToStep {
|
||||
|
||||
GrantStepOn grant(Privilege privilege);
|
||||
/**
|
||||
* Grant a privilege to a user.
|
||||
*/
|
||||
@Support
|
||||
GrantFinalStep to(User user);
|
||||
|
||||
GrantStepOn grant(Collection<? extends Privilege> privileges);
|
||||
/**
|
||||
* Grant a privilege to a role.
|
||||
*/
|
||||
@Support
|
||||
GrantFinalStep to(Role role);
|
||||
}
|
||||
@ -31,6 +31,9 @@
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package org.jooq;
|
||||
|
||||
|
||||
@ -31,17 +31,17 @@
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package org.jooq;
|
||||
|
||||
/**
|
||||
* The preparation either a user or a role.
|
||||
* The final step in the creation of a <code>REVOKE</code> statement.
|
||||
*
|
||||
* @author Timur Shaidullin
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
public interface RevokeStepFrom extends Query {
|
||||
|
||||
Query from(User user);
|
||||
|
||||
Query from(Role role);
|
||||
public interface RevokeFinalStep extends Query {
|
||||
}
|
||||
@ -31,17 +31,30 @@
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package org.jooq;
|
||||
|
||||
/**
|
||||
* The preparation a target of privilege.
|
||||
* The step in the creation of a <code>REVOKE</code> statement where the
|
||||
* <code>FROM</code> clause can be added.
|
||||
*
|
||||
* @author Timur Shaidullin
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
public interface GrantStepOn extends GrantStepTo {
|
||||
public interface RevokeFromStep {
|
||||
|
||||
GrantStepTo on(Table<?> table);
|
||||
/**
|
||||
* Revoke a privilege from a user.
|
||||
*/
|
||||
@Support
|
||||
RevokeFinalStep from(User user);
|
||||
|
||||
GrantStepTo on(String table);
|
||||
/**
|
||||
* Revoke a privilege from a role.
|
||||
*/
|
||||
@Support
|
||||
RevokeFinalStep from(Role role);
|
||||
}
|
||||
72
jOOQ/src/main/java/org/jooq/RevokeOnStep.java
Normal file
72
jOOQ/src/main/java/org/jooq/RevokeOnStep.java
Normal file
@ -0,0 +1,72 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
* Other licenses:
|
||||
* -----------------------------------------------------------------------------
|
||||
* Commercial licenses for this work are available. These replace the above
|
||||
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
|
||||
* database integrations.
|
||||
*
|
||||
* For more information, please visit: http://www.jooq.org/licenses
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package org.jooq;
|
||||
|
||||
/**
|
||||
* The step in the creation of a <code>REVOKE</code> statement where the
|
||||
* <code>ON</code> clause can be added.
|
||||
*
|
||||
* @author Timur Shaidullin
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
public interface RevokeOnStep {
|
||||
|
||||
/**
|
||||
* Revoke a privilege on a table.
|
||||
*/
|
||||
@Support
|
||||
RevokeFromStep on(Table<?> table);
|
||||
|
||||
/**
|
||||
* Revoke a privilege on a table.
|
||||
*/
|
||||
@Support
|
||||
RevokeFromStep on(Name table);
|
||||
|
||||
/**
|
||||
* Revoke a privilege on a table.
|
||||
* <p>
|
||||
* <b>NOTE</b>: When inserting plain SQL into jOOQ objects, you must
|
||||
* guarantee syntax integrity. You may also create the possibility of
|
||||
* malicious SQL injection. Be sure to properly use bind variables and/or
|
||||
* escape literals when concatenated into SQL clauses!
|
||||
*/
|
||||
@PlainSQL
|
||||
@Support
|
||||
RevokeFromStep on(String table);
|
||||
}
|
||||
@ -1,47 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
* Other licenses:
|
||||
* -----------------------------------------------------------------------------
|
||||
* Commercial licenses for this work are available. These replace the above
|
||||
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
|
||||
* database integrations.
|
||||
*
|
||||
* For more information, please visit: http://www.jooq.org/licenses
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package org.jooq;
|
||||
|
||||
/**
|
||||
* The preparation a target of privilege.
|
||||
*
|
||||
* @author Timur Shaidullin
|
||||
*/
|
||||
public interface RevokeStepOn extends RevokeStepFrom {
|
||||
|
||||
RevokeStepFrom on(Table<?> table);
|
||||
|
||||
RevokeStepFrom on(String table);
|
||||
}
|
||||
@ -161,7 +161,7 @@ import org.jooq.DropViewFinalStep;
|
||||
import org.jooq.False;
|
||||
import org.jooq.Field;
|
||||
import org.jooq.FieldOrRow;
|
||||
import org.jooq.GrantStepOn;
|
||||
import org.jooq.GrantOnStep;
|
||||
import org.jooq.GroupConcatOrderByStep;
|
||||
import org.jooq.GroupField;
|
||||
import org.jooq.Index;
|
||||
@ -256,7 +256,7 @@ import org.jooq.RecordHandler;
|
||||
import org.jooq.RecordType;
|
||||
import org.jooq.Result;
|
||||
import org.jooq.ResultQuery;
|
||||
import org.jooq.RevokeStepOn;
|
||||
import org.jooq.RevokeOnStep;
|
||||
import org.jooq.Role;
|
||||
import org.jooq.Row1;
|
||||
import org.jooq.Row10;
|
||||
@ -7874,22 +7874,50 @@ public class DSL {
|
||||
* grant(privilege)
|
||||
* .on(table)
|
||||
* .to(user)
|
||||
* .execute();
|
||||
*
|
||||
* grant(privilege)
|
||||
* .on(table)
|
||||
* .to(role)
|
||||
* .execute();
|
||||
* </pre></code>
|
||||
*
|
||||
*
|
||||
*
|
||||
* @see #grant(Collection)
|
||||
*/
|
||||
@Support
|
||||
public static GrantStepOn grant(String privilege) {
|
||||
return using(new DefaultConfiguration()).grant(privilege(privilege));
|
||||
public static GrantOnStep grant(Privilege privilege) {
|
||||
return using(new DefaultConfiguration()).grant(privilege);
|
||||
}
|
||||
|
||||
/**
|
||||
* Grant a privilege on table to user or role.
|
||||
* Grant privileges on table to user or role.
|
||||
*
|
||||
* <p>
|
||||
* Example: <code><pre>
|
||||
* import static org.jooq.impl.DSL.*;
|
||||
*
|
||||
* grant(privilege)
|
||||
* .on(table)
|
||||
* .to(user)
|
||||
* .execute();
|
||||
*
|
||||
* grant(privilege)
|
||||
* .on(table)
|
||||
* .to(role)
|
||||
* .execute();
|
||||
* </pre></code>
|
||||
*
|
||||
*
|
||||
* @see #grant(Collection)
|
||||
*/
|
||||
@Support
|
||||
public static GrantOnStep grant(Privilege... privileges) {
|
||||
return using(new DefaultConfiguration()).grant(privileges);
|
||||
}
|
||||
|
||||
/**
|
||||
* Grant privileges on table to user or role.
|
||||
*
|
||||
* <p>
|
||||
* Example: <code><pre>
|
||||
@ -7898,17 +7926,19 @@ public class DSL {
|
||||
* grant(privileges)
|
||||
* .on(table)
|
||||
* .to(user)
|
||||
* .execute();
|
||||
*
|
||||
* grant(privileges)
|
||||
* .on(table)
|
||||
* .to(role)
|
||||
* .execute();
|
||||
* </pre></code>
|
||||
* <p>
|
||||
*
|
||||
* @see #grant(String)
|
||||
* @see #grant(Privilege...)
|
||||
*/
|
||||
@Support
|
||||
public static GrantStepOn grant(Collection<? extends Privilege> privileges) {
|
||||
public static GrantOnStep grant(Collection<? extends Privilege> privileges) {
|
||||
return using(new DefaultConfiguration()).grant(privileges);
|
||||
}
|
||||
|
||||
@ -7922,22 +7952,50 @@ public class DSL {
|
||||
* revoke(privilege)
|
||||
* .on(table)
|
||||
* .from(user)
|
||||
* .execute();
|
||||
*
|
||||
* revoke(privilege)
|
||||
* .on(table)
|
||||
* .from(role)
|
||||
* .execute();
|
||||
* </pre></code>
|
||||
* <p>
|
||||
*
|
||||
* @see #revoke(Collection)
|
||||
*/
|
||||
@Support
|
||||
public static RevokeStepOn revoke(String privilege) {
|
||||
return using(new DefaultConfiguration()).revoke(privilege(privilege));
|
||||
public static RevokeOnStep revoke(Privilege privilege) {
|
||||
return using(new DefaultConfiguration()).revoke(privilege);
|
||||
}
|
||||
|
||||
/**
|
||||
* Revoke a privilege on table from user or role.
|
||||
* Revoke privileges on table from user or role.
|
||||
*
|
||||
* <p>
|
||||
* Example: <code><pre>
|
||||
* import static org.jooq.impl.DSL.*;
|
||||
*
|
||||
* revoke(privilege)
|
||||
* .on(table)
|
||||
* .from(user)
|
||||
* .execute();
|
||||
*
|
||||
* revoke(privilege)
|
||||
* .on(table)
|
||||
* .from(role)
|
||||
* .execute();
|
||||
* </pre></code>
|
||||
* <p>
|
||||
*
|
||||
* @see #revoke(Collection)
|
||||
*/
|
||||
@Support
|
||||
public static RevokeOnStep revoke(Privilege... privileges) {
|
||||
return using(new DefaultConfiguration()).revoke(privileges);
|
||||
}
|
||||
|
||||
/**
|
||||
* Revoke privileges on table from user or role.
|
||||
*
|
||||
* <p>
|
||||
* Example: <code><pre>
|
||||
@ -7946,25 +8004,32 @@ public class DSL {
|
||||
* revoke(privileges)
|
||||
* .on(table)
|
||||
* .from(user)
|
||||
* .execute();
|
||||
*
|
||||
* revoke(privileges)
|
||||
* .on(table)
|
||||
* .from(role)
|
||||
* .execute();
|
||||
* </pre></code>
|
||||
* <p>
|
||||
*
|
||||
* @see #revoke(String)
|
||||
* @see #revoke(Privilege...)
|
||||
*/
|
||||
@Support
|
||||
public static RevokeStepOn revoke(Collection<? extends Privilege> privileges) {
|
||||
public static RevokeOnStep revoke(Collection<? extends Privilege> privileges) {
|
||||
return using(new DefaultConfiguration()).revoke(privileges);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new privilege reference.
|
||||
*
|
||||
* @see #privilege(Keyword)
|
||||
* <p>
|
||||
* <b>NOTE</b>: When inserting plain SQL into jOOQ objects, you must
|
||||
* guarantee syntax integrity. You may also create the possibility of
|
||||
* malicious SQL injection. Be sure to properly use bind variables and/or
|
||||
* escape literals when concatenated into SQL clauses!
|
||||
*/
|
||||
@PlainSQL
|
||||
@Support
|
||||
public static Privilege privilege(String privilege) {
|
||||
return privilege(keyword(privilege));
|
||||
}
|
||||
@ -7972,7 +8037,8 @@ public class DSL {
|
||||
/**
|
||||
* Create a new privilege reference.
|
||||
*/
|
||||
public static Privilege privilege(Keyword privilege) {
|
||||
@Support
|
||||
static Privilege privilege(Keyword privilege) {
|
||||
return new PrivilegeImpl(privilege);
|
||||
}
|
||||
|
||||
@ -7981,6 +8047,7 @@ public class DSL {
|
||||
*
|
||||
* @see #user(Name)
|
||||
*/
|
||||
@Support
|
||||
public static User user(String name) {
|
||||
return user(name(name));
|
||||
}
|
||||
@ -7988,6 +8055,7 @@ public class DSL {
|
||||
/**
|
||||
* Create a new user reference.
|
||||
*/
|
||||
@Support
|
||||
public static User user(Name name) {
|
||||
return new UserImpl(name);
|
||||
}
|
||||
@ -7997,6 +8065,7 @@ public class DSL {
|
||||
*
|
||||
* @see #role(Name)
|
||||
*/
|
||||
@Support
|
||||
public static Role role(String name) {
|
||||
return role(name(name));
|
||||
}
|
||||
@ -8004,6 +8073,7 @@ public class DSL {
|
||||
/**
|
||||
* Create a new role reference.
|
||||
*/
|
||||
@Support
|
||||
public static Role role(Name name) {
|
||||
return new RoleImpl(name);
|
||||
}
|
||||
|
||||
@ -124,7 +124,7 @@ import org.jooq.ExecuteContext;
|
||||
import org.jooq.ExecuteListener;
|
||||
import org.jooq.Explain;
|
||||
import org.jooq.Field;
|
||||
import org.jooq.GrantStepOn;
|
||||
import org.jooq.GrantOnStep;
|
||||
import org.jooq.Index;
|
||||
import org.jooq.InsertQuery;
|
||||
import org.jooq.InsertSetStep;
|
||||
@ -179,8 +179,8 @@ import org.jooq.MergeUsingStep;
|
||||
import org.jooq.Meta;
|
||||
import org.jooq.Name;
|
||||
import org.jooq.Param;
|
||||
import org.jooq.Privilege;
|
||||
import org.jooq.Parser;
|
||||
import org.jooq.Privilege;
|
||||
import org.jooq.Queries;
|
||||
import org.jooq.Query;
|
||||
import org.jooq.QueryPart;
|
||||
@ -211,7 +211,7 @@ import org.jooq.RenderContext;
|
||||
import org.jooq.Result;
|
||||
import org.jooq.ResultQuery;
|
||||
import org.jooq.Results;
|
||||
import org.jooq.RevokeStepOn;
|
||||
import org.jooq.RevokeOnStep;
|
||||
import org.jooq.SQL;
|
||||
import org.jooq.SQLDialect;
|
||||
import org.jooq.Schema;
|
||||
@ -3410,6 +3410,40 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
|
||||
return new TruncateImpl<R>(configuration(), table);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX Access control
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public GrantOnStep grant(Privilege privilege) {
|
||||
return grant(Arrays.asList(privilege));
|
||||
}
|
||||
|
||||
@Override
|
||||
public GrantOnStep grant(Privilege... privileges) {
|
||||
return grant(Arrays.asList(privileges));
|
||||
}
|
||||
|
||||
@Override
|
||||
public GrantOnStep grant(Collection<? extends Privilege> privileges) {
|
||||
return new GrantImpl(configuration(), privileges);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RevokeOnStep revoke(Privilege privilege) {
|
||||
return revoke(Arrays.asList(privilege));
|
||||
}
|
||||
|
||||
@Override
|
||||
public RevokeOnStep revoke(Privilege... privileges) {
|
||||
return revoke(Arrays.asList(privileges));
|
||||
}
|
||||
|
||||
@Override
|
||||
public RevokeOnStep revoke(Collection<? extends Privilege> privileges) {
|
||||
return new RevokeImpl(configuration(), privileges);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX Other queries for identites and sequences
|
||||
// -------------------------------------------------------------------------
|
||||
@ -4201,28 +4235,4 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
|
||||
public String toString() {
|
||||
return configuration().toString();
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX Access control
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public GrantStepOn grant(Privilege privilege) {
|
||||
return new GrantImpl(configuration()).grant(privilege);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GrantStepOn grant(Collection<? extends Privilege> privileges) {
|
||||
return new GrantImpl(configuration()).grant(privileges);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RevokeStepOn revoke(Privilege privilege) {
|
||||
return new RevokeImpl(configuration()).revoke(privilege);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RevokeStepOn revoke(Collection<? extends Privilege> privileges) {
|
||||
return new RevokeImpl(configuration()).revoke(privileges);
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,52 +31,60 @@
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.Clause.GRANT;
|
||||
import static org.jooq.Clause.GRANT_ON;
|
||||
import static org.jooq.Clause.GRANT_PRIVILEGE;
|
||||
import static org.jooq.Clause.GRANT_TO;
|
||||
import static org.jooq.impl.DSL.table;
|
||||
import static org.jooq.impl.Keywords.K_GRANT;
|
||||
import static org.jooq.impl.Keywords.K_ON;
|
||||
import static org.jooq.impl.Keywords.K_TO;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.jooq.Clause;
|
||||
import org.jooq.Configuration;
|
||||
import org.jooq.Context;
|
||||
import org.jooq.GrantFirstStep;
|
||||
import org.jooq.GrantStepOn;
|
||||
import org.jooq.GrantStepTo;
|
||||
import org.jooq.GrantFinalStep;
|
||||
import org.jooq.GrantOnStep;
|
||||
import org.jooq.GrantToStep;
|
||||
import org.jooq.Name;
|
||||
import org.jooq.Privilege;
|
||||
import org.jooq.Query;
|
||||
import org.jooq.Role;
|
||||
import org.jooq.Table;
|
||||
import org.jooq.User;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import static org.jooq.Clause.GRANT;
|
||||
import static org.jooq.Clause.GRANT_PRIVILEGE;
|
||||
import static org.jooq.impl.Keywords.K_GRANT;
|
||||
import static org.jooq.impl.Keywords.K_ON;
|
||||
import static org.jooq.impl.Keywords.K_TO;
|
||||
|
||||
/**
|
||||
* Grant privilege or privileges on a table to user or role.
|
||||
* @author Timur Shaidullin
|
||||
*/
|
||||
final class GrantImpl extends AbstractQuery implements
|
||||
GrantFirstStep,
|
||||
GrantStepOn,
|
||||
GrantStepTo,
|
||||
Query {
|
||||
|
||||
// Cascading interface implementations for Select behaviour
|
||||
GrantOnStep,
|
||||
GrantToStep,
|
||||
GrantFinalStep {
|
||||
|
||||
/**
|
||||
* Generated UID
|
||||
*/
|
||||
private static final long serialVersionUID = -6509384254822040545L;
|
||||
private Clause[] CLAUSE = { GRANT };
|
||||
private Collection<? extends Privilege> privileges;
|
||||
private Role role;
|
||||
private Table<?> table;
|
||||
private User user;
|
||||
private static final long serialVersionUID = -6509384254822040545L;
|
||||
private static final Clause[] CLAUSE = { GRANT };
|
||||
private final Collection<? extends Privilege> privileges;
|
||||
private Role role;
|
||||
private Table<?> table;
|
||||
private User user;
|
||||
|
||||
GrantImpl(Configuration configuration) {
|
||||
GrantImpl(Configuration configuration, Collection<? extends Privilege> privileges) {
|
||||
super(configuration);
|
||||
|
||||
this.privileges = privileges;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@ -84,37 +92,36 @@ final class GrantImpl extends AbstractQuery implements
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public void accept(Context<?> ctx) {
|
||||
public final void accept(Context<?> ctx) {
|
||||
ctx.start(GRANT_PRIVILEGE)
|
||||
.visit(K_GRANT).sql(' ');
|
||||
.visit(K_GRANT).sql(' ');
|
||||
|
||||
Privilege[] arrayOfPrivileges = privileges.toArray(Tools.EMPTY_PRIVILEGE);
|
||||
String separator = "";
|
||||
for (Privilege privilege : privileges) {
|
||||
ctx.sql(separator)
|
||||
.visit(privilege);
|
||||
|
||||
for (int i = 0; i < arrayOfPrivileges.length; i++) {
|
||||
ctx.visit(arrayOfPrivileges[i]);
|
||||
|
||||
if (i != (arrayOfPrivileges.length - 1)) {
|
||||
ctx.sql(',');
|
||||
}
|
||||
|
||||
ctx.sql(' ');
|
||||
separator = ", ";
|
||||
}
|
||||
|
||||
ctx.visit(K_ON).sql(' ')
|
||||
.visit(table).sql(' ')
|
||||
.visit(K_TO).sql(' ');
|
||||
ctx.end(GRANT_PRIVILEGE).sql(' ')
|
||||
.start(GRANT_ON)
|
||||
.visit(K_ON).sql(' ')
|
||||
.visit(table)
|
||||
.end(GRANT_ON).sql(' ')
|
||||
.start(GRANT_TO)
|
||||
.visit(K_TO).sql(' ');
|
||||
|
||||
if (user != null) {
|
||||
if (user != null)
|
||||
ctx.visit(user);
|
||||
} else if (role != null) {
|
||||
else if (role != null)
|
||||
ctx.visit(role);
|
||||
}
|
||||
|
||||
ctx.end(GRANT_PRIVILEGE).sql(';');
|
||||
ctx.end(GRANT_TO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Clause[] clauses(Context<?> ctx) {
|
||||
public final Clause[] clauses(Context<?> ctx) {
|
||||
return CLAUSE;
|
||||
}
|
||||
|
||||
@ -123,38 +130,30 @@ final class GrantImpl extends AbstractQuery implements
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public GrantStepOn grant(Privilege privilege) {
|
||||
this.privileges = Collections.singletonList(privilege);
|
||||
public final GrantImpl on(Table<?> t) {
|
||||
this.table = t;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GrantStepOn grant(Collection<? extends Privilege> privileges) {
|
||||
this.privileges = privileges;
|
||||
public final GrantImpl on(Name t) {
|
||||
return on(table(t));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final GrantImpl on(String t) {
|
||||
return on(table(t));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final GrantImpl to(User u) {
|
||||
this.user = u;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GrantStepTo on(Table<?> table) {
|
||||
this.table = table;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GrantStepTo on(String table) {
|
||||
this.table = DSL.table(table);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query to(User user) {
|
||||
this.user = user;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query to(Role role) {
|
||||
this.role = role;
|
||||
public final GrantImpl to(Role r) {
|
||||
this.role = r;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,16 +31,19 @@
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.Clause.PRIVILEGE;
|
||||
|
||||
import org.jooq.Clause;
|
||||
import org.jooq.Context;
|
||||
import org.jooq.Keyword;
|
||||
import org.jooq.Privilege;
|
||||
|
||||
import static org.jooq.Clause.PRIVILEGE;
|
||||
|
||||
/**
|
||||
* @author Timur Shaidullin
|
||||
*/
|
||||
@ -62,12 +65,12 @@ final class PrivilegeImpl extends AbstractQueryPart implements Privilege {
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public void accept(Context<?> ctx) {
|
||||
public final void accept(Context<?> ctx) {
|
||||
ctx.visit(privilege);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Clause[] clauses(Context<?> ctx) {
|
||||
public final Clause[] clauses(Context<?> ctx) {
|
||||
return CLAUSES;
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,51 +31,61 @@
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.Clause.REVOKE;
|
||||
import static org.jooq.Clause.REVOKE_FROM;
|
||||
import static org.jooq.Clause.REVOKE_ON;
|
||||
import static org.jooq.Clause.REVOKE_PRIVILEGE;
|
||||
import static org.jooq.impl.DSL.table;
|
||||
import static org.jooq.impl.Keywords.K_FROM;
|
||||
import static org.jooq.impl.Keywords.K_ON;
|
||||
import static org.jooq.impl.Keywords.K_REVOKE;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.jooq.Clause;
|
||||
import org.jooq.Configuration;
|
||||
import org.jooq.Context;
|
||||
import org.jooq.Name;
|
||||
import org.jooq.Privilege;
|
||||
import org.jooq.Query;
|
||||
import org.jooq.RevokeFirstStep;
|
||||
import org.jooq.RevokeStepOn;
|
||||
import org.jooq.RevokeStepFrom;
|
||||
import org.jooq.RevokeFinalStep;
|
||||
import org.jooq.RevokeFromStep;
|
||||
import org.jooq.RevokeOnStep;
|
||||
import org.jooq.Role;
|
||||
import org.jooq.Table;
|
||||
import org.jooq.User;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import static org.jooq.Clause.REVOKE;
|
||||
import static org.jooq.Clause.REVOKE_PRIVILEGE;
|
||||
import static org.jooq.impl.Keywords.*;
|
||||
|
||||
/**
|
||||
* Revoke privilege or privileges on a table from user or role.
|
||||
*
|
||||
* @author Timur Shaidullin
|
||||
*/
|
||||
final class RevokeImpl extends AbstractQuery implements
|
||||
RevokeFirstStep,
|
||||
RevokeStepOn,
|
||||
RevokeStepFrom,
|
||||
Query {
|
||||
|
||||
// Cascading interface implementations for Select behaviour
|
||||
RevokeOnStep,
|
||||
RevokeFromStep,
|
||||
RevokeFinalStep {
|
||||
|
||||
/**
|
||||
* Generated UID
|
||||
*/
|
||||
private static final long serialVersionUID = -5777612075774539326L;
|
||||
private Clause[] CLAUSE = { REVOKE };
|
||||
private Collection<? extends Privilege> privileges;
|
||||
private Role role;
|
||||
private Table<?> table;
|
||||
private User user;
|
||||
private static final long serialVersionUID = -5777612075774539326L;
|
||||
private static final Clause[] CLAUSE = { REVOKE };
|
||||
private final Collection<? extends Privilege> privileges;
|
||||
private Role role;
|
||||
private Table<?> table;
|
||||
private User user;
|
||||
|
||||
RevokeImpl(Configuration configuration) {
|
||||
RevokeImpl(Configuration configuration, Collection<? extends Privilege> privileges) {
|
||||
super(configuration);
|
||||
|
||||
this.privileges = privileges;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@ -83,37 +93,36 @@ final class RevokeImpl extends AbstractQuery implements
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public void accept(Context<?> ctx) {
|
||||
public final void accept(Context<?> ctx) {
|
||||
ctx.start(REVOKE_PRIVILEGE)
|
||||
.visit(K_REVOKE).sql(' ');
|
||||
.visit(K_REVOKE).sql(' ');
|
||||
|
||||
Privilege[] arrayOfPrivileges = privileges.toArray(Tools.EMPTY_PRIVILEGE);
|
||||
String separator = "";
|
||||
for (Privilege privilege : privileges) {
|
||||
ctx.sql(separator)
|
||||
.visit(privilege);
|
||||
|
||||
for (int i = 0; i < arrayOfPrivileges.length; i++) {
|
||||
ctx.visit(arrayOfPrivileges[i]);
|
||||
|
||||
if (i != arrayOfPrivileges.length - 1) {
|
||||
ctx.sql(',');
|
||||
}
|
||||
|
||||
ctx.sql(' ');
|
||||
separator = ", ";
|
||||
}
|
||||
|
||||
ctx.visit(K_ON).sql(' ')
|
||||
.visit(table).sql(' ')
|
||||
.visit(K_FROM).sql(' ');
|
||||
ctx.end(REVOKE_PRIVILEGE).sql(' ')
|
||||
.start(REVOKE_ON)
|
||||
.visit(K_ON).sql(' ')
|
||||
.visit(table)
|
||||
.end(REVOKE_ON).sql(' ')
|
||||
.start(REVOKE_FROM)
|
||||
.visit(K_FROM).sql(' ');
|
||||
|
||||
if (user != null) {
|
||||
if (user != null)
|
||||
ctx.visit(user);
|
||||
} else if (role != null) {
|
||||
else if (role != null)
|
||||
ctx.visit(role);
|
||||
}
|
||||
|
||||
ctx.end(REVOKE_PRIVILEGE).sql(';');
|
||||
ctx.end(REVOKE_FROM);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Clause[] clauses(Context<?> ctx) {
|
||||
public final Clause[] clauses(Context<?> ctx) {
|
||||
return CLAUSE;
|
||||
}
|
||||
|
||||
@ -122,38 +131,30 @@ final class RevokeImpl extends AbstractQuery implements
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public RevokeStepOn revoke(Privilege privilege) {
|
||||
this.privileges = Collections.singletonList(privilege);
|
||||
public final RevokeImpl on(Table<?> t) {
|
||||
this.table = t;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RevokeStepOn revoke(Collection<? extends Privilege> privileges) {
|
||||
this.privileges = privileges;
|
||||
public final RevokeImpl on(Name t) {
|
||||
return on(table(t));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final RevokeImpl on(String t) {
|
||||
return on(table(t));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final RevokeImpl from(User u) {
|
||||
this.user = u;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RevokeStepFrom on(Table<?> table) {
|
||||
this.table = table;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RevokeStepFrom on(String table) {
|
||||
this.table = DSL.table(table);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query from(User user) {
|
||||
this.user = user;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query from(Role role) {
|
||||
this.role = role;
|
||||
public final RevokeImpl from(Role r) {
|
||||
this.role = r;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@ -193,7 +193,6 @@ import org.jooq.Field;
|
||||
import org.jooq.Name;
|
||||
import org.jooq.OrderField;
|
||||
import org.jooq.Param;
|
||||
import org.jooq.Privilege;
|
||||
import org.jooq.Query;
|
||||
import org.jooq.QueryPart;
|
||||
import org.jooq.Record;
|
||||
@ -257,7 +256,6 @@ final class Tools {
|
||||
static final int[] EMPTY_INT = {};
|
||||
static final Name[] EMPTY_NAME = {};
|
||||
static final Param<?>[] EMPTY_PARAM = {};
|
||||
static final Privilege[] EMPTY_PRIVILEGE = {};
|
||||
static final Query[] EMPTY_QUERY = {};
|
||||
static final QueryPart[] EMPTY_QUERYPART = {};
|
||||
static final Record[] EMPTY_RECORD = {};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user