Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.
SOLVED

AEM 6.5 Custom OSGI Config is not visible

Avatar

Level 1

Hey guys,

I am using AEM 6.5 and I've deployed a custom OSGI service config. I was expecting to find the config under http://localhost:4502/system/console/configMgr

Here is my Service. 

MyService.java

public interface MyService {

    /**
     * This method returns the entered password into a hash equivalent with some
     * properties passed by the user
     *
     * @Param type
     * @Return {@link String}
     */
    String getPassword(String type);
}


MyServiceImpl.java

 

@Component(service = MyService.class,
property = {
"label=My Service Implementation"
}
)
@Designate(ocd = MyConfiguration.class)
public class MyServiceImpl implements MyService {

private final Logger log = LoggerFactory.getLogger(this.getClass());

// Two properties to be read
private String propertyOne;
private String propertyTwo;

@Activate
protected void activate(MyConfiguration config) {
// Reading properties from the configuration
propertyOne = config.getPropertyOne();
propertyTwo = config.getPropertyTwo();

}

@Override
public String getPassword(String type) {

// MD5 equivalent of password string
String passwordHash = null;

try {

type = type + propertyOne + propertyTwo;

log.info("Resulant password: " + type);

// Convert string to bytes - this is for the sample implementation (for show casing)
byte[] passwordByte = type.getBytes("UTF-8");

// Getting instance of MessageDigest
MessageDigest md = MessageDigest.getInstance("MD5");

// Convert bytes array to hash using MD5 algorithm
byte[] digest = md.digest(passwordByte);

passwordHash = new String(digest);

} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}

return passwordHash;
}

}



MyConfiguration.java

import org.osgi.service.metatype.annotations.AttributeDefinition;
import org.osgi.service.metatype.annotations.AttributeType;
import org.osgi.service.metatype.annotations.ObjectClassDefinition;

@ObjectClassDefinition(name = "My Configuration",
description = "This configuration will be used to read the value of properties.")
public @interface MyConfiguration {

@AttributeDefinition(name = "Property One", description = "Read property one", type = AttributeType.STRING)
public String getPropertyOne() default "Property One";

@AttributeDefinition(name = "Property Two", description = "Read property two", type = AttributeType.STRING)
public String getPropertyTwo() default "Property Two";
}

 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi,

Could you please check if your bundle is active or not? Code looks fine, could be issue with imports.

I have a sample code you can refer just to cross check in case you missed something

https://github.com/arunpatidar02/aem63app-repo/tree/master/java/page/json/com/acc/aem64/core/service...

 



Arun Patidar

View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

Hi,

Could you please check if your bundle is active or not? Code looks fine, could be issue with imports.

I have a sample code you can refer just to cross check in case you missed something

https://github.com/arunpatidar02/aem63app-repo/tree/master/java/page/json/com/acc/aem64/core/service...

 



Arun Patidar