本文整理汇总了Java中javax.ws.rs.core.HttpHeaders.AUTHORIZATION属性的典型用法代码示例。如果您正苦于以下问题:Java HttpHeaders.AUTHORIZATION属性的具体用法?Java HttpHeaders.AUTHORIZATION怎么用?Java HttpHeaders.AUTHORIZATION使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.ws.rs.core.HttpHeaders
的用法示例。
在下文中一共展示了HttpHeaders.AUTHORIZATION属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: list
/**
* Roleリソースのルート.
* Boxの一覧を返す。
* @param authzHeader Authorization ヘッダ
* @return JAX-RS Response Object
*/
// @Path("")
@GET
public final Response list(
@HeaderParam(HttpHeaders.AUTHORIZATION) final String authzHeader) {
// アクセス制御
this.davRsCmp.checkAccessContext(this.davRsCmp.getAccessContext(), CellPrivilege.AUTH_READ);
EntitiesResponse er = op.getEntities(Box.EDM_TYPE_NAME, null);
List<OEntity> loe = er.getEntities();
List<String> sl = new ArrayList<String>();
sl.add(BOX_PATH_CELL_LEVEL);
for (OEntity oe : loe) {
OProperty<String> nameP = oe.getProperty("Name", String.class);
sl.add(nameP.getValue());
}
StringBuilder sb = new StringBuilder();
for (String s : sl) {
sb.append(s + "<br/>");
}
return Response.ok().entity(sb.toString()).build();
}
示例2: boxRole
/**
* @param boxName boxName
* @param role roleName
* @param authzHeader authzHeader
* @return JAXRS Response
*/
@Path("{box}/{role}")
@GET
public final Response boxRole(
@PathParam("box") String boxName,
@PathParam("role") String role,
@HeaderParam(HttpHeaders.AUTHORIZATION) final String authzHeader) {
// アクセス制御
this.davRsCmp.checkAccessContext(this.davRsCmp.getAccessContext(), CellPrivilege.AUTH_READ);
// BoxパスがCell Levelであれば、Cell レベルロールという扱い。
if (BOX_PATH_CELL_LEVEL.equals(boxName)) {
// TODO Bodyの生成
// EntitiesResponse er = this.op.getEntities(Role.EDM_TYPE_NAME, null);
return Response.ok().entity(boxName).build();
}
return Response.ok().entity(boxName + role).build();
}
示例3: getSupportedOpenShiftClusters
@GET
@Path("/clusters")
@Produces(MediaType.APPLICATION_JSON)
public JsonArray getSupportedOpenShiftClusters(@HeaderParam(HttpHeaders.AUTHORIZATION) final String authorization,
@Context HttpServletRequest request) {
JsonArrayBuilder arrayBuilder = Json.createArrayBuilder();
Set<OpenShiftCluster> clusters = clusterRegistry.getClusters();
if (request.getParameterMap().containsKey("all") || openShiftServiceFactory.getDefaultIdentity().isPresent()) {
// Return all clusters
clusters
.stream()
.map(OpenShiftCluster::getId)
.forEach(arrayBuilder::add);
} else {
final KeycloakService keycloakService = this.keycloakServiceInstance.get();
clusters.parallelStream().map(OpenShiftCluster::getId)
.forEach(clusterId ->
keycloakService.getIdentity(clusterId, authorization)
.ifPresent(token -> arrayBuilder.add(clusterId)));
}
return arrayBuilder.build();
}
示例4: repositoryExists
@HEAD
@Path("/repository/{repo}")
public Response repositoryExists(@HeaderParam(HttpHeaders.AUTHORIZATION) final String authorization,
@NotNull @PathParam("repo") String repository) {
Identity identity = identities.getGitHubIdentity(authorization);
GitHubService gitHubService = gitHubServiceFactory.create(identity);
if (gitHubService.repositoryExists(gitHubService.getLoggedUser().getLogin() + "/" + repository)) {
return Response.ok().build();
} else {
return Response.status(Response.Status.NOT_FOUND).build();
}
}
示例5: openShiftProjectExists
@HEAD
@Path("/project/{project}")
public Response openShiftProjectExists(@HeaderParam(HttpHeaders.AUTHORIZATION) final String authorization,
@NotNull @PathParam("project") String project,
@QueryParam("cluster") String cluster) {
Identity identity = identities.getOpenShiftIdentity(authorization, cluster);
OpenShiftCluster openShiftCluster = clusterRegistry.findClusterById(cluster)
.orElseThrow(() -> new IllegalStateException("Cluster not found"));
OpenShiftService openShiftService = openShiftServiceFactory.create(openShiftCluster, identity);
if (openShiftService.projectExists(project)) {
return Response.ok().build();
} else {
return Response.status(Response.Status.NOT_FOUND).build();
}
}
示例6: openShiftTokenExists
@HEAD
@Path("/token/openshift")
public Response openShiftTokenExists(@HeaderParam(HttpHeaders.AUTHORIZATION) final String authorization,
@QueryParam("cluster") String cluster) {
Identity identity = identities.getOpenShiftIdentity(authorization, cluster);
boolean tokenExists = (identity != null);
if (tokenExists) {
return Response.ok().build();
} else {
return Response.status(Response.Status.NOT_FOUND).build();
}
}
示例7: gitHubTokenExists
@HEAD
@Path("/token/github")
public Response gitHubTokenExists(@HeaderParam(HttpHeaders.AUTHORIZATION) final String authorization) {
Identity identity = identities.getGitHubIdentity(authorization);
boolean tokenExists = (identity != null);
if (tokenExists) {
return Response.ok().build();
} else {
return Response.status(Response.Status.NOT_FOUND).build();
}
}
示例8: authUri
@Path("/auth-uri/{issuer_id}")
@GET
@Produces(MediaType.TEXT_PLAIN)
public URI authUri(@QueryParam("state") final String state,
@PathParam("issuer_id") final String issuerId,
@HeaderParam(HttpHeaders.AUTHORIZATION) final String authorization) {
getRedirectUri(authorization);
return authenticationUriBuilder.build(state, issuerId, authorization, new JwtClaims());
}
示例9: authUriJson
@Path("/auth-info/{issuer_id}")
@GET
@Produces(MediaType.APPLICATION_JSON)
public JsonObject authUriJson(@QueryParam("state") final String state,
@PathParam("issuer_id") final String issuerId,
@HeaderParam(HttpHeaders.AUTHORIZATION) final String authorization) {
final JsonObject uriObject = new JsonObject();
uriObject.addProperty("uri", authUri(state, issuerId, authorization).toASCIIString());
return uriObject;
}
示例10: json
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@ApiResponses(@ApiResponse(code = 401,
message = "Unauthorized Response",
response = ErrorResponse.class))
public Response json(final UsernamePassword usernamePassword,
@HeaderParam(HttpHeaders.AUTHORIZATION) final String authorization) {
if (!"password".equals(usernamePassword.getPassword())) {
throw ErrorResponses.unauthorized(ErrorCodes.UNAUTHORIZED_CLIENT, "invalid username/password combination", "FORM");
}
final JwtClaims claims = new JwtClaims();
claims.setSubject(usernamePassword.getUsername());
claims.setAudience(HttpAuthorizationHeaders.parseBasicAuthorization(authorization)[0]);
final Form form = new Form();
form.param("grant_type", GrantTypes.JWT_ASSERTION);
form.param("assertion", cryptoOps.sign(claims));
return Response.ok(client.target(authorizationEndpoint).request(MediaType.APPLICATION_JSON_TYPE)
.header(HttpHeaders.AUTHORIZATION, authorization)
.post(Entity.form(form), OAuthTokenResponse.class))
.build();
}
示例11: dispatch
/**
* Performs client credential validation then dispatches to the appropriate
* handler for a given grant type.
*/
@POST
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces(MediaType.APPLICATION_JSON)
public OAuthTokenResponse dispatch(
@ApiParam(allowableValues = "refresh_token, authorization_code") @FormParam("grant_type") final String grantType,
@FormParam("code") final String code,
@FormParam("assertion") final String assertion,
@FormParam("aud") final String audience,
@FormParam("refresh_token") final String refreshToken,
@FormParam("jwks_uri") final URI jwksUri,
@HeaderParam(HttpHeaders.AUTHORIZATION) final String authorization) {
final String[] clientCredentials = HttpAuthorizationHeaders.parseBasicAuthorization(authorization);
final String clientId = clientCredentials[0];
if (!clientValidator.isValid(grantType, clientId, clientCredentials[1])) {
throw ErrorResponses.unauthorized(ErrorCodes.UNAUTHORIZED_CLIENT, "Unauthorized client", String.format("Basic realm=\"%s\", encoding=\"UTF-8\"", realmName));
}
if (GrantTypes.REFRESH_TOKEN.equals(grantType)) {
return handleRefreshGrant(refreshToken, clientId);
} else if (GrantTypes.AUTHORIZATION_CODE.equals(grantType)) {
return handleAuthorizationCodeGrant(code);
} else if (GrantTypes.JWT_ASSERTION.equals(grantType)) {
return handleJwtAssertionGrant(assertion, clientId, audience);
} else {
throw ErrorResponses.badRequest(ErrorCodes.UNSUPPORT_GRANT_TYPE, "Invalid grant type");
}
}
示例12: redirectUri
/**
* Obtains the redirect URI that can receive the OpenID token as a fragment. It
* requires that the client supports the openid grant type.
*
* @param authorization
* authorization header
* @return redirect URI
*/
@GET
@Path("/openid-redirect-uri")
@Produces(MediaType.TEXT_PLAIN)
public String redirectUri(@HeaderParam(HttpHeaders.AUTHORIZATION) final String authorization) {
LOG.debug("redirect URI for authorization={}", authorization);
if (!clientValidator.isValid(GrantTypes.OPENID, authorization)) {
throw ErrorResponses.invalidAuthorization();
}
return clientValidator.getRedirectUriFromAuthorization(authorization).toASCIIString();
}
示例13: revoke
/**
* Performs client credential validation then invokes the revocation process
* from the token cache.
*/
@POST
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces(MediaType.APPLICATION_JSON)
public JsonObject revoke(
@FormParam("token") final String token,
@FormParam("token_type_hint") final String tokenTypeHint,
@HeaderParam(HttpHeaders.AUTHORIZATION) final String authorization) {
final String[] clientCredentials = HttpAuthorizationHeaders.parseBasicAuthorization(authorization);
final String clientId = clientCredentials[0];
if (!clientValidator.isValid("revocation", clientId, clientCredentials[1])) {
throw ErrorResponses.unauthorized(ErrorCodes.UNAUTHORIZED_CLIENT, "Unauthorized client", String.format("Basic realm=\"%s\", encoding=\"UTF-8\"", realmName));
}
if (token == null) {
throw ErrorResponses.invalidRequest("Missing token");
}
if (tokenTypeHint != null && !"refresh_token".equals(tokenTypeHint)) {
throw ErrorResponses.badRequest(ErrorCodes.UNSUPPORTED_TOKEN_TYPE, "Token type is not supported");
}
tokenCache.revokeRefreshToken(token, clientId);
LOG.debug("revoked token={}", token);
final JsonObject okReturn = new JsonObject();
okReturn.addProperty("ok", 1);
return okReturn;
}
示例14: getAuthenticationHeader
public AuthenticationHeader getAuthenticationHeader(DestinationConfiguration destinationConfiguration) {
StringBuilder userPass = new StringBuilder();
userPass.append(destinationConfiguration.getProperty(USER_PROPERTY));
userPass.append(SEPARATOR);
userPass.append(destinationConfiguration.getProperty(PASSWORD_PROPERTY));
String encodedPassword = DatatypeConverter.printBase64Binary(userPass.toString().getBytes(StandardCharsets.UTF_8));
return new AuthenticationHeaderImpl(HttpHeaders.AUTHORIZATION, MessageFormat.format(BASIC_AUTHENTICATION_PREFIX, encodedPassword));
}
开发者ID:SAP,项目名称:cloud-c4c-ticket-duplicate-finder-ext,代码行数:8,代码来源:BasicAuthenticationHeaderProvider.java
示例15: cellRole
/**
* Box単位のRoleリソースのルート.
* Boxに紐付いたロール一覧を返す。
* Box名として__を指定されたときは、Cellレベルのロールとみなす。
* @param boxName boxName
* @param authzHeader authzHeader
* @return JAXRS Response
*/
@Path("{box}")
@GET
public final Response cellRole(
@PathParam("box") String boxName,
@HeaderParam(HttpHeaders.AUTHORIZATION) final String authzHeader) {
// アクセス制御
this.davRsCmp.checkAccessContext(this.davRsCmp.getAccessContext(), CellPrivilege.AUTH_READ);
// BoxパスがCell Levelであれば、Cell レベルロールを検索して一覧で返す。
if (BOX_PATH_CELL_LEVEL.equals(boxName)) {
// TODO Bodyの生成
// EntitiesResponse er = this.op.getEntities(Role.EDM_TYPE_NAME, null);
return Response.ok().entity(boxName).build();
}
try {
// EntityResponse boxEr = op.getEntity(Box.EDM_TYPE_NAME, OEntityKey.create(boxName), null);
// EntitiesResponse rolesEr = (EntitiesResponse) op.getNavProperty(Role.EDM_TYPE_NAME,
// OEntityKey.create(boxName),
// "_role", null);
// TODO Bodyの生成
return Response.ok().entity(boxName).build();
} catch (PersoniumCoreException pce) {
if (PersoniumCoreException.OData.NO_SUCH_ENTITY == pce) {
throw PersoniumCoreException.Dav.BOX_NOT_FOUND;
}
throw pce;
}
}