Dataset Viewer
function
stringlengths 87
5.09k
| validationType
stringclasses 2
values | fixed
stringlengths 289
7.12k
|
---|---|---|
@RequiresApi<method*start>android.support.annotation.RequiresApi<method*end>(api<method*start>android.support.annotation.RequiresApi.api<method*end> = Build.VERSION_CODES.M<method*start>android.os.Build.VERSION_CODES.M<method*end>)
public static String<method*start>java.lang.String<method*end>[] checkPermission(Context<method*start>android.content.Context<method*end> context, @NonNull<method*start>android.support.annotation.NonNull<method*end> String... permissions) {
List<method*start>java.util.List<method*end><String> noPermission = new ArrayList<method*start>java.util.ArrayList<method*end><>();
for (String permission : permissions) {
String[] result = new String[noPermission.size<method*start>java.util.List.size<method*end>()];
return noPermission.toArray<method*start>java.util.List.toArray<method*end>(result);
} | annotation | @RequiresApi<method*start>android.support.annotation.RequiresApi<method*end>(api<method*start>android.support.annotation.RequiresApi.api<method*end> = Build.VERSION_CODES.M<method*start>android.os.Build.VERSION_CODES.M<method*end>)
public static String<method*start>java.lang.String<method*end>[] checkPermission(Context<method*start>android.content.Context<method*end> context, @NonNull<method*start>android.support.annotation.NonNull<method*end> String... permissions) {
List<method*start>java.util.List<method*end><String> noPermission = new ArrayList<method*start>java.util.ArrayList<method*end><>();
for (String permission : permissions) {
// 检查该权限是否已经获取
if (!checkPermission(context, permission)) {
noPermission.add<method*start>java.util.List.add<method*end>(permission);
}
}
String[] result = new String[noPermission.size<method*start>java.util.List.size<method*end>()];
return noPermission.toArray<method*start>java.util.List.toArray<method*end>(result);
}
|
public void checkReadPermission(IRI<method*start>org.apache.clerezza.IRI<method*end> GraphUri) {
try {
AccessController.checkPermission<method*start>java.security.AccessController.checkPermission<method*end>(new AllPermission<method*start>java.security.AllPermission<method*end>());
} catch (AccessControlException<method*start>java.security.AccessControlException<method*end> e) {
Collection<method*start>java.util.Collection<method*end><Permission<method*start>java.security.Permission<method*end>> perms = getRequiredReadPermissions<method*start>org.apache.clerezza.dataset.security.TcAccessController.getRequiredReadPermissions<method*end>(GraphUri);
if (perms.size<method*start>java.util.Collection.size<method*end>() > 0) {
for (Permission<method*start>java.security.Permission<method*end> permission : perms) {
AccessController.checkPermission<method*start>java.security.AccessController.checkPermission<method*end>(permission);
}
} else {
AccessController.checkPermission<method*start>java.security.AccessController.checkPermission<method*end>(new TcPermission<method*start>org.apache.clerezza.dataset.security.TcPermission<method*end>(GraphUri.getUnicodeString<method*start>org.apache.clerezza.IRI.getUnicodeString<method*end>(), TcPermission.READ<method*start>org.apache.clerezza.dataset.security.TcPermission.READ<method*end>));
}
}
}
}
| conventional | public void checkReadPermission(IRI<method*start>org.apache.clerezza.IRI<method*end> GraphUri) {
if (GraphUri.equals<method*start>org.apache.clerezza.IRI.equals<method*end>(permissionGraphName)) {
// priviledged during verfification
return;
}
SecurityManager<method*start>java.lang.SecurityManager<method*end> security = System.getSecurityManager<method*start>java.lang.System.getSecurityManager<method*end>();
if (security != null) {
// will AllPermissions the rest is obsolete
try {
AccessController.checkPermission<method*start>java.security.AccessController.checkPermission<method*end>(new AllPermission<method*start>java.security.AllPermission<method*end>());
} catch (AccessControlException<method*start>java.security.AccessControlException<method*end> e) {
Collection<method*start>java.util.Collection<method*end><Permission<method*start>java.security.Permission<method*end>> perms = getRequiredReadPermissions<method*start>org.apache.clerezza.dataset.security.TcAccessController.getRequiredReadPermissions<method*end>(GraphUri);
if (perms.size<method*start>java.util.Collection.size<method*end>() > 0) {
for (Permission<method*start>java.security.Permission<method*end> permission : perms) {
AccessController.checkPermission<method*start>java.security.AccessController.checkPermission<method*end>(permission);
}
} else {
AccessController.checkPermission<method*start>java.security.AccessController.checkPermission<method*end>(new TcPermission<method*start>org.apache.clerezza.dataset.security.TcPermission<method*end>(GraphUri.getUnicodeString<method*start>org.apache.clerezza.IRI.getUnicodeString<method*end>(), TcPermission.READ<method*start>org.apache.clerezza.dataset.security.TcPermission.READ<method*end>));
}
}
}
}
|
private static QuarkusSecurityIdentityio.quarkus.security.runtime.QuarkusSecurityIdentity augmentIdentity(SecurityIdentityio.quarkus.security.identity.SecurityIdentity securityIdentity, Stringjava.lang.String accessToken, Stringjava.lang.String refreshToken, RoutingContextio.vertx.ext.web.RoutingContext context) {
final RefreshTokenio.quarkus.oidc.RefreshToken refreshTokenCredential = new RefreshToken(refreshToken);
return QuarkusSecurityIdentity.builderio.quarkus.security.runtime.QuarkusSecurityIdentity.builder().setPrincipalsecurityIdentity.getPrincipal()).addCredentialssecurityIdentity.getCredentials()).addCredential(new AccessTokenCredential(accessToken, refreshTokenCredential, context)).addCredential(refreshTokenCredential).addRolessecurityIdentity.getRoles()).addAttributessecurityIdentity.getAttributes()).addPermissionChecker(new Functionjava.util.function.Function<Permissionjava.security.Permission,
} | conventional | private static QuarkusSecurityIdentity<method*start>io.quarkus.security.runtime.QuarkusSecurityIdentity<method*end> augmentIdentity(SecurityIdentity<method*start>io.quarkus.security.identity.SecurityIdentity<method*end> securityIdentity, String<method*start>java.lang.String<method*end> accessToken, String<method*start>java.lang.String<method*end> refreshToken, RoutingContext<method*start>io.vertx.ext.web.RoutingContext<method*end> context) {
final RefreshToken<method*start>io.quarkus.oidc.RefreshToken<method*end> refreshTokenCredential = new RefreshToken(refreshToken);
return QuarkusSecurityIdentity.builder<method*start>io.quarkus.security.runtime.QuarkusSecurityIdentity.builder<method*end>().setPrincipal(securityIdentity.getPrincipal<method*start>io.quarkus.security.identity.SecurityIdentity.getPrincipal<method*end>()).addCredentials(securityIdentity.getCredentials<method*start>io.quarkus.security.identity.SecurityIdentity.getCredentials<method*end>()).addCredential(new AccessTokenCredential(accessToken, refreshTokenCredential, context)).addCredential(refreshTokenCredential).addRoles(securityIdentity.getRoles<method*start>io.quarkus.security.identity.SecurityIdentity.getRoles<method*end>()).addAttributes(securityIdentity.getAttributes<method*start>io.quarkus.security.identity.SecurityIdentity.getAttributes<method*end>()).addPermissionChecker(new Function<method*start>java.util.function.Function<method*end><Permission<method*start>java.security.Permission<method*end>, CompletionStage<method*start>java.util.concurrent.CompletionStage<method*end><Boolean<method*start>java.lang.Boolean<method*end>>>() {
@Override<method*start>java.lang.Override<method*end>
public CompletionStage<method*start>java.util.concurrent.CompletionStage<method*end><Boolean<method*start>java.lang.Boolean<method*end>> apply(Permission<method*start>java.security.Permission<method*end> permission) {
return securityIdentity.checkPermission<method*start>io.quarkus.security.identity.SecurityIdentity.checkPermission<method*end>(permission);
}
}).build();
}
|
protected boolean verifyStaticPermission(Principal<method*start>java.security.Principal<method*end> principal, final Permission<method*start>java.security.Permission<method*end> permission) {
Subject<method*start>javax.security.auth.Subject<method*end> subject = new Subject<method*start>javax.security.auth.Subject<method*end>();
subject.getPrincipals<method*start>javax.security.auth.Subject.getPrincipals<method*end>().add<method*start>java.util.Set.add<method*end>(principal);
boolean allowedByGlobalPolicy = ((Boolean<method*start>java.lang.Boolean<method*end>) Subject.doAsPrivileged<method*start>javax.security.auth.Subject.doAsPrivileged<method*end>(subject, new PrivilegedAction<method*start>java.security.PrivilegedAction<method*end><Object<method*start>java.lang.Object<method*end>>() {
public Object<method*start>java.lang.Object<method*end> run() {
(AccessControlException<method*start>java.security.AccessControlException<method*end> e) {
return Boolean.FALSE<method*start>java.lang.Boolean.FALSE<method*end>;
}
}
}, null)).booleanValue<method*start>java.lang.Boolean.booleanValue<method*end>();
// Check local policy
Principal<method*start>java.security.Principal<method*end>[] principals = new Principal<method*start>java.security.Principal<method*end>[] { principal };
return m_engine.getAuthorizationManager<method*start>org.apache.wiki.WikiEngine.getAuthorizationManager<method*end>().allowedByLocalPolicy<method*start>org.apache.wiki.auth.AuthorizationManager.allowedByLocalPolicy<method*end>(principals, permission);
} | conventional | protected boolean verifyStaticPermission(Principal<method*start>java.security.Principal<method*end> principal, final Permission<method*start>java.security.Permission<method*end> permission) {
Subject<method*start>javax.security.auth.Subject<method*end> subject = new Subject<method*start>javax.security.auth.Subject<method*end>();
subject.getPrincipals<method*start>javax.security.auth.Subject.getPrincipals<method*end>().add<method*start>java.util.Set.add<method*end>(principal);
boolean allowedByGlobalPolicy = ((Boolean<method*start>java.lang.Boolean<method*end>) Subject.doAsPrivileged<method*start>javax.security.auth.Subject.doAsPrivileged<method*end>(subject, new PrivilegedAction<method*start>java.security.PrivilegedAction<method*end><Object<method*start>java.lang.Object<method*end>>() {
public Object<method*start>java.lang.Object<method*end> run() {
try {
AccessController.checkPermission<method*start>java.security.AccessController.checkPermission<method*end>(permission);
return Boolean.TRUE<method*start>java.lang.Boolean.TRUE<method*end>;
} catch (AccessControlException<method*start>java.security.AccessControlException<method*end> e) {
return Boolean.FALSE<method*start>java.lang.Boolean.FALSE<method*end>;
}
}
}, null)).booleanValue<method*start>java.lang.Boolean.booleanValue<method*end>();
if (allowedByGlobalPolicy) {
return true;
}
// Check local policy
Principal<method*start>java.security.Principal<method*end>[] principals = new Principal<method*start>java.security.Principal<method*end>[] { principal };
return m_engine.getAuthorizationManager<method*start>org.apache.wiki.WikiEngine.getAuthorizationManager<method*end>().allowedByLocalPolicy<method*start>org.apache.wiki.auth.AuthorizationManager.allowedByLocalPolicy<method*end>(principals, permission);
}
|
private boolean checkPerm(Permission<method*start>java.security.Permission<method*end> p, Class<method*start>java.lang.Class<method*end> caller) {
if (LOG.isLoggable<method*start>java.util.logging.Logger.isLoggable<method*end>(Level.FINE<method*start>java.util.logging.Level.FINE<method*end>)) {
LOG.fine<method*start>java.util.logging.Logger.fine<method*end>("Checked perm for = " + p);
}
try {
if (caller != null) {
ProtectionDomain<method*start>java.security.ProtectionDomain<method*end> pd = this.getCallerProtDomain<method*start>org.glassfish.security.services.common.SecurityAccessValidator.getCallerProtDomain<method*end>(caller);
pd.implies<method*start>java.security.ProtectionDomain.implies<method*end>(p);
} catch (SecurityException<method*start>java.lang.SecurityException<method*end> e) {
LOG.warning<method*start>java.util.logging.Logger.warning<method*end>(localStrings.getLocalString<method*start>com.sun.enterprise.util.LocalStringManagerImpl.getLocalString<method*end>("sec.validate.lookup.deny", "Check Permission failed in lookup for permission = {0}", p));
if (LOG.isLoggable<method*start>java.util.logging.Logger.isLoggable<method*end>(Level.FINE<method*start>java.util.logging.Level.FINE<method*end>)) {
LOG.fine<method*start>java.util.logging.Logger.fine<method*end>("Check Permission failed, perm= " + p + ", message = " + e.getMessage<method*start>java.lang.SecurityException.getMessage<method*end>());
}
throw e;
}
return true;
} | conventional | private boolean checkPerm(Permission<method*start>java.security.Permission<method*end> p, Class<method*start>java.lang.Class<method*end> caller) {
if (LOG.isLoggable<method*start>java.util.logging.Logger.isLoggable<method*end>(Level.FINE<method*start>java.util.logging.Level.FINE<method*end>)) {
LOG.fine<method*start>java.util.logging.Logger.fine<method*end>("Checked perm for = " + p);
}
try {
if (caller != null) {
ProtectionDomain<method*start>java.security.ProtectionDomain<method*end> pd = this.getCallerProtDomain<method*start>org.glassfish.security.services.common.SecurityAccessValidator.getCallerProtDomain<method*end>(caller);
pd.implies<method*start>java.security.ProtectionDomain.implies<method*end>(p);
} else
AccessController.checkPermission<method*start>java.security.AccessController.checkPermission<method*end>(p);
} catch (SecurityException<method*start>java.lang.SecurityException<method*end> e) {
LOG.warning<method*start>java.util.logging.Logger.warning<method*end>(localStrings.getLocalString<method*start>com.sun.enterprise.util.LocalStringManagerImpl.getLocalString<method*end>("sec.validate.lookup.deny", "Check Permission failed in lookup for permission = {0}", p));
if (LOG.isLoggable<method*start>java.util.logging.Logger.isLoggable<method*end>(Level.FINE<method*start>java.util.logging.Level.FINE<method*end>)) {
LOG.fine<method*start>java.util.logging.Logger.fine<method*end>("Check Permission failed, perm= " + p + ", message = " + e.getMessage<method*start>java.lang.SecurityException.getMessage<method*end>());
}
throw e;
}
return true;
}
|
public static void forbidExit() {
final SecurityManager<method*start>java.lang.SecurityManager<method*end> securityManager = new SecurityManager<method*start>java.lang.SecurityManager<method*end>() {
System<method*start>java.lang.System<method*end>.setSecurityManager(securityManager);
} | annotation | public static void forbidExit() {
final SecurityManager<method*start>java.lang.SecurityManager<method*end> securityManager = new SecurityManager<method*start>java.lang.SecurityManager<method*end>() {
@Override
public void checkPermission(Permission<method*start>java.security.Permission<method*end> permission) {
if (permission.getName().contains("exitVM")) {
throw new ExitTrappedException();
}
}
};
System<method*start>java.lang.System<method*end>.setSecurityManager(securityManager);
}
|
@Override<method*start>java.lang.Override<method*end>
public void onClick(View<method*start>android.view.View<method*end> v) {
view<method*start>com.journaldev.runtimepermissions.MainActivity.view<method*end> = v;
int id = v.getId<method*start>android.view.View.getId<method*end>();
switch(id) {
case R.id.check_permission<method*start>org.scalacheck.Gen.R.id.check_permission<method*end>:
Snackbar.make<method*start>android.support.design.widget.Snackbar.make<method*end>(view, "Permission already granted.", Snackbar.LENGTH_LONG<method*start>android.support.design.widget.Snackbar.LENGTH_LONG<method*end>).show<method*start>android.support.design.widget.Snackbar.show<method*end>();
} else {
Snackbar.make<method*start>android.support.design.widget.Snackbar.make<method*end>(view, "Please request permission.", Snackbar.LENGTH_LONG<method*start>android.support.design.widget.Snackbar.LENGTH_LONG<method*end>).show<method*start>android.support.design.widget.Snackbar.show<method*end>();
}
break;
case R.id.request_permission<method*start>org.scalacheck.Gen.R.id.request_permission<method*end>:
requestPermission<method*start>com.journaldev.runtimepermissions.MainActivity.requestPermission<method*end>();
} else {
Snackbar.make<method*start>android.support.design.widget.Snackbar.make<method*end>(view, "Permission already granted.", Snackbar.LENGTH_LONG<method*start>android.support.design.widget.Snackbar.LENGTH_LONG<method*end>).show<method*start>android.support.design.widget.Snackbar.show<method*end>();
}
break;
}
}
| annotation | @Override<method*start>java.lang.Override<method*end>
public void onClick(View<method*start>android.view.View<method*end> v) {
view<method*start>com.journaldev.runtimepermissions.MainActivity.view<method*end> = v;
int id = v.getId<method*start>android.view.View.getId<method*end>();
switch(id) {
case R.id.check_permission<method*start>org.scalacheck.Gen.R.id.check_permission<method*end>:
if (checkPermission<method*start>com.journaldev.runtimepermissions.MainActivity.checkPermission<method*end>()) {
Snackbar.make<method*start>android.support.design.widget.Snackbar.make<method*end>(view, "Permission already granted.", Snackbar.LENGTH_LONG<method*start>android.support.design.widget.Snackbar.LENGTH_LONG<method*end>).show<method*start>android.support.design.widget.Snackbar.show<method*end>();
} else {
Snackbar.make<method*start>android.support.design.widget.Snackbar.make<method*end>(view, "Please request permission.", Snackbar.LENGTH_LONG<method*start>android.support.design.widget.Snackbar.LENGTH_LONG<method*end>).show<method*start>android.support.design.widget.Snackbar.show<method*end>();
}
break;
case R.id.request_permission<method*start>org.scalacheck.Gen.R.id.request_permission<method*end>:
if (!checkPermission<method*start>com.journaldev.runtimepermissions.MainActivity.checkPermission<method*end>()) {
requestPermission<method*start>com.journaldev.runtimepermissions.MainActivity.requestPermission<method*end>();
} else {
Snackbar.make<method*start>android.support.design.widget.Snackbar.make<method*end>(view, "Permission already granted.", Snackbar.LENGTH_LONG<method*start>android.support.design.widget.Snackbar.LENGTH_LONG<method*end>).show<method*start>android.support.design.widget.Snackbar.show<method*end>();
}
break;
}
}
|
@SuppressWarnings("fallthrough")
private void cd(String path) throws URI.MalformedURIException, RemoteException, SRMException, InterruptedException {
if (!path.endsWith("/")) {
path = path + "/";
}
URI uri = new URI(pwd, path);
checkValidPath(fs.stat(uri).getType() == TFileType.DIRECTORY, "Not a directory");
pwd = uri;
} | annotation | @SuppressWarnings("fallthrough")
private void cd(String<method*start>java.lang.String<method*end> path) throws URI.MalformedURIException<method*start>org.apache.axis.types.URI.MalformedURIException<method*end>, RemoteException<method*start>java.rmi.RemoteException<method*end>, SRMException<method*start>org.dcache.srm.SRMException<method*end>, InterruptedException<method*start>java.lang.InterruptedException<method*end> {
if (!path.endsWith<method*start>java.lang.String.endsWith<method*end>("/")) {
path = path + "/";
}
URI<method*start>org.apache.axis.types.URI<method*end> uri = new URI<method*start>org.apache.axis.types.URI<method*end>(pwd, path);
checkValidPath<method*start>org.dcache.srm.SRMInvalidPathException.checkValidPath<method*end>(fs.stat<method*start>org.dcache.srm.shell.SrmFileSystem.stat<method*end>(uri).getType<method*start>org.dcache.srm.v2_2.TMetaDataPathDetail.getType<method*end>() == TFileType.DIRECTORY<method*start>org.dcache.srm.v2_2.TFileType.DIRECTORY<method*end>, "Not a directory");
switch(checkCdPermission) {
case SRM_CHECK_PERMISSION:
try {
TPermissionMode<method*start>org.dcache.srm.v2_2.TPermissionMode<method*end> permission = fs.checkPermission<method*start>org.dcache.srm.shell.SrmFileSystem.checkPermission<method*end>(uri);
if (permission != TPermissionMode.RWX<method*start>org.dcache.srm.v2_2.TPermissionMode.RWX<method*end> && permission != TPermissionMode.RX<method*start>org.dcache.srm.v2_2.TPermissionMode.RX<method*end> && permission != TPermissionMode.WX<method*start>org.dcache.srm.v2_2.TPermissionMode.WX<method*end> && permission != TPermissionMode.X<method*start>org.dcache.srm.v2_2.TPermissionMode.X<method*end>) {
throw new SRMAuthorizationException<method*start>org.dcache.srm.SRMAuthorizationException<method*end>("Access denied");
}
break;
} catch (SRMNotSupportedException<method*start>org.dcache.srm.SRMNotSupportedException<method*end> e) {
/* StoRM does not support checkPermission:
*
* https://ggus.eu/index.php?mode=ticket_info&ticket_id=124634
*/
notifications.add<method*start>java.util.List.add<method*end>("The CheckPermission operation is not supported, using directory listing instead.");
checkCdPermission = PermissionOperation.SRM_LS<method*start>org.dcache.srm.shell.SrmShell.PermissionOperation.SRM_LS<method*end>;
// fall-through: use srmLs
}
case SRM_LS:
fs.list<method*start>org.dcache.srm.shell.SrmFileSystem.list<method*end>(uri, false);
}
pwd = uri;
}
|
void checkPackageList(String packageName, final String restriction, String permission) {
if (packageName == null)
throw new NullPointerException();
String list = (String) AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
return Security.getProperty(restriction);
}
});
if (list == null || list.equals(""))
return;
String packageNamePlusDot = packageName + ".";
StringTokenizer st = new StringTokenizer(list, ",");
while (st.hasMoreTokens()) {
if (packageNamePlusDot.startsWith(st.nextToken())) {
return;
}
}
} | conventional | void checkPackageList(String<method*start>java.lang.String<method*end> packageName, final String<method*start>java.lang.String<method*end> restriction, String<method*start>java.lang.String<method*end> permission) {
if (packageName == null)
throw new NullPointerException<method*start>java.lang.NullPointerException<method*end>();
String<method*start>java.lang.String<method*end> list = (String<method*start>java.lang.String<method*end>) AccessController.doPrivileged<method*start>java.security.AccessController.doPrivileged<method*end>(new PrivilegedAction<method*start>java.security.PrivilegedAction<method*end>() {
public Object<method*start>java.lang.Object<method*end> run() {
return Security.getProperty<method*start>java.security.Security.getProperty<method*end>(restriction);
}
});
if (list == null || list.equals<method*start>java.lang.String.equals<method*end>(""))
return;
String<method*start>java.lang.String<method*end> packageNamePlusDot = packageName + ".";
StringTokenizer<method*start>java.util.StringTokenizer<method*end> st = new StringTokenizer<method*start>java.util.StringTokenizer<method*end>(list, ",");
while (st.hasMoreTokens<method*start>java.util.StringTokenizer.hasMoreTokens<method*end>()) {
if (packageNamePlusDot.startsWith<method*start>java.lang.String.startsWith<method*end>(st.nextToken<method*start>java.util.StringTokenizer.nextToken<method*end>())) {
Permission<method*start>java.security.Permission<method*end> p = new RuntimePermission(permission + packageName);
checkPermission(p);
return;
}
}
}
|
private static void checkMemberAccess(final Class<method*start>java.lang.Class<method*end><?> theClass, final Member<method*start>java.lang.reflect.Member<method*end> theMember) {
if (theMember == null || Modifier.isPublic<method*start>java.lang.reflect.Modifier.isPublic<method*end>(theMember.getModifiers<method*start>java.lang.reflect.Member.getModifiers<method*end>())) {
return;
}
final SecurityManager<method*start>java.lang.SecurityManager<method*end> s = System.getSecurityManager<method*start>java.lang.System.getSecurityManager<method*end>();
if (s == null) {
return;
}
if (AccessController.doPrivileged<method*start>java.security.AccessController.doPrivileged<method*end>(new PrivilegedAction<method*start>java.security.PrivilegedAction<method*end><Boolean<method*start>java.lang.Boolean<method*end>>() {
public Boolean<method*start>java.lang.Boolean<method*end> run() {
return ReflectionUtils<method*start>com.aliyun.odps.utils.ReflectionUtils<method*end>.class.getClassLoader<method*start>java.lang.Class.getClassLoader<method*end>() == theClass.getClassLoader<method*start>java.lang.Class.getClassLoader<method*end>().getParent<method*start>java.lang.ClassLoader.getParent<method*end>();
}
})) {
return;
}
} | conventional | private static void checkMemberAccess(final Class<method*start>java.lang.Class<method*end><?> theClass, final Member<method*start>java.lang.reflect.Member<method*end> theMember) {
// 1) bypass the permission check when theMember is public or null.
if (theMember == null || Modifier.isPublic<method*start>java.lang.reflect.Modifier.isPublic<method*end>(theMember.getModifiers<method*start>java.lang.reflect.Member.getModifiers<method*end>())) {
return;
}
// 2) bypass the permission check when not in a security mode
final SecurityManager<method*start>java.lang.SecurityManager<method*end> s = System.getSecurityManager<method*start>java.lang.System.getSecurityManager<method*end>();
if (s == null) {
return;
}
// 3) bypass the permission check when theClass is an user defined class.
if (AccessController.doPrivileged<method*start>java.security.AccessController.doPrivileged<method*end>(new PrivilegedAction<method*start>java.security.PrivilegedAction<method*end><Boolean<method*start>java.lang.Boolean<method*end>>() {
public Boolean<method*start>java.lang.Boolean<method*end> run() {
return ReflectionUtils<method*start>com.aliyun.odps.utils.ReflectionUtils<method*end>.class.getClassLoader<method*start>java.lang.Class.getClassLoader<method*end>() == theClass.getClassLoader<method*start>java.lang.Class.getClassLoader<method*end>().getParent<method*start>java.lang.ClassLoader.getParent<method*end>();
}
})) {
return;
}
// do permission check on other conditions!!!
s.checkPermission<method*start>java.lang.SecurityManager.checkPermission<method*end>(SecurityConstants.CHECK_MEMBER_ACCESS_PERMISSION<method*start>sun.security.util.SecurityConstants.CHECK_MEMBER_ACCESS_PERMISSION<method*end>);
s.checkPermission<method*start>java.lang.SecurityManager.checkPermission<method*end>(new ReflectPermission<method*start>java.lang.reflect.ReflectPermission<method*end>("suppressAccessChecks"));
// this.checkPackageAccess(ccl, checkProxyInterfaces);
}
|
@Override
public void checkCurrentUserPermissions(final List<method*start>java.util.List<method*end><Permission<method*start>org.killbill.billing.security.Permission<method*end>> permissions, final Logical<method*start>org.killbill.billing.security.Logical<method*end> logical, final TenantContext<method*start>org.killbill.billing.util.callcontext.TenantContext<method*end> context) throws SecurityApiException<method*start>org.killbill.billing.security.SecurityApiException<method*end> {
final String<method*start>java.lang.String<method*end>[] permissionsString = Lists<method*start>com.google.common.collect.Lists<method*end>.<Permission<method*start>org.killbill.billing.security.Permission<method*end>, String<method*start>java.lang.String<method*end>>transform(permissions, Functions<method*start>com.google.common.base.Functions<method*end>.toStringFunction()).toArray(new String<method*start>java.lang.String<method*end>[permissions.size()]);
try {
final Subject<method*start>org.apache.shiro.subject.Subject<method*end> subject = SecurityUtils<method*start>org.apache.shiro.SecurityUtils<method*end>.getSubject();
(Logical<method*start>org.killbill.billing.security.Logical<method*end>.OR.equals(logical)) {
boolean hasAtLeastOnePermission = false;
} catch (final AuthorizationException<method*start>org.apache.shiro.authz.AuthorizationException<method*end> e) {
throw new SecurityApiException<method*start>org.killbill.billing.security.SecurityApiException<method*end>(e, ErrorCode<method*start>org.killbill.billing.ErrorCode<method*end>.SECURITY_NOT_ENOUGH_PERMISSIONS);
}
} | annotation | @Override
public void checkCurrentUserPermissions(final List<method*start>java.util.List<method*end><Permission<method*start>org.killbill.billing.security.Permission<method*end>> permissions, final Logical<method*start>org.killbill.billing.security.Logical<method*end> logical, final TenantContext<method*start>org.killbill.billing.util.callcontext.TenantContext<method*end> context) throws SecurityApiException<method*start>org.killbill.billing.security.SecurityApiException<method*end> {
final String<method*start>java.lang.String<method*end>[] permissionsString = Lists<method*start>com.google.common.collect.Lists<method*end>.<Permission<method*start>org.killbill.billing.security.Permission<method*end>, String<method*start>java.lang.String<method*end>>transform(permissions, Functions<method*start>com.google.common.base.Functions<method*end>.toStringFunction()).toArray(new String<method*start>java.lang.String<method*end>[permissions.size()]);
try {
final Subject<method*start>org.apache.shiro.subject.Subject<method*end> subject = SecurityUtils<method*start>org.apache.shiro.SecurityUtils<method*end>.getSubject();
if (permissionsString.length == 1) {
subject.checkPermission(permissionsString[0]);
} else if (Logical<method*start>org.killbill.billing.security.Logical<method*end>.AND.equals(logical)) {
subject.checkPermissions(permissionsString);
} else if (Logical<method*start>org.killbill.billing.security.Logical<method*end>.OR.equals(logical)) {
boolean hasAtLeastOnePermission = false;
for (final String<method*start>java.lang.String<method*end> permission : permissionsString) {
if (subject.isPermitted(permission)) {
hasAtLeastOnePermission = true;
break;
}
}
// Cause the exception if none match
if (!hasAtLeastOnePermission) {
subject.checkPermission(permissionsString[0]);
}
}
} catch (final AuthorizationException<method*start>org.apache.shiro.authz.AuthorizationException<method*end> e) {
throw new SecurityApiException<method*start>org.killbill.billing.security.SecurityApiException<method*end>(e, ErrorCode<method*start>org.killbill.billing.ErrorCode<method*end>.SECURITY_NOT_ENOUGH_PERMISSIONS);
}
}
|
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
// 请求的路径
String contextPath = request.getServletPath();
String url = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getServletPath();
if (request.getQueryString() != null) {
url += "?" + request.getQueryString();
}
Admin admin = AdminSessionUtils.getLoginMember(request);
if (null != admin || isLoginRequest(request, response)) {
List<Permission> permissions = permissionService.findPermissionByUserId(admin.getId());
for (Permission permission : permissions) {
}
response.sendRedirect("/403");
return Boolean.FALSE;
}
Map<String, String> resultMap = new HashMap<String, String>();
logger.debug("当前用户没有登录,并且是Ajax请求!", getClass());
resultMap.put("login_status", "300");
resultMap.put("message", "当前用户权限不足或者没有登录,请联系管理员!");
FilterUtils.out(response, resultMap);
return Boolean.FALSE;
} else {
if (!"".equals(url) && url != null) {
response.sendRedirect("/system/login?redirectUrl=" + URLEncoder.encode(url, "UTF-8"));
return Boolean.FALSE;
}
}
response.sendRedirect("/system/login");
return Boolean.FALSE;
} | conventional | public boolean preHandle(HttpServletRequest<method*start>javax.servlet.http.HttpServletRequest<method*end> request, HttpServletResponse<method*start>javax.servlet.http.HttpServletResponse<method*end> response, Object<method*start>java.lang.Object<method*end> handler) throws Exception<method*start>java.lang.Exception<method*end> {
// 请求的路径
String<method*start>java.lang.String<method*end> contextPath = request.getServletPath<method*start>javax.servlet.http.HttpServletRequest.getServletPath<method*end>();
String<method*start>java.lang.String<method*end> url = request.getScheme<method*start>javax.servlet.http.HttpServletRequest.getScheme<method*end>() + "://" + request.getServerName<method*start>javax.servlet.http.HttpServletRequest.getServerName<method*end>() + ":" + request.getServerPort<method*start>javax.servlet.http.HttpServletRequest.getServerPort<method*end>() + request.getServletPath<method*start>javax.servlet.http.HttpServletRequest.getServletPath<method*end>();
if (request.getQueryString<method*start>javax.servlet.http.HttpServletRequest.getQueryString<method*end>() != null) {
url += "?" + request.getQueryString<method*start>javax.servlet.http.HttpServletRequest.getQueryString<method*end>();
}
Admin<method*start>com.flycms.module.admin.model.Admin<method*end> admin = AdminSessionUtils.getLoginMember<method*start>com.flycms.core.utils.AdminSessionUtils.getLoginMember<method*end>(request);
// 这里可以根据session的用户来判断角色的权限,根据权限来重定向不同的页面
if (null != admin || isLoginRequest<method*start>com.flycms.interceptor.AdminInterceptor.isLoginRequest<method*end>(request, response)) {
// && isEnabled()
List<method*start>java.util.List<method*end><Permission<method*start>com.flycms.module.admin.model.Permission<method*end>> permissions = permissionService.findPermissionByUserId<method*start>com.flycms.module.admin.service.PermissionService.findPermissionByUserId<method*end>(admin.getId<method*start>com.flycms.module.admin.model.Admin.getId<method*end>());
for (Permission<method*start>com.flycms.module.admin.model.Permission<method*end> permission : permissions) {
if (CheckUrlUtils.match<method*start>com.flycms.core.utils.CheckUrlUtils.match<method*end>(permission.getActionKey<method*start>com.flycms.module.admin.model.Permission.getActionKey<method*end>(), contextPath)) {
return Boolean.TRUE<method*start>java.lang.Boolean.TRUE<method*end>;
}
}
// 没有权限情况下转到无权限403页面
response.sendRedirect<method*start>javax.servlet.http.HttpServletResponse.sendRedirect<method*end>("/403");
return Boolean.FALSE<method*start>java.lang.Boolean.FALSE<method*end>;
}
// ajax请求
if (FilterUtils.isAjax<method*start>com.flycms.core.utils.FilterUtils.isAjax<method*end>(request)) {
Map<method*start>java.util.Map<method*end><String<method*start>java.lang.String<method*end>, String<method*start>java.lang.String<method*end>> resultMap = new HashMap<method*start>java.util.HashMap<method*end><String<method*start>java.lang.String<method*end>, String<method*start>java.lang.String<method*end>>();
logger.debug<method*start>org.slf4j.Logger.debug<method*end>("当前用户没有登录,并且是Ajax请求!", getClass<method*start>com.flycms.interceptor.AdminInterceptor.getClass<method*end>());
resultMap.put<method*start>java.util.Map.put<method*end>("login_status", "300");
// 当前用户没有登录!
resultMap.put<method*start>java.util.Map.put<method*end>("message", "\u5F53\u524D\u7528\u6237\u6743\u9650\u4E0D\u8DB3\u6216\u8005\u6CA1\u6709\u767B\u5F55\uFF0C\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458\uFF01");
FilterUtils.out<method*start>com.flycms.core.utils.FilterUtils.out<method*end>(response, resultMap);
return Boolean.FALSE<method*start>java.lang.Boolean.FALSE<method*end>;
} else {
if (!"".equals<method*start>java.lang.String.equals<method*end>(url) && url != null) {
response.sendRedirect<method*start>javax.servlet.http.HttpServletResponse.sendRedirect<method*end>("/system/login?redirectUrl=" + URLEncoder.encode<method*start>java.net.URLEncoder.encode<method*end>(url, "UTF-8"));
return Boolean.FALSE<method*start>java.lang.Boolean.FALSE<method*end>;
}
}
// 未登录状态下返回到登录页面
response.sendRedirect<method*start>javax.servlet.http.HttpServletResponse.sendRedirect<method*end>("/system/login");
return Boolean.FALSE<method*start>java.lang.Boolean.FALSE<method*end>;
}
|
public static Token<method*start>org.wf.jwtp.provider.Token<method*end> parseToken(HttpServletRequest<method*start>javax.servlet.http.HttpServletRequest<method*end> request, TokenStore<method*start>org.wf.jwtp.provider.TokenStore<method*end> tokenStore) {
Token<method*start>org.wf.jwtp.provider.Token<method*end> token = getToken<method*start>org.wf.jwtp.util.SubjectUtil.getToken<method*end>(request);
try {
String<method*start>java.lang.String<method*end> tokenKey = tokenStore.getTokenKey<method*start>org.wf.jwtp.provider.TokenStore.getTokenKey<method*end>();
String<method*start>java.lang.String<method*end> userId = TokenUtil.parseToken<method*start>org.wf.jwtp.util.TokenUtil.parseToken<method*end>(access_token, tokenKey);
token = tokenStore.findToken<method*start>org.wf.jwtp.provider.TokenStore.findToken<method*end>(userId, access_token);
token.setRoles<method*start>org.wf.jwtp.provider.Token.setRoles<method*end>(tokenStore.findRolesByUserId<method*start>org.wf.jwtp.provider.TokenStore.findRolesByUserId<method*end>(userId, token));
token.setPermissions<method*start>org.wf.jwtp.provider.Token.setPermissions<method*end>(tokenStore.findPermissionsByUserId<method*start>org.wf.jwtp.provider.TokenStore.findPermissionsByUserId<method*end>(userId, token));
}
} catch (ExpiredJwtException<method*start>io.jsonwebtoken.ExpiredJwtException<method*end> e) {
System.out.println<method*start>java.io.PrintStream.println<method*end>("token已过期");
} catch (Exception<method*start>java.lang.Exception<method*end> e) {
System.out.println<method*start>java.io.PrintStream.println<method*end>(e.getMessage<method*start>java.lang.Exception.getMessage<method*end>());
}
}
}
return token;
} | conventional | public static Token<method*start>org.wf.jwtp.provider.Token<method*end> parseToken(HttpServletRequest<method*start>javax.servlet.http.HttpServletRequest<method*end> request, TokenStore<method*start>org.wf.jwtp.provider.TokenStore<method*end> tokenStore) {
Token<method*start>org.wf.jwtp.provider.Token<method*end> token = getToken<method*start>org.wf.jwtp.util.SubjectUtil.getToken<method*end>(request);
if (token == null && tokenStore != null) {
// 获取token
String<method*start>java.lang.String<method*end> access_token = CheckPermissionUtil.takeToken<method*start>org.wf.jwtp.util.CheckPermissionUtil.takeToken<method*end>(request);
if (access_token != null && !access_token.trim<method*start>java.lang.String.trim<method*end>().isEmpty<method*start>java.lang.String.isEmpty<method*end>()) {
try {
String<method*start>java.lang.String<method*end> tokenKey = tokenStore.getTokenKey<method*start>org.wf.jwtp.provider.TokenStore.getTokenKey<method*end>();
String<method*start>java.lang.String<method*end> userId = TokenUtil.parseToken<method*start>org.wf.jwtp.util.TokenUtil.parseToken<method*end>(access_token, tokenKey);
// 检查token是否存在系统中
token = tokenStore.findToken<method*start>org.wf.jwtp.provider.TokenStore.findToken<method*end>(userId, access_token);
if (token != null) {
// 查询用户的角色和权限
token.setRoles<method*start>org.wf.jwtp.provider.Token.setRoles<method*end>(tokenStore.findRolesByUserId<method*start>org.wf.jwtp.provider.TokenStore.findRolesByUserId<method*end>(userId, token));
token.setPermissions<method*start>org.wf.jwtp.provider.Token.setPermissions<method*end>(tokenStore.findPermissionsByUserId<method*start>org.wf.jwtp.provider.TokenStore.findPermissionsByUserId<method*end>(userId, token));
}
} catch (ExpiredJwtException<method*start>io.jsonwebtoken.ExpiredJwtException<method*end> e) {
System.out.println<method*start>java.io.PrintStream.println<method*end>("token已过期");
} catch (Exception<method*start>java.lang.Exception<method*end> e) {
System.out.println<method*start>java.io.PrintStream.println<method*end>(e.getMessage<method*start>java.lang.Exception.getMessage<method*end>());
}
}
}
return token;
}
|
@Override<method*start>java.lang.Override<method*end>
@CallerSensitive<method*start>jdk.internal.reflect.CallerSensitive<method*end>
public void setAccessible(boolean flag) {
// 如果需要开启访问权限
// 获取setAccessible()的调用者所处的类
Class<method*start>java.lang.Class<method*end><?> caller = Reflection.getCallerClass<method*start>jdk.internal.reflect.Reflection.getCallerClass<method*end>();
// 判断caller是否可以访问当前元素(涉及到exports和opens的判断)
checkCanSetAccessible<method*start>java.lang.reflect.Constructor.checkCanSetAccessible<method*end>(caller);
setAccessible0<method*start>java.lang.reflect.AccessibleObject.setAccessible0<method*end>(flag);
}
}
| annotation | @Override<method*start>java.lang.Override<method*end>
@CallerSensitive<method*start>jdk.internal.reflect.CallerSensitive<method*end>
public void setAccessible(boolean flag) {
AccessibleObject.checkPermission<method*start>java.lang.reflect.AccessibleObject.checkPermission<method*end>();
// 如果需要开启访问权限
if (flag) {
// 获取setAccessible()的调用者所处的类
Class<method*start>java.lang.Class<method*end><?> caller = Reflection.getCallerClass<method*start>jdk.internal.reflect.Reflection.getCallerClass<method*end>();
// 判断caller是否可以访问当前元素(涉及到exports和opens的判断)
checkCanSetAccessible<method*start>java.lang.reflect.Constructor.checkCanSetAccessible<method*end>(caller);
}
setAccessible0<method*start>java.lang.reflect.AccessibleObject.setAccessible0<method*end>(flag);
}
|
private st<method*start>java.lang.Class<method*end>atic void checkProxyAcc<method*start>java.lang.ClassLoader<method*end>ess(Class<?> c<method*start>java.lang.Class<method*end>aller, ClassLoader loader, Class<?>... inter<method*start>java.lang.SecurityManager<method*end>faces) {
retur<method*start>java.lang.ClassLoader<method*end>n;
ClassLo<method*start>java.lang.Class.getClassLoader<method*end>ader ccl = caller.getClassLoader();
// 检查ccl(加载的类)对代理接口int<method*start>sun.reflect.misc.ReflectUtil<method*end>erfaces的访问权限
ReflectUtil.checkProxyPackageAccess(ccl, interfaces);
} | conventional | private st<method*start>java.lang.Class<method*end>atic void checkProxyAcc<method*start>java.lang.ClassLoader<method*end>ess(Class<?> c<method*start>java.lang.Class<method*end>aller, ClassLoader loader, Class<?>... inter<method*start>java.lang.SecurityManager<method*end>faces) {
SecurityManage<method*start>java.lang.System.getSecurityManager<method*end>r sm = System.getSecurityManager();
if (sm == null) {
retur<method*start>java.lang.ClassLoader<method*end>n;
}
ClassLo<method*start>java.lang.Class.getClassLoader<method*end>ader ccl = caller.getClassLoader();
if (loader == null && ccl != null) <method*start>java.lang.SecurityManager.checkPermission<method*end>{
sm.checkPermission(SecurityCons<method*start>sun.security.util.SecurityConstants.GET_CLASSLOADER_PERMISSION<method*end>tants.GET_CLASSLOADER_PERMISSION);
}
// 检查ccl(加载的类)对代理接口int<method*start>sun.reflect.misc.ReflectUtil<method*end>erfaces的访问权限
ReflectUtil.checkProxyPackageAccess(ccl, interfaces);
}
|
@WrapInTransaction
@Override
public FieldVariable<method*start>com.dotcms.contenttype.model.field.FieldVariable<method*end> save(final FieldVariable<method*start>com.dotcms.contenttype.model.field.FieldVariable<method*end> var, final User<method*start>com.liferay.portal.model.User<method*end> user) throws DotDataException<method*start>com.dotmarketing.exception.DotDataException<method*end>, DotSecurityException<method*start>com.dotmarketing.exception.DotSecurityException<method*end> {
ContentTypeAPI<method*start>com.dotcms.contenttype.business.ContentTypeAPI<method*end> contentTypeAPI = APILocator.getContentTypeAPI<method*start>com.dotmarketing.business.APILocator.getContentTypeAPI<method*end>(user);
Field<method*start>com.dotcms.contenttype.model.field.Field<method*end> field = fieldFactory.byId<method*start>com.dotcms.contenttype.business.FieldFactory.byId<method*end>(var.fieldId<method*start>com.dotcms.contenttype.model.field.FieldVariable.fieldId<method*end>());
ContentType<method*start>com.dotcms.contenttype.model.type.ContentType<method*end> type = contentTypeAPI.find<method*start>com.dotcms.contenttype.business.ContentTypeAPI.find<method*end>(field.contentTypeId<method*start>com.dotcms.contenttype.model.field.Field.contentTypeId<method*end>());
FieldVariable<method*start>com.dotcms.contenttype.model.field.FieldVariable<method*end> newFieldVariable = fieldFactory.save<method*start>com.dotcms.contenttype.business.FieldFactory.save<method*end>(ImmutableFieldVariable.builder<method*start>com.dotcms.contenttype.model.field.ImmutableFieldVariable.builder<method*end>().from(var).userId(user.getUserId<method*start>com.liferay.portal.model.UserModel.getUserId<method*end>()).build());
// update Content Type mod_date to detect the changes done on the field variables
contentTypeAPI.updateModDate<method*start>com.dotcms.contenttype.business.ContentTypeAPI.updateModDate<method*end>(type);
// Validates custom mapping format
if (var.key<method*start>com.dotcms.contenttype.model.field.FieldVariable.key<method*end>().equals<method*start>java.lang.String.equals<method*end>(FieldVariable.ES_CUSTOM_MAPPING_KEY<method*start>com.dotcms.contenttype.model.field.FieldVariable.ES_CUSTOM_MAPPING_KEY<method*end>)) {
try {
new JSONObject<method*start>com.dotmarketing.util.json.JSONObject<method*end>(var.value<method*start>com.dotcms.contenttype.model.field.FieldVariable.value<method*end>());
} catch (JSONException<method*start>com.dotmarketing.util.json.JSONException<method*end> e) {
handleInvalidCustomMappingError<method*start>com.dotcms.contenttype.business.FieldAPIImpl.handleInvalidCustomMappingError<method*end>(var, user, field, type, e);
}
// Verifies the field is marked as System Indexed. In case it isn't, the field will be updated with this flag on
if (!field.indexed<method*start>com.dotcms.contenttype.model.field.Field.indexed<method*end>()) {
save(FieldBuilder.builder<method*start>com.dotcms.contenttype.model.field.FieldBuilder.builder<method*end>(field).indexed<method*start>com.dotcms.contenttype.model.field.FieldBuilder.indexed<method*end>(true).build<method*start>com.dotcms.contenttype.model.field.FieldBuilder.build<method*end>(), user);
Logger.info<method*start>com.dotmarketing.util.Logger.info<method*end>(this, "Field " + type.variable<method*start>com.dotcms.contenttype.model.type.ContentType.variable<method*end>() + "." + field.variable<method*start>com.dotcms.contenttype.model.field.Field.variable<method*end>() + " has been marked as System Indexed as it has defined a field variable with key " + FieldVariable.ES_CUSTOM_MAPPING_KEY<method*start>com.dotcms.contenttype.model.field.FieldVariable.ES_CUSTOM_MAPPING_KEY<method*end>);
}
}
return newFieldVariable;
} | annotation | @WrapInTransaction
@Override
public FieldVariable<method*start>com.dotcms.contenttype.model.field.FieldVariable<method*end> save(final FieldVariable<method*start>com.dotcms.contenttype.model.field.FieldVariable<method*end> var, final User<method*start>com.liferay.portal.model.User<method*end> user) throws DotDataException<method*start>com.dotmarketing.exception.DotDataException<method*end>, DotSecurityException<method*start>com.dotmarketing.exception.DotSecurityException<method*end> {
ContentTypeAPI<method*start>com.dotcms.contenttype.business.ContentTypeAPI<method*end> contentTypeAPI = APILocator.getContentTypeAPI<method*start>com.dotmarketing.business.APILocator.getContentTypeAPI<method*end>(user);
Field<method*start>com.dotcms.contenttype.model.field.Field<method*end> field = fieldFactory.byId<method*start>com.dotcms.contenttype.business.FieldFactory.byId<method*end>(var.fieldId<method*start>com.dotcms.contenttype.model.field.FieldVariable.fieldId<method*end>());
ContentType<method*start>com.dotcms.contenttype.model.type.ContentType<method*end> type = contentTypeAPI.find<method*start>com.dotcms.contenttype.business.ContentTypeAPI.find<method*end>(field.contentTypeId<method*start>com.dotcms.contenttype.model.field.Field.contentTypeId<method*end>());
APILocator.getPermissionAPI<method*start>com.dotmarketing.business.APILocator.getPermissionAPI<method*end>().checkPermission<method*start>com.dotmarketing.business.PermissionAPI.checkPermission<method*end>(type, PermissionLevel.EDIT_PERMISSIONS<method*start>com.dotmarketing.business.PermissionLevel.EDIT_PERMISSIONS<method*end>, user);
FieldVariable<method*start>com.dotcms.contenttype.model.field.FieldVariable<method*end> newFieldVariable = fieldFactory.save<method*start>com.dotcms.contenttype.business.FieldFactory.save<method*end>(ImmutableFieldVariable.builder<method*start>com.dotcms.contenttype.model.field.ImmutableFieldVariable.builder<method*end>().from(var).userId(user.getUserId<method*start>com.liferay.portal.model.UserModel.getUserId<method*end>()).build());
// update Content Type mod_date to detect the changes done on the field variables
contentTypeAPI.updateModDate<method*start>com.dotcms.contenttype.business.ContentTypeAPI.updateModDate<method*end>(type);
// Validates custom mapping format
if (var.key<method*start>com.dotcms.contenttype.model.field.FieldVariable.key<method*end>().equals<method*start>java.lang.String.equals<method*end>(FieldVariable.ES_CUSTOM_MAPPING_KEY<method*start>com.dotcms.contenttype.model.field.FieldVariable.ES_CUSTOM_MAPPING_KEY<method*end>)) {
try {
new JSONObject<method*start>com.dotmarketing.util.json.JSONObject<method*end>(var.value<method*start>com.dotcms.contenttype.model.field.FieldVariable.value<method*end>());
} catch (JSONException<method*start>com.dotmarketing.util.json.JSONException<method*end> e) {
handleInvalidCustomMappingError<method*start>com.dotcms.contenttype.business.FieldAPIImpl.handleInvalidCustomMappingError<method*end>(var, user, field, type, e);
}
// Verifies the field is marked as System Indexed. In case it isn't, the field will be updated with this flag on
if (!field.indexed<method*start>com.dotcms.contenttype.model.field.Field.indexed<method*end>()) {
save(FieldBuilder.builder<method*start>com.dotcms.contenttype.model.field.FieldBuilder.builder<method*end>(field).indexed<method*start>com.dotcms.contenttype.model.field.FieldBuilder.indexed<method*end>(true).build<method*start>com.dotcms.contenttype.model.field.FieldBuilder.build<method*end>(), user);
Logger.info<method*start>com.dotmarketing.util.Logger.info<method*end>(this, "Field " + type.variable<method*start>com.dotcms.contenttype.model.type.ContentType.variable<method*end>() + "." + field.variable<method*start>com.dotcms.contenttype.model.field.Field.variable<method*end>() + " has been marked as System Indexed as it has defined a field variable with key " + FieldVariable.ES_CUSTOM_MAPPING_KEY<method*start>com.dotcms.contenttype.model.field.FieldVariable.ES_CUSTOM_MAPPING_KEY<method*end>);
}
}
return newFieldVariable;
}
|
@Override
public AuthorizeForAutoscaleV4Response authorizeForAutoscale(String crn, String userId, String tenant, String permission) {
AuthorizeForAutoscaleV4Response response = new AuthorizeForAutoscaleV4Response();
try {
restRequestThreadLocalService.setCloudbreakUserByUsernameAndTenant(userId, tenant);
Stack stack = stackService.getByCrn(crn);
response.setSuccess(true);
} catch (RuntimeException ignore) {
response.setSuccess(false);
}
return response;
} | conventional | @Override<method*start>java.lang.Override<method*end>
public AuthorizeForAutoscaleV4Response<method*start>com.sequenceiq.cloudbreak.api.endpoint.v4.autoscales.response.AuthorizeForAutoscaleV4Response<method*end> authorizeForAutoscale(String<method*start>java.lang.String<method*end> crn, String<method*start>java.lang.String<method*end> userId, String<method*start>java.lang.String<method*end> tenant, String<method*start>java.lang.String<method*end> permission) {
AuthorizeForAutoscaleV4Response<method*start>com.sequenceiq.cloudbreak.api.endpoint.v4.autoscales.response.AuthorizeForAutoscaleV4Response<method*end> response = new AuthorizeForAutoscaleV4Response<method*start>com.sequenceiq.cloudbreak.api.endpoint.v4.autoscales.response.AuthorizeForAutoscaleV4Response<method*end>();
try {
restRequestThreadLocalService.setCloudbreakUserByUsernameAndTenant<method*start>com.sequenceiq.cloudbreak.service.CloudbreakRestRequestThreadLocalService.setCloudbreakUserByUsernameAndTenant<method*end>(userId, tenant);
Stack<method*start>com.sequenceiq.cloudbreak.domain.stack.Stack<method*end> stack = stackService.getByCrn<method*start>com.sequenceiq.cloudbreak.service.stack.StackService.getByCrn<method*end>(crn);
if (ResourceAction.WRITE.name<method*start>com.sequenceiq.authorization.resource.ResourceAction.name<method*end>().equalsIgnoreCase<method*start>java.lang.String.equalsIgnoreCase<method*end>(permission)) {
User<method*start>com.sequenceiq.cloudbreak.workspace.model.User<method*end> user = userService.getOrCreate<method*start>com.sequenceiq.cloudbreak.service.user.UserService.getOrCreate<method*end>(restRequestThreadLocalService.getCloudbreakUser<method*start>com.sequenceiq.cloudbreak.service.CloudbreakRestRequestThreadLocalService.getCloudbreakUser<method*end>());
permissionCheckingUtils.checkPermissionForUser<method*start>com.sequenceiq.authorization.service.CommonPermissionCheckingUtils.checkPermissionForUser<method*end>(DATAHUB<method*start>com.sequenceiq.authorization.resource.AuthorizationResource.DATAHUB<method*end>, ResourceAction.WRITE<method*start>com.sequenceiq.authorization.resource.ResourceAction.WRITE<method*end>, user.getUserCrn<method*start>com.sequenceiq.cloudbreak.workspace.model.User.getUserCrn<method*end>());
}
response.setSuccess<method*start>com.sequenceiq.cloudbreak.api.endpoint.v4.autoscales.response.AuthorizeForAutoscaleV4Response.setSuccess<method*end>(true);
} catch (RuntimeException<method*start>java.lang.RuntimeException<method*end> ignore) {
response.setSuccess<method*start>com.sequenceiq.cloudbreak.api.endpoint.v4.autoscales.response.AuthorizeForAutoscaleV4Response.setSuccess<method*end>(false);
}
return response;
}
|
public AccessControlContext delegatedContext(AccessControlContext authenticatedACC, Subject delegatedSubject, boolean removeCallerContext) throws SecurityException {
throw new SecurityException("Illegal AccessControlContext: null");
}
// Check if the subject delegation permission allows the
// authenticated subject to assume the identity of each
// principal in the delegated subject
//
Collection<Principal> ps = getSubjectPrincipals(delegatedSubject);
final Collection<Permission> permissions = new ArrayList<>(ps.size());
for (Principal p : ps) {
final String pname = p.getClass().getName() + "." + p.getName();
permissions.add(new SubjectDelegationPermission(pname));
}
AccessController.doPrivileged(action, authenticatedACC);
return getDelegatedAcc(delegatedSubject, removeCallerContext);
} | conventional | public AccessControlContext<method*start>java.security.AccessControlContext<method*end> delegatedContext(AccessControlContext<method*start>java.security.AccessControlContext<method*end> authenticatedACC, Subject<method*start>javax.security.auth.Subject<method*end> delegatedSubject, boolean removeCallerContext) throws SecurityException<method*start>java.lang.SecurityException<method*end> {
if (System.getSecurityManager<method*start>java.lang.System.getSecurityManager<method*end>() != null && authenticatedACC == null) {
throw new SecurityException<method*start>java.lang.SecurityException<method*end>("Illegal AccessControlContext: null");
}
// Check if the subject delegation permission allows the
// authenticated subject to assume the identity of each
// principal in the delegated subject
//
Collection<method*start>java.util.Collection<method*end><Principal<method*start>java.security.Principal<method*end>> ps = getSubjectPrincipals<method*start>com.sun.jmx.remote.security.SubjectDelegator.getSubjectPrincipals<method*end>(delegatedSubject);
final Collection<method*start>java.util.Collection<method*end><Permission<method*start>java.security.Permission<method*end>> permissions = new ArrayList<method*start>java.util.ArrayList<method*end><>(ps.size<method*start>java.util.Collection.size<method*end>());
for (Principal<method*start>java.security.Principal<method*end> p : ps) {
final String<method*start>java.lang.String<method*end> pname = p.getClass<method*start>java.security.Principal.getClass<method*end>().getName<method*start>java.lang.Class.getName<method*end>() + "." + p.getName<method*start>java.security.Principal.getName<method*end>();
permissions.add<method*start>java.util.Collection.add<method*end>(new SubjectDelegationPermission<method*start>javax.management.remote.SubjectDelegationPermission<method*end>(pname));
}
PrivilegedAction<method*start>java.security.PrivilegedAction<method*end><Void<method*start>java.lang.Void<method*end>> action = new PrivilegedAction<method*start>java.security.PrivilegedAction<method*end><Void<method*start>java.lang.Void<method*end>>() {
public Void<method*start>java.lang.Void<method*end> run() {
for (Permission<method*start>java.security.Permission<method*end> sdp : permissions) {
AccessController.checkPermission<method*start>java.security.AccessController.checkPermission<method*end>(sdp);
}
return null;
}
};
AccessController.doPrivileged<method*start>java.security.AccessController.doPrivileged<method*end>(action, authenticatedACC);
return getDelegatedAcc<method*start>com.sun.jmx.remote.security.SubjectDelegator.getDelegatedAcc<method*end>(delegatedSubject, removeCallerContext);
}
|
public void secure(final Account operatedAccount, final String permission, SecuredType type, UserIdentityContext userIdentityContext) throws AuthorizationException {
if (operatedAccount == null) {
// if operatedAccount is NULL, we'll probably return a 404. But let's handle that in a central place.
throw new OperatedAccountMissing();
}
if (type == SecuredType.SECURED_STANDARD) {
} else if (type == SecuredType.SECURED_APP) {
} else if (type == SecuredType.SECURED_ACCOUNT) {
}
} | conventional | public void secure(final Account<method*start>org.restcomm.connect.dao.entities.Account<method*end> operatedAccount, final String<method*start>java.lang.String<method*end> permission, SecuredType<method*start>org.restcomm.connect.http.security.PermissionEvaluator.SecuredType<method*end> type<method*start>org.restcomm.connect.extension.api.RestcommExtension.type<method*end>, UserIdentityContext<method*start>org.restcomm.connect.identity.UserIdentityContext<method*end> userIdentityContext) throws AuthorizationException {
// check an authenticated account allowed to do "permission" is available
checkPermission(permission, userIdentityContext);
// check if valid organization is attached with this account.
checkOrganization<method*start>org.restcomm.connect.http.security.PermissionEvaluator.checkOrganization<method*end>(operatedAccount, userIdentityContext);
if (operatedAccount == null) {
// if operatedAccount is NULL, we'll probably return a 404. But let's handle that in a central place.
throw new OperatedAccountMissing();
}
if (type<method*start>org.restcomm.connect.extension.api.RestcommExtension.type<method*end> == SecuredType.SECURED_STANDARD<method*start>org.restcomm.connect.http.security.PermissionEvaluator.SecuredType.SECURED_STANDARD<method*end>) {
if (secureLevelControl<method*start>org.restcomm.connect.http.security.PermissionEvaluator.secureLevelControl<method*end>(operatedAccount, null, userIdentityContext) != AuthOutcome.OK<method*start>org.restcomm.connect.identity.AuthOutcome.OK<method*end>)
throw new InsufficientPermission();
} else if (type<method*start>org.restcomm.connect.extension.api.RestcommExtension.type<method*end> == SecuredType.SECURED_APP<method*start>org.restcomm.connect.http.security.PermissionEvaluator.SecuredType.SECURED_APP<method*end>) {
if (secureLevelControlApplications<method*start>org.restcomm.connect.http.security.PermissionEvaluator.secureLevelControlApplications<method*end>(operatedAccount, null, userIdentityContext) != AuthOutcome.OK<method*start>org.restcomm.connect.identity.AuthOutcome.OK<method*end>)
throw new InsufficientPermission();
} else if (type<method*start>org.restcomm.connect.extension.api.RestcommExtension.type<method*end> == SecuredType.SECURED_ACCOUNT<method*start>org.restcomm.connect.http.security.PermissionEvaluator.SecuredType.SECURED_ACCOUNT<method*end>) {
if (secureLevelControlAccounts<method*start>org.restcomm.connect.http.security.PermissionEvaluator.secureLevelControlAccounts<method*end>(operatedAccount, userIdentityContext) != AuthOutcome.OK<method*start>org.restcomm.connect.identity.AuthOutcome.OK<method*end>)
throw new InsufficientPermission();
}
}
|
@Setup<method*start>org.openjdk.jmh.annotations.Setup<method*end>
public void makeFinder() throws Throwable<method*start>java.lang.Throwable<method*end> {
defaultThriftMessageClassFinder<method*start>com.linecorp.armeria.common.thrift.text.StackTracingBenchmark.defaultThriftMessageClassFinder<method*end> = new DefaultThriftMessageClassFinder<method*start>com.linecorp.armeria.common.thrift.text.DefaultThriftMessageClassFinder<method*end>();
stackWalkingFinderWithRetainOption = new StackWalkingThriftMessageClassFinder<method*start>com.linecorp.armeria.common.thrift.text.StackWalkingThriftMessageClassFinder<method*end>();
final SecurityManager<method*start>java.lang.SecurityManager<method*end> securityManager = System<method*start>java.lang.System<method*end>.getSecurityManager();
System<method*start>java.lang.System<method*end>.setSecurityManager(new SecurityManager<method*start>java.lang.SecurityManager<method*end>() {
@Override
public void checkExit(int status) {
}
});
stackWalkingThriftMessageClassFinder = new StackWalkingThriftMessageClassFinder<method*start>com.linecorp.armeria.common.thrift.text.StackWalkingThriftMessageClassFinder<method*end>();
System<method*start>java.lang.System<method*end>.setSecurityManager(securityManager);
} | annotation | @Setup<method*start>org.openjdk.jmh.annotations.Setup<method*end>
public void makeFinder() throws Throwable<method*start>java.lang.Throwable<method*end> {
defaultThriftMessageClassFinder<method*start>com.linecorp.armeria.common.thrift.text.StackTracingBenchmark.defaultThriftMessageClassFinder<method*end> = new DefaultThriftMessageClassFinder<method*start>com.linecorp.armeria.common.thrift.text.DefaultThriftMessageClassFinder<method*end>();
stackWalkingFinderWithRetainOption = new StackWalkingThriftMessageClassFinder<method*start>com.linecorp.armeria.common.thrift.text.StackWalkingThriftMessageClassFinder<method*end>();
final SecurityManager<method*start>java.lang.SecurityManager<method*end> securityManager = System<method*start>java.lang.System<method*end>.getSecurityManager();
System<method*start>java.lang.System<method*end>.setSecurityManager(new SecurityManager<method*start>java.lang.SecurityManager<method*end>() {
@Override
public void checkPermission(Permission<method*start>java.security.Permission<method*end> perm) {
// `getStackWalkerWithClassReference` is called by RETAIN_CLASS_REFERENCE option.
if (perm.getName().equals("getStackWalkerWithClassReference")) {
throw new SecurityException<method*start>java.lang.SecurityException<method*end>("Failing SecurityManage.checkPermission() for unit testing");
}
}
@Override
public void checkPermission(Permission<method*start>java.security.Permission<method*end> perm, Object<method*start>java.lang.Object<method*end> context) {
}
@Override
public void checkExit(int status) {
}
});
stackWalkingThriftMessageClassFinder = new StackWalkingThriftMessageClassFinder<method*start>com.linecorp.armeria.common.thrift.text.StackWalkingThriftMessageClassFinder<method*end>();
System<method*start>java.lang.System<method*end>.setSecurityManager(securityManager);
}
|
public static <T> T runWithRestrictedPermissions(PrivilegedExceptionAction<T> action, Permission... permissions) throws Exception {
assumeTrue("runWithRestrictedPermissions requires a SecurityManager enabled", System.getSecurityManager() != null);
final AccessControlContext ctx = new AccessControlContext(new ProtectionDomain[] { new ProtectionDomain(null, perms) });
try {
return AccessController.doPrivileged(action, ctx);
} catch (PrivilegedActionException e) {
throw e.getException();
}
} | conventional | public static <T> T runWithRestrict<method*start>java.lang.Exception<method*end>edPermissions(Privile<method*start>org.apache.lucene.util.LuceneTestCase.assumeTrue<method*end>gedExceptionAction<T> action, Permission... permissions) throws Exception <method*start>java.lang.System<method*end>{
assumeTrue("runWithRestrictedPermissions requires a SecurityManager enabled", System.getSecurityManager() != null);
// be sure to have re<method*start>java.security.AccessController<method*end>quired permissio<method*start>java.security.AccessController.checkPermission<method*end>n, otherwise doPrivileg<method*start>java.security.SecurityPermission<method*end>ed runs with *no* permissions:
AccessController.checkPermis<method*start>java.security.PermissionCollection<method*end>sion(new SecurityPermiss<method*start>java.security.Permissions<method*end>ion("createAccessC<method*start>java.util.Arrays<method*end>ontrolC<method*start>java.util.Arrays.stream<method*end>ontext"));
fi<method*start>java.util.stream.Stream.forEach<method*end>nal PermissionCollection perms = new Permissions<method*start>java.security.AccessControlContext<method*end>();
Arrays.stream(permi<method*start>java.security.AccessControlContext<method*end>ssions).forEach(perms<method*start>java.security.ProtectionDomain<method*end>::add);
final Acc<method*start>java.security.ProtectionDomain<method*end>essControlContext ctx = new AccessControlContext(new ProtectionDoma<method*start>java.security.AccessController<method*end>in[] { new Pr<method*start>java.security.AccessController.doPrivileged<method*end>otectionDomain(null, perms) });
try {
return AccessController.doPrivileged(<method*start>java.security.PrivilegedActionException.getException<method*end>action, ctx);
} catch (PrivilegedActionException e) {
throw e.getException();
}
}
|
public static synchronized MBeanServer<method*start>javax.management.MBeanServer<method*end> getPlatformMBeanServer() {
Permission<method*start>java.security.Permission<method*end> perm = new MBeanServerPermission<method*start>javax.management.MBeanServerPermission<method*end>("createMBeanServer");
sm.checkPermission<method*start>java.lang.SecurityManager.checkPermission<method*end>(perm);
if (platformMBeanServer == null) {
platformMBeanServer = sun.management.ManagementFactory.createPlatformMBeanServer<method*start>sun.management.ManagementFactory.createPlatformMBeanServer<method*end>();
}
return platformMBeanServer;
}
| conventional | public static synchronized MBeanServer<method*start>javax.management.MBeanServer<method*end> getPlatformMBeanServer() {
SecurityManager<method*start>java.lang.SecurityManager<method*end> sm = System.getSecurityManager<method*start>java.lang.System.getSecurityManager<method*end>();
if (sm != null) {
Permission<method*start>java.security.Permission<method*end> perm = new MBeanServerPermission<method*start>javax.management.MBeanServerPermission<method*end>("createMBeanServer");
sm.checkPermission<method*start>java.lang.SecurityManager.checkPermission<method*end>(perm);
}
if (platformMBeanServer == null) {
platformMBeanServer = sun.management.ManagementFactory.createPlatformMBeanServer<method*start>sun.management.ManagementFactory.createPlatformMBeanServer<method*end>();
}
return platformMBeanServer;
}
|
public void setContextClassLoader(ClassLoader cl) {
contextClassLoader = cl;
} | conventional | public void setContextClassLoader(ClassLoader<method*start>java.lang.ClassLoader<method*end> cl) {
/*[PR 1FCA807]*/
SecurityManager<method*start>java.lang.SecurityManager<method*end> currentManager = System.getSecurityManager<method*start>java.lang.System.getSecurityManager<method*end>();
// if there is a security manager...
if (currentManager != null) {
// then check permission
currentManager.checkPermission<method*start>java.lang.SecurityManager.checkPermission<method*end>(com.ibm.oti.util.RuntimePermissions.permissionSetContextClassLoader<method*start>com.ibm.oti.util.RuntimePermissions.permissionSetContextClassLoader<method*end>);
}
contextClassLoader = cl;
}
|
public boolean hasPermissionForActivity(Intent intent, String srcPackage) {
ResolveInfo target = mPm.resolveActivity(intent, 0);
if (target == null) {
// Not a valid target
return false;
}
if (TextUtils.isEmpty(target.activityInfo.permission)) {
// No permission is needed
return true;
}
if (TextUtils.isEmpty(srcPackage)) {
// The activity requires some permission but there is no source.
return false;
}
if (!Utilities.ATLEAST_MARSHMALLOW) {
// These checks are sufficient for below M devices.
return true;
}
if (TextUtils.isEmpty(AppOpsManager.permissionToOp(target.activityInfo.permission))) {
// There is no app-op for this permission, which could have been disabled.
return true;
}
try {
return mPm.getApplicationInfo(srcPackage, 0).targetSdkVersion >= Build.VERSION_CODES.M;
} catch (NameNotFoundException e) {
}
return false;
} | conventional | public boolean hasPermissionForActivity(Intent<method*start>android.content.Intent<method*end> intent, String<method*start>java.lang.String<method*end> srcPackage) {
ResolveInfo<method*start>android.content.pm.ResolveInfo<method*end> target = mPm.resolveActivity<method*start>android.content.pm.PackageManager.resolveActivity<method*end>(intent, 0);
if (target == null) {
// Not a valid target
return false;
}
if (TextUtils.isEmpty<method*start>android.text.TextUtils.isEmpty<method*end>(target.activityInfo.permission<method*start>android.content.pm.ActivityInfo.permission<method*end>)) {
// No permission is needed
return true;
}
if (TextUtils.isEmpty<method*start>android.text.TextUtils.isEmpty<method*end>(srcPackage)) {
// The activity requires some permission but there is no source.
return false;
}
// Source does not have sufficient permissions.
if (mPm.checkPermission<method*start>android.content.pm.PackageManager.checkPermission<method*end>(target.activityInfo.permission<method*start>android.content.pm.ActivityInfo.permission<method*end>, srcPackage) != PackageManager.PERMISSION_GRANTED<method*start>android.content.pm.PackageManager.PERMISSION_GRANTED<method*end>) {
return false;
}
if (!Utilities.ATLEAST_MARSHMALLOW<method*start>com.android.launcher3.Utilities.ATLEAST_MARSHMALLOW<method*end>) {
// These checks are sufficient for below M devices.
return true;
}
// On M and above also check AppOpsManager for compatibility mode permissions.
if (TextUtils.isEmpty<method*start>android.text.TextUtils.isEmpty<method*end>(AppOpsManager.permissionToOp<method*start>android.app.AppOpsManager.permissionToOp<method*end>(target.activityInfo.permission<method*start>android.content.pm.ActivityInfo.permission<method*end>))) {
// There is no app-op for this permission, which could have been disabled.
return true;
}
try {
return mPm.getApplicationInfo<method*start>android.content.pm.PackageManager.getApplicationInfo<method*end>(srcPackage, 0).targetSdkVersion<method*start>android.content.pm.ApplicationInfo.targetSdkVersion<method*end> >= Build.VERSION_CODES.M<method*start>android.os.Build.VERSION_CODES.M<method*end>;
} catch (NameNotFoundException<method*start>android.content.pm.PackageManager.NameNotFoundException<method*end> e) {
}
return false;
}
|
public static boolean hasPermissionForActivity(Context<method*start>android.content.Context<method*end> context, Intent<method*start>android.content.Intent<method*end> intent, String<method*start>java.lang.String<method*end> srcPackage) {
PackageManager<method*start>android.content.pm.PackageManager<method*end> pm = context.getPackageManager<method*start>android.content.Context.getPackageManager<method*end>();
ResolveInfo<method*start>android.content.pm.ResolveInfo<method*end> target = pm.resolveActivity<method*start>android.content.pm.PackageManager.resolveActivity<method*end>(intent, 0);
if (target == null) {
// Not a valid target
return false;
}
if (TextUtils.isEmpty<method*start>android.text.TextUtils.isEmpty<method*end>(target.activityInfo.permission<method*start>android.content.pm.ActivityInfo.permission<method*end>)) {
// No permission is needed
return true;
}
if (TextUtils.isEmpty<method*start>android.text.TextUtils.isEmpty<method*end>(srcPackage)) {
// The activity requires some permission but there is no source.
return false;
}
if (!Utilities.ATLEAST_MARSHMALLOW<method*start>xyz.klinker.blur.launcher3.Utilities.ATLEAST_MARSHMALLOW<method*end>) {
// These checks are sufficient for below M devices.
return true;
}
if (TextUtils.isEmpty<method*start>android.text.TextUtils.isEmpty<method*end>(AppOpsManager.permissionToOp<method*start>android.app.AppOpsManager.permissionToOp<method*end>(target.activityInfo.permission<method*start>android.content.pm.ActivityInfo.permission<method*end>))) {
// There is no app-op for this permission, which could have been disabled.
return true;
}
try {
return pm.getApplicationInfo<method*start>android.content.pm.PackageManager.getApplicationInfo<method*end>(srcPackage, 0).targetSdkVersion<method*start>android.content.pm.ApplicationInfo.targetSdkVersion<method*end> >= Build.VERSION_CODES.M<method*start>android.os.Build.VERSION_CODES.M<method*end>;
} catch (NameNotFoundException<method*start>android.content.pm.PackageManager.NameNotFoundException<method*end> e) {
}
return false;
} | conventional | public static boolean hasPermissionForActivity(Context<method*start>android.content.Context<method*end> context, Intent<method*start>android.content.Intent<method*end> intent, String<method*start>java.lang.String<method*end> srcPackage) {
PackageManager<method*start>android.content.pm.PackageManager<method*end> pm = context.getPackageManager<method*start>android.content.Context.getPackageManager<method*end>();
ResolveInfo<method*start>android.content.pm.ResolveInfo<method*end> target = pm.resolveActivity<method*start>android.content.pm.PackageManager.resolveActivity<method*end>(intent, 0);
if (target == null) {
// Not a valid target
return false;
}
if (TextUtils.isEmpty<method*start>android.text.TextUtils.isEmpty<method*end>(target.activityInfo.permission<method*start>android.content.pm.ActivityInfo.permission<method*end>)) {
// No permission is needed
return true;
}
if (TextUtils.isEmpty<method*start>android.text.TextUtils.isEmpty<method*end>(srcPackage)) {
// The activity requires some permission but there is no source.
return false;
}
// Source does not have sufficient permissions.
if (pm.checkPermission<method*start>android.content.pm.PackageManager.checkPermission<method*end>(target.activityInfo.permission<method*start>android.content.pm.ActivityInfo.permission<method*end>, srcPackage) != PackageManager.PERMISSION_GRANTED<method*start>android.content.pm.PackageManager.PERMISSION_GRANTED<method*end>) {
return false;
}
if (!Utilities.ATLEAST_MARSHMALLOW<method*start>xyz.klinker.blur.launcher3.Utilities.ATLEAST_MARSHMALLOW<method*end>) {
// These checks are sufficient for below M devices.
return true;
}
// On M and above also check AppOpsManager for compatibility mode permissions.
if (TextUtils.isEmpty<method*start>android.text.TextUtils.isEmpty<method*end>(AppOpsManager.permissionToOp<method*start>android.app.AppOpsManager.permissionToOp<method*end>(target.activityInfo.permission<method*start>android.content.pm.ActivityInfo.permission<method*end>))) {
// There is no app-op for this permission, which could have been disabled.
return true;
}
try {
return pm.getApplicationInfo<method*start>android.content.pm.PackageManager.getApplicationInfo<method*end>(srcPackage, 0).targetSdkVersion<method*start>android.content.pm.ApplicationInfo.targetSdkVersion<method*end> >= Build.VERSION_CODES.M<method*start>android.os.Build.VERSION_CODES.M<method*end>;
} catch (NameNotFoundException<method*start>android.content.pm.PackageManager.NameNotFoundException<method*end> e) {
}
return false;
}
|
private JarFile<method*start>java.util.jar.JarFile<method*end> getCachedJarFile(URL<method*start>java.net.URL<method*end> url) {
JarFile<method*start>java.util.jar.JarFile<method*end> result = (JarFile<method*start>java.util.jar.JarFile<method*end>) fileCache.get<method*start>java.util.HashMap.get<method*end>(url);
/* if the JAR file is cached, the permission will always be there */
if (result != null) {
// security managers
if ((perm instanceof java.io.FilePermission<method*start>java.io.FilePermission<method*end>) && perm.getActions<method*start>java.security.Permission.getActions<method*end>().indexOf<method*start>java.lang.String.indexOf<method*end>("read") != -1) {
sm.checkRead<method*start>java.lang.SecurityManager.checkRead<method*end>(perm.getName<method*start>java.security.Permission.getName<method*end>());
} else if ((perm instanceof java.net.SocketPermission<method*start>java.net.SocketPermission<method*end>) && perm.getActions<method*start>java.security.Permission.getActions<method*end>().indexOf<method*start>java.lang.String.indexOf<method*end>("connect") != -1) {
sm.checkConnect<method*start>java.lang.SecurityManager.checkConnect<method*end>(url.getHost<method*start>java.net.URL.getHost<method*end>(), url.getPort<method*start>java.net.URL.getPort<method*end>());
} else {
throw se;
}
}
}
}
}
return result;
}
| conventional | private JarFile<method*start>java.util.jar.JarFile<method*end> getCachedJarFile(URL<method*start>java.net.URL<method*end> url) {
JarFile<method*start>java.util.jar.JarFile<method*end> result = (JarFile<method*start>java.util.jar.JarFile<method*end>) fileCache.get<method*start>java.util.HashMap.get<method*end>(url);
/* if the JAR file is cached, the permission will always be there */
if (result != null) {
Permission<method*start>java.security.Permission<method*end> perm = getPermission<method*start>sun.net.www.protocol.jar.JarFileFactory.getPermission<method*end>(result);
if (perm != null) {
SecurityManager<method*start>java.lang.SecurityManager<method*end> sm = System.getSecurityManager<method*start>java.lang.System.getSecurityManager<method*end>();
if (sm != null) {
try {
sm.checkPermission<method*start>java.lang.SecurityManager.checkPermission<method*end>(perm);
} catch (SecurityException<method*start>java.lang.SecurityException<method*end> se) {
// security managers
if ((perm instanceof java.io.FilePermission<method*start>java.io.FilePermission<method*end>) && perm.getActions<method*start>java.security.Permission.getActions<method*end>().indexOf<method*start>java.lang.String.indexOf<method*end>("read") != -1) {
sm.checkRead<method*start>java.lang.SecurityManager.checkRead<method*end>(perm.getName<method*start>java.security.Permission.getName<method*end>());
} else if ((perm instanceof java.net.SocketPermission<method*start>java.net.SocketPermission<method*end>) && perm.getActions<method*start>java.security.Permission.getActions<method*end>().indexOf<method*start>java.lang.String.indexOf<method*end>("connect") != -1) {
sm.checkConnect<method*start>java.lang.SecurityManager.checkConnect<method*end>(url.getHost<method*start>java.net.URL.getHost<method*end>(), url.getPort<method*start>java.net.URL.getPort<method*end>());
} else {
throw se;
}
}
}
}
}
return result;
}
|
private JarFile<method*start>java.util.jar.JarFile<method*end> getCachedJarFile(URL<method*start>java.net.URL<method*end> url) {
JarFile<method*start>java.util.jar.JarFile<method*end> result = fileCache.get<method*start>java.util.HashMap.get<method*end>(URLUtil.urlNoFragString<method*start>sun.net.util.URLUtil.urlNoFragString<method*end>(url));
/* if the JAR file is cached, the permission will always be there */
if (result != null) {
Permission<method*start>java.security.Permission<method*end> perm = getPermission<method*start>sun.net.www.protocol.jar.JarFileFactory.getPermission<method*end>(result);
sm.checkRead<method*start>java.lang.SecurityManager.checkRead<method*end>(perm.getName<method*start>java.security.Permission.getName<method*end>());
} else if ((perm instanceof java.net.SocketPermission<method*start>java.net.SocketPermission<method*end>) && perm.getActions<method*start>java.security.Permission.getActions<method*end>().indexOf<method*start>java.lang.String.indexOf<method*end>("connect") != -1) {
sm.checkConnect<method*start>java.lang.SecurityManager.checkConnect<method*end>(url.getHost<method*start>java.net.URL.getHost<method*end>(), url.getPort<method*start>java.net.URL.getPort<method*end>());
} else {
throw se;
}
}
}
}
}
return result;
} | conventional | private JarFile<method*start>java.util.jar.JarFile<method*end> getCachedJarFile(URL<method*start>java.net.URL<method*end> url) {
assert Thread.holdsLock<method*start>java.lang.Thread.holdsLock<method*end>(instance);
JarFile<method*start>java.util.jar.JarFile<method*end> result = fileCache.get<method*start>java.util.HashMap.get<method*end>(URLUtil.urlNoFragString<method*start>sun.net.util.URLUtil.urlNoFragString<method*end>(url));
/* if the JAR file is cached, the permission will always be there */
if (result != null) {
Permission<method*start>java.security.Permission<method*end> perm = getPermission<method*start>sun.net.www.protocol.jar.JarFileFactory.getPermission<method*end>(result);
if (perm != null) {
SecurityManager<method*start>java.lang.SecurityManager<method*end> sm = System.getSecurityManager<method*start>java.lang.System.getSecurityManager<method*end>();
if (sm != null) {
try {
sm.checkPermission<method*start>java.lang.SecurityManager.checkPermission<method*end>(perm);
} catch (SecurityException<method*start>java.lang.SecurityException<method*end> se) {
// security managers
if ((perm instanceof java.io.FilePermission<method*start>java.io.FilePermission<method*end>) && perm.getActions<method*start>java.security.Permission.getActions<method*end>().indexOf<method*start>java.lang.String.indexOf<method*end>("read") != -1) {
sm.checkRead<method*start>java.lang.SecurityManager.checkRead<method*end>(perm.getName<method*start>java.security.Permission.getName<method*end>());
} else if ((perm instanceof java.net.SocketPermission<method*start>java.net.SocketPermission<method*end>) && perm.getActions<method*start>java.security.Permission.getActions<method*end>().indexOf<method*start>java.lang.String.indexOf<method*end>("connect") != -1) {
sm.checkConnect<method*start>java.lang.SecurityManager.checkConnect<method*end>(url.getHost<method*start>java.net.URL.getHost<method*end>(), url.getPort<method*start>java.net.URL.getPort<method*end>());
} else {
throw se;
}
}
}
}
}
return result;
}
|
public final ClassLoader<method*start>java.lang.ClassLoader<method*end> getClassLoader(ObjectName<method*start>javax.management.ObjectName<method*end> name) {
ClassLoader<method*start>java.lang.ClassLoader<method*end> instance = loadersWithNames.get<method*start>java.util.Map.get<method*end>(name);
if (instance != null) {
SecurityManager<method*start>java.lang.SecurityManager<method*end> sm = System.getSecurityManager<method*start>java.lang.System.getSecurityManager<method*end>();
Permission<method*start>java.security.Permission<method*end> perm = new MBeanPermission<method*start>javax.management.MBeanPermission<method*end>(instance.getClass<method*start>java.lang.ClassLoader.getClass<method*end>().getName<method*start>java.lang.Class.getName<method*end>(), null, name, "getClassLoader");
}
return instance;
}
| conventional | public final ClassLoader<method*start>java.lang.ClassLoader<method*end> getClassLoader(ObjectName<method*start>javax.management.ObjectName<method*end> name) {
ClassLoader<method*start>java.lang.ClassLoader<method*end> instance = loadersWithNames.get<method*start>java.util.Map.get<method*end>(name);
if (instance != null) {
SecurityManager<method*start>java.lang.SecurityManager<method*end> sm = System.getSecurityManager<method*start>java.lang.System.getSecurityManager<method*end>();
if (sm != null) {
Permission<method*start>java.security.Permission<method*end> perm = new MBeanPermission<method*start>javax.management.MBeanPermission<method*end>(instance.getClass<method*start>java.lang.ClassLoader.getClass<method*end>().getName<method*start>java.lang.Class.getName<method*end>(), null, name, "getClassLoader");
sm.checkPermission<method*start>java.lang.SecurityManager.checkPermission<method*end>(perm);
}
}
return instance;
}
|
@CallerSensitive
public final ClassLoader<method*start>java.lang.ClassLoader<method*end> getParent() {
SecurityManager<method*start>java.lang.SecurityManager<method*end> security = System.getSecurityManager<method*start>java.lang.System.getSecurityManager<method*end>();
ClassLoader<method*start>java.lang.ClassLoader<method*end> callersClassLoader = callerClassLoader();
/*[PR JAZZ103 76960] permission check is needed against the parent instead of this classloader */
if (needsClassLoaderPermissionCheck<method*start>java.lang.ClassLoader.needsClassLoaderPermissionCheck<method*end>(callersClassLoader, parent)) {
return parent;
}
| annotation | @CallerSensitive
public final ClassLoader<method*start>java.lang.ClassLoader<method*end> getParent() {
SecurityManager<method*start>java.lang.SecurityManager<method*end> security = System.getSecurityManager<method*start>java.lang.System.getSecurityManager<method*end>();
if (security != null) {
ClassLoader<method*start>java.lang.ClassLoader<method*end> callersClassLoader = callerClassLoader();
/*[PR JAZZ103 76960] permission check is needed against the parent instead of this classloader */
if (needsClassLoaderPermissionCheck<method*start>java.lang.ClassLoader.needsClassLoaderPermissionCheck<method*end>(callersClassLoader, parent)) {
security.checkPermission<method*start>java.lang.SecurityManager.checkPermission<method*end>(SecurityConstants.GET_CLASSLOADER_PERMISSION<method*start>sun.security.util.SecurityConstants.GET_CLASSLOADER_PERMISSION<method*end>);
}
}
return parent;
}
|
@Override
public void deleteProcRoleBinding(String procId, ProcRoleRequestDto procRoleRequestDto) throws WecubeCoreException {
ProcRoleBindingEntity.permissionEnum permissionEnum = transferPermissionStrToEnum(procRoleRequestDto.getPermission());
Optional<List<ProcRoleBindingEntity>> foundMgmtData = this.procRoleBindingRepository.findAllByProcIdAndPermission(procId, permissionEnum);
foundMgmtData.ifPresent(procRoleBindingEntities -> {
if (procRoleBindingEntities.size() <= procRoleRequestDto.getRoleIdList().size()) {
String msg = "The process's management permission should have at least one role.";
logger.info(String.format("The DELETE management roles operation was blocked, the process id is [%s].", procId));
throw new WecubeCoreException(msg);
}
);
}
for (String roleId : procRoleRequestDto.getRoleIdList()) {
this.procRoleBindingRepository.deleteByProcIdAndRoleIdAndPermission(procId, roleId, permissionEnum);
}
} | annotation | @Override<method*start>java.lang.Override<method*end>
public void deleteProcRoleBinding(String<method*start>java.lang.String<method*end> procId, ProcRoleRequestDto<method*start>com.webank.wecube.platform.core.dto.workflow.ProcRoleRequestDto<method*end> procRoleRequestDto) throws WecubeCoreException<method*start>com.webank.wecube.platform.core.commons.WecubeCoreException<method*end> {
ProcRoleBindingEntity.permissionEnum<method*start>com.webank.wecube.platform.core.entity.workflow.ProcRoleBindingEntity.permissionEnum<method*end> permissionEnum = transferPermissionStrToEnum(procRoleRequestDto.getPermission<method*start>com.webank.wecube.platform.core.dto.workflow.ProcRoleRequestDto.getPermission<method*end>());
// check if the current user has the role to manage such process
checkPermission<method*start>com.webank.wecube.platform.core.service.workflow.ProcessRoleServiceImpl.checkPermission<method*end>(procId, ProcRoleBindingEntity.permissionEnum.MGMT<method*start>com.webank.wecube.platform.core.entity.workflow.ProcRoleBindingEntity.permissionEnum.MGMT<method*end>);
// assure corresponding data has at least one row of MGMT permission
if (ProcRoleBindingEntity.permissionEnum.MGMT.equals<method*start>com.webank.wecube.platform.core.entity.workflow.ProcRoleBindingEntity.permissionEnum.equals<method*end>(permissionEnum)) {
Optional<method*start>java.util.Optional<method*end><List<method*start>java.util.List<method*end><ProcRoleBindingEntity>> foundMgmtData = this.procRoleBindingRepository.findAllByProcIdAndPermission<method*start>com.webank.wecube.platform.core.jpa.workflow.ProcRoleBindingRepository.findAllByProcIdAndPermission<method*end>(procId, permissionEnum);
foundMgmtData.ifPresent<method*start>java.util.Optional.ifPresent<method*end>(procRoleBindingEntities -> {
if (procRoleBindingEntities.size<method*start>procRoleBindingEntities.size<method*end>() <= procRoleRequestDto.getRoleIdList<method*start>com.webank.wecube.platform.core.dto.workflow.ProcRoleRequestDto.getRoleIdList<method*end>().size<method*start>java.util.List.size<method*end>()) {
String<method*start>java.lang.String<method*end> msg = "The process's management permission should have at least one role.";
logger.info<method*start>org.slf4j.Logger.info<method*end>(String.format<method*start>java.lang.String.format<method*end>("The DELETE management roles operation was blocked, the process id is [%s].", procId));
throw new WecubeCoreException<method*start>com.webank.wecube.platform.core.commons.WecubeCoreException<method*end>(msg);
}
});
}
for (String<method*start>java.lang.String<method*end> roleId : procRoleRequestDto.getRoleIdList<method*start>com.webank.wecube.platform.core.dto.workflow.ProcRoleRequestDto.getRoleIdList<method*end>()) {
this.procRoleBindingRepository.deleteByProcIdAndRoleIdAndPermission<method*start>com.webank.wecube.platform.core.jpa.workflow.ProcRoleBindingRepository.deleteByProcIdAndRoleIdAndPermission<method*end>(procId, roleId, permissionEnum);
}
}
|
@Deprecated
public boolean checkTopLevelWindow(Object window) {
if (window == null) {
throw new NullPointerException("window can't be null");
}
perm = SecurityConstants.ALL_PERMISSION;
}
try {
return true;
} catch (SecurityException se) {
// just return false
}
return false;
} | conventional | @Deprecated<method*start>java.lang.Deprecated<method*end>
public boolean checkTopLevelWindow(Object<method*start>java.lang.Object<method*end> window) {
if (window == null) {
throw new NullPointerException<method*start>java.lang.NullPointerException<method*end>("window can't be null");
}
Permission<method*start>java.security.Permission<method*end> perm = SecurityConstants.AWT.TOPLEVEL_WINDOW_PERMISSION<method*start>sun.security.util.SecurityConstants.AWT.TOPLEVEL_WINDOW_PERMISSION<method*end>;
if (perm == null) {
perm = SecurityConstants.ALL_PERMISSION<method*start>sun.security.util.SecurityConstants.ALL_PERMISSION<method*end>;
}
try {
checkPermission(perm);
return true;
} catch (SecurityException se) {
// just return false
}
return false;
}
|
@Override<method*start>java.lang.Override<method*end>
public Enumeration<method*start>java.util.Enumeration<method*end> findEntries(String<method*start>java.lang.String<method*end> path, String<method*start>java.lang.String<method*end> filePattern, boolean recurse) {
Object<method*start>java.lang.Object<method*end> sm = System.getSecurityManager<method*start>java.lang.System.getSecurityManager<method*end>();
return getFramework().findBundleEntries<method*start>org.apache.felix.framework.Felix.findBundleEntries<method*end>(this, path, filePattern, recurse);
} | annotation | @Override<method*start>java.lang.Override<method*end>
public Enumeration<method*start>java.util.Enumeration<method*end> findEntries(String<method*start>java.lang.String<method*end> path, String<method*start>java.lang.String<method*end> filePattern, boolean recurse) {
Object<method*start>java.lang.Object<method*end> sm = System.getSecurityManager<method*start>java.lang.System.getSecurityManager<method*end>();
if (sm != null) {
try {
((SecurityManager<method*start>java.lang.SecurityManager<method*end>) sm).checkPermission<method*start>java.lang.SecurityManager.checkPermission<method*end>(new AdminPermission<method*start>org.osgi.framework.AdminPermission<method*end>(this, AdminPermission.RESOURCE<method*start>org.osgi.framework.AdminPermission.RESOURCE<method*end>));
} catch (Exception<method*start>java.lang.Exception<method*end> e) {
// No permission
return null;
}
}
return getFramework().findBundleEntries<method*start>org.apache.felix.framework.Felix.findBundleEntries<method*end>(this, path, filePattern, recurse);
}
|
@Override<method*start>java.lang.Override<method*end>
public Path<method*start>java.nio.file.Path<method*end> readSymbolicLink(Path<method*start>java.nio.file.Path<method*end> obj1) throws IOException<method*start>java.io.IOException<method*end> {
WindowsPath<method*start>sun.nio.fs.WindowsPath<method*end> link = WindowsPath.toWindowsPath<method*start>sun.nio.fs.WindowsPath.toWindowsPath<method*end>(obj1);
WindowsFileSystem fs = link.getFileSystem<method*start>sun.nio.fs.WindowsPath.getFileSystem<method*end>();
// permission check
SecurityManager<method*start>java.lang.SecurityManager<method*end> sm = System.getSecurityManager<method*start>java.lang.System.getSecurityManager<method*end>();
FilePermission<method*start>java.io.FilePermission<method*end> perm = new FilePermission<method*start>java.io.FilePermission<method*end>(link.getPathForPermissionCheck<method*start>sun.nio.fs.WindowsPath.getPathForPermissionCheck<method*end>(), SecurityConstants.FILE_READLINK_ACTION<method*start>sun.security.util.SecurityConstants.FILE_READLINK_ACTION<method*end>);
return WindowsPath.createFromNormalizedPath<method*start>sun.nio.fs.WindowsPath.createFromNormalizedPath<method*end>(fs, target);
} | annotation | @Override<method*start>java.lang.Override<method*end>
public Path<method*start>java.nio.file.Path<method*end> readSymbolicLink(Path<method*start>java.nio.file.Path<method*end> obj1) throws IOException<method*start>java.io.IOException<method*end> {
WindowsPath<method*start>sun.nio.fs.WindowsPath<method*end> link = WindowsPath.toWindowsPath<method*start>sun.nio.fs.WindowsPath.toWindowsPath<method*end>(obj1);
WindowsFileSystem fs = link.getFileSystem<method*start>sun.nio.fs.WindowsPath.getFileSystem<method*end>();
// permission check
SecurityManager<method*start>java.lang.SecurityManager<method*end> sm = System.getSecurityManager<method*start>java.lang.System.getSecurityManager<method*end>();
if (sm != null) {
FilePermission<method*start>java.io.FilePermission<method*end> perm = new FilePermission<method*start>java.io.FilePermission<method*end>(link.getPathForPermissionCheck<method*start>sun.nio.fs.WindowsPath.getPathForPermissionCheck<method*end>(), SecurityConstants.FILE_READLINK_ACTION<method*start>sun.security.util.SecurityConstants.FILE_READLINK_ACTION<method*end>);
sm.checkPermission<method*start>java.lang.SecurityManager.checkPermission<method*end>(perm);
}
String<method*start>java.lang.String<method*end> target = WindowsLinkSupport.readLink<method*start>sun.nio.fs.WindowsLinkSupport.readLink<method*end>(link);
return WindowsPath.createFromNormalizedPath<method*start>sun.nio.fs.WindowsPath.createFromNormalizedPath<method*end>(fs, target);
}
|
private String<method*start>java.lang.String<method*end> getRealRoot(boolean isUser) {
// not sure about this, we should have already these permissions...
SecurityManager<method*start>java.lang.SecurityManager<method*end> security = System.getSecurityManager<method*start>java.lang.System.getSecurityManager<method*end>();
String<method*start>java.lang.String<method*end> root = null;
root = System.getProperty<method*start>java.lang.System.getProperty<method*end>("gnu.java.util.prefs.gconf.user_root", DEFAULT_USER_ROOT);
root = System.getProperty<method*start>java.lang.System.getProperty<method*end>("gnu.java.util.prefs.gconf.system_root", DEFAULT_SYSTEM_ROOT);
}
return root;
}
| conventional | private String<method*start>java.lang.String<method*end> getRealRoot(boolean isUser) {
// not sure about this, we should have already these permissions...
SecurityManager<method*start>java.lang.SecurityManager<method*end> security = System.getSecurityManager<method*start>java.lang.System.getSecurityManager<method*end>();
if (security != null) {
security.checkPermission<method*start>java.lang.SecurityManager.checkPermission<method*end>(PERMISSION);
}
String<method*start>java.lang.String<method*end> root = null;
if (isUser) {
root = System.getProperty<method*start>java.lang.System.getProperty<method*end>("gnu.java.util.prefs.gconf.user_root", DEFAULT_USER_ROOT);
} else {
root = System.getProperty<method*start>java.lang.System.getProperty<method*end>("gnu.java.util.prefs.gconf.system_root", DEFAULT_SYSTEM_ROOT);
}
return root;
}
|
@ImmediateService<method*start>org.objectweb.proactive.annotation.ImmediateService<method*end>
public boolean removeJobs(List<method*start>java.util.List<method*end><JobId<method*start>org.ow2.proactive.scheduler.common.job.JobId<method*end>> jobIds) throws NotConnectedException<method*start>org.ow2.proactive.scheduler.common.exception.NotConnectedException<method*end>, PermissionException<method*start>org.ow2.proactive.scheduler.common.exception.PermissionException<method*end> {
if (jobIds.isEmpty<method*start>java.util.List.isEmpty<method*end>()) {
return false;
}
// checking permission for each of the job
for (JobId<method*start>org.ow2.proactive.scheduler.common.job.JobId<method*end> jobId : jobIds) {
try {
} catch (UnknownJobException<method*start>org.ow2.proactive.scheduler.common.exception.UnknownJobException<method*end> e) {
logger.debug<method*start>org.apache.log4j.Logger.debug<method*end>(e);
}
}
return schedulingService.removeJobs<method*start>org.ow2.proactive.scheduler.core.SchedulingService.removeJobs<method*end>(jobIds);
} | annotation | @ImmediateService<method*start>org.objectweb.proactive.annotation.ImmediateService<method*end>
public boolean removeJobs(List<method*start>java.util.List<method*end><JobId<method*start>org.ow2.proactive.scheduler.common.job.JobId<method*end>> jobIds) throws NotConnectedException<method*start>org.ow2.proactive.scheduler.common.exception.NotConnectedException<method*end>, PermissionException<method*start>org.ow2.proactive.scheduler.common.exception.PermissionException<method*end> {
if (jobIds.isEmpty<method*start>java.util.List.isEmpty<method*end>()) {
return false;
}
// checking permission for each of the job
for (JobId<method*start>org.ow2.proactive.scheduler.common.job.JobId<method*end> jobId : jobIds) {
try {
frontendState.checkPermissions<method*start>org.ow2.proactive.scheduler.core.SchedulerFrontendState.checkPermissions<method*end>("removeJob", frontendState.getIdentifiedJob<method*start>org.ow2.proactive.scheduler.core.SchedulerFrontendState.getIdentifiedJob<method*end>(jobId), YOU_DO_NOT_HAVE_PERMISSION_TO_REMOVE_THIS_JOB<method*start>org.ow2.proactive.scheduler.core.SchedulerFrontendState.YOU_DO_NOT_HAVE_PERMISSION_TO_REMOVE_THIS_JOB<method*end>);
} catch (UnknownJobException<method*start>org.ow2.proactive.scheduler.common.exception.UnknownJobException<method*end> e) {
logger.debug<method*start>org.apache.log4j.Logger.debug<method*end>(e);
}
}
return schedulingService.removeJobs<method*start>org.ow2.proactive.scheduler.core.SchedulingService.removeJobs<method*end>(jobIds);
}
|
public static synchronized MBeanServer<method*start>javax.management.MBeanServer<method*end> getPlatformMBeanServer() {
SecurityManager<method*start>java.lang.SecurityManager<method*end> sm = System.getSecurityManager<method*start>java.lang.System.getSecurityManager<method*end>();
Permission<method*start>java.security.Permission<method*end> perm = new MBeanServerPermission<method*start>javax.management.MBeanServerPermission<method*end>("createMBeanServer");
platformMBeanServer = MBeanServerFactory.createMBeanServer<method*start>javax.management.MBeanServerFactory.createMBeanServer<method*end>();
platformComponents<method*start>java.lang.management.ManagementFactory.platformComponents<method*end>().stream<method*start>java.util.Collection.stream<method*end>().filter<method*start>java.util.stream.Stream.filter<method*end>(PlatformComponent<method*start>sun.management.spi.PlatformMBeanProvider.PlatformComponent<method*end>::shouldRegister).flatMap<method*start>java.util.stream.Stream.flatMap<method*end>(pc -> pc.nameToMBeanMap<method*start>com.google.android.gms.internal.pc.nameToMBeanMap<method*end>().entrySet().stream()).forEach<method*start>java.util.stream.Stream.forEach<method*end>(entry -> addMXBean<method*start>java.lang.management.ManagementFactory.addMXBean<method*end>(platformMBeanServer, entry.getKey<method*start>entry.getKey<method*end>(), entry.getValue<method*start>entry.getValue<method*end>()));
return platformMBeanServer;
}
| conventional | public static synchronized MBeanServer<method*start>javax.management.MBeanServer<method*end> getPlatformMBeanServer() {
SecurityManager<method*start>java.lang.SecurityManager<method*end> sm = System.getSecurityManager<method*start>java.lang.System.getSecurityManager<method*end>();
if (sm != null) {
Permission<method*start>java.security.Permission<method*end> perm = new MBeanServerPermission<method*start>javax.management.MBeanServerPermission<method*end>("createMBeanServer");
sm.checkPermission<method*start>java.lang.SecurityManager.checkPermission<method*end>(perm);
}
if (platformMBeanServer == null) {
platformMBeanServer = MBeanServerFactory.createMBeanServer<method*start>javax.management.MBeanServerFactory.createMBeanServer<method*end>();
platformComponents<method*start>java.lang.management.ManagementFactory.platformComponents<method*end>().stream<method*start>java.util.Collection.stream<method*end>().filter<method*start>java.util.stream.Stream.filter<method*end>(PlatformComponent<method*start>sun.management.spi.PlatformMBeanProvider.PlatformComponent<method*end>::shouldRegister).flatMap<method*start>java.util.stream.Stream.flatMap<method*end>(pc -> pc.nameToMBeanMap<method*start>com.google.android.gms.internal.pc.nameToMBeanMap<method*end>().entrySet().stream()).forEach<method*start>java.util.stream.Stream.forEach<method*end>(entry -> addMXBean<method*start>java.lang.management.ManagementFactory.addMXBean<method*end>(platformMBeanServer, entry.getKey<method*start>entry.getKey<method*end>(), entry.getValue<method*start>entry.getValue<method*end>()));
}
return platformMBeanServer;
}
|
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull<method*start>androidx.annotation.NonNull<method*end> String[] permissions, @NonNull<method*start>androidx.annotation.NonNull<method*end> int[] grantResults) {
super.onRequestPermissionsResult<method*start>androidx.appcompat.app.AppCompatActivity.onRequestPermissionsResult<method*end>(requestCode, permissions, grantResults);
if (requestCode == 1000) {
if (grantResults.length<method*start>int[].length<method*end> > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED<method*start>android.content.pm.PackageManager.PERMISSION_GRANTED<method*end>) {
downloadFile(current_Xmodel);
} else {
Toast.makeText<method*start>android.widget.Toast.makeText<method*end>(this, "You need to allow this permission!", Toast.LENGTH_SHORT<method*start>android.widget.Toast.LENGTH_SHORT<method*end>).show<method*start>android.widget.Toast.show<method*end>();
}
return;
}
} | annotation | @Override
public void onRequestPermissionsResult(int requestCode, @NonNull<method*start>androidx.annotation.NonNull<method*end> String[] permissions, @NonNull<method*start>androidx.annotation.NonNull<method*end> int[] grantResults) {
super.onRequestPermissionsResult<method*start>androidx.appcompat.app.AppCompatActivity.onRequestPermissionsResult<method*end>(requestCode, permissions, grantResults);
if (requestCode == 1000) {
if (grantResults.length<method*start>int[].length<method*end> > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED<method*start>android.content.pm.PackageManager.PERMISSION_GRANTED<method*end>) {
downloadFile(current_Xmodel);
} else {
checkPermissions();
Toast.makeText<method*start>android.widget.Toast.makeText<method*end>(this, "You need to allow this permission!", Toast.LENGTH_SHORT<method*start>android.widget.Toast.LENGTH_SHORT<method*end>).show<method*start>android.widget.Toast.show<method*end>();
}
return;
}
}
|
public boolean hasAccess(final WikiContext<method*start>org.apache.wiki.WikiContext<method*end> context, final HttpServletResponse<method*start>javax.servlet.http.HttpServletResponse<method*end> response, final boolean redirect) throws IOException<method*start>java.io.IOException<method*end> {
final boolean allowed = context.requiredPermission<method*start>org.apache.wiki.WikiContext.requiredPermission<method*end>());
final ResourceBundle<method*start>java.util.ResourceBundle<method*end> rb = Preferences.getBundle<method*start>org.apache.wiki.preferences.Preferences.getBundle<method*end>(context, InternationalizationManager.CORE_BUNDLE<method*start>org.apache.wiki.i18n.InternationalizationManager.CORE_BUNDLE<method*end>);
// Stash the wiki context
if (context.getHttpRequest<method*start>org.apache.wiki.WikiContext.getHttpRequest<method*end>() != null && context.getHttpRequest<method*start>org.apache.wiki.WikiContext.getHttpRequest<method*end>().getAttribute<method*start>javax.servlet.http.HttpServletRequest.getAttribute<method*end>(WikiContext.ATTR_CONTEXT<method*start>org.apache.wiki.WikiContext.ATTR_CONTEXT<method*end>) == null) {
context.getHttpRequest<method*start>org.apache.wiki.WikiContext.getHttpRequest<method*end>().setAttribute<method*start>javax.servlet.http.HttpServletRequest.setAttribute<method*end>(WikiContext.ATTR_CONTEXT<method*start>org.apache.wiki.WikiContext.ATTR_CONTEXT<method*end>, context);
}
// If access not allowed, redirect
final Principal<method*start>java.security.Principal<method*end> currentUser = context.getWikiSession<method*start>org.apache.wiki.WikiContext.getWikiSession<method*end>().getUserPrincipal<method*start>org.apache.wiki.WikiSession.getUserPrincipal<method*end>();
final String<method*start>java.lang.String<method*end> pageurl = context.getPage<method*start>org.apache.wiki.WikiContext.getPage<method*end>().getName<method*start>org.apache.wiki.WikiPage.getName<method*end>();
if (context.getWikiSession<method*start>org.apache.wiki.WikiContext.getWikiSession<method*end>().isAuthenticated<method*start>org.apache.wiki.WikiSession.isAuthenticated<method*end>()) {
log.info<method*start>org.apache.log4j.Logger.info<method*end>("User " + currentUser.getName<method*start>java.security.Principal.getName<method*end>() + " has no access - forbidden (permission=" + context.requiredPermission<method*start>org.apache.wiki.WikiContext.requiredPermission<method*end>() + ")");
context.getWikiSession<method*start>org.apache.wiki.WikiContext.getWikiSession<method*end>().addMessage<method*start>org.apache.wiki.WikiSession.addMessage<method*end>(MessageFormat.format<method*start>java.text.MessageFormat.format<method*end>(rb.getString<method*start>java.util.ResourceBundle.getString<method*end>("security.error.noaccess.logged"), context.getName<method*start>org.apache.wiki.WikiContext.getName<method*end>()));
} else {
log.info<method*start>org.apache.log4j.Logger.info<method*end>("User " + currentUser.getName<method*start>java.security.Principal.getName<method*end>() + " has no access - redirecting (permission=" + context.requiredPermission<method*start>org.apache.wiki.WikiContext.requiredPermission<method*end>() + ")");
context.getWikiSession<method*start>org.apache.wiki.WikiContext.getWikiSession<method*end>().addMessage<method*start>org.apache.wiki.WikiSession.addMessage<method*end>(MessageFormat.format<method*start>java.text.MessageFormat.format<method*end>(rb.getString<method*start>java.util.ResourceBundle.getString<method*end>("security.error.noaccess"), context.getName<method*start>org.apache.wiki.WikiContext.getName<method*end>()));
}
response.sendRedirect<method*start>javax.servlet.http.HttpServletResponse.sendRedirect<method*end>(m_engine.getURL<method*start>org.apache.wiki.WikiEngine.getURL<method*end>(WikiContext.LOGIN<method*start>org.apache.wiki.WikiContext.LOGIN<method*end>, pageurl, null));
}
return allowed;
} | conventional | public boolean hasAccess(final WikiContext<method*start>org.apache.wiki.WikiContext<method*end> context, final HttpServletResponse<method*start>javax.servlet.http.HttpServletResponse<method*end> response, final boolean redirect) throws IOException<method*start>java.io.IOException<method*end> {
final boolean allowed = checkPermission(context.getWikiSession<method*start>org.apache.wiki.WikiContext.getWikiSession<method*end>(), context.requiredPermission<method*start>org.apache.wiki.WikiContext.requiredPermission<method*end>());
final ResourceBundle<method*start>java.util.ResourceBundle<method*end> rb = Preferences.getBundle<method*start>org.apache.wiki.preferences.Preferences.getBundle<method*end>(context, InternationalizationManager.CORE_BUNDLE<method*start>org.apache.wiki.i18n.InternationalizationManager.CORE_BUNDLE<method*end>);
// Stash the wiki context
if (context.getHttpRequest<method*start>org.apache.wiki.WikiContext.getHttpRequest<method*end>() != null && context.getHttpRequest<method*start>org.apache.wiki.WikiContext.getHttpRequest<method*end>().getAttribute<method*start>javax.servlet.http.HttpServletRequest.getAttribute<method*end>(WikiContext.ATTR_CONTEXT<method*start>org.apache.wiki.WikiContext.ATTR_CONTEXT<method*end>) == null) {
context.getHttpRequest<method*start>org.apache.wiki.WikiContext.getHttpRequest<method*end>().setAttribute<method*start>javax.servlet.http.HttpServletRequest.setAttribute<method*end>(WikiContext.ATTR_CONTEXT<method*start>org.apache.wiki.WikiContext.ATTR_CONTEXT<method*end>, context);
}
// If access not allowed, redirect
if (!allowed && redirect) {
final Principal<method*start>java.security.Principal<method*end> currentUser = context.getWikiSession<method*start>org.apache.wiki.WikiContext.getWikiSession<method*end>().getUserPrincipal<method*start>org.apache.wiki.WikiSession.getUserPrincipal<method*end>();
final String<method*start>java.lang.String<method*end> pageurl = context.getPage<method*start>org.apache.wiki.WikiContext.getPage<method*end>().getName<method*start>org.apache.wiki.WikiPage.getName<method*end>();
if (context.getWikiSession<method*start>org.apache.wiki.WikiContext.getWikiSession<method*end>().isAuthenticated<method*start>org.apache.wiki.WikiSession.isAuthenticated<method*end>()) {
log.info<method*start>org.apache.log4j.Logger.info<method*end>("User " + currentUser.getName<method*start>java.security.Principal.getName<method*end>() + " has no access - forbidden (permission=" + context.requiredPermission<method*start>org.apache.wiki.WikiContext.requiredPermission<method*end>() + ")");
context.getWikiSession<method*start>org.apache.wiki.WikiContext.getWikiSession<method*end>().addMessage<method*start>org.apache.wiki.WikiSession.addMessage<method*end>(MessageFormat.format<method*start>java.text.MessageFormat.format<method*end>(rb.getString<method*start>java.util.ResourceBundle.getString<method*end>("security.error.noaccess.logged"), context.getName<method*start>org.apache.wiki.WikiContext.getName<method*end>()));
} else {
log.info<method*start>org.apache.log4j.Logger.info<method*end>("User " + currentUser.getName<method*start>java.security.Principal.getName<method*end>() + " has no access - redirecting (permission=" + context.requiredPermission<method*start>org.apache.wiki.WikiContext.requiredPermission<method*end>() + ")");
context.getWikiSession<method*start>org.apache.wiki.WikiContext.getWikiSession<method*end>().addMessage<method*start>org.apache.wiki.WikiSession.addMessage<method*end>(MessageFormat.format<method*start>java.text.MessageFormat.format<method*end>(rb.getString<method*start>java.util.ResourceBundle.getString<method*end>("security.error.noaccess"), context.getName<method*start>org.apache.wiki.WikiContext.getName<method*end>()));
}
response.sendRedirect<method*start>javax.servlet.http.HttpServletResponse.sendRedirect<method*end>(m_engine.getURL<method*start>org.apache.wiki.WikiEngine.getURL<method*end>(WikiContext.LOGIN<method*start>org.apache.wiki.WikiContext.LOGIN<method*end>, pageurl, null));
}
return allowed;
}
|
@Override
public boolean hasPermissionOffline(String<method*start>java.lang.String<method*end> name, PermissionNode<method*start>fr.xephi.authme.permission.PermissionNode<method*end> node) {
User<method*start>net.luckperms.api.model.user.User<method*end> user = luckPerms.getUserManager<method*start>net.luckperms.api.LuckPerms.getUserManager<method*end>().getUser(name);
logger.warning<method*start>fr.xephi.authme.ConsoleLogger.warning<method*end>("LuckPermsHandler: tried to check permission for offline user " + name + " but it isn't loaded!");
return false;
CachedPermissionData<method*start>net.luckperms.api.cacheddata.CachedPermissionData<method*end> permissionData = user.getCachedData<method*start>net.luckperms.api.model.user.User.getCachedData<method*end>().getPermissionData(QueryOptions.builder<method*start>net.luckperms.api.query.QueryOptions.builder<method*end>(QueryMode.NON_CONTEXTUAL<method*start>net.luckperms.api.query.QueryMode.NON_CONTEXTUAL<method*end>).build());
return permissionData.checkPermission<method*start>net.luckperms.api.cacheddata.CachedPermissionData.checkPermission<method*end>(node.getNode<method*start>fr.xephi.authme.permission.PermissionNode.getNode<method*end>()).asBoolean();
} | annotation | @Override
public boolean hasPermissionOffline(String<method*start>java.lang.String<method*end> name, PermissionNode<method*start>fr.xephi.authme.permission.PermissionNode<method*end> node) {
User<method*start>net.luckperms.api.model.user.User<method*end> user = luckPerms.getUserManager<method*start>net.luckperms.api.LuckPerms.getUserManager<method*end>().getUser(name);
if (user == null) {
logger.warning<method*start>fr.xephi.authme.ConsoleLogger.warning<method*end>("LuckPermsHandler: tried to check permission for offline user " + name + " but it isn't loaded!");
return false;
}
CachedPermissionData<method*start>net.luckperms.api.cacheddata.CachedPermissionData<method*end> permissionData = user.getCachedData<method*start>net.luckperms.api.model.user.User.getCachedData<method*end>().getPermissionData(QueryOptions.builder<method*start>net.luckperms.api.query.QueryOptions.builder<method*end>(QueryMode.NON_CONTEXTUAL<method*start>net.luckperms.api.query.QueryMode.NON_CONTEXTUAL<method*end>).build());
return permissionData.checkPermission<method*start>net.luckperms.api.cacheddata.CachedPermissionData.checkPermission<method*end>(node.getNode<method*start>fr.xephi.authme.permission.PermissionNode.getNode<method*end>()).asBoolean();
}
|
private static void checkMBeanTrustPermission(final Class<method*start>java.lang.Class<method*end> theClass) throws
Permission<method*start>java.security.Permission<method*end> perm = new MBeanTrustPermission<method*start>javax.management.MBeanTrustPermission<method*end>("register");
PrivilegedAction<method*start>java.security.PrivilegedAction<method*end><ProtectionDomain<method*start>java.security.ProtectionDomain<method*end>> act = new PrivilegedAction<method*start>java.security.PrivilegedAction<method*end><ProtectionDomain<method*start>java.security.ProtectionDomain<method*end>>() {
public ProtectionDomain<method*start>java.security.ProtectionDomain<method*end> run() {
return theClass.getProtectionDomain<method*start>java.lang.Class.getProtectionDomain<method*end>();
}
};
ProtectionDomain<method*start>java.security.ProtectionDomain<method*end> pd = AccessController.doPrivileged<method*start>java.security.AccessController.doPrivileged<method*end>(act);
AccessControlContext<method*start>java.security.AccessControlContext<method*end> acc = new AccessControlContext<method*start>java.security.AccessControlContext<method*end>(new ProtectionDomain<method*start>java.security.ProtectionDomain<method*end>[] { pd });
}
} | conventional | private static void checkMBeanTrustPermission(final Class<method*start>java.lang.Class<method*end> theClass) throws SecurityException<method*start>java.lang.SecurityException<method*end> {
SecurityManager<method*start>java.lang.SecurityManager<method*end> sm = System.getSecurityManager<method*start>java.lang.System.getSecurityManager<method*end>();
if (sm != null) {
Permission<method*start>java.security.Permission<method*end> perm = new MBeanTrustPermission<method*start>javax.management.MBeanTrustPermission<method*end>("register");
PrivilegedAction<method*start>java.security.PrivilegedAction<method*end><ProtectionDomain<method*start>java.security.ProtectionDomain<method*end>> act = new PrivilegedAction<method*start>java.security.PrivilegedAction<method*end><ProtectionDomain<method*start>java.security.ProtectionDomain<method*end>>() {
public ProtectionDomain<method*start>java.security.ProtectionDomain<method*end> run() {
return theClass.getProtectionDomain<method*start>java.lang.Class.getProtectionDomain<method*end>();
}
};
ProtectionDomain<method*start>java.security.ProtectionDomain<method*end> pd = AccessController.doPrivileged<method*start>java.security.AccessController.doPrivileged<method*end>(act);
AccessControlContext<method*start>java.security.AccessControlContext<method*end> acc = new AccessControlContext<method*start>java.security.AccessControlContext<method*end>(new ProtectionDomain<method*start>java.security.ProtectionDomain<method*end>[] { pd });
sm.checkPermission<method*start>java.lang.SecurityManager.checkPermission<method*end>(perm, acc);
}
}
|
@Override<method*start>java.lang.Override<method*end>
public void createLink(Path<method*start>java.nio.file.Path<method*end> linkPath, Path<method*start>java.nio.file.Path<method*end> targetPath) throws IOException<method*start>java.io.IOException<method*end> {
WindowsPath<method*start>sun.nio.fs.WindowsPath<method*end> link = WindowsPath.toWindowsPath<method*start>sun.nio.fs.WindowsPath.toWindowsPath<method*end>(linkPath);
WindowsPath<method*start>sun.nio.fs.WindowsPath<method*end> existing = WindowsPath.toWindowsPath<method*start>sun.nio.fs.WindowsPath.toWindowsPath<method*end>(targetPath);
SecurityManager<method*start>java.lang.SecurityManager<method*end> sm = System.getSecurityManager<method*start>java.lang.System.getSecurityManager<method*end>();
link.checkWrite<method*start>sun.nio.fs.WindowsPath.checkWrite<method*end>();
existing.checkWrite<method*start>sun.nio.fs.WindowsPath.checkWrite<method*end>();
// create hard link
try {
CreateHardLink<method*start>sun.nio.fs.WindowsNativeDispatcher.CreateHardLink<method*end>(link.getPathForWin32Calls<method*start>sun.nio.fs.WindowsPath.getPathForWin32Calls<method*end>(), existing.getPathForWin32Calls<method*start>sun.nio.fs.WindowsPath.getPathForWin32Calls<method*end>());
} catch (WindowsException x) {
x.rethrowAsIOException<method*start>sun.nio.fs.WindowsException.rethrowAsIOException<method*end>(link, existing);
}
}
| annotation | @Override<method*start>java.lang.Override<method*end>
public void createLink(Path<method*start>java.nio.file.Path<method*end> linkPath, Path<method*start>java.nio.file.Path<method*end> targetPath) throws IOException<method*start>java.io.IOException<method*end> {
WindowsPath<method*start>sun.nio.fs.WindowsPath<method*end> link = WindowsPath.toWindowsPath<method*start>sun.nio.fs.WindowsPath.toWindowsPath<method*end>(linkPath);
WindowsPath<method*start>sun.nio.fs.WindowsPath<method*end> existing = WindowsPath.toWindowsPath<method*start>sun.nio.fs.WindowsPath.toWindowsPath<method*end>(targetPath);
// permission check
SecurityManager<method*start>java.lang.SecurityManager<method*end> sm = System.getSecurityManager<method*start>java.lang.System.getSecurityManager<method*end>();
if (sm != null) {
sm.checkPermission<method*start>java.lang.SecurityManager.checkPermission<method*end>(new LinkPermission<method*start>java.nio.file.LinkPermission<method*end>("hard"));
link.checkWrite<method*start>sun.nio.fs.WindowsPath.checkWrite<method*end>();
existing.checkWrite<method*start>sun.nio.fs.WindowsPath.checkWrite<method*end>();
}
// create hard link
try {
CreateHardLink<method*start>sun.nio.fs.WindowsNativeDispatcher.CreateHardLink<method*end>(link.getPathForWin32Calls<method*start>sun.nio.fs.WindowsPath.getPathForWin32Calls<method*end>(), existing.getPathForWin32Calls<method*start>sun.nio.fs.WindowsPath.getPathForWin32Calls<method*end>());
} catch (WindowsException x) {
x.rethrowAsIOException<method*start>sun.nio.fs.WindowsException.rethrowAsIOException<method*end>(link, existing);
}
}
|
@Override<method*start>java.lang.Override<method*end>
public String<method*start>java.lang.String<method*end> registerConfigProvider(String<method*start>java.lang.String<method*end> className, Map<method*start>java.util.Map<method*end> properties, String<method*start>java.lang.String<method*end> layer, String<method*start>java.lang.String<method*end> appContext, String<method*start>java.lang.String<method*end> description) {
// XXX do we need doPrivilege here
AuthConfigProvider<method*start>javax.security.auth.message.config.AuthConfigProvider<method*end> provider = _constructProvider<method*start>com.sun.jaspic.config.factory.BaseAuthConfigFactory._constructProvider<method*end>(className, properties, null);
return _register<method*start>com.sun.jaspic.config.factory.BaseAuthConfigFactory._register<method*end>(provider, properties, layer, appContext, description, true);
}
| annotation | @Override<method*start>java.lang.Override<method*end>
public String<method*start>java.lang.String<method*end> registerConfigProvider(String<method*start>java.lang.String<method*end> className, Map<method*start>java.util.Map<method*end> properties, String<method*start>java.lang.String<method*end> layer, String<method*start>java.lang.String<method*end> appContext, String<method*start>java.lang.String<method*end> description) {
// XXX factory must check permission
SecurityManager<method*start>java.lang.SecurityManager<method*end> sm = System.getSecurityManager<method*start>java.lang.System.getSecurityManager<method*end>();
if (sm != null) {
sm.checkPermission<method*start>java.lang.SecurityManager.checkPermission<method*end>(AuthConfigFactory.providerRegistrationSecurityPermission<method*start>javax.security.auth.message.config.AuthConfigFactory.providerRegistrationSecurityPermission<method*end>);
}
// XXX do we need doPrivilege here
AuthConfigProvider<method*start>javax.security.auth.message.config.AuthConfigProvider<method*end> provider = _constructProvider<method*start>com.sun.jaspic.config.factory.BaseAuthConfigFactory._constructProvider<method*end>(className, properties, null);
return _register<method*start>com.sun.jaspic.config.factory.BaseAuthConfigFactory._register<method*end>(provider, properties, layer, appContext, description, true);
}
|
public static synchronized boolean checkRemoveCallerContext(Subject subject) {
try {
final Principal[] dp = subject.getPrincipals().toArray(new Principal[0]);
for (int i = 0; i < dp.length; i++) {
final String pname = dp[i].getClass().getName() + "." + dp[i].getName();
final Permission sdp = new SubjectDelegationPermission(pname);
}
} catch (SecurityException e) {
return false;
}
return true;
} | conventional | public static synchronized boolean checkRemoveCallerContext(Subject<method*start>javax.security.auth.Subject<method*end> subject) {
try {
final Principal<method*start>java.security.Principal<method*end>[] dp = subject.getPrincipals<method*start>javax.security.auth.Subject.getPrincipals<method*end>().toArray<method*start>java.util.Set.toArray<method*end>(new Principal[0]);
for (int i = 0; i < dp.length<method*start>java.security.Principal[].length<method*end>; i++) {
final String<method*start>java.lang.String<method*end> pname = dp[i].getClass<method*start>java.security.Principal.getClass<method*end>().getName<method*start>java.security.Principal.getName<method*end>() + "." + dp[i].getName<method*start>java.security.Principal.getName<method*end>();
final Permission<method*start>java.security.Permission<method*end> sdp = new SubjectDelegationPermission<method*start>javax.management.remote.SubjectDelegationPermission<method*end>(pname);
AccessController.checkPermission<method*start>java.security.AccessController.checkPermission<method*end>(sdp);
}
} catch (SecurityException<method*start>java.lang.SecurityException<method*end> e) {
return false;
}
return true;
}
|
@Ove<method*start>java.util.Set<method*end>rride
public Set<String> getCallerGroups(Creden<method*start>javax.security.enterprise.identitystore.CredentialValidationResult<method*end>tialValidationResult validationResult) {
LdapContext searchContext = cre<method*start>org.glassfish.soteria.identitystores.LdapIdentityStore.createSearchLdapContext<method*end>ateSearchLdapContext();
try <method*start>java.lang.String<method*end>{
String callerDn = validati<method*start>javax.security.enterprise.identitystore.CredentialValidationResult.getCallerDn<method*end>onResult.getCallerDn();
if (callerDn == null<method*start>java.lang.String.isEmpty<method*end> || callerDn.isEmpty()) {
callerDn = getCallerDn(searchContext, validationResul<method*start>javax.security.enterprise.identitystore.CredentialValidationResult.getCallerPrincipal<method*end>t.getCalle<method*start>javax.security.enterprise.CallerPrincipal.getName<method*end>rPrincipal().getName());
}
return retrieveGroupsForCallerDn(searchContext, callerDn);
} finally {
closeContext(searchContext);
}
} | annotation | @Ove<method*start>java.util.Set<method*end>rride
public Set<String> getCallerGroups(Creden<method*start>javax.security.enterprise.identitystore.CredentialValidationResult<method*end>tialValidationResult validationResult) {
// Make sure caller has permission to invoke this method
SecurityManager secu<method*start>java.lang.System<method*end>rityManager = Syste<method*start>java.lang.System.getSecurityManager<method*end>m.getSecurityManager();
if (securityManager != null) {
securityMan<method*start>java.lang.SecurityManager.checkPermission<method*end>ager.checkPermission(new Ide<method*start>javax.security.enterprise.identitystore.IdentityStorePermission<method*end>ntityStorePermission("getGroups"));
}
LdapContext searchContext = cre<method*start>org.glassfish.soteria.identitystores.LdapIdentityStore.createSearchLdapContext<method*end>ateSearchLdapContext();
try <method*start>java.lang.String<method*end>{
String callerDn = validati<method*start>javax.security.enterprise.identitystore.CredentialValidationResult.getCallerDn<method*end>onResult.getCallerDn();
if (callerDn == null<method*start>java.lang.String.isEmpty<method*end> || callerDn.isEmpty()) {
callerDn = getCallerDn(searchContext, validationResul<method*start>javax.security.enterprise.identitystore.CredentialValidationResult.getCallerPrincipal<method*end>t.getCalle<method*start>javax.security.enterprise.CallerPrincipal.getName<method*end>rPrincipal().getName());
}
return retrieveGroupsForCallerDn(searchContext, callerDn);
} finally {
closeContext(searchContext);
}
}
|
@Override
@ImmediateService
public boolean killJobs(List<String> jobIds) throws NotConnectedException, PermissionException {
if (jobIds.isEmpty()) {
return false;
}
List<JobId> jobIdsConverted = jobIds.stream().map(JobIdImpl::makeJobId).collect(Collectors.toList());
return schedulingService.killJobs(jobIdsConverted);
} | annotation | @Override<method*start>java.lang.Override<method*end>
@ImmediateService<method*start>org.objectweb.proactive.annotation.ImmediateService<method*end>
public boolean killJobs(List<method*start>java.util.List<method*end><String<method*start>java.lang.String<method*end>> jobIds) throws NotConnectedException<method*start>org.ow2.proactive.scheduler.common.exception.NotConnectedException<method*end>, PermissionException<method*start>org.ow2.proactive.scheduler.common.exception.PermissionException<method*end> {
if (jobIds.isEmpty<method*start>java.util.List.isEmpty<method*end>()) {
return false;
}
List<method*start>java.util.List<method*end><JobId<method*start>org.ow2.proactive.scheduler.common.job.JobId<method*end>> jobIdsConverted = jobIds.stream<method*start>java.util.List.stream<method*end>().map<method*start>java.util.stream.Stream.map<method*end>(JobIdImpl<method*start>org.ow2.proactive.scheduler.job.JobIdImpl<method*end>::makeJobId).collect<method*start>java.util.stream.Stream.collect<method*end>(Collectors.toList<method*start>java.util.stream.Collectors.toList<method*end>());
// checking permission for each of the job
for (JobId<method*start>org.ow2.proactive.scheduler.common.job.JobId<method*end> jobId : jobIdsConverted) {
try {
frontendState.checkPermissions<method*start>org.ow2.proactive.scheduler.core.SchedulerFrontendState.checkPermissions<method*end>("removeJob", frontendState.getIdentifiedJob<method*start>org.ow2.proactive.scheduler.core.SchedulerFrontendState.getIdentifiedJob<method*end>(jobId), YOU_DO_NOT_HAVE_PERMISSION_TO_REMOVE_THIS_JOB<method*start>org.ow2.proactive.scheduler.core.SchedulerFrontendState.YOU_DO_NOT_HAVE_PERMISSION_TO_REMOVE_THIS_JOB<method*end>);
} catch (UnknownJobException<method*start>org.ow2.proactive.scheduler.common.exception.UnknownJobException<method*end> e) {
logger.debug<method*start>org.apache.log4j.Logger.debug<method*end>(e);
}
}
return schedulingService.killJobs<method*start>org.ow2.proactive.scheduler.core.SchedulingService.killJobs<method*end>(jobIdsConverted);
}
|
@Implementation(minSdk<method*start>org.robolectric.annotation.Implements.minSdk<method*end> = M<method*start>android.os.Build.VERSION_CODES.M<method*end>)
protected void grantRuntimePermission(String<method*start>java.lang.String<method*end> packageName, String<method*start>java.lang.String<method*end> permissionName, UserHandle<method*start>android.os.UserHandle<method*end> user) {
if (!packageInfos.containsKey<method*start>java.util.Map.containsKey<method*end>(packageName)) {
throw new SecurityException<method*start>java.lang.SecurityException<method*end>("Package not found: " + packageName);
}
PackageInfo<method*start>android.content.pm.PackageInfo<method*end> packageInfo = packageInfos.get<method*start>java.util.Map.get<method*end>(packageName);
packageInfo.requestedPermissionsFlags<method*start>android.content.pm.PackageInfo.requestedPermissionsFlags<method*end>[permissionIndex] |= REQUESTED_PERMISSION_GRANTED<method*start>android.content.pm.PackageInfo.REQUESTED_PERMISSION_GRANTED<method*end>;
} | annotation | @Implementation(minSdk<method*start>org.robolectric.annotation.Implements.minSdk<method*end> = M<method*start>android.os.Build.VERSION_CODES.M<method*end>)
protected void grantRuntimePermission(String<method*start>java.lang.String<method*end> packageName, String<method*start>java.lang.String<method*end> permissionName, UserHandle<method*start>android.os.UserHandle<method*end> user) {
if (!packageInfos.containsKey<method*start>java.util.Map.containsKey<method*end>(packageName)) {
throw new SecurityException<method*start>java.lang.SecurityException<method*end>("Package not found: " + packageName);
}
PackageInfo<method*start>android.content.pm.PackageInfo<method*end> packageInfo = packageInfos.get<method*start>java.util.Map.get<method*end>(packageName);
checkPermissionGrantStateInitialized<method*start>org.robolectric.shadows.ShadowApplicationPackageManager.checkPermissionGrantStateInitialized<method*end>(packageInfo);
int permissionIndex = getPermissionIndex<method*start>org.robolectric.shadows.ShadowApplicationPackageManager.getPermissionIndex<method*end>(packageInfo, permissionName);
if (permissionIndex < 0) {
throw new SecurityException<method*start>java.lang.SecurityException<method*end>("Permission " + permissionName + " not requested by package " + packageName);
}
packageInfo.requestedPermissionsFlags<method*start>android.content.pm.PackageInfo.requestedPermissionsFlags<method*end>[permissionIndex] |= REQUESTED_PERMISSION_GRANTED<method*start>android.content.pm.PackageInfo.REQUESTED_PERMISSION_GRANTED<method*end>;
}
|
public byte[] getHardwareAddress() throws SocketException {
catch (SecurityException e) {
if (!getInetAddresses().hasMoreElements()) {
// don't have connect permission to any local address
return null;
}
}
}
for (InetAddress addr : addrs) {
if (addr instanceof Inet4Address) {
return getMacAddr0(((Inet4Address) addr).getAddress(), name, index);
}
}
return getMacAddr0(null, name, index);
} | conventional | public byte[] getHardwareAddress() throws SocketException<method*start>java.net.SocketException<method*end> {
SecurityManager<method*start>java.lang.SecurityManager<method*end> sec = System.getSecurityManager<method*start>java.lang.System.getSecurityManager<method*end>();
if (sec != null) {
try {
sec.checkPermission<method*start>java.lang.SecurityManager.checkPermission<method*end>(new NetPermission("getNetworkInformation"));
} catch (SecurityException<method*start>java.lang.SecurityException<method*end> e) {
if (!getInetAddresses().hasMoreElements<method*start>java.util.Enumeration.hasMoreElements<method*end>()) {
// don't have connect permission to any local address
return null;
}
}
}
for (InetAddress<method*start>java.net.InetAddress<method*end> addr : addrs) {
if (addr instanceof Inet4Address<method*start>java.net.Inet4Address<method*end>) {
return getMacAddr0<method*start>java.net.NetworkInterface.getMacAddr0<method*end>(((Inet4Address<method*start>java.net.Inet4Address<method*end>) addr).getAddress<method*start>java.net.Inet4Address.getAddress<method*end>(), name, index);
}
}
return getMacAddr0<method*start>java.net.NetworkInterface.getMacAddr0<method*end>(null, name, index);
}
|
@Override<method*start>java.lang.Override<method*end>
public void setAdmin(String<method*start>java.lang.String<method*end> domain, String<method*start>java.lang.String<method*end> requestAdminLoginName, String<method*start>java.lang.String<method*end> targetUserLoginName, Admin<method*start>org.krakenapps.dom.model.Admin<method*end> admin) {
prepare<method*start>org.krakenapps.dom.api.impl.AdminApiImpl.prepare<method*end>(admin);
User<method*start>org.krakenapps.dom.model.User<method*end> target = userApi.getUser<method*start>org.krakenapps.dom.api.UserApi.getUser<method*end>(domain, targetUserLoginName);
if (target.getExt<method*start>org.krakenapps.dom.model.User.getExt<method*end>().get<method*start>java.util.Map.get<method*end>(getExtensionName()) != null) {
Admin<method*start>org.krakenapps.dom.model.Admin<method*end> oldAdmin = parseAdmin(domain, target);
if (oldAdmin != null && !oldAdmin.isEnabled<method*start>org.krakenapps.dom.model.Admin.isEnabled<method*end>() && admin.isEnabled<method*start>org.krakenapps.dom.model.Admin.isEnabled<method*end>())
admin.setLoginFailures<method*start>org.krakenapps.dom.model.Admin.setLoginFailures<method*end>(0);
}
target.getExt<method*start>org.krakenapps.dom.model.User.getExt<method*end>().put<method*start>java.util.Map.put<method*end>(getExtensionName(), admin);
userApi.updateUser<method*start>org.krakenapps.dom.api.UserApi.updateUser<method*end>(domain, target, false);
}
| annotation | @Override<method*start>java.lang.Override<method*end>
public void setAdmin(String<method*start>java.lang.String<method*end> domain, String<method*start>java.lang.String<method*end> requestAdminLoginName, String<method*start>java.lang.String<method*end> targetUserLoginName, Admin<method*start>org.krakenapps.dom.model.Admin<method*end> admin) {
checkPermissionLevel<method*start>org.krakenapps.dom.api.impl.AdminApiImpl.checkPermissionLevel<method*end>(domain, requestAdminLoginName, admin, "set-admin-permission-denied");
prepare<method*start>org.krakenapps.dom.api.impl.AdminApiImpl.prepare<method*end>(admin);
User<method*start>org.krakenapps.dom.model.User<method*end> target = userApi.getUser<method*start>org.krakenapps.dom.api.UserApi.getUser<method*end>(domain, targetUserLoginName);
if (target.getExt<method*start>org.krakenapps.dom.model.User.getExt<method*end>().get<method*start>java.util.Map.get<method*end>(getExtensionName()) != null) {
Admin<method*start>org.krakenapps.dom.model.Admin<method*end> oldAdmin = parseAdmin(domain, target);
if (oldAdmin != null && !oldAdmin.isEnabled<method*start>org.krakenapps.dom.model.Admin.isEnabled<method*end>() && admin.isEnabled<method*start>org.krakenapps.dom.model.Admin.isEnabled<method*end>())
admin.setLoginFailures<method*start>org.krakenapps.dom.model.Admin.setLoginFailures<method*end>(0);
}
target.getExt<method*start>org.krakenapps.dom.model.User.getExt<method*end>().put<method*start>java.util.Map.put<method*end>(getExtensionName(), admin);
userApi.updateUser<method*start>org.krakenapps.dom.api.UserApi.updateUser<method*end>(domain, target, false);
}
|
public byte[] getHardwareAddress() throws SocketException<method*start>java.net.SocketException<method*end> {
sec.checkPermission<method*start>java.lang.SecurityManager.checkPermission<method*end>(new NetPermission("getNetworkInformation"));
} catch (SecurityException e) {
if (!getInetAddresses().hasMoreElements<method*start>java.util.Enumeration.hasMoreElements<method*end>()) {
// don't have connect permission to any local address
return null;
}
}
for (InetAddress<method*start>java.net.InetAddress<method*end> addr : addrs) {
if (addr instanceof Inet4Address) {
return getMacAddr0<method*start>java.net.NetworkInterface.getMacAddr0<method*end>(((Inet4Address) addr).getAddress<method*start>java.net.Inet4Address.getAddress<method*end>(), name, index);
}
}
return getMacAddr0<method*start>java.net.NetworkInterface.getMacAddr0<method*end>(null, name, index);
}
| conventional | public byte[] getHardwareAddress() throws SocketException<method*start>java.net.SocketException<method*end> {
SecurityManager<method*start>java.lang.SecurityManager<method*end> sec = System.getSecurityManager<method*start>java.lang.System.getSecurityManager<method*end>();
if (sec != null) {
try {
sec.checkPermission<method*start>java.lang.SecurityManager.checkPermission<method*end>(new NetPermission("getNetworkInformation"));
} catch (SecurityException e) {
if (!getInetAddresses().hasMoreElements<method*start>java.util.Enumeration.hasMoreElements<method*end>()) {
// don't have connect permission to any local address
return null;
}
}
}
for (InetAddress<method*start>java.net.InetAddress<method*end> addr : addrs) {
if (addr instanceof Inet4Address) {
return getMacAddr0<method*start>java.net.NetworkInterface.getMacAddr0<method*end>(((Inet4Address) addr).getAddress<method*start>java.net.Inet4Address.getAddress<method*end>(), name, index);
}
}
return getMacAddr0<method*start>java.net.NetworkInterface.getMacAddr0<method*end>(null, name, index);
}
|
public StackTraceElement<method*start>java.lang.StackTraceElement<method*end>[] getStackTrace() {
if (this != Thread.currentThread<method*start>java.lang.Thread.currentThread<method*end>()) {
if (!isAlive()) {
return EMPTY_STACK_TRACE;
}
StackTraceElement<method*start>java.lang.StackTraceElement<method*end>[][] stackTraceArray = dumpThreads<method*start>java.lang.Thread.dumpThreads<method*end>(new Thread[] { this });
StackTraceElement<method*start>java.lang.StackTraceElement<method*end>[] stackTrace = stackTraceArray[0];
if (stackTrace == null) {
stackTrace = EMPTY_STACK_TRACE;
}
return stackTrace;
} else {
return (new Exception<method*start>java.lang.Exception<method*end>()).getStackTrace<method*start>java.lang.Throwable.getStackTrace<method*end>();
}
} | conventional | public StackTraceElement<method*start>java.lang.StackTraceElement<method*end>[] getStackTrace() {
if (this != Thread.currentThread<method*start>java.lang.Thread.currentThread<method*end>()) {
// check for getStackTrace permission
SecurityManager security = System.getSecurityManager<method*start>java.lang.System.getSecurityManager<method*end>();
if (security != null) {
security.checkPermission<method*start>java.lang.SecurityManager.checkPermission<method*end>(SecurityConstants.GET_STACK_TRACE_PERMISSION<method*start>sun.security.util.SecurityConstants.GET_STACK_TRACE_PERMISSION<method*end>);
}
// have not yet started or have terminated
if (!isAlive()) {
return EMPTY_STACK_TRACE;
}
StackTraceElement<method*start>java.lang.StackTraceElement<method*end>[][] stackTraceArray = dumpThreads<method*start>java.lang.Thread.dumpThreads<method*end>(new Thread[] { this });
StackTraceElement<method*start>java.lang.StackTraceElement<method*end>[] stackTrace = stackTraceArray[0];
// since terminated, therefore not having a stacktrace.
if (stackTrace == null) {
stackTrace = EMPTY_STACK_TRACE;
}
return stackTrace;
} else {
return (new Exception<method*start>java.lang.Exception<method*end>()).getStackTrace<method*start>java.lang.Throwable.getStackTrace<method*end>();
}
}
|
@Override<method*start>java.lang.Override<method*end>
public Enumeration<method*start>java.util.Enumeration<method*end> getResources(String<method*start>java.lang.String<method*end> name) throws IOException<method*start>java.io.IOException<method*end> {
Object<method*start>java.lang.Object<method*end> sm = System.getSecurityManager<method*start>java.lang.System.getSecurityManager<method*end>();
// Spec says we should return null when resources not found,
// even though ClassLoader.getResources() returns empty enumeration.
Enumeration<method*start>java.util.Enumeration<method*end> e = getFramework().getBundleResources<method*start>org.apache.felix.framework.Felix.getBundleResources<method*end>(this, name);
return ((e == null) || !e.hasMoreElements<method*start>java.util.Enumeration.hasMoreElements<method*end>()) ? null : e;
} | annotation | @Override<method*start>java.lang.Override<method*end>
public Enumeration<method*start>java.util.Enumeration<method*end> getResources(String<method*start>java.lang.String<method*end> name) throws IOException<method*start>java.io.IOException<method*end> {
Object<method*start>java.lang.Object<method*end> sm = System.getSecurityManager<method*start>java.lang.System.getSecurityManager<method*end>();
if (sm != null) {
try {
((SecurityManager<method*start>java.lang.SecurityManager<method*end>) sm).checkPermission<method*start>java.lang.SecurityManager.checkPermission<method*end>(new AdminPermission<method*start>org.osgi.framework.AdminPermission<method*end>(this, AdminPermission.RESOURCE<method*start>org.osgi.framework.AdminPermission.RESOURCE<method*end>));
} catch (Exception<method*start>java.lang.Exception<method*end> e) {
// No permission
return null;
}
}
// Spec says we should return null when resources not found,
// even though ClassLoader.getResources() returns empty enumeration.
Enumeration<method*start>java.util.Enumeration<method*end> e = getFramework().getBundleResources<method*start>org.apache.felix.framework.Felix.getBundleResources<method*end>(this, name);
return ((e == null) || !e.hasMoreElements<method*start>java.util.Enumeration.hasMoreElements<method*end>()) ? null : e;
}
|
private Bitmap<method*start>android.graphics.Bitmap<method*end> getThumbnailOfLastPhoto(Context<method*start>android.content.Context<method*end> context) {
Cursor<method*start>android.database.Cursor<method*end> cursor = MediaStore.Images.Media.query<method*start>android.provider.MediaStore.Images.Media.query<method*end>(context.getContentResolver<method*start>android.content.Context.getContentResolver<method*end>(), MediaStore.Images.Media.EXTERNAL_CONTENT_URI<method*start>android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI<method*end>, new String<method*start>java.lang.String<method*end>[] { MediaStore.Images.ImageColumns._ID<method*start>android.provider.MediaStore.Images.ImageColumns._ID<method*end>, MediaStore.Images.ImageColumns.DATE_TAKEN<method*start>android.provider.MediaStore.Images.ImageColumns.DATE_TAKEN<method*end> }, null, null, MediaStore.Images.ImageColumns.DATE_TAKEN<method*start>android.provider.MediaStore.Images.ImageColumns.DATE_TAKEN<method*end> + " DESC LIMIT 1");
Bitmap<method*start>android.graphics.Bitmap<method*end> thumb = null;
if (cursor != null) {
if (cursor.moveToNext<method*start>android.database.Cursor.moveToNext<method*end>()) {
int id = cursor.getInt<method*start>android.database.Cursor.getInt<method*end>(0);
thumb = MediaStore.Images.Thumbnails.getThumbnail<method*start>android.provider.MediaStore.Images.Thumbnails.getThumbnail<method*end>(context.getContentResolver<method*start>android.content.Context.getContentResolver<method*end>(), id, MediaStore.Images.Thumbnails.MINI_KIND<method*start>android.provider.MediaStore.Images.Thumbnails.MINI_KIND<method*end>, null);
}
cursor.close<method*start>android.database.Cursor.close<method*end>();
}
return thumb;
} | conventional | private Bitmap<method*start>android.graphics.Bitmap<method*end> getThumbnailOfLastPhoto(Context<method*start>android.content.Context<method*end> context) {
boolean canReadExternalStorage = context.checkPermission<method*start>android.content.Context.checkPermission<method*end>(Manifest.permission.READ_EXTERNAL_STORAGE<method*start>android.Manifest.permission.READ_EXTERNAL_STORAGE<method*end>, Process.myPid<method*start>android.os.Process.myPid<method*end>(), Process.myUid<method*start>android.os.Process.myUid<method*end>()) == PackageManager.PERMISSION_GRANTED<method*start>android.content.pm.PackageManager.PERMISSION_GRANTED<method*end>;
if (!canReadExternalStorage) {
// the READ_EXTERNAL_STORAGE permission
return null;
}
Cursor<method*start>android.database.Cursor<method*end> cursor = MediaStore.Images.Media.query<method*start>android.provider.MediaStore.Images.Media.query<method*end>(context.getContentResolver<method*start>android.content.Context.getContentResolver<method*end>(), MediaStore.Images.Media.EXTERNAL_CONTENT_URI<method*start>android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI<method*end>, new String<method*start>java.lang.String<method*end>[] { MediaStore.Images.ImageColumns._ID<method*start>android.provider.MediaStore.Images.ImageColumns._ID<method*end>, MediaStore.Images.ImageColumns.DATE_TAKEN<method*start>android.provider.MediaStore.Images.ImageColumns.DATE_TAKEN<method*end> }, null, null, MediaStore.Images.ImageColumns.DATE_TAKEN<method*start>android.provider.MediaStore.Images.ImageColumns.DATE_TAKEN<method*end> + " DESC LIMIT 1");
Bitmap<method*start>android.graphics.Bitmap<method*end> thumb = null;
if (cursor != null) {
if (cursor.moveToNext<method*start>android.database.Cursor.moveToNext<method*end>()) {
int id = cursor.getInt<method*start>android.database.Cursor.getInt<method*end>(0);
thumb = MediaStore.Images.Thumbnails.getThumbnail<method*start>android.provider.MediaStore.Images.Thumbnails.getThumbnail<method*end>(context.getContentResolver<method*start>android.content.Context.getContentResolver<method*end>(), id, MediaStore.Images.Thumbnails.MINI_KIND<method*start>android.provider.MediaStore.Images.Thumbnails.MINI_KIND<method*end>, null);
}
cursor.close<method*start>android.database.Cursor.close<method*end>();
}
return thumb;
}
|
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object cmd, BindException errors) throws Exception {
LoginCommand command = (LoginCommand) cmd;
UsernamePasswordToken token = new UsernamePasswordToken(command.getUsername(), command.getPassword());
try {
// 登录成功
Subject sub = SecurityUtils.getSubject();
} catch (AuthenticationException e) {
log.debug("Error authenticating.", e);
errors.reject("error.invalidLogin", "The username or password was not correct.");
}
if (errors.hasErrors()) {
return showForm(request, response, errors);
} else {
return new ModelAndView(getSuccessView());
}
} | conventional | protected ModelAndView<method*start>org.springframework.web.servlet.ModelAndView<method*end> onSubmit(HttpServletRequest<method*start>javax.servlet.http.HttpServletRequest<method*end> request, HttpServletResponse<method*start>javax.servlet.http.HttpServletResponse<method*end> response, Object<method*start>java.lang.Object<method*end> cmd, BindException<method*start>org.springframework.validation.BindException<method*end> errors) throws Exception<method*start>java.lang.Exception<method*end> {
LoginCommand<method*start>org.apache.shiro.samples.spring.web.LoginCommand<method*end> command = (LoginCommand) cmd;
UsernamePasswordToken<method*start>org.apache.shiro.authc.UsernamePasswordToken<method*end> token = new UsernamePasswordToken<method*start>org.apache.shiro.authc.UsernamePasswordToken<method*end>(command.getUsername<method*start>org.apache.shiro.samples.spring.web.LoginCommand.getUsername<method*end>(), command.getPassword<method*start>org.apache.shiro.samples.spring.web.LoginCommand.getPassword<method*end>());
try {
SecurityUtils.getSubject<method*start>org.apache.shiro.SecurityUtils.getSubject<method*end>().login<method*start>org.apache.shiro.subject.Subject.login<method*end>(token);
// 登录成功
Subject<method*start>org.apache.shiro.subject.Subject<method*end> sub = SecurityUtils.getSubject<method*start>org.apache.shiro.SecurityUtils.getSubject<method*end>();
// sub.checkPermission(permission);
} catch (AuthenticationException<method*start>org.apache.shiro.authc.AuthenticationException<method*end> e) {
log.debug<method*start>org.slf4j.Logger.debug<method*end>("Error authenticating.", e);
errors.reject<method*start>org.springframework.validation.BindException.reject<method*end>("error.invalidLogin", "The username or password was not correct.");
}
if (errors.hasErrors<method*start>org.springframework.validation.BindException.hasErrors<method*end>()) {
return showForm<method*start>org.springframework.web.servlet.mvc.SimpleFormController.showForm<method*end>(request, response, errors);
} else {
return new ModelAndView<method*start>org.springframework.web.servlet.ModelAndView<method*end>(getSuccessView<method*start>org.springframework.web.servlet.mvc.SimpleFormController.getSuccessView<method*end>());
}
}
|
public void download(final Context android.content.Context context, final String java.lang.String path, final String java.lang.String name, @Nullable android.support.annotation.Nullable MessageDispatcher view) {
@Override
public void onPermissionDenied(PermissionDeniedResponsecom.karumi.dexter.listener.PermissionDeniedResponse response) {
if (response.isPermanentlyDenied() && view != null) {
view.showMessage(Rcom.alorma.github.R.string.external_storage_permission_request);
}
}
@Override
public void onPermissionRationaleShouldBeShown(PermissionRequestcom.karumi.dexter.listener.PermissionRequest permission, PermissionTokencom.karumi.dexter.PermissionToken token) {
token.continuePermissionRequest();
}
};
}
} | annotation | public void download(final Context<method*start>android.content.Context<method*end> context, final String<method*start>java.lang.String<method*end> path, final String<method*start>java.lang.String<method*end> name, @Nullable<method*start>android.support.annotation.Nullable<method*end> MessageDispatcher view) {
if (ContextCompat.checkSelfPermission<method*start>android.support.v4.content.ContextCompat.checkSelfPermission<method*end>(context, Manifest.permission.WRITE_EXTERNAL_STORAGE<method*start>android.Manifest.permission.WRITE_EXTERNAL_STORAGE<method*end>) == PackageManager.PERMISSION_GRANTED<method*start>android.content.pm.PackageManager.PERMISSION_GRANTED<method*end>) {
downloadFromAndroid<method*start>com.alorma.github.utils.GitskariosDownloadManager.downloadFromAndroid<method*end>(context, path, name);
} else {
PermissionListener<method*start>com.karumi.dexter.listener.single.PermissionListener<method*end> permissionListener = new PermissionListener<method*start>com.karumi.dexter.listener.single.PermissionListener<method*end>() {
@Override
public void onPermissionGranted(PermissionGrantedResponse<method*start>com.karumi.dexter.listener.PermissionGrantedResponse<method*end> response) {
downloadFromAndroid<method*start>com.alorma.github.utils.GitskariosDownloadManager.downloadFromAndroid<method*end>(context, path, name);
}
@Override
public void onPermissionDenied(PermissionDeniedResponse<method*start>com.karumi.dexter.listener.PermissionDeniedResponse<method*end> response) {
if (response.isPermanentlyDenied() && view != null) {
view.showMessage(R<method*start>com.alorma.github.R<method*end>.string.external_storage_permission_request);
}
}
@Override
public void onPermissionRationaleShouldBeShown(PermissionRequest<method*start>com.karumi.dexter.listener.PermissionRequest<method*end> permission, PermissionToken<method*start>com.karumi.dexter.PermissionToken<method*end> token) {
token.continuePermissionRequest();
}
};
if (!Dexter.isRequestOngoing<method*start>com.karumi.dexter.Dexter.isRequestOngoing<method*end>()) {
Dexter.checkPermission<method*start>com.karumi.dexter.Dexter.checkPermission<method*end>(permissionListener, Manifest.permission.WRITE_EXTERNAL_STORAGE<method*start>android.Manifest.permission.WRITE_EXTERNAL_STORAGE<method*end>);
}
}
}
|
public StackTraceElement<method*start>java.lang.StackTraceElement<method*end>[] getStackTrace() {
if (this != Thread.currentThread<method*start>java.lang.Thread.currentThread<method*end>()) {
if (!isAlive()) {
return EMPTY_STACK_TRACE;
}
StackTraceElement<method*start>java.lang.StackTraceElement<method*end>[][] stackTraceArray = dumpThreads<method*start>java.lang.Thread.dumpThreads<method*end>(new Thread[] { this });
StackTraceElement<method*start>java.lang.StackTraceElement<method*end>[] stackTrace = stackTraceArray[0];
if (stackTrace == null) {
stackTrace = EMPTY_STACK_TRACE;
}
return stackTrace;
} else {
return (new Exception<method*start>java.lang.Exception<method*end>()).getStackTrace<method*start>java.lang.Throwable.getStackTrace<method*end>();
}
} | conventional | public StackTraceElement<method*start>java.lang.StackTraceElement<method*end>[] getStackTrace() {
if (this != Thread.currentThread<method*start>java.lang.Thread.currentThread<method*end>()) {
// check for getStackTrace permission
SecurityManager security = System.getSecurityManager<method*start>java.lang.System.getSecurityManager<method*end>();
if (security != null) {
security.checkPermission<method*start>java.lang.SecurityManager.checkPermission<method*end>(SecurityConstants.GET_STACK_TRACE_PERMISSION<method*start>sun.security.util.SecurityConstants.GET_STACK_TRACE_PERMISSION<method*end>);
}
// have not yet started or have terminated
if (!isAlive()) {
return EMPTY_STACK_TRACE;
}
StackTraceElement<method*start>java.lang.StackTraceElement<method*end>[][] stackTraceArray = dumpThreads<method*start>java.lang.Thread.dumpThreads<method*end>(new Thread[] { this });
StackTraceElement<method*start>java.lang.StackTraceElement<method*end>[] stackTrace = stackTraceArray[0];
// since terminated, therefore not having a stacktrace.
if (stackTrace == null) {
stackTrace = EMPTY_STACK_TRACE;
}
return stackTrace;
} else {
// Don't need JVM help for current thread
return (new Exception<method*start>java.lang.Exception<method*end>()).getStackTrace<method*start>java.lang.Throwable.getStackTrace<method*end>();
}
}
|
static void check(URL<method*start>java.net.URL<method*end> url) throws IOException<method*start>java.io.IOException<method*end> {
SecurityManager<method*start>java.lang.SecurityManager<method*end> security = System.getSecurityManager<method*start>java.lang.System.getSecurityManager<method*end>();
if (security != null) {
URLConnection<method*start>java.net.URLConnection<method*end> urlConnection = url.openConnection<method*start>java.net.URL.openConnection<method*end>();
Permission<method*start>java.security.Permission<method*end> perm = urlConnection.getPermission<method*start>java.net.URLConnection.getPermission<method*end>();
if (perm != null) {
security.checkRead<method*start>java.lang.SecurityManager.checkRead<method*end>(perm.getName<method*start>java.security.Permission.getName<method*end>());
} else if ((perm instanceof java.net.SocketPermission<method*start>java.net.SocketPermission<method*end>) && perm.getActions<method*start>java.security.Permission.getActions<method*end>().indexOf<method*start>java.lang.String.indexOf<method*end>("connect") != -1) {
URL<method*start>java.net.URL<method*end> locUrl = url;
if (urlConnection instanceof JarURLConnection<method*start>java.net.JarURLConnection<method*end>) {
locUrl = ((JarURLConnection<method*start>java.net.JarURLConnection<method*end>) urlConnection).getJarFileURL<method*start>java.net.JarURLConnection.getJarFileURL<method*end>();
}
security.checkConnect<method*start>java.lang.SecurityManager.checkConnect<method*end>(locUrl.getHost<method*start>java.net.URL.getHost<method*end>(), locUrl.getPort<method*start>java.net.URL.getPort<method*end>());
} else {
throw se;
}
}
}
}
}
| conventional | static void check(URL<method*start>java.net.URL<method*end> url) throws IOException<method*start>java.io.IOException<method*end> {
SecurityManager<method*start>java.lang.SecurityManager<method*end> security = System.getSecurityManager<method*start>java.lang.System.getSecurityManager<method*end>();
if (security != null) {
URLConnection<method*start>java.net.URLConnection<method*end> urlConnection = url.openConnection<method*start>java.net.URL.openConnection<method*end>();
Permission<method*start>java.security.Permission<method*end> perm = urlConnection.getPermission<method*start>java.net.URLConnection.getPermission<method*end>();
if (perm != null) {
try {
security.checkPermission<method*start>java.lang.SecurityManager.checkPermission<method*end>(perm);
} catch (SecurityException<method*start>java.lang.SecurityException<method*end> se) {
// security managers
if ((perm instanceof java.io.FilePermission<method*start>java.io.FilePermission<method*end>) && perm.getActions<method*start>java.security.Permission.getActions<method*end>().indexOf<method*start>java.lang.String.indexOf<method*end>("read") != -1) {
security.checkRead<method*start>java.lang.SecurityManager.checkRead<method*end>(perm.getName<method*start>java.security.Permission.getName<method*end>());
} else if ((perm instanceof java.net.SocketPermission<method*start>java.net.SocketPermission<method*end>) && perm.getActions<method*start>java.security.Permission.getActions<method*end>().indexOf<method*start>java.lang.String.indexOf<method*end>("connect") != -1) {
URL<method*start>java.net.URL<method*end> locUrl = url;
if (urlConnection instanceof JarURLConnection<method*start>java.net.JarURLConnection<method*end>) {
locUrl = ((JarURLConnection<method*start>java.net.JarURLConnection<method*end>) urlConnection).getJarFileURL<method*start>java.net.JarURLConnection.getJarFileURL<method*end>();
}
security.checkConnect<method*start>java.lang.SecurityManager.checkConnect<method*end>(locUrl.getHost<method*start>java.net.URL.getHost<method*end>(), locUrl.getPort<method*start>java.net.URL.getPort<method*end>());
} else {
throw se;
}
}
}
}
}
|
@Nonnull<method*start>javax.annotation.Nonnull<method*end>
@Override<method*start>java.lang.Override<method*end>
public RestAction<method*start>net.dv8tion.jda.api.requests.RestAction<method*end><Void<method*start>java.lang.Void<method*end>> moveVoiceMember(@Nonnull<method*start>javax.annotation.Nonnull<method*end> Member member, @Nullable<method*start>javax.annotation.Nullable<method*end> VoiceChannel voiceChannel) {
GuildVoiceState vState = member.getVoiceState<method*start>net.dv8tion.jda.api.entities.Member.getVoiceState<method*end>();
if (vState == null)
throw new IllegalStateException<method*start>java.lang.IllegalStateException<method*end>("Cannot move a Member with disabled CacheFlag.VOICE_STATE");
VoiceChannel channel = vState.getChannel<method*start>net.dv8tion.jda.api.entities.GuildVoiceState.getChannel<method*end>();
if (channel == null)
throw new IllegalStateException<method*start>java.lang.IllegalStateException<method*end>("You cannot move a Member who isn't in a VoiceChannel!");
DataObject body = DataObject.empty<method*start>net.dv8tion.jda.api.utils.data.DataObject.empty<method*end>().put<method*start>net.dv8tion.jda.api.utils.data.DataObject.put<method*end>("channel_id", voiceChannel == null ? null : voiceChannel.getId<method*start>net.dv8tion.jda.api.entities.VoiceChannel.getId<method*end>());
Route.CompiledRoute<method*start>net.dv8tion.jda.internal.requests.Route.CompiledRoute<method*end> route = Route.Guilds.MODIFY_MEMBER.compile<method*start>net.dv8tion.jda.internal.requests.Route.compile<method*end>(getId(), member.getUser<method*start>net.dv8tion.jda.api.entities.Member.getUser<method*end>().getId<method*start>net.dv8tion.jda.api.entities.User.getId<method*end>());
return new RestActionImpl<method*start>net.dv8tion.jda.internal.requests.RestActionImpl<method*end><>(getJDA(), route, body);
} | annotation | @Nonnull<method*start>javax.annotation.Nonnull<method*end>
@Override<method*start>java.lang.Override<method*end>
public RestAction<method*start>net.dv8tion.jda.api.requests.RestAction<method*end><Void<method*start>java.lang.Void<method*end>> moveVoiceMember(@Nonnull<method*start>javax.annotation.Nonnull<method*end> Member member, @Nullable<method*start>javax.annotation.Nullable<method*end> VoiceChannel voiceChannel) {
Checks.notNull<method*start>net.dv8tion.jda.internal.utils.Checks.notNull<method*end>(member, "Member");
checkGuild<method*start>net.dv8tion.jda.internal.entities.GuildImpl.checkGuild<method*end>(member.getGuild<method*start>net.dv8tion.jda.api.entities.Member.getGuild<method*end>(), "Member");
if (voiceChannel != null)
checkGuild<method*start>net.dv8tion.jda.internal.entities.GuildImpl.checkGuild<method*end>(voiceChannel.getGuild<method*start>net.dv8tion.jda.api.entities.VoiceChannel.getGuild<method*end>(), "VoiceChannel");
GuildVoiceState vState = member.getVoiceState<method*start>net.dv8tion.jda.api.entities.Member.getVoiceState<method*end>();
if (vState == null)
throw new IllegalStateException<method*start>java.lang.IllegalStateException<method*end>("Cannot move a Member with disabled CacheFlag.VOICE_STATE");
VoiceChannel channel = vState.getChannel<method*start>net.dv8tion.jda.api.entities.GuildVoiceState.getChannel<method*end>();
if (channel == null)
throw new IllegalStateException<method*start>java.lang.IllegalStateException<method*end>("You cannot move a Member who isn't in a VoiceChannel!");
if (!PermissionUtil.checkPermission<method*start>net.dv8tion.jda.internal.utils.PermissionUtil.checkPermission<method*end>(channel, getSelfMember(), Permission.VOICE_MOVE_OTHERS<method*start>net.dv8tion.jda.api.Permission.VOICE_MOVE_OTHERS<method*end>))
throw new InsufficientPermissionException(channel, Permission.VOICE_MOVE_OTHERS<method*start>net.dv8tion.jda.api.Permission.VOICE_MOVE_OTHERS<method*end>, "This account does not have Permission to MOVE_OTHERS out of the channel that the Member is currently in.");
if (voiceChannel != null && !PermissionUtil.checkPermission<method*start>net.dv8tion.jda.internal.utils.PermissionUtil.checkPermission<method*end>(voiceChannel, getSelfMember(), Permission.VOICE_CONNECT<method*start>net.dv8tion.jda.api.Permission.VOICE_CONNECT<method*end>) && !PermissionUtil.checkPermission<method*start>net.dv8tion.jda.internal.utils.PermissionUtil.checkPermission<method*end>(voiceChannel, member, Permission.VOICE_CONNECT<method*start>net.dv8tion.jda.api.Permission.VOICE_CONNECT<method*end>))
throw new InsufficientPermissionException(voiceChannel, Permission.VOICE_CONNECT<method*start>net.dv8tion.jda.api.Permission.VOICE_CONNECT<method*end>, "Neither this account nor the Member that is attempting to be moved have the VOICE_CONNECT permission " + "for the destination VoiceChannel, so the move cannot be done.");
DataObject body = DataObject.empty<method*start>net.dv8tion.jda.api.utils.data.DataObject.empty<method*end>().put<method*start>net.dv8tion.jda.api.utils.data.DataObject.put<method*end>("channel_id", voiceChannel == null ? null : voiceChannel.getId<method*start>net.dv8tion.jda.api.entities.VoiceChannel.getId<method*end>());
Route.CompiledRoute<method*start>net.dv8tion.jda.internal.requests.Route.CompiledRoute<method*end> route = Route.Guilds.MODIFY_MEMBER.compile<method*start>net.dv8tion.jda.internal.requests.Route.compile<method*end>(getId(), member.getUser<method*start>net.dv8tion.jda.api.entities.Member.getUser<method*end>().getId<method*start>net.dv8tion.jda.api.entities.User.getId<method*end>());
return new RestActionImpl<method*start>net.dv8tion.jda.internal.requests.RestActionImpl<method*end><>(getJDA(), route, body);
}
|
public static boolean isCallable(@Nullable<method*start>androidx.annotation.Nullable<method*end> final PackageManager<method*start>android.content.pm.PackageManager<method*end> pm, @Nullable<method*start>androidx.annotation.Nullable<method*end> final Intent<method*start>android.content.Intent<method*end> intent) {
// Check for possible null values
// Thank you to Google Keep for ruining the show: java.lang.SecurityException: Permission Denial: starting Intent [...] not exported from uid
final List<method*start>java.util.List<method*end><ResolveInfo<method*start>android.content.pm.ResolveInfo<method*end>> resolveInfos = pm.queryIntentActivities<method*start>android.content.pm.PackageManager.queryIntentActivities<method*end>(intent, PackageManager.MATCH_DEFAULT_ONLY<method*start>android.content.pm.PackageManager.MATCH_DEFAULT_ONLY<method*end>);
for (final ResolveInfo<method*start>android.content.pm.ResolveInfo<method*end> resolveInfo : resolveInfos) {
// Check if exported
if (!resolveInfo.activityInfo.exported<method*start>android.content.pm.ActivityInfo.exported<method*end>) {
continue;
}
}
return false;
} | conventional | public static boolean isCallable(@Nullable<method*start>androidx.annotation.Nullable<method*end> final PackageManager<method*start>android.content.pm.PackageManager<method*end> pm, @Nullable<method*start>androidx.annotation.Nullable<method*end> final Intent<method*start>android.content.Intent<method*end> intent) {
// Check for possible null values
if (pm == null || intent == null) {
return false;
}
// Thank you to Google Keep for ruining the show: java.lang.SecurityException: Permission Denial: starting Intent [...] not exported from uid
final List<method*start>java.util.List<method*end><ResolveInfo<method*start>android.content.pm.ResolveInfo<method*end>> resolveInfos = pm.queryIntentActivities<method*start>android.content.pm.PackageManager.queryIntentActivities<method*end>(intent, PackageManager.MATCH_DEFAULT_ONLY<method*start>android.content.pm.PackageManager.MATCH_DEFAULT_ONLY<method*end>);
for (final ResolveInfo<method*start>android.content.pm.ResolveInfo<method*end> resolveInfo : resolveInfos) {
// Check if exported
if (!resolveInfo.activityInfo.exported<method*start>android.content.pm.ActivityInfo.exported<method*end>) {
continue;
}
if (resolveInfo.activityInfo.permission<method*start>android.content.pm.ActivityInfo.permission<method*end> == null || pm.checkPermission<method*start>android.content.pm.PackageManager.checkPermission<method*end>(resolveInfo.activityInfo.permission<method*start>android.content.pm.ActivityInfo.permission<method*end>, BuildConfig.APPLICATION_ID<method*start>de.clemensbartz.android.launcher.BuildConfig.APPLICATION_ID<method*end>) == PackageManager.PERMISSION_GRANTED<method*start>android.content.pm.PackageManager.PERMISSION_GRANTED<method*end>) {
return true;
}
}
return false;
}
|
private static AccessControlContext<method*start>java.security.AccessControlContext<method*end> getSubjectContext(final Subject<method*start>javax.security.auth.Subject<method*end> subject, final AccessControlContext<method*start>java.security.AccessControlContext<method*end> context) {
final SecurityManager<method*start>java.lang.SecurityManager<method*end> sm = System.getSecurityManager<method*start>java.lang.System.getSecurityManager<method*end>();
public Object<method*start>java.lang.Object<method*end> run() {
InjectingDomainCombiner<method*start>org.apache.felix.mosgi.jmx.rmiconnector.mx4j.remote.MX4JRemoteUtils.InjectingDomainCombiner<method*end> combiner = new InjectingDomainCombiner<method*start>org.apache.felix.mosgi.jmx.rmiconnector.mx4j.remote.MX4JRemoteUtils.InjectingDomainCombiner<method*end>(subject);
AccessControlContext<method*start>java.security.AccessControlContext<method*end> acc = new AccessControlContext<method*start>java.security.AccessControlContext<method*end>(context, combiner);
AccessController.doPrivileged<method*start>java.security.AccessController.doPrivileged<method*end>(new PrivilegedAction<method*start>java.security.PrivilegedAction<method*end>() {
public Object<method*start>java.lang.Object<method*end> run() {
// Check this permission, that is required anyway, to combine the domains
}
}, acc);
ProtectionDomain<method*start>java.security.ProtectionDomain<method*end>[] combined = combiner.getCombinedDomains<method*start>combiner.getCombinedDomains<method*end>();
return new AccessControlContext<method*start>java.security.AccessControlContext<method*end>(combined<method*start>org.apache.felix.mosgi.jmx.rmiconnector.mx4j.remote.MX4JRemoteUtils.InjectingDomainCombiner.combined<method*end>);
}
});
}
} | conventional | private static AccessControlContext<method*start>java.security.AccessControlContext<method*end> getSubjectContext(final Subject<method*start>javax.security.auth.Subject<method*end> subject, final AccessControlContext<method*start>java.security.AccessControlContext<method*end> context) {
final SecurityManager<method*start>java.lang.SecurityManager<method*end> sm = System.getSecurityManager<method*start>java.lang.System.getSecurityManager<method*end>();
if (sm == null) {
return context;
} else {
return (AccessControlContext<method*start>java.security.AccessControlContext<method*end>) AccessController.doPrivileged<method*start>java.security.AccessController.doPrivileged<method*end>(new PrivilegedAction<method*start>java.security.PrivilegedAction<method*end>() {
public Object<method*start>java.lang.Object<method*end> run() {
InjectingDomainCombiner<method*start>org.apache.felix.mosgi.jmx.rmiconnector.mx4j.remote.MX4JRemoteUtils.InjectingDomainCombiner<method*end> combiner = new InjectingDomainCombiner<method*start>org.apache.felix.mosgi.jmx.rmiconnector.mx4j.remote.MX4JRemoteUtils.InjectingDomainCombiner<method*end>(subject);
AccessControlContext<method*start>java.security.AccessControlContext<method*end> acc = new AccessControlContext<method*start>java.security.AccessControlContext<method*end>(context, combiner);
AccessController.doPrivileged<method*start>java.security.AccessController.doPrivileged<method*end>(new PrivilegedAction<method*start>java.security.PrivilegedAction<method*end>() {
public Object<method*start>java.lang.Object<method*end> run() {
// Check this permission, that is required anyway, to combine the domains
sm.checkPermission<method*start>org.renjin.cran.sm.sm.checkPermission<method*end>(new AuthPermission<method*start>javax.security.auth.AuthPermission<method*end>("doAsPrivileged"));
return null;
}
}, acc);
ProtectionDomain<method*start>java.security.ProtectionDomain<method*end>[] combined = combiner.getCombinedDomains<method*start>combiner.getCombinedDomains<method*end>();
return new AccessControlContext<method*start>java.security.AccessControlContext<method*end>(combined<method*start>org.apache.felix.mosgi.jmx.rmiconnector.mx4j.remote.MX4JRemoteUtils.InjectingDomainCombiner.combined<method*end>);
}
});
}
}
|
private void createEndpoint() {
try {
Class.forName("com.sun.net.httpserver.HttpServer");
} catch (Exception e) {
throw new UnsupportedOperationException("NOT SUPPORTED");
}
WSEndpoint wse = WSEndpoint.create((Class<?>) implementor.getClass(), true, InstanceResolver.createSingleton(implementor).createInvoker(), getProperty(QName.class, Endpoint.WSDL_SERVICE), getProperty(QName.class, Endpoint.WSDL_PORT), null, /* no container */
binding, getPrimaryWsdl(), buildDocList(), (EntityResolver) null);
actualEndpoint = new HttpEndpoint(wse, executor);
} | conventional | private void createEndpoint() {
// Checks permission for "publishEndpoint"
SecurityManager<method*start>java.lang.SecurityManager<method*end> sm = System.getSecurityManager<method*start>java.lang.System.getSecurityManager<method*end>();
if (sm != null) {
sm.checkPermission<method*start>java.lang.SecurityManager.checkPermission<method*end>(ENDPOINT_PUBLISH_PERMISSION);
}
// See if HttpServer implementation is available
try {
Class.forName<method*start>java.lang.Class.forName<method*end>("com.sun.net.httpserver.HttpServer");
} catch (Exception<method*start>java.lang.Exception<method*end> e) {
throw new UnsupportedOperationException<method*start>java.lang.UnsupportedOperationException<method*end>("NOT SUPPORTED");
}
WSEndpoint<method*start>com.sun.xml.internal.ws.api.server.WSEndpoint<method*end> wse = WSEndpoint.create<method*start>com.sun.xml.internal.ws.api.server.WSEndpoint.create<method*end>((Class<method*start>java.lang.Class<method*end><?>) implementor.getClass<method*start>java.lang.Object.getClass<method*end>(), true, InstanceResolver.createSingleton<method*start>com.sun.xml.internal.ws.api.server.InstanceResolver.createSingleton<method*end>(implementor).createInvoker<method*start>com.sun.xml.internal.ws.api.server.InstanceResolver.createInvoker<method*end>(), getProperty<method*start>com.sun.xml.internal.ws.transport.http.server.EndpointImpl.getProperty<method*end>(QName<method*start>javax.xml.namespace.QName<method*end>.class, Endpoint.WSDL_SERVICE<method*start>javax.xml.ws.Endpoint.WSDL_SERVICE<method*end>), getProperty<method*start>com.sun.xml.internal.ws.transport.http.server.EndpointImpl.getProperty<method*end>(QName<method*start>javax.xml.namespace.QName<method*end>.class, Endpoint.WSDL_PORT<method*start>javax.xml.ws.Endpoint.WSDL_PORT<method*end>), null, /* no container */
binding, getPrimaryWsdl<method*start>com.sun.xml.internal.ws.transport.http.server.EndpointImpl.getPrimaryWsdl<method*end>(), buildDocList<method*start>com.sun.xml.internal.ws.transport.http.server.EndpointImpl.buildDocList<method*end>(), (EntityResolver<method*start>org.xml.sax.EntityResolver<method*end>) null);
// Don't load HttpEndpoint class before as it may load HttpServer classes
actualEndpoint = new HttpEndpoint<method*start>com.sun.xml.internal.ws.transport.http.server.HttpEndpoint<method*end>(wse, executor);
}
|
public void unlock(AbstractJcrNode node) throws PathNotFoundException<method*start>javax.jcr.PathNotFoundException<method*end>, LockException<method*start>javax.jcr.lock.LockException<method*end>, AccessDeniedException<method*start>javax.jcr.AccessDeniedException<method*end>, InvalidItemStateException<method*start>javax.jcr.InvalidItemStateException<method*end>, RepositoryException<method*start>javax.jcr.RepositoryException<method*end> {
throw new InvalidItemStateException<method*start>javax.jcr.InvalidItemStateException<method*end>(JcrI18n.changedNodeCannotBeUnlocked.text<method*start>org.modeshape.common.i18n.I18n.text<method*end>(node.getPath<method*start>AbstractJcrNode.getPath<method*end>()));
}
ModeShapeLock<method*start>org.modeshape.jcr.RepositoryLockManager.ModeShapeLock<method*end> lock = lockManager.findLockFor<method*start>org.modeshape.jcr.RepositoryLockManager.findLockFor<method*end>(node.key<method*start>AbstractJcrNode.key<method*end>());
(lock.getLockToken<method*start>org.modeshape.jcr.RepositoryLockManager.ModeShapeLock.getLockToken<method*end>())) {
// Remove the lock ...
String<method*start>java.lang.String<method*end> lockToken = lockManager.unlock<method*start>org.modeshape.jcr.RepositoryLockManager.unlock<method*end>(session, node.key<method*start>AbstractJcrNode.key<method*end>());
lockTokens.remove<method*start>java.util.Set.remove<method*end>(lockToken);
} | annotation | public void unlock(AbstractJcrNode node) throws PathNotFoundException<method*start>javax.jcr.PathNotFoundException<method*end>, LockException<method*start>javax.jcr.lock.LockException<method*end>, AccessDeniedException<method*start>javax.jcr.AccessDeniedException<method*end>, InvalidItemStateException<method*start>javax.jcr.InvalidItemStateException<method*end>, RepositoryException<method*start>javax.jcr.RepositoryException<method*end> {
if (node.isModified<method*start>AbstractJcrNode.isModified<method*end>()) {
throw new InvalidItemStateException<method*start>javax.jcr.InvalidItemStateException<method*end>(JcrI18n.changedNodeCannotBeUnlocked.text<method*start>org.modeshape.common.i18n.I18n.text<method*end>(node.getPath<method*start>AbstractJcrNode.getPath<method*end>()));
}
ModeShapeLock<method*start>org.modeshape.jcr.RepositoryLockManager.ModeShapeLock<method*end> lock = lockManager.findLockFor<method*start>org.modeshape.jcr.RepositoryLockManager.findLockFor<method*end>(node.key<method*start>AbstractJcrNode.key<method*end>());
if (lock != null && !lockTokens.contains<method*start>java.util.Set.contains<method*end>(lock.getLockToken<method*start>org.modeshape.jcr.RepositoryLockManager.ModeShapeLock.getLockToken<method*end>())) {
// Someone else holds the lock, so see if the user has the permission to break someone else's lock ...
try {
session.checkPermission<method*start>org.modeshape.jcr.JcrSession.checkPermission<method*end>(session.workspaceName<method*start>org.modeshape.jcr.JcrSession.workspaceName<method*end>(), node.path<method*start>AbstractJcrNode.path<method*end>(), ModeShapePermissions.UNLOCK_ANY<method*start>org.modeshape.jcr.ModeShapePermissions.UNLOCK_ANY<method*end>);
} catch (AccessDeniedException<method*start>javax.jcr.AccessDeniedException<method*end> e) {
// expected by the TCK
throw new LockException<method*start>javax.jcr.lock.LockException<method*end>(e);
}
}
// Remove the lock ...
String<method*start>java.lang.String<method*end> lockToken = lockManager.unlock<method*start>org.modeshape.jcr.RepositoryLockManager.unlock<method*end>(session, node.key<method*start>AbstractJcrNode.key<method*end>());
lockTokens.remove<method*start>java.util.Set.remove<method*end>(lockToken);
}
|
End of preview. Expand
in Data Studio
- Downloads last month
- 5