當前位置: 首頁>>代碼示例>>Java>>正文


Java HttpHeaders.AUTHORIZATION屬性代碼示例

本文整理匯總了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();
    }
 
開發者ID:personium,項目名稱:personium-core,代碼行數:26,代碼來源:RoleResource.java

示例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();
    }
 
開發者ID:personium,項目名稱:personium-core,代碼行數:22,代碼來源:RoleResource.java

示例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();
}
 
開發者ID:fabric8-launcher,項目名稱:launcher-backend,代碼行數:23,代碼來源:OpenShiftResource.java

示例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();
    }
}
 
開發者ID:fabric8-launcher,項目名稱:launcher-backend,代碼行數:12,代碼來源:ValidationResource.java

示例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();
    }
}
 
開發者ID:fabric8-launcher,項目名稱:launcher-backend,代碼行數:16,代碼來源:ValidationResource.java

示例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();
    }
}
 
開發者ID:fabric8-launcher,項目名稱:launcher-backend,代碼行數:12,代碼來源:ValidationResource.java

示例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();
    }
}
 
開發者ID:fabric8-launcher,項目名稱:launcher-backend,代碼行數:11,代碼來源:ValidationResource.java

示例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());
}
 
開發者ID:trajano,項目名稱:app-ms,代碼行數:10,代碼來源:OpenIdConnectResource.java

示例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;
}
 
開發者ID:trajano,項目名稱:app-ms,代碼行數:11,代碼來源:OpenIdConnectResource.java

示例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();

}
 
開發者ID:trajano,項目名稱:app-ms,代碼行數:27,代碼來源:AuthnResource.java

示例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");
    }

}
 
開發者ID:trajano,項目名稱:app-ms,代碼行數:35,代碼來源:TokenResource.java

示例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();

}
 
開發者ID:trajano,項目名稱:app-ms,代碼行數:21,代碼來源:ClientCheckResource.java

示例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;

}
 
開發者ID:trajano,項目名稱:app-ms,代碼行數:34,代碼來源:RevocationResource.java

示例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;
        }
    }
 
開發者ID:personium,項目名稱:personium-core,代碼行數:35,代碼來源:RoleResource.java


注:本文中的javax.ws.rs.core.HttpHeaders.AUTHORIZATION屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。