-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* WINDUPRULE-909: eap8 ejb removed methods rules and test * WINDUPRULE-893: fix for tests * removal of commented out test * rules not firing * alter rule method sugnature * rule method signature altered * fixing tests (cherry picked from commit 86e3dd6) Co-authored-by: Mark Brophy <36955467+m-brophy@users.noreply.github.com>
- Loading branch information
1 parent
1229f1d
commit ed73c47
Showing
3 changed files
with
151 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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({*})"> | ||
<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> |
32 changes: 32 additions & 0 deletions
32
rules/rules-reviewed/eap8/eap6/tests/data/ejb/EJBContextMethodsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
48
rules/rules-reviewed/eap8/eap6/tests/eap8.ejb.windup.test.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |