Here are the examples of the java api play.libs.typedmap.TypedKey taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
4 Examples
19
Source : Attrs.java
with MIT License
from project-sunbird
with MIT License
from project-sunbird
public clreplaced Attrs {
public static final TypedKey<String> USER_ID = TypedKey.<String>create(JsonKey.USER_ID);
public static final TypedKey<String> CONTEXT = TypedKey.<String>create(JsonKey.CONTEXT);
public static final TypedKey<String> MANAGED_FOR = TypedKey.<String>create(JsonKey.MANAGED_FOR);
public static final TypedKey<String> START_TIME = TypedKey.<String>create(JsonKey.START_TIME);
public static final TypedKey<String> AUTH_WITH_MASTER_KEY = TypedKey.<String>create(JsonKey.AUTH_WITH_MASTER_KEY);
public static final TypedKey<String> IS_AUTH_REQ = TypedKey.<String>create(JsonKey.IS_AUTH_REQ);
public static final TypedKey<String> X_REQUEST_ID = TypedKey.<String>create(JsonKey.X_REQUEST_ID);
}
19
Source : Attrs.java
with MIT License
from franzgranlund
with MIT License
from franzgranlund
public clreplaced Attrs {
public static final TypedKey<VerifiedJwt> VERIFIED_JWT = TypedKey.<VerifiedJwt>create("verifiedJwt");
}
19
Source : Authorizer.java
with MIT License
from Azure
with MIT License
from Azure
/**
* Handles authorization based on user's role and related allowed actions.
*/
public clreplaced Authorizer extends Results {
public static final TypedKey<List<String>> ALLOWED_ACTIONS_TYPED_KEY = TypedKey.create("allowedActions");
public static final TypedKey<Boolean> AUTH_REQUIRED_TYPED_KEY = TypedKey.create("AuthRequired");
public static final TypedKey<Boolean> EXTERNAL_REQUEST_TYPED_KEY = TypedKey.create("ExternalRequest");
/**
* Retrieves user allowed actions
*
* @param ctx the current request context
* @return a list of allowed actions
*/
public List<String> getAllowedActions(Http.Context ctx) {
return ctx.request().attrs().get(ALLOWED_ACTIONS_TYPED_KEY);
}
/**
* Retrieves the configuration of auth
*
* @param ctx the current request context
* @return a list of allowed actions
*/
public Boolean isAuthRequired(Http.Context ctx) {
return ctx.request().attrs().get(AUTH_REQUIRED_TYPED_KEY);
}
public Boolean isExternalRequest(Http.Context ctx) {
return ctx.request().attrs().get(EXTERNAL_REQUEST_TYPED_KEY);
}
/**
* Generates an alternative result if the user is not Authorize; the default '403 Forbidden'.
*
* @param ctx the current request context
* @return a <code>403 Forbidden</code> result
*/
public Result onUnauthorized(Http.Context ctx, String action) {
return forbidden(Json.toJson(new HashMap<String, String>() {
{
put("Error", String.format("The current user is not allowed to perform this action: `%s`", action));
}
}));
}
}
19
Source : Authorizer.java
with MIT License
from Azure
with MIT License
from Azure
/**
* Handles authorization based on user's role and related allowed actions.
*/
public clreplaced Authorizer extends Results {
public static final TypedKey<List<String>> ALLOWED_ACTIONS_TYPED_KEY = TypedKey.create("allowedActions");
public static final TypedKey<Boolean> AUTH_REQUIRED_TYPED_KEY = TypedKey.create("AuthRequired");
public static final TypedKey<Boolean> EXTERNAL_REQUEST_TYPED_KEY = TypedKey.create("ExternalRequest");
/**
* Retrieves user allowed actions
*
* @param ctx the current request context
* @return a list of allowed actions
*/
public List<String> getAllowedActions(Http.Context ctx) {
return ctx.request().attrs().get(ALLOWED_ACTIONS_TYPED_KEY);
}
/**
* Retrieves the configuration of auth
*
* @param ctx the current request context
* @return a list of allowed actions
*/
public Boolean isAuthRequired(Http.Context ctx) {
return ctx.request().attrs().get(AUTH_REQUIRED_TYPED_KEY);
}
public Boolean isExternalRequest(Http.Context ctx) {
return ctx.request().attrs().get(EXTERNAL_REQUEST_TYPED_KEY);
}
/**
* Generates an alternative result if the user is not Authorize; the default '403 Forbidden'.
*
* @param ctx the current request context
* @return a <code>403 Forbidden</code> result
*/
public Result onUnauthorized(Http.Context ctx, String action) {
return forbidden(String.format("The current user is not allowed to perform this action: `%s`", action));
}
}