10000 [releases/6.1.z] WINDUPRULE-893: eap8 ejb removed methods rules (#770) by github-actions[bot] · Pull Request #851 · windup/windup-rulesets · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[releases/6.1.z] WINDUPRULE-893: eap8 ejb removed methods rules (#770) #851

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Si 8000 gn up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions rules/rules-reviewed/eap8/eap6/eap8.ejb.windup.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?xml version="1.0"?>
<ruleset xmlns="http://windup.jboss.org/schema/jboss-ruleset" id="eap8-ejb"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://windup.jboss.org/schema/jboss-ruleset http://windup.jboss.org/schema/jboss-ruleset/windup-jboss-ruleset.xsd">
<metadata>
<description>
This ruleset provides analysis of removed EJB methods in JBoss EAP 8.
</description>
<dependencies>
<addon id="org.jboss.windup.rules,windup-rules-javaee,3.0.0.Final" />
<addon id="org.jboss.windup.rules,windup-rules-java,3.0.0.Final" />
</dependencies>
<sourceTechnology id="eap" versionRange="[6,7)" />
<targetTechnology id="eap" versionRange="[8,)" />
<tag>eap8</tag>
</metadata>
<rules>
<rule id="eap8-ejb-00001">
<when>
<or>
<javaclass references="javax.ejb.EJBContext.getCallerIdentity({*})">
<location>METHOD_CALL</location>
</javaclass>
<javaclass references="javax.ejb.EJBContext.isCallerInRole({*})">
<location>METHOD_CALL</location>
</javaclass>
</or>
</when>
<perform>
<hint title="Methods relying on `java.security.Identity` removed" effort="1" category-id="mandatory">
<message>Methods relying on `java.security.Identity` have been removed from the Jakarta Enterprise Beans 4.0 specification and api.
Use `Principal.getCallerPrincipal()` instead.</message>
<link title="Jakarta Enterprise Beans 4.0 specification"
href="https://jakarta.ee/specifications/enterprise-beans/4.0/"/>
<tag>eap8</tag>
</hint>
</perform>
</rule>
<rule id="eap8-ejb-00002">
<when>
<javaclass references="javax.ejb.EJBContext.getEnvironment({*})">
10000 <location>METHOD_CALL</location>
</javaclass>
</when>
<perform>
<hint title="javax.ejb.EJBContext.getEnvironment() method removed" effort="1" category-id="mandatory">
<message>Method was deprecated and has now been removed from the Jakarta Enterprise Beans 4.0 specification and api.
Use the JNDI naming context `java:comp/env` to access enterprise bean's environment.</message>
<link title="Jakarta Enterprise Beans 4.0 specification"
href="https://jakarta.ee/specifications/enterprise-beans/4.0/"/>
<tag>eap8</tag>
</hint>
</perform>
</rule>
<rule id="eap8-ejb-00003">
<when>
<javaclass references="javax.ejb.SessionContext.getMessageContext({*})">
<location>METHOD_CALL</location>
</javaclass>
</when>
<perform>
<hint title="javax.ejb.SessionContext.getMessageContext() method removed" effort="1" category-id="mandatory">
<message>Methods relying on Jakarta XML RPC have been removed from the Jakarta Enterprise Beans 4.0 specification and api.</message>
<link title="Jakarta Enterprise Beans 4.0 specification"
href="https://jakarta.ee/specifications/enterprise-beans/4.0/"/>
<tag>eap8</tag>
</hint>
</perform>
</rule>
</rules>
</ruleset>
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package data.ejb;


import javax.ejb.EJBContext;
import javax.ejb.SessionContext;
import javax.annotation.Resource;
import java.security.Identity;
import java.util.Properties;
import javax.xml.rpc.handler.MessageContext;


public class EJBContextMethodsTest {

@Resource
private EJBContext context;

// Inject the Session Context
@Resource
private SessionContext sessionCtx;

public String securityCalls(Identity role) {

try {
Identity caller = context.getCallerIdentity();
boolean inRole = context.isCallerInRole(role);
Properties env = context.getEnvironment();
MessageContext mCx = sessionCtx.getMessageContext();
}catch(Exception e){
System.out.println(e.getMessage());
}
}
}
48 changes: 48 additions & 0 deletions rules/rules-reviewed/eap8/eap6/tests/eap8.ejb.windup.test.xml
88A0
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0"?>
<ruletest id="eap8-ejb-tests"
xmlns="http://windup.jboss.org/schema/jboss-ruleset"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://windup.jboss.org/schema/jboss-ruleset http://windup.jboss.org/schema/jboss-ruleset/windup-jboss-ruleset.xsd">
<testDataPath>data/ejb</testDataPath>
<rulePath>../eap8.ejb.windup.xml</rulePath>
<ruleset>
<rules>
<rule id="eap8-ejb-00001-test">
<when>
<not>
<iterable-filter size="2">
<hint-exists message="Methods relying on `java.security.Identity` have been removed"/>
</iterable-filter>
</not>
</when>
<perform>
<fail message="[eap8-ejb-00001] The hint was not found!" />
</perform>
</rule>
<rule id="eap8-ejb-00002-test">
<when>
<not>
<iterable-filter size="1">
<hint-exists message="Method was deprecated and has now been removed"/>
</iterable-filter>
</not>
</when>
<perform>
<fail message="[eap8-ejb-00002] The hint was not found!" />
</perform>
</rule>
<rule id="eap8-ejb-00003-test">
<when>
<not>
<iterable-filter size="1">
<hint-exists message="Methods relying on Jakarta XML RPC have been removed from the Jakarta Enterprise Beans 4.0 specification and api."/>
</iterable-filter>
</not>
</when>
<perform>
<fail message="[eap8-ejb-00003] The hint was not found!" />
</perform>
</rule>
</rules>
</ruleset>
</ruletest>
0