List of usage examples for java.security Permission toString
public String toString()
From source file:com.thoughtworks.acceptance.SecurityManagerTest.java
protected void runTest() throws Throwable { try {// w w w . j av a 2 s .c om super.runTest(); } catch (Throwable e) { for (final Iterator iter = sm.getFailedPermissions().iterator(); iter.hasNext();) { final Permission permission = (Permission) iter.next(); System.out.println("SecurityException: Permission " + permission.toString()); } throw e; } }
From source file:com.baidubce.services.bos.BosClient.java
/** * Sets the Acl for the specified Bos bucket. * * @param request The request object containing the bucket to modify and the ACL to set. */// w w w .j a v a 2 s . c o m public void setBucketAcl(SetBucketAclRequest request) { checkNotNull(request, "request should not be null."); InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT); internalRequest.addParameter("acl", null); if (request.getCannedAcl() != null) { internalRequest.addHeader(Headers.BCE_ACL, request.getCannedAcl().toString()); this.setZeroContentLength(internalRequest); } else if (request.getAccessControlList() != null) { byte[] json = null; List<Grant> grants = request.getAccessControlList(); StringWriter writer = new StringWriter(); try { JsonGenerator jsonGenerator = JsonUtils.jsonGeneratorOf(writer); jsonGenerator.writeStartObject(); jsonGenerator.writeArrayFieldStart("accessControlList"); for (Grant grant : grants) { jsonGenerator.writeStartObject(); jsonGenerator.writeArrayFieldStart("grantee"); for (Grantee grantee : grant.getGrantee()) { jsonGenerator.writeStartObject(); jsonGenerator.writeStringField("id", grantee.getId()); jsonGenerator.writeEndObject(); } jsonGenerator.writeEndArray(); jsonGenerator.writeArrayFieldStart("permission"); for (Permission permission : grant.getPermission()) { jsonGenerator.writeString(permission.toString()); } jsonGenerator.writeEndArray(); jsonGenerator.writeEndObject(); } jsonGenerator.writeEndArray(); jsonGenerator.writeEndObject(); jsonGenerator.close(); } catch (IOException e) { throw new BceClientException("Fail to generate json", e); } try { json = writer.toString().getBytes(DEFAULT_ENCODING); } catch (UnsupportedEncodingException e) { throw new BceClientException("Fail to get UTF-8 bytes", e); } internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(json.length)); internalRequest.addHeader(Headers.CONTENT_TYPE, "application/json"); internalRequest.setContent(RestartableInputStream.wrap(json)); } else { checkNotNull(null, "request.acl should not be null."); } this.invokeHttpClient(internalRequest, BosResponse.class); }
From source file:org.jboss.dashboard.users.UserStatus.java
/** * Determine if current user has given permission. * * @param perm permission to check//from w w w . ja v a2 s . c o m * @throws SecurityException if permission is denied */ public void checkPermission(Permission perm) throws SecurityException { if (!hasPermission(perm)) throw new SecurityException("Permission denied.\r\n" + "permission=" + perm.toString() + "\r\n"); }