/** * Constructs a new access control policy condition that tests the incoming * request's referer field against the specified value, using the specified * comparison type. * * @param comparisonType * The type of string comparison to perform when testing an * incoming request's referer field with the specified value. * @param value * The value against which to compare the incoming request's * referer field. * * @return A new access control policy condition that tests an incoming * request's referer field. */ public static Condition newRefererCondition(StringComparisonType comparisonType, String value) { return new StringCondition(comparisonType, REFERER_CONDITION_KEY, value); } }
/** * Constructs a new AWS access control policy condition that allows an * access control statement to restrict subscriptions to an Amazon SNS topic * based on the protocol being used for the subscription. For example, this * condition can restrict subscriptions to a topic to endpoints using HTTPS * to ensure that messages are securely delivered. * * @param protocol * The protocol against which to compare the requested protocol * for an Amazon SNS topic subscription. * * @return A new access control policy condition that compares the * notification protocol requested in a request to subscribe to an * Amazon SNS topic with the protocol value specified. */ public static Condition newProtocolCondition(String protocol) { return new StringCondition(StringComparisonType.StringEquals, PROTOCOL_CONDITION_KEY, protocol); }
/** * Constructs a new access control policy condition that tests the incoming * request's user agent field against the specified value, using the * specified comparison type. This condition can be used to allow or deny * access to a resource based on what user agent is specified in the * request. * * @param comparisonType * The type of string comparison to perform when testing an * incoming request's user agent field with the specified value. * @param value * The value against which to compare the incoming request's user * agent. * * @return A new access control policy condition that tests an incoming * request's user agent field. */ public static Condition newUserAgentCondition(StringComparisonType comparisonType, String value) { return new StringCondition(comparisonType, USER_AGENT_CONDITION_KEY, value); }
/** * Constructs a new access policy condition that compares the requested * endpoint used to subscribe to an Amazon SNS topic with the specified * endpoint pattern. The endpoint pattern may optionally contain the * multi-character wildcard (*) or the single-character wildcard (?). * <p> * For example, this condition can restrict subscriptions to a topic to * email addresses in a certain domain ("*@my-company.com"). * * <pre class="brush: java"> * Policy policy = new Policy("MyTopicPolicy"); * policy.withStatements(new Statement("RestrictSubscriptions", Effect.Allow) * .withPrincipals(new Principal("*")).withActions(SNSActions.Subscribe) * .withResources(new Resource(myTopicArn)) * .withConditions(SNSConditionFactory.newEndpointCondition("*@my-company.com"))); * </pre> * * @param endpointPattern * The endpoint pattern against which to compare the requested * endpoint for an Amazon SNS topic subscription. * * @return A new access control policy condition that compares the endpoint * used in a request to subscribe to an Amazon SNS topic with the * endpoint pattern specified. */ public static Condition newEndpointCondition(String endpointPattern) { return new StringCondition(StringComparisonType.StringLike, ENDPOINT_CONDITION_KEY, endpointPattern); }
/** * Constructs a new access policy condition that compares an Amazon S3 * canned ACL with the canned ACL specified by an incoming request. * <p> * You can use this condition to ensure that any objects uploaded to an * Amazon S3 bucket have a specific canned ACL set. * * @param cannedAcl * The Amazon S3 canned ACL to compare against. * * @return A new access control policy condition that compares the Amazon S3 * canned ACL specified in incoming requests against the value * specified. */ public static Condition newCannedACLCondition(CannedAccessControlList cannedAcl) { return new StringCondition(StringComparisonType.StringEquals, CANNED_ACL_CONDITION_KEY, cannedAcl.toString()); }
/** * Constructs a new AWS access control policy condition that allows an * access control statement to restrict subscriptions to an Amazon SNS topic * based on the protocol being used for the subscription. For example, this * condition can restrict subscriptions to a topic to endpoints using HTTPS * to ensure that messages are securely delivered. * * @param protocol The protocol against which to compare the requested * protocol for an Amazon SNS topic subscription. * @return A new access control policy condition that compares the * notification protocol requested in a request to subscribe to an * Amazon SNS topic with the protocol value specified. */ public static Condition newProtocolCondition(String protocol) { return new StringCondition(StringComparisonType.StringEquals, PROTOCOL_CONDITION_KEY, protocol); }
/** * Constructs a new access control policy condition that tests the incoming * request's referer field against the specified value, using the specified * comparison type. * * @param comparisonType The type of string comparison to perform when * testing an incoming request's referer field with the specified * value. * @param value The value against which to compare the incoming request's * referer field. * @return A new access control policy condition that tests an incoming * request's referer field. */ public static Condition newRefererCondition(StringComparisonType comparisonType, String value) { return new StringCondition(comparisonType, REFERER_CONDITION_KEY, value); } }
/** * Constructs a new access control policy condition that tests the incoming * request's user agent field against the specified value, using the * specified comparison type. This condition can be used to allow or deny * access to a resource based on what user agent is specified in the * request. * * @param comparisonType The type of string comparison to perform when * testing an incoming request's user agent field with the * specified value. * @param value The value against which to compare the incoming request's * user agent. * @return A new access control policy condition that tests an incoming * request's user agent field. */ public static Condition newUserAgentCondition(StringComparisonType comparisonType, String value) { return new StringCondition(comparisonType, USER_AGENT_CONDITION_KEY, value); }
/** * Constructs a new access control policy condition that tests the incoming * request's referer field against the specified value, using the specified * comparison type. * * @param comparisonType * The type of string comparison to perform when testing an * incoming request's referer field with the specified value. * @param value * The value against which to compare the incoming request's * referer field. * * @return A new access control policy condition that tests an incoming * request's referer field. */ public static Condition newRefererCondition(StringComparisonType comparisonType, String value) { return new StringCondition(comparisonType, REFERER_CONDITION_KEY, value); } }
/** * Constructs a new access control policy condition that tests the incoming * request's user agent field against the specified value, using the * specified comparison type. This condition can be used to allow or deny * access to a resource based on what user agent is specified in the * request. * * @param comparisonType * The type of string comparison to perform when testing an * incoming request's user agent field with the specified value. * @param value * The value against which to compare the incoming request's user * agent. * * @return A new access control policy condition that tests an incoming * request's user agent field. */ public static Condition newUserAgentCondition(StringComparisonType comparisonType, String value) { return new StringCondition(comparisonType, USER_AGENT_CONDITION_KEY, value); }
/** * Constructs a new access policy condition that compares the requested * endpoint used to subscribe to an Amazon SNS topic with the specified * endpoint pattern. The endpoint pattern may optionally contain the * multi-character wildcard (*) or the single-character wildcard (?). * <p> * For example, this condition can restrict subscriptions to a topic to * email addresses in a certain domain ("*@my-company.com"). * * <pre class="brush: java"> * Policy policy = new Policy("MyTopicPolicy"); * policy.withStatements(new Statement("RestrictSubscriptions", Effect.Allow) * .withPrincipals(new Principal("*")).withActions(SNSActions.Subscribe) * .withResources(new Resource(myTopicArn)) * .withConditions(SNSConditionFactory.newEndpointCondition("*@my-company.com"))); * </pre> * * @param endpointPattern The endpoint pattern against which to compare the * requested endpoint for an Amazon SNS topic subscription. * @return A new access control policy condition that compares the endpoint * used in a request to subscribe to an Amazon SNS topic with the * endpoint pattern specified. */ public static Condition newEndpointCondition(String endpointPattern) { return new StringCondition(StringComparisonType.StringLike, ENDPOINT_CONDITION_KEY, endpointPattern); }
/** * Constructs a new access policy condition that compares an Amazon S3 * canned ACL with the canned ACL specified by an incoming request. * <p> * You can use this condition to ensure that any objects uploaded to an * Amazon S3 bucket have a specific canned ACL set. * * @param cannedAcl The Amazon S3 canned ACL to compare against. * @return A new access control policy condition that compares the Amazon S3 * canned ACL specified in incoming requests against the value * specified. */ public static Condition newCannedACLCondition(CannedAccessControlList cannedAcl) { return new StringCondition(StringComparisonType.StringEquals, CANNED_ACL_CONDITION_KEY, cannedAcl.toString()); }
Query query = ATableDao.queryBuilder().where( new StringCondition("nameid IN " + "(SELECT nameid FROM B_Table )").build();
Query query = userDao.queryBuilder().where( new StringCondition("(select * from table where upper(name) = "ABC")").build();
/** * Constructs a new access control policy condition that tests the incoming * request's referer field against the specified value, using the specified * comparison type. * * @param comparisonType The type of string comparison to perform when * testing an incoming request's referer field with the specified * value. * @param value The value against which to compare the incoming request's * referer field. * @return A new access control policy condition that tests an incoming * request's referer field. */ public static Condition newRefererCondition(StringComparisonType comparisonType, String value) { return new StringCondition(comparisonType, REFERER_CONDITION_KEY, value); } }
/** * Constructs a new access control policy condition that tests the incoming * request's referer field against the specified value, using the specified * comparison type. * * @param comparisonType The type of string comparison to perform when * testing an incoming request's referer field with the specified * value. * @param value The value against which to compare the incoming request's * referer field. * @return A new access control policy condition that tests an incoming * request's referer field. */ public static Condition newRefererCondition(StringComparisonType comparisonType, String value) { return new StringCondition(comparisonType, REFERER_CONDITION_KEY, value); } }
/** * Constructs a new AWS access control policy condition that allows an * access control statement to restrict subscriptions to an Amazon SNS topic * based on the protocol being used for the subscription. For example, this * condition can restrict subscriptions to a topic to endpoints using HTTPS * to ensure that messages are securely delivered. * * @param protocol The protocol against which to compare the requested * protocol for an Amazon SNS topic subscription. * @return A new access control policy condition that compares the * notification protocol requested in a request to subscribe to an * Amazon SNS topic with the protocol value specified. */ public static Condition newProtocolCondition(String protocol) { return new StringCondition(StringComparisonType.StringEquals, PROTOCOL_CONDITION_KEY, protocol); }
/** * Constructs a new access control policy condition that tests the incoming * request's user agent field against the specified value, using the * specified comparison type. This condition can be used to allow or deny * access to a resource based on what user agent is specified in the * request. * * @param comparisonType The type of string comparison to perform when * testing an incoming request's user agent field with the * specified value. * @param value The value against which to compare the incoming request's * user agent. * @return A new access control policy condition that tests an incoming * request's user agent field. */ public static Condition newUserAgentCondition(StringComparisonType comparisonType, String value) { return new StringCondition(comparisonType, USER_AGENT_CONDITION_KEY, value); }
@Test public void testMultipleConditionKeysForConditionType() throws Exception { Policy policy = new Policy(); policy.withStatements(new Statement(Effect.Allow) .withResources(new Resource("arn:aws:sqs:us-east-1:987654321000:MyQueue")) .withPrincipals(Principal.AllUsers) .withActions(new TestAction("foo")) .withConditions( new StringCondition(StringComparisonType.StringNotLike, "key1", "foo"), new StringCondition(StringComparisonType.StringNotLike, "key1", "bar"))); policy = Policy.fromJson(policy.toJson()); assertEquals(1, policy.getStatements().size()); List<Statement> statements = new LinkedList<Statement>(policy.getStatements()); assertEquals(Effect.Allow, statements.get(0).getEffect()); assertEquals(1, statements.get(0).getActions().size()); assertEquals("foo", statements.get(0).getActions().get(0).getActionName()); assertEquals(1, statements.get(0).getConditions().size()); assertEquals("StringNotLike", statements.get(0).getConditions().get(0).getType()); assertEquals("key1", statements.get(0).getConditions().get(0).getConditionKey()); assertEquals(2, statements.get(0).getConditions().get(0).getValues().size()); assertEquals("foo", statements.get(0).getConditions().get(0).getValues().get(0)); assertEquals("bar", statements.get(0).getConditions().get(0).getValues().get(1)); }
/** * Constructs a new access policy condition that compares an Amazon S3 * canned ACL with the canned ACL specified by an incoming request. * <p> * You can use this condition to ensure that any objects uploaded to an * Amazon S3 bucket have a specific canned ACL set. * * @param cannedAcl The Amazon S3 canned ACL to compare against. * @return A new access control policy condition that compares the Amazon S3 * canned ACL specified in incoming requests against the value * specified. */ public static Condition newCannedACLCondition(CannedAccessControlList cannedAcl) { return new StringCondition(StringComparisonType.StringEquals, CANNED_ACL_CONDITION_KEY, cannedAcl.toString()); }