Package org.sonatype.security.rest.model

Examples of org.sonatype.security.rest.model.PrivilegeStatusResourceResponse


  @Override
  @GET
  public PrivilegeStatusResourceResponse get(Context context, Request request, Response response, Variant variant)
      throws ResourceException
  {
    PrivilegeStatusResourceResponse result = new PrivilegeStatusResourceResponse();

    Privilege priv = null;

    try {
      AuthorizationManager authzManager = getSecuritySystem().getAuthorizationManager(PRIVILEGE_SOURCE);
      priv = authzManager.getPrivilege(getPrivilegeId(request));
    }
    catch (NoSuchPrivilegeException e) {
      throw new ResourceException(Status.CLIENT_ERROR_NOT_FOUND, "Privilege could not be found.");
    }
    catch (NoSuchAuthorizationManagerException e) {
      this.getLogger().warn("Could not found AuthorizationManager: " + PRIVILEGE_SOURCE, e);
      // we should not ever get here
      throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, "Authorization Manager for: "
          + PRIVILEGE_SOURCE + " could not be found.");
    }

    result.setData(securityToRestModel(priv, request, false));

    return result;
  }
View Full Code Here


  {
    String responseString = response.getEntity().getText();

    XStreamRepresentation representation = new XStreamRepresentation(xstream, responseString, mediaType);

    PrivilegeStatusResourceResponse resourceResponse =
        (PrivilegeStatusResourceResponse) representation.getPayload(new PrivilegeStatusResourceResponse());

    return resourceResponse.getData();

  }
View Full Code Here

    prop = new PrivilegeProperty();
    prop.setKey(ApplicationPrivilegeMethodPropertyDescriptor.ID);
    prop.setValue("Method1");
    appResource1.addProperty(prop);

    PrivilegeStatusResourceResponse resourceResponse = new PrivilegeStatusResourceResponse();
    resourceResponse.setData(appResource1);

    this.marshalUnmarchalThenCompare(resourceResponse);
    this.validateXmlHasNoPackageNames(resourceResponse);

    PrivilegeStatusResource targetResource1 = new PrivilegeStatusResource();
    targetResource1.setId("Id1");
    targetResource1.setResourceURI("ResourceURI1");
    targetResource1.setName("Name1");
    targetResource1.setDescription("Description1");
    targetResource1.setType(TargetPrivilegeDescriptor.TYPE);

    prop = new PrivilegeProperty();
    prop.setKey(TargetPrivilegeGroupPropertyDescriptor.ID);
    prop.setValue("RepositoryGroupId1");
    targetResource1.addProperty(prop);

    prop = new PrivilegeProperty();
    prop.setKey(TargetPrivilegeRepositoryPropertyDescriptor.ID);
    prop.setValue("RepositoryId1");
    targetResource1.addProperty(prop);

    prop = new PrivilegeProperty();
    prop.setKey(TargetPrivilegeRepositoryTargetPropertyDescriptor.ID);
    prop.setValue("RepositoryTargetId1");
    targetResource1.addProperty(prop);

    prop = new PrivilegeProperty();
    prop.setKey(ApplicationPrivilegeMethodPropertyDescriptor.ID);
    prop.setValue("Method1");
    targetResource1.addProperty(prop);

    resourceResponse = new PrivilegeStatusResourceResponse();
    resourceResponse.setData(targetResource1);

    this.marshalUnmarchalThenCompare(resourceResponse);
    this.validateXmlHasNoPackageNames(resourceResponse);
  }
View Full Code Here

TOP

Related Classes of org.sonatype.security.rest.model.PrivilegeStatusResourceResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.