~ubuntu-branches/ubuntu/raring/eucalyptus/raring

« back to all changes in this revision

Viewing changes to clc/modules/authentication/src/main/java/com/eucalyptus/auth/policy/key/CurrentTime.java

  • Committer: Package Import Robot
  • Author(s): Brian Thomason
  • Date: 2011-11-29 13:17:52 UTC
  • mfrom: (1.2.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 185.
  • Revision ID: package-import@ubuntu.com-20111129131752-rq31al3ntutv2vvl
Tags: upstream-3.0.999beta1
ImportĀ upstreamĀ versionĀ 3.0.999beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package com.eucalyptus.auth.policy.key;
 
2
 
 
3
import java.util.Date;
 
4
import net.sf.json.JSONException;
 
5
import com.eucalyptus.auth.AuthException;
 
6
import com.eucalyptus.auth.policy.condition.ConditionOp;
 
7
import com.eucalyptus.auth.policy.condition.DateConditionOp;
 
8
 
 
9
@PolicyKey( Keys.AWS_CURRENTTIME )
 
10
public class CurrentTime implements Key {
 
11
  
 
12
  private static final String KEY = Keys.AWS_CURRENTTIME;
 
13
 
 
14
  @Override
 
15
  public String value( ) throws AuthException {
 
16
    return Iso8601DateParser.toString( new Date( ) );
 
17
  }
 
18
 
 
19
  @Override
 
20
  public void validateConditionType( Class<? extends ConditionOp> conditionClass ) throws JSONException {
 
21
    if ( !DateConditionOp.class.isAssignableFrom( conditionClass ) ) {
 
22
      throw new JSONException( KEY + " is not allowed in condition " + conditionClass.getName( ) + ". Date conditions are required." );
 
23
    }
 
24
  }
 
25
 
 
26
  @Override
 
27
  public void validateValueType( String value ) throws JSONException {
 
28
    KeyUtils.validateDateValue( value, KEY );
 
29
  }
 
30
 
 
31
  @Override
 
32
  public boolean canApply( String action, String resourceType ) {
 
33
    return true;
 
34
  }
 
35
  
 
36
}